8
$\begingroup$

i'm searching for a curve type with a minimum of functionality and maximum of usability. I run into quadratic Bézier curves and i wonder, if its possible to draw a circle with it.

$\endgroup$
0

5 Answers 5

19
$\begingroup$

No, you can only produce some good approximations for sufficiently small arcs. Bezier curves can be parametrized as $(x(t),y(t))$ where $x,y$ are polynomials in $t$. To run on a circle arc, wlog. the unit circle, we must have $x(t)^2+y(t)^2=1$ for all $t$. If wlog. $d:=\deg x\ge \deg y$ then $x(t)^2+y(t)^2$ is a polynomial of degree $2d$ and can conincide with the constant $1$ only if $d=0$. That is: A nonconstant Bézier curve (even of higher than quadratic degree) cannot describe an arc.

$\endgroup$
16
$\begingroup$

That depends on what you mean. If you're looking for a planar Bézier curve which describes a circular arc in that plane, the existing answers are correct that it isn't possible.

However, if you're willing to consider a Bézier curve in 3D which forms a perfect circular arc when viewed from the correct point (i.e. with a perspective projection; this is also known as "rational Bézier curves"). E.g. these notes show how to construct any conic section with rational quadratic Béziers.[Now 404s and not in archive.org].

And these notes handle the case of a circular arc explicitly: Diagram of circular arc as quadratic rational Bézier curve

This works for $\theta < \pi$ (or $\theta = \pi$ using homogeneous coordinates); for a full circle, you need more than one arc.

$\endgroup$
2
  • 1
    $\begingroup$ just curious: what software did you use to draw the diagram? $\endgroup$
    – Jason S
    Feb 23, 2014 at 23:24
  • $\begingroup$ @JasonS, I took a screenshot of the linked PDF. $\endgroup$ Feb 23, 2014 at 23:26
7
$\begingroup$

Quadratic Bezier curves are parabolas, so can only represent circular arcs approximately.

Cubic Bezier curves are very popular (e.g. they are used in Postscript, SVG, and most drawing and CAD programs). Again, they can only represent circular arcs approximately, but the approximation might be good enough for your needs. Many drawing programs use four 90-degree cubic segments to represent a complete circle, and I'm not aware of any flood of accuracy complaints.

You can look at this site for a simple method that uses four cubic Bezier curves and gives an approximation whose maximum error is 0.0196% of the radius. This might be good enough for your application.

Higher degree Bezier curves can produce even better approximations, of course, but the computational costs are obviously higher. Look at this answer for details.

Rational quadratic curves can exactly represent circular arcs (and other conic section curves).

A final thought ... if you want to be able to represent circles exactly, why not use circular arcs as your basic curve form. In 2D, you can have a curve defined by its end-points and a "bulge" parameter. When the bulge is non-zero, you get a circular arc, and when its zero you get a straight line. To get "free-form" curves, you just string together these basic curves. Circular arcs make many computations easy: they are easy to intersect, easy to offset, and its easy to compute their arclength and distance to them. These four basic computations are much more difficult with quadratic Bezier curves.

Another final thought :-) : if you draw a circle using sine and cosine functions on a computer, it's still an approximation. It's just that the approximation is hidden inside your computer's implementation of the sine and cosine functions.

$\endgroup$
2
  • 1
    $\begingroup$ "and I'm not aware of any flood of accuracy complaints" somewhat related: this snafu on the New York Regents Exams. $\endgroup$ Jul 22, 2013 at 8:34
  • $\begingroup$ @ Willie. Interesting discussion. Thanks. I think the poor approximation comes from lack of skill and knowledge, not from weaknesses in the approximation technique. In other words, user error. I'm sure it's possible to construct cubic Bezier curves that are indistinguishable from sine function graphs on a printed page (if you know what you're doing). $\endgroup$
    – bubba
    Jul 23, 2013 at 13:09
2
$\begingroup$

"a curve type with a ... maximum of usability"

reminds me that Don Lancaster once said, "I feel the "best" method for simple and graceful curves involves using a cubic spline technique." (He specifically prefers cubic Bézier splines over quadratic Bézier splines).

A single cubic Bézier curves can exactly fit any straight line, any parabola (including any quadratic Bézier curve), and certain other curves.

Is it possible to build a circle with quadratic Bézier curves?

Any smooth curve can be approximated by a series of cubic curves in a way that is visually indistinguishable from the original smooth curve.

(Each cubic curve, in turn, can be approximated by a series of a few quadratic Bézier curves in a way that is visually indistinguishable from the cubic curve or from the original smooth curve).

Most "circles" you see on a computer screen are, in fact, drawn using a Bezier curve approximation. All the shapes you see in typography -- including circles and circular arcs -- are approximated by cubic Bézier curves (in PostScript, Asymptote, Metafont, and SVG fonts) or quadratic Bézier curves (in TrueType fonts).

It is possible to create an approximation of a circle (or a sine wave) to an accuracy of about 1 part in a thousand with 4 cubic Bezier curves, and to about 4 parts per million with 8 Bezier curves. See "Wikibooks: fixed-point", "Wikipedia: Bezigon circle approximation", "Approximating Cubic Bezier Curves with a few Quadratic Bezier curves in Flash MX", and "Don Lancaster's Cubic Spline Library" -- which in turn includes "Approximating a Circle or an Ellipse Using Bezier Cubic Splines" and "How to determine the control points of a Bézier curve that approximates a small circular arc".

$\endgroup$
1
$\begingroup$

The answers saying you can only approximate a circle with a cubic spline are correct. If you are looking for a recipe for how to do that approximation (in my case, for a graphics programming project) with accurate appearing results:

  • Given starting and ending degrees, a radius and center x/y coordinate
  • Divide endDegrees - startDegrees by a number of steps to get you a result accurate enough for your purposes (by trial and error, or however you wish) - the more points, the more accuracy, but ... more points
  • For each angle incrementing through numSteps steps of (endDegrees - startDegrees) / steps degrees
    • Compute the location on the circle described by the radius and coordinates, of the current step's angle in x/y coordinates. That's your primary point for the current quadratic segment
    • Compute the tangent line of the preceding step and the tangent line for the current step
    • Find the intersection of those two lines. That's your control point.
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .