Bernstein Polynomials and Tangents
Multiply out de Casteljau's lerps and a cubic Bézier becomes a blend of its four control points, with weights that are never negative and always add to . Differentiate the blend and you get the velocity of a point moving along the curve: at each end it points straight along the handle, and it's three times as long.
What the symbols mean
- Weight of P₀
Starts at 1 and fades to 0: the start point is in charge early on.
- Weight of P₁
Zero at both ends, largest (4/9) at t = 1/3.
- Weight of P₂
Zero at both ends, largest (4/9) at t = 2/3.
- Weight of P₃
Grows from 0 to 1: the end point takes over at the end.
What the symbols mean
- Velocity
How fast and in which direction the point moves, per unit of t. It's tangent to the curve.
- First handle
The arrow from the start point to the first handle.
- Middle leg
The arrow along the middle of the control polygon.
- Last handle
The arrow from the second handle to the end point.
What the symbols mean
- Acceleration
How the velocity changes, per unit of t squared. Needed for smooth joins in the next lesson.
Explanation
Bernstein polynomials are the four weights that say how much each control point counts at a given moment: , , and . They're named after Sergei Bernstein, a mathematician who used them in 1912 to prove that polynomials can imitate any continuous function, decades before anyone drew a curve with them. All we're really saying is that a point on a Bézier curve is a blend of the control points, like mixing paint: at the start it's all , at the end it's all , and in between it's some of each. The velocity formula looks long, but it's the same kind of blend applied to the three arrows of the control polygon instead of the four points. Bear with it; it's two ideas, not twenty.
From lerps to weights. In Bézier Curves by Repeated Lerp we multiplied out a quadratic and got . The cubic works the same way, and there's a neat way to see where its weights come from. Every round of de Casteljau multiplies by (the weight on the left point of a lerp) or by (the weight on the right one). To get from to the final point you go through three rounds, and you must pick exactly once and twice. There are ways to choose which round picks , so ends up with weight . can only ever be a left point, so it gets . The in front are a row of Pascal's triangle, and a degree- curve uses the weights .
The weights add to 1. Expand with the binomial theorem and you get exactly the four weights. But , and . So for every ,
and for between and every weight is or positive. That makes a true weighted average of the control points, which is the convex hull property again, from a different angle. Each weight also has its moment: is biggest at , peaks at with value , peaks at , and is biggest at . Control passes from point to point like a baton, and there's an animation further down that shows the four weights trading off as moves.
Velocity: differentiate the blend. The control points are constants, so only the weights get differentiated. Using the chain rule (The Chain Rule) and the product rule:
Now collect by pieces. Everything multiplying is . Everything multiplying is . Everything multiplying is . Put together, that's the velocity formula at the top. Notice what it is: a quadratic Bézier whose three "control points" are the arrows , , , times . Differentiating a Bézier gives a Bézier one degree lower.
The ends point along the handles. Put in the velocity: only the first term survives, so . At only the last survives: . That's the reason the pen tool feels the way it does. Dragging a handle sets the direction the curve leaves its anchor point, and the handle's length sets how fast the point leaves, three times the handle per unit of . A long handle keeps the curve heading that way for longer before it bends.
A shortcut from de Casteljau. The last segment in the construction, from to , is always tangent to the curve, and the velocity is exactly . So one run of de Casteljau gives you the point and its velocity together.
Velocity in real seconds. If an object follows the curve over seconds, then , and by the chain rule its velocity is . If the control points are in meters, that's meters per second, and the speed is its length . Differentiate once more to get the acceleration in the last formula (per unit ; divide by for seconds). The next lesson needs it to join curves without a jolt.
// Velocity of a cubic Bézier, one coordinate (per unit of t; divide by the duration for per second).
function bezierVelocity(p0: number, p1: number, p2: number, p3: number, t: number): number {
const u = 1 - t;
return 3 * (u * u * (p1 - p0) + 2 * u * t * (p2 - p1) + t * t * (p3 - p2));
}
A common mistake. It's tempting to write , since the handle is the arrow you can see. That's the right direction but a third of the speed: the comes down from the cube in . A second slip is forgetting to divide by the duration when the motion takes seconds. The formula gives velocity per unit of , and a camera move that lasts seconds goes a quarter as fast as that.
See it
Worked examples
A cubic Bézier has control points , , and . Find its velocity at , and , and compare the speeds.
- 1
The velocity formula only needs the three arrows of the control polygon, so find those first. .
A drone flies the cubic Bézier with control points , , and , in meters, and the flight takes seconds. Find its velocity and speed at takeoff and seconds in.
- 1
First turn clock time into the curve's parameter: . Takeoff is and seconds in is .
Practice
Type your answer and check it. Solve them all to complete the lesson.
A cubic Bézier has control points , , and . Find its velocity at the end of the curve. Enter it as .
A cubic Bézier has control points , , and . Find . Enter it as .
For a cubic Bézier, how much weight does the first handle get at ?
A one-dimensional cubic Bézier has control values , , and . Write it as an ordinary polynomial in .
A delivery drone flies a cubic Bézier that starts at with first handle , in meters, and ends at . The whole flight takes seconds. How fast is it moving at takeoff, in m/s?
A designer wants a cubic Bézier from to that leaves the start moving straight up and arrives at the end moving straight down. Which handles do that?
A cubic Bézier has control points , , and . What is the highest point the curve reaches? Give the height .
The hardest one here. Get it, and you've got this lesson.
A camera dolly moves along a cubic Bézier from to , in meters, in seconds. It must leave the start with velocity m/s and arrive at the end with velocity m/s. Find the handles that do this, then find the dolly's speed halfway through the move, at second.
Where it's used
Every vector drawing tool shows you and directly: they're the handles, and dragging one changes how the curve leaves its anchor. Animation software uses the same derivative to orient a character or a camera along a motion path (face along ), and games use it to bank a vehicle or point a projectile along a rail. Robot arms and CNC machines check and along a planned path so that no joint is asked for more speed or acceleration than its motor can give.