CUGL
2.0
|
#include <cugl.h>
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 () |
![]() | |
BaseCamera () | |
void | setSteps (int s) |
Protected Member Functions | |
void | initialize () |
Protected Attributes | |
Quaternion | current |
Quaternion | first |
Quaternion | last |
double | omega |
double | sinOmega |
double | cosOmega |
![]() | |
int | steps |
int | maxSteps |
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:
i.apply(t)
, giving t a sequence of values ranging from 0 to 1. 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
.
void cugl::Interpolator::apply | ( | double | t | ) | const |
Perform the rotation at position t, 0 <= t <= 1 by modifying the current OpenGL transformation matrix.
|
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.
|
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 |
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.
|
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
.
|
inlinevirtual |
Update Interpolator first and last Quaternion.
Reimplemented from cugl::BaseCamera.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |