Fact-checked by Grok 2 weeks ago

Slerp

Slerp, short for , is a geometric algorithm that computes an interpolated value between two unit by traversing the shortest path ( arc) on the unit at a , ensuring smooth and natural rotational transitions in . Introduced by Ken Shoemake in his seminal paper "Animating Rotation with Curves," slerp was developed to enable the creation of spline curves on the quaternion hypersphere for interpolating sequences of arbitrary rotations in . Unlike , which can produce uneven motion or distortions when applied directly to rotation representations, slerp maintains uniform angular speed and avoids issues like inherent in Euler angle methods. The technique has become a cornerstone in and related fields, powering rotation animations in , film production, and by providing efficient, high-quality for object orientations and camera paths. It is implemented in numerous mathematical libraries and engines, such as for scientific computing and for general operations, highlighting its versatility beyond to areas like and .

Introduction

Definition and Motivation

Spherical linear interpolation (SLERP) is a geometric interpolation technique that computes a path between two points on the unit by following the , or , connecting them, thereby ensuring a along the trajectory. Introduced in the context of , SLERP produces smooth, uniform-speed transitions on the spherical manifold, making it particularly suitable for representing continuous changes in or . The primary motivation for SLERP arises from the limitations of linear interpolation in non-Euclidean spaces such as spheres, where rotations and orientations are naturally embedded. Linear methods, such as linearly interpolating Euler angles or rotation matrices, often distort angular distances, result in uneven speeds—accelerating midway through the path—and introduce singularities like gimbal lock, leading to abrupt or unnatural motions. In contrast, SLERP maintains the intrinsic geometry of the sphere, preserving angular uniformity and avoiding these artifacts to enable more realistic and computationally stable animations. A basic intuitive example involves transitioning between two 3D orientations, such as shifting a camera's viewpoint from one direction to another in a virtual scene; SLERP generates a fluid arc along without erratic twisting or speed variations that would occur with linear approaches. Quaternions serve as an effective representation for these rotations due to their compactness and lack of singularities, allowing SLERP to operate directly on them for efficient computation.

Historical Context

The concept of spherical linear interpolation, known as SLERP, was coined by Ken Shoemake in 1985 while developing rotation tools for software at The Singer Company's Link Flight Simulation Division. Shoemake introduced SLERP to enable smooth of 3D rotations, addressing the challenges of animating motions and camera movements that traditional Euler angle representations could not handle effectively. SLERP was first formalized in Shoemake's seminal paper, "Animating Rotation with Quaternion Curves," presented at the 12th annual Conference on and Interactive Techniques in 1985. In this work, SLERP was defined for unit to interpolate along the shortest path () on the unit sphere, ensuring constant angular velocity and avoiding singularities. The method built on earlier mathematical foundations, including William Rowan Hamilton's invention of quaternions in for describing rotations and Arthur Cayley's subsequent developments in the 1840s. The roots of SLERP's geometric principle—interpolation along great circles—lie in 19th-century , where concepts of geodesics on curved surfaces, including spheres, were formalized by mathematicians such as and . Following its introduction, SLERP saw rapid integration into professional graphics tools. Its influence persists in contemporary libraries, such as the OpenGL Mathematics (GLM) C++ library, which implements SLERP via its mix function to facilitate efficient rotation blending in graphics applications.

Mathematical Foundations

Spherical Geometry Essentials

In spherical geometry, points on the unit sphere are represented as unit vectors in three-dimensional , where the sphere serves as a model for directions or orientations with radius one centered at the origin. These points satisfy the condition \|\mathbf{v}\| = 1, ensuring they lie on the surface without scaling distortions. The shortest paths connecting two such points are geodesics, which trace great circles on the sphere—intersections of the sphere with planes passing through its center. Great circles represent the analogs of straight lines in , providing the minimal-distance routes that preserve the intrinsic metric of the spherical surface. The angular separation \theta between two points \mathbf{a} and \mathbf{b} on the unit sphere is computed using the dot product formula: \cos \theta = \mathbf{a} \cdot \mathbf{b} This relation directly yields the subtended at the sphere's center, enabling precise measurement of distances as \theta radians (or scaled by the for general spheres). For effective between points, a uniform parameterization along the arc is essential, ensuring constant angular speed to prevent artifacts like varying acceleration in animations or simulations. Such constant-speed traversal maintains smooth motion proportional to the interpolation parameter. SLERP paths adhere to these great circle arcs, inherently preserving geodesic distances between endpoints and minimizing geometric distortion during interpolation. This property ensures that interpolated points remain on the sphere while following the most direct route, avoiding unnecessary deviations that could arise from linear approximations in ambient space.

