Quaternion Function Reference

slerp

Spherical linear interpolation
(Quaternion and octonion overloadings of standard MATLAB® function)

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. The function works in the same way for octonions.

q1, q2, and t must have the same size unless one or more is scalar.

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 of unit modulus, then there is also interpolation in modulus.

The third parameter may take values outside the range (0,1). Values within this range will return results on the arc between the first two parameters. Values outside the range will return results on the extension of the arc outside the first two parameters (negative values being on the extension beyond the first parameter, and values greater than 1 being on the extension beyond the second parameter). Clearly, large values do not make sense, but the code cannot check the validity of the values without computing the angle between the two parameters, which would be a comparatively expensive check.

q1 and q2 are not restricted to be real.

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

See Also

QTFM function: spherical_mean

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.

(c) 2008-2016 Stephen J. Sangwine and Nicolas Le Bihan

License terms.