Inaccurate rendering of circular arc of angle 45 degrees.
Affects  Status  Importance  Assigned to  Milestone  

 Inkscape 
Undecided

Unassigned 
Bug Description
Attached is an svg drawing showing a comparison of two full circles to a superimposed 90 degree arc and a superimposed 45 degree arc, such that in both cases the circle and the arc should agree exactly.
 zoom in to about 500% to confirm that the 90 degree arc superimposed on the full circle is indistinguishable from it.
 by comparison the 45 degree arc is significantly different from the full circle.
 this does not make sense because the 45 degree arc should be easier to render properly.
I cannot prove it, but I suspect that the problem may be in the formula used to calculate the curve in the file \trunk\
line 184 : C1 = 0.552
line 223 : len = C1*(es)/M_PI_2
I think the formula should read : len = 4*tan((es)/4)/3
This formula was obtained by fitting a Bezier curve to a circular arc of angle (es), and forcing the slopes to be correct at the endpoints and forcing the midpoint of the Bezier curve to touch the circular arc tangentially. The formula agrees with the original equation if (es) is 90 degrees, but they differ significantly at smaller angles such as 45 degrees. The new formula has been tested in the file cubicsuperpath.py, and appears to work well there, as far as I can tell (svn rev 20706).
I wonder if someone could test this, to see if it helps.
Alvin Penner (apenner) wrote :  #1 
Alvin Penner (apenner) wrote :  #2 
Alvin Penner (apenner) wrote :  #3 
patch attached.
as a side note, exactly the same code also appears in the files : drawcontext.cpp, dynadraw
I wonder if 2geom could be used here.
Alvin Penner (apenner) wrote :  #8 
after further inspection, it looks like the files : drawcontext.cpp, dynadraw
C1 = 4*tan(PI/8)/3 = 4*(sqrt(2)1)/3 = .552285
which is close enough to .552. So there is no point in modifying these files.
However, it is still essential that the file spellipse.cpp be patched, because it is used to calculate arbitrary arc angle values where the agreement will not be so good.
For example, at an arc angle of 45 degrees, the new formula predicts
len = 4*tan(PI/16)/3 = .265
while the original formula predicts
len = .552/2 = .276
This is 4 % too high, which is easily detectable on a visual display, and this 4% error is most likely causing the bulge outwards which is shown in the attached svg file.
Alvin Penner (apenner) wrote :  #9 
fixed in rev 20771
patch attached.
as a side note, exactly the same code also appears in the files : drawcontext.cpp, dynadrawcontext.cpp, droppercontext.cpp, tweakcontext.cpp. However, in these files, it is not clear to me what the code is trying to do, so I don't know if these comments apply there.