Quaternions for Rotations

Quaternions, introduced by William Rowan Hamilton in 1843, extend complex numbers to four dimensions and serve as an effective algebraic structure for representing rotations in three-dimensional space. A quaternion is expressed as q = w + x i + y j + z k, where w, x, y, z are real numbers, and i, j, k are imaginary units satisfying i^2 = j^2 = k^2 = ijk = -1. For rotations, unit s with norm \|q\| = \sqrt{w^2 + x^2 + y^2 + z^2} = 1 are used, as they form a double cover of the special SO(3) and parameterize orientations without singularities. These unit quaternions lie on the three-dimensional in , enabling a geometrically intuitive approach to composition. The rotation of a three-dimensional \mathbf{v} by a unit q is given by the conjugation formula \mathbf{v}' = q \mathbf{v} q^{-1}, where \mathbf{v} is treated as a pure quaternion $0 + v_x i + v_y j + v_z k, and q^{-1} is the conjugate \overline{q} = w - x i - y j - z k since \|q\| = 1. This formulation adapts , expressing the rotated as \mathbf{v}' = \cos\theta \cdot \mathbf{v} + (1 - \cos\theta) (\mathbf{u} \cdot \mathbf{v}) \mathbf{u} + \sin\theta \cdot (\mathbf{u} \times \mathbf{v}), where q = \cos(\theta/2) + \sin(\theta/2) (u_x i + u_y j + u_z k) with \mathbf{u} as the unit rotation and \theta the angle. Compared to Euler angles, which parameterize rotations using three sequential angles about fixed or body axes, quaternions avoid gimbal lock—a degeneracy where intermediate axes align, losing a degree of freedom (e.g., at pitch angles of ±90°). Additionally, the spherical geometry of unit quaternions facilitates smooth interpolation between orientations by traversing great-circle paths on the unit sphere. To ensure a quaternion represents a pure rotation, it must be normalized by dividing by its norm: q_{\text{unit}} = q / \|q\|. Non-unit quaternions may introduce scaling effects, so normalization is essential after operations like addition or multiplication that could alter the magnitude.

Core Algorithms

Geometric SLERP

