Inaccurate rendering of circular arc of angle 45 degrees.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
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*(e-s)/M_PI_2
I think the formula should read : len = 4*tan((e-s)/4)/3
This formula was obtained by fitting a Bezier curve to a circular arc of angle (e-s), 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 (e-s) 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.
patch attached.
as a side note, exactly the same code also appears in the files : draw-context.cpp, dyna-draw- context. cpp, dropper- context. cpp, tweak-context.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.