When we discuss Bézier and B-spline curves, we mentioned that they are polynomial curves that can only represent parabolas. Since NURBS and rational Bézier curves are rational, we would like to known if they can represent ellipses, circles and hyperbolas. If they can, how can we do it? This page will provide some details of representing conic arcs.
Suppose the resulting conic curve that passes through P_{0} and P_{2} and is tangent to P_{0}P_{1} and P_{1}P_{2} at P_{0} and P_{2}, respectively, be represented by an implicit equation of degree 2 as follows, where the six coefficients are unknowns:
If f is not zero in the above equation, we can divide the whole equation by f as shown below:
Then, we actually have only five unknowns! Note that if f is zero, we already have five unknowns. Since this curve passes through P_{0}, plugging the coordinates of P_{0} into the above equation yields:
The gradient of the equation is computed as follows:
The tangent line and the gradient at a P_{0} = (U_{0}, V_{0}) are perpendicular to each other. Since the gradient has a slope of (bU_{0}+cV_{0}+e)/ (aU_{0}+bV_{0}+d), the slope of the tangent line at P_{0} = (U_{0}, V_{0}) is -(aU_{0}+bV_{0}+d)/ (bU_{0}+cV_{0}+e). Since P_{0}P_{1} is tangent to the conic at P_{0} and since the slope of line P_{0}P_{1} is (V_{1} - V_{0})/(U_{1} - U_{0}), these two slope values must be equal to each other. Therefore, the following must hold:
Since this unknown conic also passes through P_{2}, we have
Since this unknown conic is tangent to P_{1}P_{2} at P_{2}, the slope argument used earlier yields:
Now, we have four equations, each of which is linear in the unknowns a, b, c, d and e. If we could find one more condition to generate one more needed linear equation, we will have five linear equations with five unknowns. Solving this system of linear equations yields all five coefficients and the conic curve is uniquely determined.
A very natural addition would be one more point. Plugging the coordinates of this point into the equation will give us an equation that is similar to those for control points P_{0} and P_{2}. But, where is this point? This point should be inside of the triangle of the three control points so that the convex hull property can be maintained. The position of this point should also be "regular" so that we can easily change this point to produce another conic curve. One way to do this is allowing this point to be on the line segment joining P_{1} and the mid-point of P_{0}P_{2}. In this way, moving the fifth point on this line segment generates different conic curves as shown below:
The connection with a NURBS curve can be seen easily. If the chosen point moves from the mid-point of P_{0}P_{2} toward P_{1}, the conic curve it helps define moves toward control point P_{1}. On the other hand, if the point moves away from P_{1}, the curve it helps define also moves away from P_{1}. Therefore, this observation makes us to speculate that the position of this moving point can be controlled by the weight assigned to control P_{1}. In fact, this is exactly the case.
Since we only need one point, which is affected by the weight of control point P_{1}, we can use a rational Bézier curve with three control points P_{0}, P_{1} and P_{2} with weights 1, w and 1, respectively. The weight assigned to control point P_{1} will control the position of the extra point. Since we use rational Bézier curve of degree 2, the coefficients are the following:
The equation of this rational Bézier curve of degree 2 is simply:
To continue our discussion, for convenience, let us put P_{0} and P_{2} on the opposite sides of the x-axis with the mid-point of P_{0}P_{2} being the coordinate origin. This will not affect our discussion because rational Bézier curves are projective invariant. Moreover, a simple translation followed by a rotation, both being Euclidean transformations, can get the job done. With this setting, we have P_{0} = -P_{2}. Let the mid-point of P_{0}P_{2} be M, and let the rational Bézier curve meets the line segment MP_{1} at X as shown below.
Let us evaluate C(u) at u=0.5. Keep in mind that we have made P_{0} = -P_{2}. A simple calculation gives us the following:
Since C(0.5) and X are the same point, X and control point P_{1} are on the same line through the coordinate origin M, and the length of the vector X is w/(1+w) times of the length of vector P_{1}. In other words, we have |MX|/|MP_{1}| = w/(1+w).
We know that if w = 1, the rational Bézier curve becomes a Bézier curve, which is a parabola. In this case, since |MX|/|MP_{1}| = w/(1+w) = 1/2, point X is the mid-point of the line segment MP_{1}.
When is this rational Bézier curve an ellipse or a hyperbola? The answer comes from a theorem in projective geometry. From a point A outside of a given conic curve draw two tangents meeting the curve at X and Y, and an arbitrary secant line that meets the chord XY at C and the conic at B and D with B being inside of the triangle AXY as shown in the figures below. Note that if the curve is an ellipse, the order of these points is A, B, C and D; however, if it is a hyperbola, point D lies on the other branch of the curve!
(a) Ellipse | (b) Hyperbola |
Then, a theorem in projective geometry states that the following relation holds.
Note that a correct version of this theorem should use signed distance; however, singed distance is not used here because we do not need it. A simple manipulation yields the relation below.
Since |CA| = |CB| + |BA|, we can compute |CB|/|CA| as follows:
If the curve is an ellipse (resp., hyperbola), we have |DA| > |DC| (resp., |DA| < |DC|), and, hence, |CB|/|CA| is less (resp., larger) than 1/2.
Return to our rational Bézier curve, we have P_{0}=X, P_{1}=A, P_{2}=Y, M = C and X = C(0.5) = B. Consequently, for the case of an ellipse, we have
This means we have an ellipse if w < 1. Similarly, we have a hyperbola if w > 1.
The following summarizes the findings:
The rational Bézier curve defined by three non-collinear control points P_{0}, P_{1} and P_{2} and weights 1, w and 1 is a hyperbola, a parabola or an ellipse if w is greater than, equal to, or less than 1. |