Geometric spherical linear interpolation (SLERP) provides a method for interpolating between two unit vectors \mathbf{a} and \mathbf{b} on the surface of a unit sphere, ensuring the path follows a great circle arc at constant angular velocity. This approach is essential for applications requiring smooth transitions along spherical geodesics, such as direction mapping or orientation blending in vector spaces. Unlike linear interpolation, which may produce paths that deviate from the sphere, SLERP maintains the interpolated points on the unit sphere. The derivation begins with the angular bisector concept in . Given two unit vectors \mathbf{a} and \mathbf{b}, the angle between them is computed as \theta = \arccos(\mathbf{a} \cdot \mathbf{b}). To achieve constant angular speed along the , the weights are derived using sine functions, which arise from the applied to the formed by the , \mathbf{a}, and \mathbf{b}. The resulting formula is: \text{slerp}(\mathbf{a}, \mathbf{b}, t) = \frac{\sin((1-t)\theta)}{\sin \theta} \mathbf{a} + \frac{\sin(t \theta)}{\sin \theta} \mathbf{b} for t \in [0, 1]. This weighted sum ensures the output is a unit vector lying in the plane spanned by \mathbf{a} and \mathbf{b}, tracing the shorter arc when \theta \leq \pi. The sine normalization guarantees that the interpolation parameter t corresponds directly to the fraction of the angular distance traveled. Geometrically, the SLERP result resides on the great circle defined by the plane through the origin, \mathbf{a}, and \mathbf{b}, providing the shortest path on the sphere between the endpoints. This preserves the spherical metric, avoiding distortions from planar projections. Special cases require careful handling to avoid numerical issues. When \theta \approx 0 (vectors nearly aligned), \sin \theta \approx 0, leading to division by zero; in such instances, SLERP falls back to linear interpolation: \text{lerp}(\mathbf{a}, \mathbf{b}, t) = (1-t)\mathbf{a} + t\mathbf{b}, normalized if necessary. For antipodal points where \theta = \pi (\mathbf{a} \cdot \mathbf{b} = -1), the path is ambiguous, as infinitely many great circles connect the points; SLERP is undefined here, and alternative methods, such as selecting a specific plane or using normalized linear interpolation, must be employed based on context. The following pseudocode outlines the step-by-step computation:
function slerp(a, b, t):
    dot = a · b
    if dot > 0.9995:  // θ ≈ 0
        return normalize((1 - t) * a + t * b)
    theta = acos([clamp](/page/Clamp)(dot, -1, 1))
    if theta == π:  // antipodal, handle specially (e.g., fallback)
        return normalize((1 - t) * a + t * b)
    sin_theta = sin(theta)
    coeff_a = sin((1 - t) * theta) / sin_theta
    coeff_b = sin(t * theta) / sin_theta
    return normalize(coeff_a * a + coeff_b * b)
This implementation includes clamping for in the acos computation and to ensure unit length, though the formula theoretically preserves it.

Quaternion SLERP

spherical linear (SLERP) adapts the geometric SLERP to unit s for smooth , ensuring constant angular velocity along the arc on the unit quaternion hypersphere. The standard formula is given by \text{slerp}(q_1, q_2, t) = \frac{\sin((1-t)\theta)}{\sin \theta} \, q_1 + \frac{\sin(t \theta)}{\sin \theta} \, q_2, where t \in [0, 1], \theta = \arccos(q_1 \cdot q_2), and the result is renormalized to unit length. This weighted sum of the input quaternions produces intermediate orientations that avoid the singularities of Euler angles and provide uniform motion in angular space, making it ideal for keyframe animation in computer graphics. A key consideration in quaternion SLERP is the double-cover property, where q and -q encode the same due to the projective nature of the rotation group SO(3). To ensure the shortest interpolation path and prevent discontinuities, the q_1 \cdot q_2 is adjusted by negating q_2 if it is negative, guaranteeing \theta \leq \pi/2 and selecting the representative closest to q_1. In sequential interpolations, such as curves, this sign adjustment is applied relative to the previous to maintain smoothness. For improved , particularly when \theta is small (near 0, causing division by near-zero \sin \theta) or in iterative computations, the logarithmic form of SLERP is often preferred: \text{slerp}(q_1, q_2, t) = q_1 \cdot \exp\left( t \cdot \log(q_2 \cdot q_1^{-1}) \right), where \log and \exp are the quaternion logarithm and exponential maps, and q_1^{-1} is the conjugate for unit quaternions. This exponentiation-based approach avoids trigonometric function instabilities by operating in the , reducing cancellation errors and enabling efficient repeated evaluations without recomputing \theta. Computationally, the standard formula's reliance on \arccos can be sidestepped in loops by approximating \theta via \atantwo(\sqrt{1 - (q_1 \cdot q_2)^2}, q_1 \cdot q_2) for better handling of the full angular range, or by approximations to eliminate altogether.

Applications and Variants

Use in Computer Graphics

