qinterp

RTSX Help: quaternion interpolation

qinterp

interpolates a rotation between two quaternions

Syntax

  • q = qinterp(q1, q2, r)

Input Arguments

  • q1, q2 — quaternion s <v1,v2,v3>
  • r — a vector of points between 0 and 1

Output Arguments

  • q — a vector of quaternions corresponding to sequential elements of r

Description

q = qinterp(q1, q2, r) is an interpolation between two unit quaternions that produces a rotation around a fixed axis in space. Quaternion interpolation is achieved using spherical linear interpolation (slerp) in which the unit quaternions follow a great circle path on a 4-dimensional hypersphere.

Examples

The example below demonstrates how to apply qinterp( ) to coordinate frame rotation.

-->R0 = rotz(-pi/3)*roty(-pi/3);  	// start frame
 -->R1 = rotz(pi/3)*roty(pi/3);	// end frame
 -->q0 = Quaternion(R0);    // creates start and end quaternions
 -->q1 = Quaternion(R1);
 -->q = qinterp(q0, q1, [0:49]'/49);    // perform interpolation
 -->tranimate(q)             // rotation animation

See also