Bezier Curve
calculator.
Find the point, tangent, length and split of a Bezier curve at any value of t.
- Speed |B′(t)|
- 5.1845
- Tangent direction
- 32.66°
- Curvature κ
- −0.4214
At t = 0.35 the point is 35% of the way through t and 36.2% of the way along the curve by length, 2.1086 of 5.8299. It is turning right here, along a circle of radius 2.37. It turns back once, so the curve itself spans x 0 to 4 and y 0 to 1.89.
The curve and its construction
Drag a control pointCubic Bezier curve from (0, 0) to (4, 0) with control points P₀ (0, 0), P₁ (1, 2), P₂ (3, 3), P₃ (4, 0). The construction at t = 0.35 reaches (1.33, 1.6), with the tangent pointing 33° from the x-axis. Rings mark 1 turning point; the dotted box is the curve's tight box, x 0 to 4 and y 0 to 1.89.
Dashed: the control polygon. Thin lines and small dots: each round of the construction at t. The line from the point is the tangent direction. Rings: where the curve turns back in x or y. Dotted: the tight box.
Working
- 1Cubic curve, so 3 rounds of interpolationP₀ = (0, 0)P₁ = (1, 2)P₂ = (3, 3)P₃ = (4, 0)
- 2Round 1: move 0.35 of the way from each point to the next(0.35, 0.7)(1.7, 2.35)(3.35, 1.95)
- 3Round 2: move 0.35 of the way from each point to the next(0.8225, 1.2775)(2.2775, 2.21)
- 4Round 3: move 0.35 of the way from each point to the next(1.3318, 1.6039)
- 5The last point left is on the curveB(0.35) = (1.3318, 1.6039)
- 6Check: the Bernstein weights times the control points give the same pointweights 0.2746, 0.4436, 0.2389, 0.0429sum = (1.3318, 1.6039)
- 7Tangent: the derivative is a curve with control points 3(Pᵢ₊₁ − Pᵢ)(3, 6), (6, 3), (3, −9)B′(0.35) = (4.365, 2.7975)
Turning points and the tight box
- y turns at t = 0.5486
- (2.2184, 1.8934)
- x runs
- 0 to 4
- y runs
- 0 to 1.8934
A turning point is where x′(t) or y′(t) is 0. With the two end points, these give the smallest box around the curve, which can be smaller than the box around the control points.
Splitting the curve at t = 0.35
| Point | Left piece | Right piece |
|---|---|---|
| Q₀ | (0, 0) | (1.3318, 1.6039) |
| Q₁ | (0.35, 0.7) | (2.2775, 2.21) |
| Q₂ | (0.8225, 1.2775) | (3.35, 1.95) |
| Q₃ | (1.3318, 1.6039) | (4, 0) |
The left piece runs from P₀ to B(t) and the right piece from B(t) to P₃; each is a curve of the same degree.
Coordinates along the curve
| t | x(t) | y(t) | Length |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0.05 | 0.1573 | 0.2921 | 0.3318 |
| 0.1 | 0.328 | 0.567 | 0.6555 |
| 0.15 | 0.5108 | 0.8224 | 0.9695 |
| 0.2 | 0.704 | 1.056 | 1.2728 |
| 0.25 | 0.9063 | 1.2656 | 1.5642 |
| 0.3 | 1.116 | 1.449 | 1.8429 |
| 0.35 | 1.3318 | 1.6039 | 2.1086 |
| 0.4 | 1.552 | 1.728 | 2.3615 |
| 0.45 | 1.7753 | 1.8191 | 2.6028 |
| 0.5 | 2 | 1.875 | 2.8347 |
For code
- SVG path
- M 0 0 C 1 2, 3 3, 4 0
Keyboard shortcuts
- Tab to a control point on the drawing, then the arrow keys move it one small grid step. Hold Shift for ten steps.
- Tab to the t slider, then ← and → move t by 0.01.
How it's worked out
A Bezier curve is set by its control points. The first and last are the ends of the curve. The ones between act like magnets: they pull the curve toward them without the curve passing through them. With n + 1 points the curve has degree n, so 4 points make a cubic.
The number t runs from 0 at the start to 1 at the end. Each point on the curve is a weighted average of the control points, and the weights are the Bernstein polynomials:
The weights are never negative and add to 1, so the curve stays inside the shape made by its control points. At t = 0.5 a cubic uses the weights 0.125, 0.375, 0.375, 0.125.
De Casteljau's method finds the same point by drawing. Move the fraction t of the way along each side of the control polygon. That gives one point fewer. Repeat until one point is left, and that point is on the curve. The Bézier primer calls it a geometric approach, and it is the one the tool uses, with the weighted sum as the check.
The tangent comes from the derivative, which is itself a Bezier curve one degree lower, with control points:
So a cubic leaves its first point heading straight at the second: here B′(0) = (3, 6), which is 3 times the step from P₀ to P₁.
Arc length has no closed formula for a cubic, the primer notes, so it is worked out by Gauss-Legendre quadrature: the speed is sampled at five set points in each of 64 slices of t and added with set weights. Turning points are where x′(t) or y′(t) is 0, and with the two ends they give the smallest box around the curve.
Worked examples
Kai places a marker on an animation path
Kai animates a dot along a cubic path in pixels, with control points (0, 0), (40, 120), (160, 120) and (200, 0). He wants the halfway point and the way the dot should face.
At t = 0.5 the dot is at (100, 90), the top of the arch, and the tangent points 0° from the x-axis, so it is moving level. The whole path is 287.6 px long.
t is not distance. At t = 0.25 the dot has gone 80.7 px, which is 28.1% of the path, not 25%. For even spacing he should step by length, using the length column of the coordinates table.
Rosa checks the CSS ease-in-out curve
The CSS Easing Functions spec fixes P₀ at (0, 0) and P₃ at (1, 1), and defines ease-in-out as cubic-bezier(0.42, 0, 0.58, 1). The x value is the share of the time gone and y is the share of the change done.
At t = 0.25 the point is (0.2744, 0.1563). So when 27.4% of the time has passed, the animation is 15.6% done. That slow start is what "ease in" means.
A browser works the other way: it knows the time, so it solves x(t) for t first and then reads y. The tool prints the cubic-bezier text whenever the points fit those rules.
Tom finds the true height of an arch
Tom draws an arch for a sign with control points (0, 0), (1, 2), (3, 3) and (4, 0). The control points reach y = 3, but the curve does not.
y stops rising where y′(t) = 0, at t = 0.5486. The top of the arch is at (2.2184, 1.8934), so the tight box is 4 wide and 1.8934 tall. The primer finds a box the same way, from the roots of the derivative.
The top is not at t = 0.5. There the curve is at (2, 1.875), a little lower and to the left, because the second handle is higher than the first.
Reading your result
The point B(t) is where the curve is at your t. The working lists every round of De Casteljau, and the last step checks the answer with the Bernstein weights.
Speed is how fast the point moves as t grows, in your units per unit of t. Tangent direction is the angle of travel from the positive x-axis, which is how you would rotate an object riding the curve.
Curvature is positive when the curve turns left, with y pointing up, and negative when it turns right. One over its size is the radius of the circle that best fits there. Where the speed is 0 there is no direction and no curvature, and the tool says so.
The split gives two new sets of control points, one for the piece before t and one for the piece after. Together they draw the same curve.
Common mistakes
- Expecting the curve to pass through every point. Only the first and last points are on it. To pass through a point in the middle, join two curves there.
- Using t as time or distance. Equal steps in t bunch up where the curve moves slowly and spread out where it moves fast.
- Taking the control-point box as the size. The handles usually stick out past the curve, as the arch example shows. Use the tight box.
- Building a circle from one cubic. A cubic cannot be a true circle. With handles of about 0.552285 on a quarter circle, the midpoint lands at (0.7071, 0.7071), on the circle, but other points are slightly off.
- Breaking the CSS rule. A cubic-bezier easing needs both middle x values from 0 to 1; outside that the tool does not print one.