In , SLERP plays a crucial role in by enabling keyframe for object rotations, particularly in tools like where the Quaternion.Slerp function produces transitions with constant angular speed, avoiding the uneven pacing of linear methods. This approach ensures natural-looking motion for characters and objects, as rotations follow the shortest path on the unit sphere without singularities like . Introduced in seminal work on quaternion-based , SLERP has become a standard for blending orientations in applications. SLERP is also integral to camera path generation in and simulations, where it facilitates smooth fly-throughs by interpolating camera orientations along arcs, eliminating the abrupt shifts that occur with of rotation matrices. For instance, in dynamic scenes like virtual tours or first-person navigation, this results in immersive, fluid camera movements that maintain consistent rotational velocity. The SLERP method is predominantly used here for its ability to handle complex orientations efficiently. In lighting and shading pipelines, SLERP supports the interpolation of normal vectors—unit directions on spherical surfaces—to avoid distortions from linear methods. This spherical approach outperforms linear interpolation for directions, preserving vector lengths and preventing distortions in shading calculations across hemispheres or globes. Performance-wise, SLERP is suitable for shader environments like GLSL in real-time rendering, as quaternions provide a compact representation for rotations compared to matrices, avoiding the need for full matrix conversions in graphics engines.

Extensions and Alternatives

, or spherical quadrangle interpolation, extends SLERP by enabling C1-continuous curves through a double application of SLERP, incorporating intermediate control to achieve smoother transitions between multiple orientations. This method, introduced by Ken Shoemake, constructs a cubic-like on the quaternion sphere by first blending to an intermediate quaternion and then to the target, ensuring tangent continuity for animation paths. An alternative to SLERP is normalized linear interpolation (NLERP), which performs a linear blend between two quaternions followed by to the unit , offering computational simplicity at the cost of reduced accuracy in compared to SLERP's constant-speed geodesic path. While faster due to avoiding , NLERP approximates the great-circle arc less precisely, particularly for larger angles, making it suitable for applications where outweighs exact . SLERP is limited to interpolating along the shortest great-circle arc, which may not align with intuitive paths for arcs exceeding 180 degrees, potentially leading to unexpected rotations in sequences; for higher-order continuity in splines, alternatives like the de Casteljau algorithm adapted to the replace linear steps with SLERP operations to generate smooth spherical Bézier curves. This spherical de Casteljau method supports arbitrary-degree interpolants on the unit , addressing SLERP's piecewise nature for complex trajectories. Modern implementations of SLERP appear in libraries such as Eigen for quaternion operations. Recent extensions include dual-quaternion-based SLERP for interpolating combined rotations and translations, applied in and autonomous vehicle path planning as of 2023.

