third_party/cairo/src/cairo-arc.c
static void
_cairo_arc_segment (cairo_t *cr,
		    double   xc,
		    double   yc,
		    double   radius,
		    double   angle_A,
		    double   angle_B)
{
    double r_sin_A, r_cos_A;
    double r_sin_B, r_cos_B;
    double h;

    r_sin_A = radius * sin (angle_A);
    r_cos_A = radius * cos (angle_A);
    r_sin_B = radius * sin (angle_B);
    r_cos_B = radius * cos (angle_B);

    h = 4.0/3.0 * tan ((angle_B - angle_A) / 4.0);

    cairo_curve_to (cr,
		    xc + r_cos_A - h * r_sin_A,
		    yc + r_sin_A + h * r_cos_A,
		    xc + r_cos_B + h * r_sin_B,
		    yc + r_sin_B - h * r_cos_B,
		    xc + r_cos_B,
		    yc + r_sin_B);
}
/* We want to draw a single spline approximating a circular arc radius
   R from angle A to angle B. Since we want a symmetric spline that
   matches the endpoints of the arc in position and slope, we know
   that the spline control points must be:

	(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))

   for some value of h.

   "Approximation of circular arcs by cubic polynomials", Michael
   Goldapp, Computer Aided Geometric Design 8 (1991) 227-238, provides
   various values of h along with error analysis for each.

   From that paper, a very practical value of h is:

	h = 4/3 * R * tan(angle/4)

   This value does not give the spline with minimal error, but it does
   provide a very good approximation, (6th-order convergence), and the
   error expression is quite simple, (see the comment for
   _arc_error_normalized).
*/
We want to draw a single spline approximating a circular arc radius
R from angle A to angle B. Since we want a symmetric spline that
matches the endpoints of the arc in position and slope, we know
that the spline control points must be.



for some value of h.

"Approximation of circular arcs by cubic polynomials", Michael
Goldapp, Computer Aided Geometric Design 8 (1991) 227-238, provides
various values of h along with error analysis for each.

From that paper, a very practical value of h is.



This value does not give the spline with minimal error, but it does
provide a very good approximation, (6th-order convergence), and the
error expression is quite simple, (see the comment for
_arc_error_normalized).
We want to draw a single spline approximating a circular arc radius R from angle A to angle B . Since we want a symmetric spline that matches the endpoints of the arc in position and slope we know that the spline control points must be . for some value of h . " Approximation of circular arcs by cubic polynomials " Michael Goldapp Computer Aided Geometric Design 8 ( 1991 ) 227 - 238 provides various values of h along with error analysis for each . From that paper a very practical value of h is . This value does not give the spline with minimal error but it does provide a very good approximation ( 6th - order convergence ) and the error expression is quite simple ( see the comment for _arc_error_normalized ) .
static void
_cairo_arc_segment (cairo_t *cr,
		    double   xc,
		    double   yc,
		    double   radius,
		    double   angle_A,
		    double   angle_B)
{
    double r_sin_A, r_cos_A;
    double r_sin_B, r_cos_B;
    double h;
    r_sin_A = radius * sin (angle_A);
    r_cos_A = radius * cos (angle_A);
    r_sin_B = radius * sin (angle_B);
    r_cos_B = radius * cos (angle_B);
    h = 4.0/3.0 * tan ((angle_B - angle_A) / 4.0);
    cairo_curve_to (cr,
		    xc + r_cos_A - h * r_sin_A,
		    yc + r_sin_A + h * r_cos_A,
		    xc + r_cos_B + h * r_sin_B,
		    yc + r_sin_B - h * r_cos_B,
		    xc + r_cos_B,
		    yc + r_sin_B);
}
static void _cairo_arc_segment ( cairo_t * cr , double xc , double yc , double radius , double angle_A , double angle_B ) { double r_sin_A , r_cos_A ; double r_sin_B , r_cos_B ; double h ; r_sin_A = radius * sin ( angle_A ) ; r_cos_A = radius * cos ( angle_A ) ; r_sin_B = radius * sin ( angle_B ) ; r_cos_B = radius * cos ( angle_B ) ; h = 4.0 / 3.0 * tan ( ( angle_B - angle_A ) / 4.0 ) ; cairo_curve_to ( cr , xc + r_cos_A - h * r_sin_A , yc + r_sin_A + h * r_cos_A , xc + r_cos_B + h * r_sin_B , yc + r_sin_B - h * r_cos_B , xc + r_cos_B , yc + r_sin_B ) ; }
We want to draw a single spline approximating a circular arc radius
R from angle A to angle B.
We want to draw a single spline approximating a circular arc radius R from angle A to angle B .