[sci.math] Computing Bezier Control Points for an Arc of a Circle

stephenj@deblil.Sun.COM (Stephen Johnson) (06/06/89)

How do you compute the control points for a fourth order (third
degree) Bezier if the user gives you the following data:

	x, y	- center of circle
	rad	- radius of circle
	ang1	- starting angle for arc
	ang2	- ending angle for arc

Once you have the control points, its a simple task to render the
Bezier.  So, how do you compute the control points?  Can it be done
exactly for any angle between 0 and 360?

--------------------------+--------------------------------------------------
Stephen P. Johnson        | Some Disclaimer and such stating the company
Sun Microsystems, Inc.    | I work for knows absoutely nothing about what I
2550 Garcia Ave.,         | really do.

knutm@raadgrid.uio.no (Knut Moerken) (06/06/89)

In article <108121@sun.Eng.Sun.COM>, stephenj@deblil.Sun.COM (Stephen Johnson) writes:
> 
> 
> How do you compute the control points for a fourth order (third
> degree) Bezier if the user gives you the following data:
> 
> 	x, y	- center of circle
> 	rad	- radius of circle
> 	ang1	- starting angle for arc
> 	ang2	- ending angle for arc
> 
> Once you have the control points, its a simple task to render the
> Bezier.  So, how do you compute the control points?  Can it be done
> exactly for any angle between 0 and 360?
> 
> --------------------------+--------------------------------------------------
> Stephen P. Johnson        | Some Disclaimer and such stating the company
> Sun Microsystems, Inc.    | I work for knows absoutely nothing about what I
> 2550 Garcia Ave.,         | really do.

Let us for simplicity assume that the radius is one and that ang1=0
and a=ang2.
To get back to the general case just requires multiplication of the
Bezier coefficients by the radius and a suitable rotation.

A good solution to the problem is provided by the four Bezier coefficients

P0=[1,0],                                 P1=[1,0] + L*[0,1],
P2=[cos(a),sin(a)] - L*[-sin(a),cos(a)],  P3=[cos(a),sin(a)],

where

             L=(4/3)*tan(a/4).

This approximation always lies outside the circle, so the error
can be roughly halved by scaling the approximation appropriately.
In either case the error is O(a^6) for reasonably small angles a.
(The error is approximately 10^(-3) for a=90 degrees.)
When the angle approaches 360 degrees the error goes to infinity.

Note also that by piecing together several Bezier segments of this type,
one obtains a curvature continuous spline.

For angles greater than 90 or 180 degrees it is therefore
adviceable to use more than one Bezier segment.

All the claims made here are proved in the paper

Near best approximation of circles by curvature continuous Bezier curves

by Tor Dokken, Morten Daehlen, Tom Lyche and Knut Morken.

This is currently only a draft, but will in its final form be submitted
for publication in C(omputer) A(ided) G(eometric) D(esign) in the
proceedings of a conference held at Oberwolfach in April (Surfaces in
CAGD'89 ???).

Knut Morken
Institutt for informatikk
University of Oslo
P.O Box 1080 Blindern
0316 Oslo 3
Norway

rhbartels@watcgl.waterloo.edu (Richard Bartels) (06/07/89)

In article <108121@sun.Eng.Sun.COM>
stephenj@deblil.Sun.COM (Stephen Johnson) writes:
>
>How do you compute the control points for a fourth order (third
>degree) Bezier if the user gives you the following data:
>
>	x, y	- center of circle
>	rad	- radius of circle
>	ang1	- starting angle for arc
>	ang2	- ending angle for arc
>
>Once you have the control points, its a simple task to render the
>Bezier.  So, how do you compute the control points?  Can it be done
>exactly for any angle between 0 and 360?

This is one of the Golden Oldies.  You can't do a circle exactly
as a Bezier curve (at least as an integral Bezier curve, you can do
conic sections as rational Bezier curves).

For those interested in how close you can get, however, the following
was presented in April at a conference at Oberwolfach:

	"Almost best Approximations of Circles
	 by Curvature-continuous Bezier curves"
			by
	 Tor Dokken, Morten Daehlen, Tom Lyche, Knut Morken

The userids of the 2nd - 4th authors are:

	mortend@ifi.uio.no
	tom@ifi.uio.no
	knut@ifi.uio.no

I hope they will forgive me for giving this pointer to their work,
but the world is waiting; they promised me a reprint at least a month ago,
and nothing has been heard since.  I am tired waiting.  This is my revenge.

-Richard

nelson@berlioz (Ted Nelson) (06/07/89)

In article <10150@watcgl.waterloo.edu> rhbartels@watcgl.waterloo.edu (Richard Bartels) writes:
>This is one of the Golden Oldies.  You can't do a circle exactly
>as a Bezier curve (at least as an integral Bezier curve, you can do
>conic sections as rational Bezier curves).

Yes, but there is nothing to stop you from using 8-way symmetry.  Worst
  case is 2-way symmetry for a rotated ellipse.

We did a simple solution to this problem.  The user would input 3 points
  on the circle and it would draw the circular arc which they define.  All
  we did was to compute the radius of the circle, have a look-up table to
  grab pre-computed Bezier increments which were then stepped up by the
  radius (thus, it would work for ellipses too).  From this it would construct
  a point list in memory of only the octants (use 8-way symmetry) that it
  go through.  It took out the display list before the first point and after
  the third point, and proceeded to draw a line from the first point, the
  complete remaining point list, and then to the third point.

In fact, we did it in assembly language on a NSC Raster Graphics Processor.
  It was only about 12 pages ==> a page or two of C code...

-- Ted.

skinner@saturn.ucsc.edu (Robert Skinner) (06/09/89)

> 
> How do you compute the control points for a fourth order (third
> degree) Bezier if the user gives you the following data:
> 
> 	x, y	- center of circle
> 	rad	- radius of circle
> 	ang1	- starting angle for arc
> 	ang2	- ending angle for arc
> 

quoting from Computational Geometry for Design and Manufacturing,
by Faux and Pratt, page 134:

A close approximation to the circular are r = cos(t) i + sin(t) j for
0 <= t <= pi/2 is obtained by writing P0 = i, P2 = i + k*j, 
P3 = k*i + j and P4 = j, where k = 4(sqrt(2)-1)/3.  The radius of the
approximate arc varies betwen 1 and 1.00027 in this case, the maximum
deviation from the mean radius being +-0.13%. 
(Where t = theta, r0 - r4 are the Bezier control points,
and i and j are unit vectors in the x and y directions.)

To generate a partial arc, you take advantage of a property of Bezier 
curves.  If you divide each segment from P(i) to P(i+1) by some ratio,
0 <= t' <= 1, then connect those three points by two segments and divide 
by the same ratio, then connect the final two point and divide it
by the same ratio, then the resulting point is on the curve at
t = t' AND the interior points define two smaller Bezier that subdivide
the original one, in the desired ratio.

The end result of all this is from your original points for the
quadrant curve, P you get the points for P' by this:

	P0' = P0
	P1' = (1 - t')P0 + t*P1
	P2' = (1 - t')^2*P0 + 2t(1-t')P1 + t^2 * P2
	P3' = (1 - t')^3*P0 + 3t(1-t')^2*P1 + 3t^2(1-t')P2 + t^3 * P3

Note that P3' is on the curve, which is to be expected.

that should do it.
Robert
skinner@saturn.ucsc.edu