References

  1. [1]
    slerp - Spherical linear interpolation - MATLAB - MathWorks
    Quaternion spherical linear interpolation (SLERP) is an extension of linear interpolation along a plane to spherical interpolation in three dimensions. The ...
  2. [2]
    Animating rotation with quaternion curves - ACM Digital Library
    Animating rotation with quaternion curves. Author: Ken Shoemake. Ken Shoemake ... View or Download as a PDF file. PDF. eReader. View online with eReader ...
  3. [3]
    Lowpass Filter Orientation Using Quaternion SLERP - MathWorks
    SLERP is a commonly used computer graphics technique for creating animations of a rotating object. SLERP Overview. Consider a pair of quaternions $q_0$ and ...Missing: applications | Show results with:applications
  4. [4]
    Slerp — SciPy v1.16.2 Manual
    Spherical Linear Interpolation of Rotations. The interpolation between consecutive rotations is performed as a rotation around a fixed axis with a constant ...1.15.2 · scipy.spatial.transform.Slerp · 1.14.0 · Scipy.spatial.transform.
  5. [5]
    Slerp (Apache Commons Numbers Quaternion 1.2 API)
    Perform spherical linear interpolation (Slerp). The Slerp algorithm is designed to interpolate smoothly between two rotations/orientations, ...
  6. [6]
    [PDF] SAN FRANCISCO JULY 22-26 Volume 19, Number 3, 1985
    Spherical linear interpolation gives two conflicting arc segments at a joint, one on each side. Smooth the difference with an even compromise, aiming for a ...
  7. [7]
    Nineteenth Century Geometry - Stanford Encyclopedia of Philosophy
    Jul 26, 1999 · The present article reviews the aspects of nineteenth century geometry that are of major interest for philosophy and hints in passing, at their ...
  8. [8]
    3ds Max 2024 Developer Help | Keyframe Interpolation | Autodesk
    In general, 3ds Max uses cubic (polynomial of degree three) splines for interpolation. Rotations are done using spherical linear interpolation (slerps).Missing: SLERP adoption
  9. [9]
    Common functions
    Referenced by glm::lerp(), and glm::slerp(). genType glm::mod, (, genType const &, x,. genType const &, y. ) Modulus. Returns x - y * floor(x / y) for each ...Missing: library | Show results with:library<|control11|><|separator|>
  10. [10]
    3.8 Spherical Geometry
    Spherical geometry uses the unit sphere to represent 3D direction vectors. Solid angles measure areas on the sphere, and spherical polygons are projections of ...
  11. [11]
    Great Circle -- from Wolfram MathWorld
    ) Now find the angle alpha between r_1 and r_2 using the dot product,. cosalpha, = r_1^^·r_2^^. (2). = cosdelta_1cosdelta_2(sinlambda_1sinlambda_2+ ...Missing: unit | Show results with:unit
  12. [12]
    Animating rotation with quaternion curves
    Solid bodies roll and tumble through space. In computer animation, so do cameras. The rotations of these objects are best described using a four coordinate.
  13. [13]
    [PDF] ON QUATERNIONS, OR ON A NEW SYSTEM OF IMAGINARIES IN ...
    The paper On Quaternions; or on a new System of Imaginaries in Algebra, is included in The Mathematical Papers of Sir William Rowan Hamilton, vol. iii ...
  14. [14]
    [PDF] Quaternions and Rotations∗
    Sep 10, 2013 · Quaternions are very efficient for analyzing situations where rotations in R3 are involved. A quaternion is a 4-tuple, which is a more concise ...
  15. [15]
    [PDF] Quaternions, Interpolation and Animation - MIT
    Jul 17, 1998 · [Shoemake, 1985] Ken Shoemake. Animating rotation with quaternion curves. Computer Graph- ics, 19(3):245{254, 1985. [Shoemake, 1987] Ken ...
  16. [16]
    [PDF] Interpolation of Rigid Motions in 3D - Geometric Tools
    Oct 15, 2017 · This document describes how to intepolate between two rigid transformations, each involving rotation and translation; reflections are not ...<|control11|><|separator|>
  17. [17]
    [PDF] A Fast and Accurate Estimate for SLERP - Geometric Tools
    Sep 11, 2018 · SLERP is a spherical interpolation of quaternions, a common operation in animation. This document describes an accurate estimate using ...
  18. [18]
    Normalized Vector Interpolation TL;DR
    Feb 19, 2016 · Normalized Vector Interpolation TL;DR · Slerp – short for “spherical interpolation”, this is the most correct way, but is also the costliest.
  19. [19]
    How to implement SLERP in GLSL/HLSL - Stack Overflow
    May 21, 2014 · I'm attempting to SLERP from GLSL (HLSL would also be okay as I'm targeting Unity3D) I've found this page:Why is this GLSL shader so slow? - Stack OverflowHow to accurately time performance of intensive vertex shader?More results from stackoverflow.com
  20. [20]
    [PDF] 3D Math Primer for Graphics and Game Development | TFE Times
    Apr 10, 2015 · Dunn, Fletcher. 3D math primer for graphics and game development / by Fletcher Dunn and Ian Parberry. p. cm. ISBN 1-55622-911-9. 1. Computer ...Missing: NLERP | Show results with:NLERP
  21. [21]
    [PDF] Spherical Essentially Non-Oscillatory (SENO) Interpolation - arXiv
    Dec 5, 2022 · One is that the interpolant runs on the shortest path (geodesic) between both endpoints at a constant (angular) speed. If both two data ...<|control11|><|separator|>
  22. [22]
    Spatial interpolation on Earth as a 3D sphere - StatnMap
    Nov 1, 2017 · A simple interpolation is the inverse distance interpolation. We can calculate distances between observations and world map using great circle.Missing: alternatives SLEEP