# Math

Performer provides classes and functions for mathematical operations
involving floating point vectors, matrices, quaternions, and
bounding volumes.
## Vectors

Classes: pfVec2, pfVec3, pfVec4
Most of the standard math operators (=,+,-,*,/,+=,-=,*=,/=,==) are
overloaded to work with vectors. The 'vec' member can be used to
directly access the float array.

pfVec3 vector;
CAVEGetVector(CAVE_WAND_FRONT,vector.vec);
vector *= 3.0f;
z = vector[2];

Class methods are also provided for more advanced vector operations:
- length()
- normalize()
- distance(v2)
- almostEqual(v2,tolerance)
- cross(v1,v2)
- dot(v2)

## Matrices

Class: pfMatrix
Most of the standard math operators (=,+,-,*,/,+=,-=,*=,==) are
overloaded to work with matrices. The 'mat' member can be used to
directly access the float array.

Methods are also available for creating transformation matrices
(translate, rotate, scale), for adding transformations to
existing matrices, and for inverting matrices.

## Quaternions

Class: pfQuat (subclass of pfVec4)
pfQuat includes methods for mathematical operations on quaternions,
and for interpolating quaternions.

*pfMatrix::makeQuat(q)* builds a matrix for the rotation defined
by the quaternion q.

## Bounding volumes

Classes: pfSphere, pfCylinder, pfBox
*pfNode::getBound(&sphere)* returns the bounding sphere for a
node (including its children).

The *contains(v)* method tests whether a point is inside a
bounding volume.

## Fast math

Macro versions of most of the vector and matrix operations
are also available.
Performer's trigonometric functions provide faster, although less
accurate, versions of the standard math library functions:

- pfSinCos()
- pfTan()
- pfArcTan2()
- pfArcSin()
- pfArcCos()
- pfSqrt()

Previous page
Table of contents
Next page

Last modified 5 February 1996.

Dave Pape, pape@evl.uic.edu