diff options
author | Carl Worth <cworth@cworth.org> | 2003-09-29 11:55:56 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2003-09-29 11:55:56 +0000 |
commit | 9edacaf78075c3ed3a5e27da81f41ddc265acfc1 (patch) | |
tree | 6fde18fa5a0fc0338caf670e1a4ecc6b6789b2db /TODO | |
parent | 6f87c8bc6c4b539049b089a0f90559eac0f2ffa2 (diff) |
Bugfix from Graydon Hoare.
Diffstat (limited to 'TODO')
-rw-r--r-- | TODO | 84 |
1 files changed, 0 insertions, 84 deletions
@@ -2,8 +2,6 @@ * Implement text support for the image backend. -* Add arc support. - * Re-implement pattern support with a more PostScript-like API. * Virtualize the backend interface so that the various backends can be @@ -11,88 +9,6 @@ compiled conditionally. * Verification, profiling, optimization. -Some notes on arc support -========================= - -Some general notions --------------------- -This is from "Approximation of circular arcs by cubic poynomials", -Michael Goldapp, Computer Aided Geometric Design 8 (1991) 227-238. - -To draw a unit arc from 0 to A with 0 < A < pi/2: - - Y - - | . - | / . - | / . - |/A . - +------.-- X - 0 1 - -The deviation in radius is given by: - - rho(t) = sqrt ( x^2(t) + y^2(t) ) - 1 - -A simpler error function to work with is: - - e(t) = x^2(t) + y^2(t) - 1 - -And from "Good approximation of circles by curvature-continuous Bezier -curves", Tor Dokken and Morten Daehlen, Computer Aided Geometric -Design 8 (1990) 22-41, we learn: - - e(t) ~ 2 abs( rho(t) ) - -Continuing with Goldapp's analysis, a single cubic Bezier spline -approximation must have the 4 control points: - - (1, 0) - (1, h) - (cos(A) + h * sin(A), sin(A) - h * cos(A)) - (cos(A), sin(A)) - -Various approximations can be determined by selecting the value of -h. A convenient value, (though not optimal in terms of error), is: - - h = 4/3 * tan(A/4) - -From which we can determine the maximum error: - - abs( max(e(t)) ) = 4/27 * (sin^6 (A/4)) / (cos^2 (A/4)) - t in [0,1] - ------ - -Now, for Cairo we want to draw an arc of radius R from an angle A to -an angle B, (where B > A). So the equations above have trivial -modifications: - -The spline control points become - - (R * cos(A), R * sin(A)) - (R * cos(A) - h * sin(A), R * sin(A) + h * cos (A)) - (R * cos(B) + h * sin(B), R * sin(B) - h * cos (B)) - (R * cos(B), R * sin(B)) - -where h = 4/3 * R * tan ((B-A)/4) - -And the maximum deviation in radius is approximately: - - 2/27 * (sin^6 ((B-A)/4) / cos^2 ((B-A)/4)) - -So now we can get down to writing some C code: - -double -_arc_error_normalized (double angle) -{ - return 2/27 * pow (sin (angle / 4), 6) / pow (cos (angle / 4), 2); -} - -And for accurate drawing the following must hold in device space: - - tolerance/radius >= _arc_error_normalized (B-A) - A comparison with PostScript ============================ |