Derivatives of a Bézier Curve

To compute tangent and normal vectors at a point on a Bézier curve, one must compute the derivative at a point. Fortunately, computing derivative at a point on a Bézier curve is extremely easy.

Recall that the Bézier curve defined by n + 1 control points p0, p1, ..., pn has the following equation:

where the Bézier coefficient Bn,i(u) is defined as follows:

Since the control points are constant and independent of the variable u, computing p'(u) reduces to computing the derivative of the Bézier coefficients. With some simple algebraic manipulations, we have the following result for B'n,i(u):

Then, computing the derivative of the curve p(u) yields:

Let q0 = n(p1 - p0), q1 = n(p2 - p1), q2 = n(p3 - p2), ..., qn-1 = n(pn - pn-1). The above equation reduces to the following:

Therefore, the derivative of p(u) is a degree n - 1 Bézier curve defined by n control points n(p1 - p0), n(p2 - p1), n(p3 - p2), ..., n(pn - pn-1). This derivative curve is usually referred to as the hodograph of the original Bézier curve.

It should not be surprised that the derivative curve is of degree n - 1, since p(u) is a degree n curve. The beauty is that p'(u) is also a Bézier curve described elegantly with the given control points. Note that (pi+1 - pi) is the direction vector from pi to pi+1 and n(pi+1 - pi) is n times longer than the direction vector. Once the control points are known, the control points of its derivative can be obtained immediately. The left figure below shows a Bézier curve of degree 7 and the right figure shows its derivative which is a degree 6 Bézier curve.

Bézier Curves Are Tangent to Their First and Last Legs

Letting u = 0 and u = 1 gives p'(0) = n(p1 - p0) and p'(1) = n(pn - pn-1) The first means that the tangent vector at u = 0 is in the direction of p1 - p0 multiplied by n. Therefore, the first leg in the indicated direction is tangent to the Bézier curve. The second means that the tangent vector at u = 1 is in the direction of pn - pn-1 multiplied by n. Therefore, the last leg in the indicated direction is tangent to the Bézier curve. The following figures show this property well.

This nice property (i.e., a Bézier curve being tangent to its first and last legs) provides us with a technique for joining two or more Bézier curves together for designing a desired shape. Let the first curve be defined by m + 1 control points p0, p1, p2, ..., pm and hence its degree is m. Let the second curve be defined by n + 1 control points q0, q1, q2, ..., qn and hence its degree is n. If we want to join these two Bézier curves together, then pm must be equal to q0. This would guarantee a C0 continuous join. Please recall that the first curve is tangent to its last leg and the second curve is tangent to its first leg. Consequently, to achieve a smooth transition, pm-1, pm = q0, and q1 must be on the same line such that the directions from pm-1 to pm and the direction from q0 to q1 are the same. This is shown below.

While joining two Bézier curves in this way looks smooth, mathematically is it still a C0 join and is not yet C1. However, it is G1, because they have the same tangent vector directions and have a common tangent line. To achieve C1 continuity, one has to make sure that the tangent vector at u = 1 of the first curve, p'(1), and the tangent vector at u = 0 of the second curve, q'(0), are identical. That is, the following must be true:

m(pm - pm-1) = n(q1 - q0)

This relation states that to achieve C1 continuity at the joining point the ratio of the length of the last leg of the first curve and the length of the first leg of the second curve must be n/m. Since the degrees m and n are fixed, one can adjust the positions of pm-1 and q1 on the same line so that the above relation is satisfied.

The following left figure has two Bézier curves. The light color polyline defines a Bézier curve of degree 4 while the dark color polyline defines a Bézier curve of degree 5. Since the last leg of the first curve and the first leg of the second are not on the same line, the two curves are not joint smoothly. The right figure shows two Bézier curves that are tangent to a line at the joining point. However, they are not C1 continuous there. The left curve is of degree 4, while the right curve is of degree 7. But, the ratio of the last leg of the left curve and the first leg of the second curve seems near 1 rather than 7/4=1.75. To achieve C1 continuity, one should increase (resp., decrease) the length of the last (resp. first) leg of the left (resp., right). However, they are G1 continuous.

There is one more interesting application of this tangency property. If we let the first and last control points be identical (i.e., p0 - pn) and p1, p0 and pn-1 collinear, the generated Bézier curve will be a closed one and is G1 continuous at the joining point as shown below:

Note that although the above curve looks like an ellipse, it is not because this curve is of degree 6 and Bézier curves are polynomials which cannot represent circles and ellipses.

Higher Derivatives

Computing higher order derivatives of a Bézier curve is a simple matter. Recall that the derivative of p(u) is the following:

Applying the derivative formula to the above Bézier curve yields the following, which gives the second derivative of the original Bézier curve:

After obtaining p'(u) and p''(u), the moving triad and curvature at p(u) can be computed easily. Higher derivatives can be found by recursively applying the formula of derivative.