cugl::Interpolator Class Reference

#include <cugl.h>

Inheritance diagram for cugl::Interpolator:

Inheritance graph
Collaboration diagram for cugl::Interpolator:

Collaboration graph
List of all members.

Public Member Functions

 Interpolator ()
 Interpolator (Quaternion &qFirst, Quaternion &qLast)
void set (const Quaternion &qFirst, const Quaternion &qLast)
void apply (double t) const
void getMatrix (double t, GL_Matrix m) const
Quaternion getQuaternion (double t) const
virtual void idle ()
virtual void apply () const
virtual void update ()

Protected Member Functions

void initialize ()

Protected Attributes

Quaternion current
Quaternion first
Quaternion last
double omega
double sinOmega
double cosOmega

Detailed Description

An instance is an interpolator for rotations. An instance of Interpolator is used to interpolate between two rotations. In other words, given two orientations of an object, an interpolator can be used to move the object smoothly from one orientation to the other. An interpolator is represented by two quaternions representing the extreme values of the rotations. When a real number t in the interval [0,1] is passed to the interpolator, the interpolator constructs a third quaternion representing an intermediate orientation. This quaternion can be used to generate a rotation matrix or transform the OpenGL model view.

The simplest way to use this class is as follows:

  1. Construct two quaternions, q and r, corresponding to the first and last positions of the desired movement.
  2. Construct an interpolator i(q,r).
  3. In the OpenGL display function, call i.apply(t), giving t a sequence of values ranging from 0 to 1.

Definition at line 1701 of file cugl.h.

Constructor & Destructor Documentation

cugl::Interpolator::Interpolator (  ) 

Construct an interpolator with dummy values for the quaternions. The interpolator may fail if it is used without first setting the start and finish quaternions. Use Quaternion::set() to change the first and last quaternions to useful values.

cugl::Interpolator::Interpolator ( Quaternion qFirst,
Quaternion qLast 

Construct an interpolator to rotate from qFirst to qLast. Report error BAD_INTERPOLATOR_ARG if qFirst = qLast.

Member Function Documentation

void cugl::Interpolator::set ( const Quaternion qFirst,
const Quaternion qLast 

Change the first and last quaternions of an existing interpolator. Report error BAD_INTERPOLATOR_ARG if qFirst = qLast.

void cugl::Interpolator::apply ( double  t  )  const

Perform the rotation at position t, 0 <= t <= 1 by modifying the current OpenGL transformation matrix.

void cugl::Interpolator::getMatrix ( double  t,
GL_Matrix  m 
) const [inline]

Compute the rotation matrix for position t, 0 <= t <= 1.

Definition at line 2976 of file cugl.h.

References getQuaternion(), and cugl::Quaternion::matrix().

Quaternion cugl::Interpolator::getQuaternion ( double  t  )  const

Return the quaternion for position t, 0 <= t <= 1.

Referenced by getMatrix().

virtual void cugl::Interpolator::idle (  )  [virtual]

Update the Interpolator position. This function should be called from the GLUT idle() function or its equivalent. It performs one step of the motion until the motion is complete, after which it has no effect.

Implements cugl::BaseCamera.

virtual void cugl::Interpolator::apply (  )  const [virtual]

Apply the Interpolator rotation to the model-view matrix. This function calls apply(t) with parameters t which is actually steps/maxSteps. It should be called in the GLUT display function or its equivalent after the model-view matrix has been initialized.

Implements cugl::BaseCamera.

virtual void cugl::Interpolator::update (  )  [inline, virtual]

Update Interpolator first and last Quaternion.

Reimplemented from cugl::BaseCamera.

Definition at line 1761 of file cugl.h.

void cugl::Interpolator::initialize (  )  [protected]

Initialize the interpolator.

Member Data Documentation

Quaternion cugl::Interpolator::current [protected]

The quaternion currently in use.

Definition at line 1772 of file cugl.h.

Quaternion cugl::Interpolator::first [protected]

The start quaternion for the interpolation.

Definition at line 1775 of file cugl.h.

Quaternion cugl::Interpolator::last [protected]

The final quaternion for the interpolation.

Definition at line 1778 of file cugl.h.

double cugl::Interpolator::omega [protected]

The angle between the first and last positions.

Definition at line 1781 of file cugl.h.

double cugl::Interpolator::sinOmega [protected]

The sine of the angle between the first and last positions.

Definition at line 1784 of file cugl.h.

double cugl::Interpolator::cosOmega [protected]

The cosine of the angle between the first and last positions.

Definition at line 1787 of file cugl.h.

The documentation for this class was generated from the following file:
Generated on Wed Sep 12 14:31:42 2007 for CUGL by  doxygen 1.5.2