Quaternion Function Reference

slerp

Spherical linear interpolation

Syntax

y = slerp(q1, q2, t)

Description

slerp(q1, q2, t) interpolates between two quaternions q1 and q2, using parameter t to determine how far along the 'arc' between the two quaternions to position the result (0 ≤ t ≤ 1).

q1 and q2 must be of the same size. Either the two quaternions, or t, must be scalar, or t must have the same size as the two quaternions.

The third parameter, t, gives the 'distance' along the 'arc' between the quaternions, 0 representing q1 and 1 representing q2. If q1 and q2 are unit pure quaternions, the interpolation is along a great circle of the sphere between the points represented by q1 and q2. If q1 and q2 are unit full quaternions, the interpolation is along the 'arc' on the 4-sphere: this means the result is a quaternion which represents a rotation intermediate between the two rotations represented by q1 and q2. If the first two parameters are not unit quaternions, then there is also interpolation in modulus.

q1 and q2 are not restricted to be real quaternions.

The slerp function can be simply understood in terms of the ratio of two vectors (pure quaternions). The ratio is the quaternion that rotates one vector into the other. Taking a fractional power of this rotation and then multiplying it by the first vector obviously gives a vector which is part way along the arc between the two quaternions. The ratio is computed using the multiplicative inverse. If the two quaternions are full, then their ratio again gives a quaternion which multiplies one to give the other, but this time in 4-space, including, if the moduli are not unity, the scale factor needed to scale one into the other.

Examples

To interpolate between qi and qj, we can supply a vector for t. The result shows that when t is zero, the result is qi, and when t is 1, the result is qj. At the mid-point of the interpolation, we get qi/√2 + qj/√2, the mid-point of the arc in 3-space:
>> arc = slerp(qi, qj, [0:0.2:1])
 
arc = 1x6 quaternion array
 
>> show(arc)
 
arc.S = 0     0     0     0     0     0

arc.X = 1.0000    0.9511    0.8090    0.5878    0.3090    0.0000

arc.Y = 0    0.3090    0.5878    0.8090    0.9511    1.0000

arc.Z = 0     0     0     0     0     0

References

  1. Ken Shoemake, 'Animating rotation with quaternion curves', SIGGRAPH Computer Graphics, 19 (3), July 1985, 245-254, ACM, New York, USA. DOI: 10.1145/325165.325242.

© 2008-2013 Stephen J. Sangwine and Nicolas Le Bihan

License terms.