5

I have 2 questions about bezier curves, and using them to approximate portions of circles.

  1. Given the unit circle arc (1,0)->(cos(a),sin(a)) where 0 < a < pi/2, will it result in a good approximation of this arc to find the bezier curve's control points p1, p2 by solving the equations imposed by the requirements B(1/3) = (cos(a/3), sin(a/3)) and B(2/3) = (cos(2a/3), sin(2a/3)). (In other words, requiring that the bezier curve go through two evenly spaced points in the arc).

  2. If we have an affine transformation A which turns the circle arc in an ellipse arc will the transformed control points Ap0, Ap1, Ap2, Ap3 define a good bezier approximation to the ellipse arc?

p0 and p3, of course, are the start and end points of the curve: (1,0) and (cos(a), sin(a)).

Thank you

CromTheDestroyer
  • 3,616
  • 3
  • 20
  • 26

2 Answers2

4

Here's a general solution for any elliptical arc as a cubic Bezier curve.

The error is most dependent on the difference of the start and end angles. I've had good success by limiting the angle difference to 60°. That is, I make a separate cubic segment for every 60° (or fraction thereof) and chain them together.

skomisa
  • 16,436
  • 7
  • 61
  • 102
xan
  • 7,511
  • 2
  • 32
  • 45
2

Your questions basically ask "are these good approximations for a semicircle/arc of an ellipse".

You might want to try computing B_y(a) - sin(a) (of course, parameterizing your equations to both end at (-1,0) at the same value of a) for your curve B(a), on a graphing utility such as Wolfram Alpha to graph it, and see how much the variance is, and whether or not it suits your purposes.

If you want a more precise and non-visual answer, you may calculate

Integral (from 0 to K) [B_y(a) - sin(a)]^2 da / 2

Where K is the value of a where both parameterized curves end up at (-1,0).

This integral is related/proportional (somewhat) to some measure of Standard Deviation, and will serve well as a numerical analysis. If it's within your desired accuracy, you are good.

Your second question, where you mention an affine transformation of a circle to an ellipse, will give you an error proportional to your original error, if your transformation is essentially linear. If not, you could try using the Jacobian Determinant of your transformation to see how the error would vary.

I have also found a nice Analysis of Semicircle-Bezier Approximations where the author finds a pretty sexy approximation:

Bezier Semicircle

Given by:

xValueInset = Diameter * 0.05
yValueOffset = radius * 4.0 / 3.0

P0 = (0,0)
P1 = (xValueInset, yValueOffset)
P2 = (Diameter - xValueInset, yValueOffset)
P3 = (Diameter, 0)

Where P1 and P2 are your control points. Note that this approximates the semicircle:

B(a) = [ (d/2)*cos(a)+d/2 , (d/2)*sin(a) ]
Community
  • 1
  • 1
Justin L.
  • 13,510
  • 5
  • 48
  • 83
  • 2
    as a follow up comment for people who found this post through google like I just did, this solution only looks good as semi-circle. It cannot be used for creating a full circle by sticking two of these together (the result is easily detected as "not a circle" by the human eye) – Mike 'Pomax' Kamermans Jan 22 '12 at 14:42
  • The fundamental error here is the non-continuity of the first derivative at the edges if you were to stick two together. The most common approximation is to use one bézier curve in each quadrant. I haven't seen anyone discuss a more accurate approximation, since that approach is "good enough." – Andrew Pouliot Dec 20 '14 at 04:45