{
  "id": "slerp",
  "title": "Spherical linear interpolation",
  "lang": "en",
  "source_lang": "en",
  "summary": "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.",
  "category": "mathematics",
  "subcategory": "applied",
  "type": "concept",
  "aliases": [
    "Slerp",
    "SLERP"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/slerp/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/slerp/",
      "json": "https://aiwiki.page/zh/slerp.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "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."
    },
    {
      "heading": "Definition",
      "text": "Let \\(a\\) and \\(b\\) be unit vectors in a real inner-product space, with angle\n\n\\[\\theta=\\arccos\\langle a,b\\rangle, \\qquad 0<\\theta<\\pi.\\]\n\nFor a parameter \\(t\\in[0,1]\\), spherical linear interpolation is defined by\n\n\\[\\operatorname{slerp}(a,b;t) = \\frac{\\sin((1-t)\\theta)}{\\sin\\theta}\\,a + \\frac{\\sin(t\\theta)}{\\sin\\theta}\\,b.\\]\n\nThe parameter specifies the fraction of the arc traversed:\n\n\\[\\operatorname{slerp}(a,b;0)=a, \\qquad \\operatorname{slerp}(a,b;1)=b.\\]\n\nThe result remains a unit vector. Although the expression is a linear combination of the endpoints, its coefficients depend nonlinearly on \\(t\\) 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.\n\nThe same construction works on a sphere of radius \\(r>0\\) centered at the origin by normalizing the endpoints, applying slerp, and multiplying the result by \\(r\\). For a sphere with another center, the center is first subtracted and later restored."
    },
    {
      "heading": "Geometric interpretation",
      "text": "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.\n\nDefine\n\n\\[u=\\frac{b-\\cos\\theta\\,a}{\\sin\\theta}.\\]\n\nThen \\(a\\) and \\(u\\) are orthogonal unit vectors, and the interpolation can be rewritten as\n\n\\[p(t)=\\cos(t\\theta)\\,a+\\sin(t\\theta)\\,u.\\]\n\nThis form makes the circular motion explicit. Differentiating gives\n\n\\[p'(t) = \\theta\\bigl[-\\sin(t\\theta)\\,a+\\cos(t\\theta)\\,u\\bigr],\\]\n\nso its norm is constant:\n\n\\[\\|p'(t)\\|=\\theta.\\]\n\nConsequently, the arc length traveled from \\(a\\) to \\(p(t)\\) is \\(t\\theta\\) on the unit sphere. If the motion lasts a physical time \\(T\\), its angular speed is \\(\\theta/T\\).\n\nThe second derivative satisfies\n\n\\[p''(t)=-\\theta^2p(t).\\]\n\nThus, the acceleration points radially inward and has no component tangent to the sphere. This is another characterization of constant-speed geodesic motion.\n\nExample\n\nFor\n\n\\[a=(1,0,0), \\qquad b=(0,1,0),\\]\n\nthe endpoint angle is \\(\\pi/2\\), and\n\n\\[\\operatorname{slerp}(a,b;t) = \\left( \\cos\\frac{\\pi t}{2}, \\sin\\frac{\\pi t}{2}, 0 \\right).\\]\n\nAt \\(t=1/2\\), the result is\n\n\\[\\left(\\frac{1}{\\sqrt2},\\frac{1}{\\sqrt2},0\\right),\\]\n\nthe midpoint of the quarter-circle arc."
    },
    {
      "heading": "Quaternion interpolation of rotations",
      "text": "A unit quaternion represents a three-dimensional rotation. In scalar–vector notation, a rotation through angle \\(\\alpha\\) about a unit axis \\(\\mathbf n\\) is represented by\n\n\\[q= \\left( \\cos\\frac{\\alpha}{2}, \\mathbf n\\sin\\frac{\\alpha}{2} \\right).\\]\n\nUnit quaternions lie on the three-dimensional unit sphere \\(S^3\\) in four-dimensional Euclidean space. Applying slerp to two such quaternions therefore preserves their unit length.\n\nDouble representation and the shortest rotation\n\nThe quaternions \\(q\\) and \\(-q\\) represent the same physical rotation. This double representation is essential when selecting the interpolation path.\n\nGiven unit quaternions \\(q_0\\) and \\(q_1\\), implementations commonly compute their four-dimensional dot product\n\n\\[d=q_0\\cdot q_1.\\]\n\nIf \\(d<0\\), \\(q_1\\) is replaced by \\(-q_1\\). This selects the nearer quaternion representative and ensures that the interpolated orientations follow a shortest rotational path.\n\nAfter this sign choice,\n\n\\[\\theta=\\arccos(q_0\\cdot q_1)\\]\n\nlies between \\(0\\) and \\(\\pi/2\\). The corresponding physical rotation angle between the endpoint orientations is \\(2\\theta\\), because quaternion coordinates use half-angles.\n\nWhen 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.\n\nRelative-rotation form\n\nQuaternion slerp can also be expressed as\n\n\\[q(t)=q_0\\left(q_0^{-1}q_1\\right)^t,\\]\n\nwith a consistent branch chosen for the quaternion power. Equivalently,\n\n\\[q(t) = q_0\\exp\\left( t\\log(q_0^{-1}q_1) \\right).\\]\n\nThis formula expresses interpolation as taking a fraction of the relative rotation. Quaternion multiplication is not commutative, so the multiplication order must be preserved.\n\nThe 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\n\n\\[R(t)=R_0\\exp\\left( t\\log(R_0^{-1}R_1) \\right),\\]\n\nwhere the exponential is the matrix exponential and the logarithm must again be chosen consistently."
    },
    {
      "heading": "Degenerate cases and numerical implementation",
      "text": "Coincident endpoints\n\nWhen \\(a=b\\), the displayed sine-weight formula has a removable singularity because \\(\\sin\\theta=0\\). The natural definition is\n\n\\[\\operatorname{slerp}(a,a;t)=a.\\]\n\nFor 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.\n\nAnother expression uses the function \\(\\operatorname{sinc}(x)=\\sin(x)/x\\), extended continuously by \\(\\operatorname{sinc}(0)=1\\):\n\n\\[\\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.\\]\n\nNear zero, sinc can be evaluated using its Taylor series.\n\nAntipodal endpoints\n\nWhen \\(b=-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.\n\nIf \\(u\\) is a selected unit vector orthogonal to \\(a\\), a possible interpolation is\n\n\\[p(t)=\\cos(\\pi t)a+\\sin(\\pi t)u.\\]\n\nThis ambiguity is geometric, not merely a numerical defect. Near-antipodal interpolation is also sensitive to small endpoint perturbations.\n\nFor 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.\n\nFloating-point precautions\n\nWith floating-point arithmetic, an inner product of nominally unit vectors may fall slightly outside \\([-1,1]\\). Practical implementations normalize the inputs and clamp the computed dot product before applying \\(\\arccos\\).\n\nAn angle may alternatively be computed as\n\n\\[\\theta= \\operatorname{atan2} \\left( \\|b-\\langle a,b\\rangle a\\|, \\langle a,b\\rangle \\right).\\]\n\nThis 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."
    },
    {
      "heading": "Comparison with linear interpolation",
      "text": "Ordinary linear interpolation is\n\n\\[\\operatorname{lerp}(a,b;t)=(1-t)a+tb.\\]\n\nFor distinct unit endpoints and \\(0<t<1\\), this follows the chord inside the sphere rather than its surface.\n\nNormalized linear interpolation is\n\n\\[\\operatorname{nlerp}(a,b;t) = \\frac{(1-t)a+tb} {\\|(1-t)a+tb\\|}.\\]\n\nFor 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/2\\).\n\nThus, the main distinction is not necessarily the geometric path but its parameterization: slerp advances uniformly in angle, whereas nlerp generally does not."
    },
    {
      "heading": "History, applications, and limitations",
      "text": "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.\n\nBeyond 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.\n\nA 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.\n\nLikewise, constant angular speed may be unsuitable when a motion should accelerate or decelerate. Replacing \\(t\\) 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."
    }
  ],
  "links": [
    "interpolation",
    "euclidean-space",
    "quaternion",
    "inner-product",
    "linear-combination",
    "geodesic",
    "norm-mathematics",
    "derivative",
    "dot-product",
    "lie-group",
    "matrix",
    "matrix-exponential",
    "taylor-series",
    "floating-point-arithmetic",
    "numerical-stability",
    "manifold"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}