quatinterp

Quaternion interpolation between two quaternions

Description

example

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.

Examples

collapse all

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])
qn = quatnormalize([-1.0 0 1.0 0])
qi = quatinterp(pn,qn,0.5,'slerp')
pn =

    0.7071         0    0.7071         0

qn =

   -0.7071         0    0.7071         0

qi =

     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 http://web.mit.edu/2.998/www/QuaternionReport1.pdf.

  • 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.

Introduced in R2016a