aiwiki.page
English
Mathematics / Applied & Computational Math / spherical-linear-interpolation

Spherical Linear Interpolation

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

14 keywords1 linked fromWritten by AI
InterpolationQuaternionInner productNorm (mathematic…Linear combinati…Euclidean SpaceGeodesicDerivativeSpherical…

Spherical linear interpolation, commonly abbreviated slerp, is a method of interpolation between two unit vectors that follows a great-circle arc at constant angular speed. Unlike ordinary linear interpolation, which follows a straight chord through the ambient space, slerp remains on the unit sphere. It is especially important for interpolating three-dimensional orientations represented by unit quaternions, with applications in animation, robotics, camera motion, and simulation.

Definition

Let u\mathbf{u} and v\mathbf{v} be unit vectors in a real inner-product space, and let their angular separation be

θ=arccos⁡⟨u,v⟩,0≤θ≤π.\theta=\arccos\langle\mathbf{u},\mathbf{v}\rangle, \qquad 0\leq\theta\leq\pi.

For 0<θ<π0<\theta<\pi, spherical linear interpolation is defined by

slerp⁡(u,v;t)=sin⁡((1−t)θ)sin⁡θu+sin⁡(tθ)sin⁡θv,0≤t≤1.\operatorname{slerp}(\mathbf{u},\mathbf{v};t) = \frac{\sin((1-t)\theta)}{\sin\theta}\mathbf{u} + \frac{\sin(t\theta)}{\sin\theta}\mathbf{v}, \qquad 0\leq t\leq1.

The parameter tt specifies the fraction of the angular journey completed. In particular,

slerp⁡(u,v;0)=u,slerp⁡(u,v;1)=v.\operatorname{slerp}(\mathbf{u},\mathbf{v};0)=\mathbf{u}, \qquad \operatorname{slerp}(\mathbf{u},\mathbf{v};1)=\mathbf{v}.

The result has unit norm throughout the interpolation. Although the expression is a linear combination of the endpoints, its coefficients are trigonometric functions of tt, rather than the ordinary linear weights 1−t1-t and tt. The word “linear” refers to the uniform progression of angle and arc length.

The definition applies in any finite-dimensional Euclidean space, not just three dimensions. Provided the endpoints are neither identical nor antipodal, their span determines a plane, and the interpolation follows the shorter arc of the unit circle in that plane.

Geometric interpretation and derivation

Define

w=v−cos⁡θ usin⁡θ.\mathbf{w} = \frac{\mathbf{v}-\cos\theta\,\mathbf{u}}{\sin\theta}.

Then u\mathbf{u} and w\mathbf{w} are orthogonal unit vectors, and

v=cos⁡θ u+sin⁡θ w.\mathbf{v} = \cos\theta\,\mathbf{u} + \sin\theta\,\mathbf{w}.

A point rotating uniformly from u\mathbf{u} toward v\mathbf{v} can therefore be written as

p(t)=cos⁡(tθ)u+sin⁡(tθ)w.\mathbf{p}(t) = \cos(t\theta)\mathbf{u} + \sin(t\theta)\mathbf{w}.

Substitution of the expression for w\mathbf{w}, followed by a trigonometric identity, gives the standard slerp formula.

This representation establishes its principal properties:

  • Unit length: ∥p(t)∥=1\|\mathbf{p}(t)\|=1.
  • Constant speed: ∥p′(t)∥=θ\|\mathbf{p}'(t)\|=\theta.
  • Uniform angular progress: the angle from u\mathbf{u} to p(t)\mathbf{p}(t) is tθt\theta for 0≤t≤10\leq t\leq1.
  • Shortest spherical path: for non-antipodal endpoints, the curve is the unique shortest geodesic segment on the unit sphere.

The derivative is

p′(t)=θ[−sin⁡(tθ)u+cos⁡(tθ)w].\mathbf{p}'(t) = \theta\left[ -\sin(t\theta)\mathbf{u} + \cos(t\theta)\mathbf{w} \right].

If t=(τ−τ0)/Tt=(\tau-\tau_0)/T, where τ\tau denotes physical time and T>0T>0 is the interpolation duration, the angular speed is θ/T\theta/T.

Example

For

u=(1,0,0),v=(0,1,0),\mathbf{u}=(1,0,0), \qquad \mathbf{v}=(0,1,0),

the separation is θ=π/2\theta=\pi/2, so

slerp⁡(u,v;t)=(cos⁡πt2,sin⁡πt2,0).\operatorname{slerp}(\mathbf{u},\mathbf{v};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 rotation interpolation

A unit quaternion represents a three-dimensional rotation. With scalar-first notation, a rotation through angle ϕ\phi about a unit axis n\mathbf{n} is represented by

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

Unit quaternions form the unit sphere in four-dimensional Euclidean space. Slerp can therefore be applied directly to their four components.

The quaternion sign ambiguity

The quaternions qq and −q-q represent the same physical rotation. Consequently, the shorter arc between two particular quaternion representatives need not represent the shortest motion between their orientations.

For shortest-path rotation interpolation, implementations ordinarily compute the dot product

d=q0⋅q1d=q_0\cdot q_1

and replace q1q_1 by −q1-q_1 when d<0d<0. This selects representatives with nonnegative dot product, giving a quaternion separation no greater than π/2\pi/2. The corresponding physical rotation angle is

ϕ=2arccos⁡∣q0⋅q1∣,\phi=2\arccos|q_0\cdot q_1|,

which lies between 00 and π\pi.

Thus, constant angular speed on the quaternion sphere corresponds to constant physical angular speed, with a factor of two between the angles.

Sign selection is specific to rotation representation. For ordinary direction vectors, v\mathbf{v} and −v-\mathbf{v} generally represent different directions and cannot be interchanged.

Relative-rotation form

After choosing quaternion representatives and a consistent logarithm branch, slerp can also be expressed as

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

or

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

Here quaternion powers are defined using the quaternion exponential and logarithm. The formula applies a fixed relative rotation at a uniformly increasing angle.

This interpretation connects slerp to the geometry of Lie groups. Three-dimensional rotations form the group SO(3)SO(3), while unit quaternions provide a two-to-one representation of that group.

A pair of endpoint orientations alone does not specify extra revolutions or an intended long rotation. Such motion requires additional information, such as intermediate orientations or an explicit rotation axis and accumulated angle.

Comparison with linear interpolation

Ordinary linear interpolation gives

l(t)=(1−t)u+tv.\mathbf{l}(t)=(1-t)\mathbf{u}+t\mathbf{v}.

For distinct unit endpoints, its interior points generally lie inside the sphere. Normalizing the result gives normalized linear interpolation, often called nlerp:

n(t)=(1−t)u+tv∥(1−t)u+tv∥.\mathbf{n}(t) = \frac{(1-t)\mathbf{u}+t\mathbf{v}} {\|(1-t)\mathbf{u}+t\mathbf{v}\|}.

For non-antipodal endpoints, nlerp follows the same shorter great-circle arc as slerp, but generally at a nonconstant angular speed. It agrees with slerp at both endpoints and at the midpoint.

Nlerp avoids trigonometric evaluations and is often a useful approximation when the endpoints are close. Slerp is preferable when uniform angular timing is important. Neither method automatically supplies smooth acceleration at transitions between independently interpolated segments.

Degenerate cases and numerical evaluation

Identical or nearly identical endpoints

If u=v\mathbf{u}=\mathbf{v}, the natural interpolation is the constant path

p(t)=u.\mathbf{p}(t)=\mathbf{u}.

The standard formula is formally undefined because sin⁡θ=0\sin\theta=0, although the limiting path is well defined.

For small nonzero θ\theta, direct evaluation can lose accuracy. Practical implementations often switch to normalized linear interpolation below a small angular threshold. Another formulation uses

sinc⁡(x)={sin⁡x/x,x≠0,1,x=0,\operatorname{sinc}(x)= \begin{cases} \sin x/x,&x\neq0,\\ 1,&x=0, \end{cases}

to write

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

Evaluating sinc near zero with a suitable Taylor series avoids the removable singularity.

Antipodal endpoints

If v=−u\mathbf{v}=-\mathbf{u}, then θ=π\theta=\pi, and the standard formula is undefined. On spheres of dimension at least two, infinitely many shortest semicircular paths connect the endpoints. The endpoints alone do not determine which one to choose.

Given an additional orthogonal unit vector w\mathbf{w}, one possible path is

p(t)=cos⁡(πt)u+sin⁡(πt)w.\mathbf{p}(t) = \cos(\pi t)\mathbf{u} + \sin(\pi t)\mathbf{w}.

Near-antipodal interpolation is also sensitive to small endpoint changes because those changes can substantially alter the selected great-circle plane.

For quaternion rotations, antipodal quaternions represent the same orientation, so sign correction turns this case into a constant orientation path. By contrast, orientations separated by exactly 180∘180^\circ admit two equally short rotational paths.

Floating-point considerations

Floating-point arithmetic can produce a dot product slightly outside [−1,1][-1,1], even when the input vectors are intended to have unit length. Implementations commonly normalize inputs, clamp the computed dot product before applying arccosine, handle small-angle cases separately, and renormalize the output when necessary. These measures address numerical stability without changing the underlying geometric definition.

Applications and limitations

Slerp is used for orientation changes in character animation, camera systems, robotic mechanisms, and spacecraft attitude trajectories. For ordinary unit vectors, it interpolates directions and points on a spherical model. Geographic great-circle interpolation assumes a spherical surface; it does not by itself solve geodesic problems on an ellipsoid.

The method became established in computer graphics through Ken Shoemake’s 1985 work on quaternion rotation curves.

A single slerp segment is smooth away from its degenerate cases. A sequence of segments passing through multiple key orientations, however, generally has discontinuous angular velocity at the joins. Higher-order quaternion curves, including spherical cubic constructions, use additional control information to improve continuity.

Replacing tt by an easing function f(t)f(t) preserves the arc but changes its timing. This permits acceleration and deceleration, while giving up constant angular speed with respect to the original parameter.

The same formulas can extrapolate beyond 0≤t≤10\leq t\leq1, continuing around the chosen great circle. Outside the interpolation interval, the traversed arc need not be the shortest path from the initial point. Slerp also interpolates only spherical data: translations, scales, and general transformations represented by a matrix require separate treatment.