How does a Catmull-Rom spline pass through every waypoint of a camera path, and how does it relate to a cubic Hermite curve?
answer
- points, not handles
- endpoints plus end tangents
- tangent from both neighbours
- half of next minus previous
basics
~20 sEach Catmull-Rom segment is a cubic Hermite curve whose end tangents come from the neighbours: half the vector from the previous to the next waypoint. Hermite curves hit their endpoints by design, so every waypoint is passed with a shared tangent.
solid answer
~50 sA cubic Hermite segment is defined by two endpoints and their tangents, blended with the basis `h00 = 2t^3 - 3t^2 + 1`, `h10 = t^3 - 2t^2 + t`, `h01 = -2t^3 + 3t^2`, `h11 = t^3 - t^2`; at `t = 0` it equals `P1` and at `t = 1` it equals `P2`. Catmull-Rom removes the need to author tangents: for the segment from `P1` to `P2` it sets `m1 = (P2 - P0) / 2` and `m2 = (P3 - P1) / 2`. Neighbouring segments compute the same tangent at their shared waypoint, so the path is C1 continuous, and each segment depends on only four points, so moving one waypoint reshapes only nearby segments. The ends need an invented neighbour. It can overshoot between points, and with uneven spacing the uniform version can loop, which the centripetal variant avoids.
code
pseudocode · 14 lines// segment from p1 to p2, neighbours p0 and p3, t in [0, 1]
function catmullRom(p0, p1, p2, p3, t):
t2 = t * t
t3 = t2 * t
return 0.5 * ( 2 * p1
+ (p2 - p0) * t
+ (2 * p0 - 5 * p1 + 4 * p2 - p3) * t2
+ (3 * p1 - p0 - 3 * p2 + p3) * t3 )
// equivalent Bezier control points for the same segment
b0 = p1
b1 = p1 + (p2 - p0) / 6
b2 = p2 - (p3 - p1) / 6
b3 = p2go deeper
Recall that Catmull-Rom passes through every waypoint and computes each tangent from the waypoints either side.
Write the Hermite form and the tangent rule (P2 - P0) / 2, explain C1 continuity and locality, and convert a segment to Bezier control points.
Diagnose overshoot, cusps and loops from uneven spacing, choose centripetal parameterisation, and handle path ends and tension deliberately.
Pick the spline family and parameterisation your path tools ship with, weighing designer expectations of passing through points against overshoot.
## The problem: designers place points, not handles A cinematic camera path is usually authored as a list of **waypoints** the camera must pass through. A Bezier curve does not suit that directly: it passes through its endpoints but only approaches its handles, so someone would have to author two extra handles per segment and keep them aligned. A **Catmull-Rom spline** passes through every waypoint and works out the tangents itself, which is why it is the default choice for paths built from points. ## Cubic Hermite curves A **cubic Hermite segment** is defined by two endpoints `P1`, `P2` and the tangents `m1`, `m2` at them, blended with four basis functions: `H(t) = h00(t) P1 + h10(t) m1 + h01(t) P2 + h11(t) m2` | Basis | Formula | Value at 0 | Value at 1 | Slope at 0 | Slope at 1 | |---|---|---|---|---|---| | `h00` | `2t^3 - 3t^2 + 1` | 1 | 0 | 0 | 0 | | `h10` | `t^3 - 2t^2 + t` | 0 | 0 | 1 | 0 | | `h01` | `-2t^3 + 3t^2` | 0 | 1 | 0 | 0 | | `h11` | `t^3 - t^2` | 0 | 0 | 0 | 1 | The table is the whole design: each basis function controls exactly one of the four end conditions and is zero on the other three, so `H(0) = P1`, `H(1) = P2`, `H'(0) = m1` and `H'(1) = m2` by construction. A Hermite curve therefore always passes through its endpoints with exactly the tangents you give it. ## Catmull-Rom: tangents from neighbours Catmull-Rom is a rule for choosing those tangents from the waypoints themselves. For the segment from `P1` to `P2`, with neighbour `P0` before and `P3` after: 1. set `m1 = (P2 - P0) / 2`, half the vector from the previous waypoint to the next; 2. set `m2 = (P3 - P1) / 2` the same way at the other end; 3. evaluate the Hermite segment with those tangents for `t` in [0, 1]; 4. move on to the next segment, which uses the four waypoints shifted along by one. Folding the tangents into the basis gives the closed form in the code example; at `t = 0.5` its weights on `P0..P3` are `-1/16, 9/16, 9/16, -1/16`. Three properties follow: - **it interpolates**: every interior waypoint is the end of one segment and the start of the next; - **it is C1 continuous**: the two segments meeting at a waypoint compute the same tangent from the same two neighbours, so position and first derivative match. The second derivative generally does not, so it is not C2 and curvature can change abruptly at a waypoint; - **it is local**: each segment depends on four waypoints, so moving one waypoint reshapes at most the four segments that use it, not the whole path. ## Converting to Bezier control points A Hermite segment and a cubic Bezier are both cubics, so one converts exactly into the other: the Bezier handles sit one third of the way along each tangent. For a Catmull-Rom segment that gives `B0 = P1`, `B1 = P1 + (P2 - P0) / 6`, `B2 = P2 - (P3 - P1) / 6`, `B3 = P2`. Worked example with `P0 = (0, 0)`, `P1 = (2, 0)`, `P2 = (4, 2)`, `P3 = (6, 2)`: `B1` is about `(2.67, 0.33)` and `B2` about `(3.33, 1.67)`, and both forms give `(3, 1)` at `t = 0.5`. The conversion lets a Catmull-Rom path reuse Bezier tooling: de Casteljau evaluation, splitting, flattening and convex-hull bounds of the converted control points. ## Overshoot, loops and the centripetal variant Catmull-Rom weights go negative (the `-1/16` above), so unlike a Bezier the curve can leave the convex hull of its four points and **overshoot** around sharp turns. The uniform version also gives every segment the same parameter span regardless of its length, which causes trouble with uneven spacing: - beside a long segment, a short one inherits a tangent sized for its long neighbour and can bulge, form a **cusp** or even **loop**; - **centripetal Catmull-Rom** spaces the parameter values (the knots) by the square root of the distance between consecutive waypoints, and is known not to form cusps or self-intersections within a segment; - **chordal** spacing uses the full distance and gives rounder, wider turns; uniform, centripetal and chordal correspond to exponents 0, 0.5 and 1 on that distance. ## Ends of the path and tension - **The first and last segments lack a neighbour.** With waypoints `W0, W1, ...`, duplicating `W0` as its own neighbour gives an end tangent of `(W1 - W0) / 2`; reflecting, `2 * W0 - W1`, gives `W1 - W0`, the full first chord, so the path leaves its end along that chord at the speed its length implies. Closed loops simply wrap the indices. - **Tension** generalises the tangent rule: a cardinal spline uses `(1 - c) * (P2 - P0) / 2`, where `c = 0` is Catmull-Rom and `c = 1` makes every tangent zero, so the camera eases to a stop at each waypoint. - **Speed is still uneven.** Passing through the points says nothing about moving along them at constant speed; that needs arc-length reparameterisation on top.
- Why does a uniform Catmull-Rom camera path sometimes loop or kink when two waypoints sit close together, and what fixes it?Uniform parameterisation gives every segment the same span of `t` whatever its length, so a short segment beside long ones gets tangents sized for the long ones; the curve overshoots inside it and can cusp or loop. Centripetal Catmull-Rom spaces the knots by the square root of the distance between waypoints, which avoids cusps and self-intersections within a segment; inserting extra waypoints usually just moves the uneven spacing elsewhere.
- How do you handle the first and last segments, which have no outer neighbour?Invent one. Duplicating the end waypoint gives an end tangent of half the first chord, so the camera starts gently; reflecting the neighbour, `2 * W0 - W1`, gives the full first chord as tangent, so the camera leaves the end at speed along that chord. For a closed loop, wrap the indices so the last waypoint's neighbour is the first.
- Catmull-Rom tangents must be authored by hand at every waypoint.
- A Catmull-Rom spline stays inside the convex hull of its points, like a Bezier.
- Moving one Catmull-Rom waypoint reshapes the whole path.
- Uniform Catmull-Rom can never form a loop or a cusp.
- Catmull-Rom is C2 continuous, so curvature is smooth at every waypoint.