CUGL  2.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cugl::Interpolator Class Reference

#include <cugl.h>

Inheritance diagram for cugl::Interpolator:
Inheritance graph
[legend]
Collaboration diagram for cugl::Interpolator:
Collaboration graph
[legend]

Public Member Functions

 Interpolator ()
 
 Interpolator (const Quaternion &qFirst, const 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 ()
 
- Public Member Functions inherited from cugl::BaseCamera
 BaseCamera ()
 
void setSteps (int s)
 

Protected Member Functions

void initialize ()
 

Protected Attributes

Quaternion current
 
Quaternion first
 
Quaternion last
 
double omega
 
double sinOmega
 
double cosOmega
 
- Protected Attributes inherited from cugl::BaseCamera
int steps
 
int maxSteps
 

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 1845 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 ( const Quaternion qFirst,
const 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::apply ( double  t) const

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

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.

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

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

Definition at line 3307 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.

void cugl::Interpolator::initialize ( )
protected

Initialize the interpolator.

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.

virtual void cugl::Interpolator::update ( )
inlinevirtual

Update Interpolator first and last Quaternion.

Reimplemented from cugl::BaseCamera.

Definition at line 1905 of file cugl.h.

Member Data Documentation

double cugl::Interpolator::cosOmega
protected

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

Definition at line 1931 of file cugl.h.

Quaternion cugl::Interpolator::current
protected

The quaternion currently in use.

Definition at line 1916 of file cugl.h.

Quaternion cugl::Interpolator::first
protected

The start quaternion for the interpolation.

Definition at line 1919 of file cugl.h.

Quaternion cugl::Interpolator::last
protected

The final quaternion for the interpolation.

Definition at line 1922 of file cugl.h.

double cugl::Interpolator::omega
protected

The angle between the first and last positions.

Definition at line 1925 of file cugl.h.

double cugl::Interpolator::sinOmega
protected

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

Definition at line 1928 of file cugl.h.


The documentation for this class was generated from the following file: