[Intermediate → Advanced] — Implicit, explicit and parametric curves; affine and barycentric combinations; where the Bézier weights come from; position, velocity, de Casteljau and splitting; B-splines and the Cox–de Boor recursion; Chaikin corner cutting; and drawing a curve with straight lines to a tolerance.
Part 1 of the course. Note 15 gives the big picture (NURBS, subdivision surfaces, CAD versus real-time). This note is the hand-calculation version that SSG 511 Q1(c) is worth 15 marks on.
Before you start
You can add vectors and multiply them by numbers, expand and , and differentiate a polynomial.
After this note you will be able to:
- Choose between implicit, explicit and parametric forms and say why.
- Find a cubic Bézier’s control points from end positions and velocities, and evaluate and .
- Run de Casteljau by hand and read off the control points of each half.
- Explain local versus global control, and what the B-spline knot vector does.
The kid version
Stick a pin in a board at the start and another at the end, and add a couple of “magnet” pins in between. A bendy wire runs from the first pin to the last and is pulled towards the magnets without usually touching them. Move a magnet and the wire bends. That wire is a Bézier curve, and the pins are its control points.
There’s a neat way to find any point on it: join the pins with straight lines, mark the point a fraction along each line, join those marks, mark along those, and keep going until one point is left. That point is on the curve. That’s de Casteljau’s algorithm.
Where the analogy stops working. With a Bézier curve, moving any magnet nudges the whole wire, even far away. B-splines fix that: each control point only influences a nearby stretch.
Terms used in curves
- Control point: This is one of the points that shape the curve.
- Control polygon: This is the polyline joining the control points in order.
- Degree: This is the highest power of in the curve’s polynomial. For a Bézier curve it is the number of control points minus 1.
- Affine combination: This is a weighted sum whose weights add up to 1. It always gives a point, whatever coordinate system you use.
- Barycentric combination: This is an affine combination of a triangle’s three corners. The weights are the point’s barycentric coordinates.
- Bernstein basis functions: These are the weights that a Bézier curve gives its control points.
- Convex hull: This is the smallest convex shape containing all the control points — the shape a rubber band makes when stretched around them.
- Knot vector: This is the list of non-decreasing numbers that marks where a B-spline’s polynomial pieces join.
- Order: This is a B-spline’s degree plus 1, written .
- Local control: This is the property that moving one control point only changes the nearby part of the curve.
1. Three ways to represent a curve
| Type | Form | Circle of radius | Strength | Weakness |
|---|---|---|---|---|
| Implicit | Easy to test on/inside/outside — check the sign of | Hard to generate points in order | ||
| Explicit | Simple | Single-valued: one per , so no full circle or vertical line | ||
| Parametric | , | General: closed and multi-valued curves; tangents from the derivative; can be time | Needs a parameter; harder inside/outside test |
In a parametric curve, and give the coordinates while varies over an interval, usually . Adding gives a 3D curve. Bézier curves and B-splines are parametric.
2. Vectors and affine combinations
A vector has magnitude and direction. It can stand for a direction (a velocity) or a point in space; in 2D it has , components, in 3D , , . It can be scaled and added to or subtracted from another.
Two points. Any point on the segment from to is “start at and go a fraction of the way to ”:
The weights and sum to 1. A sum with is an affine combination. (The weights are ; is the parameter. Write "", not "".)
Three points (triangle ). Start at and move along the edges and :
Call ‘s weight . Then always. This is a barycentric combination — the same coordinates the rasteriser interpolates with in note 10.
3. Where the Bézier weights come from
For any , . Square both sides and expand:
Use those three terms as weights — they are never negative on and they sum to 1, so the result is an affine combination. That is the quadratic Bézier curve:
For control points, expand . Each term is one weight; Pascal’s triangle gives the coefficients.
| Degree | Coefficients | Curve |
|---|---|---|
| 1 | 1, 1 | |
| 2 | 1, 2, 1 | |
| 3 | 1, 3, 3, 1 |
4. Bézier curves
A Bézier curve is the Bernstein-weighted sum of its control points:
(Use one index throughout — summing over while the terms use is a common slip.)
- is the degree, the index, the variable, control point .
- Degree = number of control points − 1. Two points give a line, three a quadratic, four a cubic.
- It passes through the first and last control points (not usually the others), and lies inside the convex hull of its control points.
- Limits: the degree grows with the number of control points, so long curves get expensive and hard to control; and moving any one control point changes the whole curve (global control).
The cubic in detail
Position:
Do every calculation separately on each coordinate (, , ).
Matrix form. Expanding , , and :
(A cubic has four weights, so the column must hold four points.)
Velocity. If is time, the derivative is the velocity:
In general, the derivative of a degree- Bézier is a degree- Bézier whose control points are times the differences of neighbouring control points:
so .
End conditions. Put and into the two formulas:
So given start/end positions and velocities , , the control points follow directly:
Position at : every weight is times :
de Casteljau and splitting
To find , repeatedly take points a fraction of the way along each segment:
It forms a triangle of points; the one at the bottom is . It is numerically stable and needs only interpolation — no powers of .
Splitting. The part of the curve for is itself a cubic Bézier. Its control points are the left edge of the de Casteljau triangle at : . The second part uses the right edge, read from the bottom up.
For — the “first half” :
and the second half has control points , , , . It is still a cubic because replacing by in a degree-3 polynomial gives another degree-3 polynomial.
Properties
- Convexity of the basis: the weights are never negative and sum to 1.
- Convex-hull property: the curve lies inside the convex hull of its control points. (This is what makes cheap curve clipping possible → note 04.)
- Affine invariance: transforming the curve equals transforming its control points and redrawing — which is why you move a Bézier curve by moving four points.
- Linear precision: control points on a line give that line.
- Variation diminishing: no straight line crosses the curve more often than it crosses the control polygon.
- End tangents: the curve leaves towards and arrives at from .
5. Worked examples
(a) Control points from end conditions
Position at , at ; velocity at , at .
(b) de Casteljau at for , , ,
| Level | Points |
|---|---|
| 0 | (1,2), (3,8), (8,9), (7,3) |
| 1 | (2,5), (5.5,8.5), (7.5,6) |
| 2 | (3.75,6.75), (6.5,7.25) |
| 3 | (5.125, 7) |
. First half’s control points (first point of each level): . Second half (last point of each level, bottom up): . End tangents: , .
Check with the formula: . ✓
(c) A curve through two points with given slopes
A slope gives a direction, not a speed. So must lie on the line through with the first slope, and on the line through with the second slope — but how far along is your choice. Write and , pick sensible positive , (say a fraction of the distance between the points), state the choice, and substitute into the cubic. A different , gives a different curve through the same points with the same slopes.
Runnable check
# bezier.py — run: python3 bezier.py
def lerp(a, b, t):
return tuple((1 - t) * x + t * y for x, y in zip(a, b))
def de_casteljau(points, t):
"""Return all levels of the de Casteljau triangle; the last level is B(t)."""
levels = [list(points)]
while len(levels[-1]) > 1:
prev = levels[-1]
levels.append([lerp(prev[i], prev[i + 1], t) for i in range(len(prev) - 1)])
return levels
levels = de_casteljau([(1, 2), (3, 8), (8, 9), (7, 3)], 0.5)
for level in levels:
print(level)
first_half = [level[0] for level in levels]
second_half = [level[-1] for level in reversed(levels)]
print("first half:", first_half)
print("second half:", second_half)Expected: the four levels in the table above, then first half: [(1, 2), (2.0, 5.0), (3.75, 6.75), (5.125, 7.0)] and second half: [(5.125, 7.0), (6.5, 7.25), (7.5, 6.0), (7, 3)].
6. B-spline curves
A B-spline is built from several polynomial pieces joined smoothly. It is more flexible than a Bézier curve because the degree does not have to grow with the number of control points. It is a weighted sum of the control points with B-spline basis functions :
- There are control points. is the order, and the degree is .
- The knot vector marks where the pieces join.
- The basis functions come from the Cox–de Boor recursion. In words: order-1 functions are “1 on their own knot interval, 0 elsewhere”, and each higher order blends two neighbouring lower-order functions with linear ramps:
(A term with a zero denominator is taken as 0.)
- The maximum order is the number of control points (“the number of vertices defining the B-spline polygon”). With that order and suitable knots, the B-spline is a Bézier curve.
- Local control: is non-zero only on , so moving changes only that stretch.
- The basis functions are never negative and sum to 1, so the curve stays inside the convex hull of its control points.
- With distinct knots the curve has continuity . A cubic B-spline () is smooth up to the second derivative — why it is the default in modelling tools.
| Bézier | B-spline | |
|---|---|---|
| Degree | Number of control points − 1 | Chosen separately (order ) |
| Control | Global — one point moves the whole curve | Local — one point moves part of it |
| Extra ingredient | None | A knot vector |
| Relationship | A Bézier is a B-spline with order = number of control points |
7. Chaikin’s corner-cutting algorithm
Class notes only have the heading “curve drawing algorithm: George Chaikin’s algorithm”; this is the standard method — check it against the lecturer’s version.
Start with a polygon . For each edge , make two new points a quarter and three-quarters of the way along:
Replace the polygon with and repeat. Each round cuts the corners off, and the polygon converges to a smooth quadratic B-spline.
Worked — the closed square : after one round the 4 points become 8: . After the next round there are 16.
8. Drawing a curve with straight lines
Distance from a point to a segment
Assumptions: 2D Euclidean space; segment from to ; point ; (if , the distance is ).
- Let and .
- Project onto the line through and : . is , is .
- A segment stops at its ends, so clamp to .
- The closest point is ; the distance is .
Three cases: nearest to (), nearest to (), or the perpendicular foot in between.
Worked — segment to , , :
| P | t | Clamped | Closest point | Distance |
|---|---|---|---|---|
| (3,7) | 0.5 | 0.5 | (5,3) | |
| (12,2) | 1.15 | 1 | B (9,5) | |
| (0,0) | −0.15 | 0 | A (1,1) |
Rows 2 and 3 are why the clamp matters: without it you measure to the infinite line, which is wrong for a segment. (Also: , gives 1 for , 5 for , and 5 for .)
Flattening a quadratic Bézier to tolerance
Split the curve until each piece is nearly straight, then draw each piece as a line. The quadratic’s furthest point from its chord is at , where the tangent is parallel to the chord. That point is .
draw_bezier(P1, P2, P3, sigma):
M = (P1 + 2*P2 + P3) / 4
if distance(M, segment P1P3) <= sigma: # the point-to-segment routine above
draw_line(P1, P3) # flat enough
else: # de Casteljau split at t = 1/2
A = (P1 + P2) / 2
B = (P2 + P3) / 2
draw_bezier(P1, A, M, sigma) # first half
draw_bezier(M, B, P3, sigma) # second half
The flatness (maximum distance from the chord) is
and each split in half divides it by 4, so the recursion always stops. (Equivalently, it is half the distance of from the chord’s line — another common flatness test.)
Worked: , , . , so (indeed and the chord midpoint is ). For : , two levels of splitting, giving 4 straight segments.
Common pitfalls
- Mixing – with – labels mid-question. Pick one.
- Forgetting the factor 3 in , so instead of .
- Reading the second half from the wrong edge of the de Casteljau triangle.
- Not clamping in the point-to-segment distance.
- Treating a slope as a velocity — a slope fixes direction only.
- Reversed binomial index — the standard form is so the highest power of sits on the first point.
Check your understanding
- A cubic Bézier has . What is , and what does that mean physically?
- Why does moving one control point of a cubic B-spline with many points leave most of the curve unchanged?
- How many line segments does flattening need for a quadratic with at ?
Answers (after your attempt)
- Zero: the particle starts at rest (the curve still leaves towards ).
- Each basis function is non-zero only over knot intervals, so each control point’s weight is zero elsewhere.
- : two levels, 4 segments.
Practice — independent tasks
From SSG 511 — full wording in the question bank:
- Exam Q1(c) — particle from to , velocities and : equations, , , , and the first half’s control points.
- B-9 — , , , : sketch, de Casteljau , sketch the curve with end slopes.
- B-10 — the 2D particle with velocities and , including the second half’s control points.
- Supplementary 4–6 — point-to-segment distance, flattening, and the curve through slope 2 and slope 3.
Done when each agrees between the formula and de Casteljau, and the bezier.py script reproduces your halves.
Before moving on
Next: Visible Surface Detection.
Related
- Geometry and Meshes — NURBS, subdivision surfaces, the CAD divide
- Animation — curves as motion paths
- Interpolation and splines
- Computer graphics map
Software engineering
Infrastructure & security
Computer science
Hardware & engineering