Create two quaternions with the following interpretation:
a
= 45 degree rotation around the z-axis
c
= -45 degree rotation around the z-axis
Call slerp
with the quaternions a
and c
and specify an interpolation coefficient of 0.5.
The output of slerp
, b
, represents an average rotation of a
and c
. To verify, convert b
to Euler angles in degrees.
averageRotation = 1×3
0 0 0
The interpolation coefficient is specified as a normalized value between 0
and 1
, inclusive. An interpolation coefficient of 0
corresponds to the a
quaternion, and an interpolation coefficient of 1
corresponds to the c
quaternion. Call slerp
with coefficients 0
and 1
to confirm.
ans = 2×3
45.0000 0 0
-45.0000 0 0
You can create smooth paths between quaternions by specifying arrays of equally spaced interpolation coefficients.
For quaternions that represent rotation only about a single axis, specifying interpolation coefficients as equally spaced results in quaternions equally spaced in Euler angles. Convert interpolatedQuaternions
to Euler angles and verify that the difference between the angles in the path is constant.
abc = 10×3
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
9.0000 0 0
Alternatively, you can use the dist
function to verify that the distance between the interpolated quaternions is consistent. The dist
function returns angular distance in radians; convert to degrees for easy comparison.
def = 1×10
9.0000 9.0000 9.0000 9.0000 9.0000 9.0000 9.0000 9.0000 9.0000 9.0000