Game Development Reference
In-Depth Information
8.5.12 Quaternion Interpolation, a.k.a. Slerp
The raison d'etre of quaternions in games and graphics today is an op-
eration known as slerp, which stands for S pherical L inear int erp olation.
The slerp operation is useful because it allows us to smoothly interpolate
between two orientations. Slerp avoids all the problems that plagued inter-
polation of Euler angles (see Section 8.3.4).
Slerp is a ternary operator, meaning it accepts three operands. The
first two operands to slerp are the two quaternions between which we wish
to interpolate. We'll assign these starting and ending orientations to the
variables q 0 and q 1 , respectively. The interpolation parameter will be as-
signed to the variable t, and as t varies from 0 to 1, the slerp function
slerp( q 0 , q 1 ,t) returns an orientation that interpolates from q 0 to q 1 .
Let's see if we can't derive the slerp formula by using the tools we have
so far. If we were interpolating between two scalar values a 0 and a 1 , we
could use the standard linear interpolation (lerp) formula:
∆a = a 1 − a 0 ,
lerp(a 0 ,a 1 ,t) = a 0 + t∆a.
The standard linear interpolation formula works by starting at a 0 and
adding the fraction t of the difference between a 1 and a 0 . This requires
three basic steps:
1. Compute the difference between the two values.
Simple linear
interpolation
2. Take a fraction of this difference.
3. Take the original value and adjust it by this fraction of the difference.
We can use the same basic idea to interpolate between orientations. (Again,
remember that quaternion multiplication reads right-to-left.)
1. Compute the difference between the two values. We showed how to
do this in Section 8.5.8. The angular displacement from q 0 to q 1 is
given by
−1 .
q = q 1 q 0
2. Take a fraction of this difference. To do this, we use quaternion
exponentiation, which we discussed in Section 8.5.11. The fraction of
the difference is given by
(∆ q ) t .
3. Take the original value and adjust it by this fraction of the difference.
We “adjust” the initial value by composing the angular displacements
via quaternion multiplication:
(∆ q ) t q 0 .
 
Search WWH ::




Custom Search