Main Content

quatinterp

Quaternion interpolation between two quaternions

Description

qi=quatinterp(p,q,f,method) calculates the quaternion interpolation between two normalized quaternions p and q by interval fraction f.

p and q are the two extremes between which the function calculates the quaternion.

Aerospace Toolbox uses quaternions that are defined using the scalar-first convention.

example

Examples

collapse all

This example shows how to use interpolation to calculate quaternion between two quaternions p=[1.0 0 1.0 0] and q=[-1.0 0 1.0 0] using the SLERP method. This example uses the quatnormalize function to first-normalize the two quaternions to pn and qn.

pn = quatnormalize([1.0 0 1.0 0])
pn = 1×4

    0.7071         0    0.7071         0

qn = quatnormalize([-1.0 0 1.0 0])
qn = 1×4

   -0.7071         0    0.7071         0

qi = quatinterp(pn,qn,0.5,'slerp')
qi = 1×4

     0     0     1     0

Input Arguments

collapse all

First normalized quaternion for which to calculate the interpolation, specified as an M-by-4 matrix containing M quaternions. This quaternion must be a normalized quaternion.

Data Types: double

Second normalized quaternion for which to calculate the interpolation, specified as an M-by-4 matrix containing M quaternions. This quaternion must be a normalized quaternion.

Data Types: double

Interval fraction by which to calculate the quaternion interpolation, specified as an M-by-1 matrix containing M fractions (scalar). f varies between 0 and 1. It represents the intermediate rotation of the quaternion to be calculated.

qi=(qp,qn,qf), where:

  • If f equals 0, qi equals qp.

  • If f is between 0 and 1, qi equals method.

  • If f equals 1, qi equals qn.

Data Types: double

Quaternion interpolation method to calculate the quaternion interpolation. These methods have different rotational velocities, depending on the interval fraction. For more information on interval fractions, see [1].

  • slerp

    Quaternion slerp. Spherical linear quaternion interpolation method. This method is most accurate, but also most computation intense.

    Slerp(p,q,h)=p(p*q)h with h[0,1].

  • lerp

    Quaternion lerp. Linear quaternion interpolation method. This method is the quickest, but is also least accurate. The method does not always generate normalized output.

    LERP(p,q,h)=p(1h)+qh with h[0,1].

  • nlerp

    Normalized quaternion linear interpolation method.

    With r=LERP(p,q,h), NLERP(p,q,h)=r|r|.

Data Types: char

Output Arguments

collapse all

Interpolation of quaternion.

References

[1] ==Dam, Erik B., Martin Koch, Martin Lillholm. "Quaternions, Interpolation, and Animation." University of Copenhagen, København, Denmark, 1998.

Version History

Introduced in R2016a