← All Labs
MATHS · VISUAL LAB · IDEA 41

Transformations — the space between two poses

Give a computer a start and an end — two positions, two orientations — and ask for the "in‑between." There is no single answer. Lerp walks the straight chord and blends the raw numbers; slerp swings the true arc at a steady turning rate; easing keeps the path but bends time. Drag the blue and pink craft, spin their headings, then scrub t and watch three different "middles" appear at once. How you interpolate is a design decision, not a law of nature.

DRIVE IT

Two poses, three in‑betweens.

Drag a craft's body to move it; drag its ring handle to rotate it. The pale disc is the slerp pivot — drag it too. Then scrub the time slider.
p5.js · LIVE
Drag the blue craft (start) and pink craft (end). Scrub t to send all three in‑betweens along their paths.
TIME  t0.35
eased t' = ease(t)
lerp heading
slerp heading
lerp turn‑rate
slerp turn‑rate
lerp path length
slerp path length
start / end lerp slerp eased
WALKTHROUGH

What to try, what to notice

Five moves that separate the three notions of "in‑between."
5 STEPS
1
Scrub t and watch the split. Slide t from 0 to 1. At the ends all three craft coincide with the blue and pink originals — that's the one rule every interpolation must obey (hit the endpoints). It's the middle where they disagree.
2
Straight chord vs. true arc. Move the pink craft far from the blue one. The lerp path is a dead‑straight line; the slerp path bows into an arc around the pale pivot. Drag the pivot and the arc reshapes — slerp interpolates angle about a centre, not raw coordinates.
3
Turn one craft most of the way around. Rotate the pink craft's heading. The slerp craft turns at a steady rate; the lerp craft — blending the heading vector's raw x,y — rushes through the middle angles and its little arrow even shrinks inside the circle. Check the two "turn‑rate" numbers: slerp is constant, lerp is not.
4
Turn on the ticks. The dots mark equal steps of t (0, 0.1, 0.2 …). On the lerp/slerp paths they're evenly spaced — constant speed. On the eased path they bunch and stretch: same route, but the craft lingers, then lunges. That bunching is the easing curve, drawn in space.
5
Swap easing curves. Try ease‑in‑out, then back (overshoot) and bounce. Overshoot pushes the eased craft past the target before settling; bounce lands and rebounds. None of this changes the geometry — only the mapping t' = ease(t) from clock‑time to path‑time.
AHA

"In‑between" is a choice

The single idea to leave with.
THE POINT
AHA MOMENT
Two endpoints do not determine the road between them. Lerp blends the numbers and takes the shortest chord; slerp honours the geometry of rotation and sweeps a constant‑rate arc; easing leaves the road alone and reshapes the passage of time. Interpolation isn't "the" middle — it's a designer choosing which middle, and every animation, camera move and morph you've ever seen is that choice made visible.
EXPLANATION

The maths, computed live

Every path, angle and tick is solved from the live handle positions each frame — no pre‑baked plots.
UNDER THE HOOD

Linear interpolation (lerp). The workhorse: blend two quantities in a straight line and scale the blend by t ∈ [0,1].

Applied to the two positions it traces the straight chord. Applied to the two heading vectors it blends their x,y components — which is why the lerped arrow dips inside the unit circle and turns unevenly.

Spherical interpolation (slerp). For orientations, blend along the arc at constant angular speed. On the circle/sphere of unit directions,

Ω is the angle between the two directions. The result stays exactly unit‑length and sweeps Ω at a uniform rate — the property lerp lacks. In 2D this reduces to advancing the heading angle linearly along the shortest arc.

Here the craft's position‑slerp swings around a movable pivot p: interpolate the polar angle on the shortest arc and the radius linearly,

Δθ is the signed shortest angle from A to B about the pivot. Equal radii give a circular arc; unequal radii give a smooth spiral.

Easing. Easing never touches the path. It replaces the clock with a reparametrised time t' = e(t), then interpolates as usual with t'. A valid easing pins the ends, e(0)=0, e(1)=1, and is free in between:

A zero slope at both ends (smoothstep) reads as a gentle start and stop. "Back" lets e(t) exceed 1 briefly (overshoot); "bounce"/"elastic" oscillate before settling.

The equal‑t tick dots make easing legible: they sit at t = 0, 0.1, …, 1, but the craft sits at e(t), so where e is steep the dots race apart and where e is flat they crowd.

The derivative of the easing curve is the craft's speed. Flat curve → slow; steep curve → fast. That's the whole feel of an animation in one function.

Why slerp needs 3D in general. Real orientations live on the unit quaternions (a 3‑sphere); slerping them is the honest way to blend two 3D rotations without the wobble and gimbal artefacts of blending Euler angles. This 2D lab is that idea's shadow — it links directly to the repo's quaternions and Hopf‑fibration pieces.

Where you meet it. Camera fly‑throughs, character animation "tweening," morph transitions, keyframe curves in After Effects/Blender, texture and colour blends, and robot trajectory planning are all this same three‑way choice: blend the numbers, blend the geometry, or blend the time.

RESEARCH NOTE

What's genuine here

Provenance & verification.
HONESTY

Real computation. Each frame the sketch reads the live pose handles (positions and headings of A and B and the pivot) and recomputes, from scratch: the lerp chord as (1−t)A+tB; the slerp arc by interpolating the shortest polar angle about the pivot with a linearly‑blended radius; the lerp heading by blending the raw heading unit vectors and taking atan2; the slerp heading by advancing the angle along the shortest arc at constant rate; and the eased pose by feeding t'=e(t) into the straight‑line blend. Nothing is tabled or pre‑rendered.

Cross‑checks on screen. The "turn‑rate" readout numerically differentiates each heading (finite difference around t); slerp reports a flat rate while lerp visibly varies — the textbook signature. Path lengths are integrated by sampling each curve at 240 points and summing segment lengths, so the slerp arc always reports longer than the lerp chord for the same endpoints, matching "a chord is the shortest path." The equal‑t ticks are placed at exact tenths of t, so their spacing is a direct read‑out of local speed e'(t).

Honest limits. True orientation slerp lives on unit quaternions; the 2D reduction used here is exact for planar rotations (a single angle) but is a simplification of the full 3D story — flagged, not hidden. When the two headings are exactly antipodal the shortest arc is ambiguous; the code picks the positive direction deterministically rather than pretending the choice doesn't exist.

Built to sit beside the repo's other applets (Quaternions, Hopf fibration #21, Matrices #40, Eigenvectors #23). Idea #41 from the 45 maths visual‑teaching ideas list. Tech: p5.js + KaTeX, self‑contained single file, no build step.