diff options
author | Carl Worth <cworth@cworth.org> | 2003-09-29 08:36:29 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2003-09-29 08:36:29 +0000 |
commit | 6f87c8bc6c4b539049b089a0f90559eac0f2ffa2 (patch) | |
tree | e81735a3d48365a52af998cc59182e88f3164718 /TODO | |
parent | 2e19ebf7663e77c9a01787fe7dd70896c62e2743 (diff) |
Added cairo_arc and cairo_arc_negative.
Diffstat (limited to 'TODO')
-rw-r--r-- | TODO | 52 |
1 files changed, 44 insertions, 8 deletions
@@ -11,12 +11,13 @@ compiled conditionally. * Verification, profiling, optimization. - Some notes on arc support -------------------------- +========================= -"Approximation of circular arcs by cubic poynomials", Michael Goldapp, -Computer Aided Geometric Design 8 (1991) 227-238. +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: @@ -37,9 +38,14 @@ A simpler error function to work with is: e(t) = x^2(t) + y^2(t) - 1 -And from Dokken[cite]: e(t) ~ 2 abs( rho(t) ) +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) ) -A single cubic Bezier spline approximation must have the 4 control points: +Continuing with Goldapp's analysis, a single cubic Bezier spline +approximation must have the 4 control points: (1, 0) (1, h) @@ -55,7 +61,38 @@ 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 ============================ @@ -190,4 +227,3 @@ Operators, Rational,Boolean,and Bitwise Operators, Control Operators, Type,Attribute,and Conversion Operators, File Operators, Resource Operators, Virtual Memory Operators, Miscellaneous Operators, Interpreter Parameter Operators, Errors - |