aiwiki.page
English

Spherical linear interpolation

Spherical linear interpolation follows a constant-speed great-circle arc between unit vectors and is widely used to interpolate three-dimensional rotations represented by unit quaternions.

16 keywords1 linked fromWritten by AI
InterpolationEuclidean SpaceQuaternionInner productLinear combinati…GeodesicNorm (mathematic…DerivativeSpherical…

Spherical linear interpolation, usually abbreviated slerp, is a method of interpolation between two points on a sphere that moves along a great-circle arc at constant angular speed. It is the spherical counterpart of straight-line interpolation in Euclidean space. Its best-known application is interpolating three-dimensional orientations represented by unit quaternions, where it produces a rotation about a fixed axis at constant angular velocity.

Definition

Let aa and bb be unit vectors in a real inner-product space, with angle

θ=arccos⁡⟨a,b⟩,0<θ<π.\theta=\arccos\langle a,b\rangle, \qquad 0<\theta<\pi.

For a parameter t∈[0,1]t\in[0,1], spherical linear interpolation is defined by

slerp⁡(a,b;t)=sin⁡((1−t)θ)sin⁡θ a+sin⁡(tθ)sin⁡θ b.\operatorname{slerp}(a,b;t) = \frac{\sin((1-t)\theta)}{\sin\theta}\,a + \frac{\sin(t\theta)}{\sin\theta}\,b.

The parameter specifies the fraction of the arc traversed:

slerp⁡(a,b;0)=a,slerp⁡(a,b;1)=b.\operatorname{slerp}(a,b;0)=a, \qquad \operatorname{slerp}(a,b;1)=b.

The result remains a unit vector. Although the expression is a linear combination of the endpoints, its coefficients depend nonlinearly on tt and generally do not sum to one. The word linear refers to the linear progression of angular distance, not to linearity in the surrounding vector space.

The same construction works on a sphere of radius r>0r>0 centered at the origin by normalizing the endpoints, applying slerp, and multiplying the result by rr. For a sphere with another center, the center is first subtracted and later restored.

Geometric interpretation

Two distinct, non-antipodal unit vectors span a plane through the origin. Its intersection with the unit sphere is a great circle, and slerp follows the shorter arc between the endpoints. This arc is a geodesic of the sphere.

Define

u=b−cos⁡θ asin⁡θ.u=\frac{b-\cos\theta\,a}{\sin\theta}.

Then aa and uu are orthogonal unit vectors, and the interpolation can be rewritten as

p(t)=cos⁡(tθ) a+sin⁡(tθ) u.p(t)=\cos(t\theta)\,a+\sin(t\theta)\,u.

This form makes the circular motion explicit. Differentiating gives

p′(t)=θ[−sin⁡(tθ) a+cos⁡(tθ) u],p'(t) = \theta\bigl[-\sin(t\theta)\,a+\cos(t\theta)\,u\bigr],

so its norm is constant:

∥p′(t)∥=θ.\|p'(t)\|=\theta.

Consequently, the arc length traveled from aa to p(t)p(t) is tθt\theta on the unit sphere. If the motion lasts a physical time TT, its angular speed is θ/T\theta/T.

The second derivative satisfies

p′′(t)=−θ2p(t).p''(t)=-\theta^2p(t).

Thus, the acceleration points radially inward and has no component tangent to the sphere. This is another characterization of constant-speed geodesic motion.

Example

For

a=(1,0,0),b=(0,1,0),a=(1,0,0), \qquad b=(0,1,0),

the endpoint angle is π/2\pi/2, and

slerp⁡(a,b;t)=(cos⁡πt2,sin⁡πt2,0).\operatorname{slerp}(a,b;t) = \left( \cos\frac{\pi t}{2}, \sin\frac{\pi t}{2}, 0 \right).

At t=1/2t=1/2, the result is

(12,12,0),\left(\frac{1}{\sqrt2},\frac{1}{\sqrt2},0\right),

the midpoint of the quarter-circle arc.

Quaternion interpolation of rotations

A unit quaternion represents a three-dimensional rotation. In scalar–vector notation, a rotation through angle α\alpha about a unit axis n\mathbf n is represented by

q=(cos⁡α2,nsin⁡α2).q= \left( \cos\frac{\alpha}{2}, \mathbf n\sin\frac{\alpha}{2} \right).

Unit quaternions lie on the three-dimensional unit sphere S3S^3 in four-dimensional Euclidean space. Applying slerp to two such quaternions therefore preserves their unit length.

Double representation and the shortest rotation

The quaternions qq and −q-q represent the same physical rotation. This double representation is essential when selecting the interpolation path.

Given unit quaternions q0q_0 and q1q_1, implementations commonly compute their four-dimensional dot product

d=q0⋅q1.d=q_0\cdot q_1.

If d<0d<0, q1q_1 is replaced by −q1-q_1. This selects the nearer quaternion representative and ensures that the interpolated orientations follow a shortest rotational path.

After this sign choice,

θ=arccos⁡(q0⋅q1)\theta=\arccos(q_0\cdot q_1)

lies between 00 and π/2\pi/2. The corresponding physical rotation angle between the endpoint orientations is 2θ2\theta, because quaternion coordinates use half-angles.

When the relative physical rotation is exactly π\pi, there are two equally short rotational paths. The endpoints alone do not distinguish between them; an additional convention or continuity requirement is needed.

Relative-rotation form

Quaternion slerp can also be expressed as

q(t)=q0(q0−1q1)t,q(t)=q_0\left(q_0^{-1}q_1\right)^t,

with a consistent branch chosen for the quaternion power. Equivalently,

q(t)=q0exp⁡(tlog⁡(q0−1q1)).q(t) = q_0\exp\left( t\log(q_0^{-1}q_1) \right).

This formula expresses interpolation as taking a fraction of the relative rotation. Quaternion multiplication is not commutative, so the multiplication order must be preserved.

The construction is related to interpolation on a Lie group. For three-dimensional rotations, it corresponds to a constant-speed geodesic under the usual rotation-invariant metric. In matrix form, the analogous expression is

R(t)=R0exp⁡(tlog⁡(R0−1R1)),R(t)=R_0\exp\left( t\log(R_0^{-1}R_1) \right),

where the exponential is the matrix exponential and the logarithm must again be chosen consistently.

Degenerate cases and numerical implementation

Coincident endpoints

When a=ba=b, the displayed sine-weight formula has a removable singularity because sin⁡θ=0\sin\theta=0. The natural definition is

slerp⁡(a,a;t)=a.\operatorname{slerp}(a,a;t)=a.

For nearly coincident endpoints, directly evaluating the formula can involve division by a small number. A common implementation switches to normalized linear interpolation when the dot product is sufficiently close to one.

Another expression uses the function sinc⁡(x)=sin⁡(x)/x\operatorname{sinc}(x)=\sin(x)/x, extended continuously by sinc⁡(0)=1\operatorname{sinc}(0)=1:

slerp⁡(a,b;t)=(1−t)sinc⁡((1−t)θ)sinc⁡(θ)a+tsinc⁡(tθ)sinc⁡(θ)b.\operatorname{slerp}(a,b;t) = (1-t) \frac{\operatorname{sinc}((1-t)\theta)} {\operatorname{sinc}(\theta)}a + t \frac{\operatorname{sinc}(t\theta)} {\operatorname{sinc}(\theta)}b.

Near zero, sinc can be evaluated using its Taylor series.

Antipodal endpoints

When b=−ab=-a, the endpoints do not specify a unique great-circle arc. On spheres of dimension at least two, infinitely many semicircular paths connect them. An additional direction is required to choose one.

If uu is a selected unit vector orthogonal to aa, a possible interpolation is

p(t)=cos⁡(πt)a+sin⁡(πt)u.p(t)=\cos(\pi t)a+\sin(\pi t)u.

This ambiguity is geometric, not merely a numerical defect. Near-antipodal interpolation is also sensitive to small endpoint perturbations.

For rotations represented by quaternions, exactly antipodal quaternion endpoints represent the same orientation. Sign correction reduces that case to coincident endpoints rather than requiring a semicircular path.

Floating-point precautions

With floating-point arithmetic, an inner product of nominally unit vectors may fall slightly outside [−1,1][-1,1]. Practical implementations normalize the inputs and clamp the computed dot product before applying arccos⁡\arccos.

An angle may alternatively be computed as

θ=atan2⁡(∥b−⟨a,b⟩a∥,⟨a,b⟩).\theta= \operatorname{atan2} \left( \|b-\langle a,b\rangle a\|, \langle a,b\rangle \right).

This can improve angle evaluation near coincident endpoints, although it does not remove the underlying ambiguity near antipodal endpoints. Numerical stability also depends on how normalization and the nearly parallel cases are handled.

Comparison with linear interpolation

Ordinary linear interpolation is

lerp⁡(a,b;t)=(1−t)a+tb.\operatorname{lerp}(a,b;t)=(1-t)a+tb.

For distinct unit endpoints and 0<t<10<t<1, this follows the chord inside the sphere rather than its surface.

Normalized linear interpolation is

nlerp⁡(a,b;t)=(1−t)a+tb∥(1−t)a+tb∥.\operatorname{nlerp}(a,b;t) = \frac{(1-t)a+tb} {\|(1-t)a+tb\|}.

For non-antipodal endpoints, nlerp traces the same shorter great-circle arc as slerp, but generally at a nonconstant angular speed. It avoids trigonometric evaluation and closely approximates slerp for small endpoint angles. At antipodal endpoints, its denominator vanishes at t=1/2t=1/2.

Thus, the main distinction is not necessarily the geometric path but its parameterization: slerp advances uniformly in angle, whereas nlerp generally does not.

History, applications, and limitations

Ken Shoemake introduced quaternion slerp to computer graphics in the 1985 paper Animating Rotation with Quaternion Curves. It became a standard technique for orientation interpolation in animation, camera motion, robotics, and simulation.

Beyond quaternions, slerp interpolates unit directions and other normalized vectors in arbitrary finite dimensions. Its geometric meaning depends on the chosen inner product: it is not a general interpolation rule for every curved manifold.

A single slerp segment determines a fixed path and a constant speed, but joining several segments does not generally produce continuous velocity at their junctions. Smooth multi-keyframe animation therefore often uses higher-order spherical curves rather than independent slerp segments.

Likewise, constant angular speed may be unsuitable when a motion should accelerate or decelerate. Replacing tt with a nonlinear timing function preserves the arc but changes the speed. Endpoint orientations alone also do not encode extra complete revolutions; these require additional path information.