Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

openvrml::mat4f Class Reference
[Base Types]

A class for all matrix operations. More...

List of all members.


Public Member Functions

 mat4f () throw ()
 Construct.

 mat4f (float f11, float f12, float f13, float f14, float f21, float f22, float f23, float f24, float f31, float f32, float f33, float f34, float f41, float f42, float f43, float f44) throw ()
 Construct mat4f with given 16 elements in row-major order.

 mat4f (const float mat[16]) throw ()
 Construct from an array of 16 values.

 mat4f (const float(&mat)[4][4]) throw ()
 Construct from a 4x4 array.

mat4foperator *= (float scalar) throw ()
 Multiply by a scalar.

mat4foperator *= (const mat4f &mat) throw ()
 Multiply by another matrix.

 float (&operator[](size_t index) throw())[4]
const  float (&operator[](size_t index) const throw())[4]
void transformation (vec3f &t, openvrml::rotation &r, vec3f &s) const throw ()
 Get the translation, rotation and scale from the orthogonal transformation matrix.

void transformation (vec3f &t, openvrml::rotation &r, vec3f &s, vec3f &shear) const throw ()
 Get the translation, rotation, scale and shear from affine transformation matrix.

const mat4f inverse () const throw ()
 Get the inverse of an affine matrix.

const mat4f transpose () const throw ()
 Get the transposition of the matrix.

float det () const throw ()
 Return determinant of entire matrix.


Static Public Member Functions

const mat4f rotation (const openvrml::rotation &rot) throw ()
 Create a rotation matrix.

const mat4f rotation (const quatf &quat) throw ()
 Create a rotation matrix.

const mat4f scale (float s) throw ()
 Create a uniform scale matrix.

const mat4f scale (const vec3f &s) throw ()
 Create a scale matrix.

const mat4f translation (const vec3f &t) throw ()
 Create a translation matrix.

const mat4f transformation (const vec3f &t, const openvrml::rotation &r, const vec3f &s, const openvrml::rotation &sr, const vec3f &c) throw ()
 Create a transformation matrix from a translation, a rotation, a scale, a scaleOrientation, and a center.


Private Attributes

float mat [4][4]
 4x4 float matrix.


Related Functions

(Note that these are not member functions.)

const mat4f operator * (const mat4f &mat, const float scalar) throw()
 Multiply a matrix by a scalar value.

const mat4f operator * (const float scalar, const mat4f &mat) throw()
 Multiply a scalar value by matrix.

const mat4f operator * (const mat4f &lhs, const mat4f &rhs) throw()
 Multiply two matrices.

std::ostream & operator<< (std::ostream &out, const mat4f &mat)
 Stream output.

bool operator== (const mat4f &lhs, const mat4f &rhs) throw()
 Equality comparison operator.

bool operator!= (const mat4f &lhs, const mat4f &rhs) throw()
 Inequality comparison operator.


Detailed Description

A class for all matrix operations.

Matrices are stored in row-major order.


Constructor & Destructor Documentation

openvrml::mat4f::mat4f  )  throw ()
 

Construct.

Matrix is initialized to the identity matrix.

openvrml::mat4f::mat4f float  f11,
float  f12,
float  f13,
float  f14,
float  f21,
float  f22,
float  f23,
float  f24,
float  f31,
float  f32,
float  f33,
float  f34,
float  f41,
float  f42,
float  f43,
float  f44
throw ()
 

Construct mat4f with given 16 elements in row-major order.

Parameters:
f11 
f12 
f13 
f14 
f21 
f22 
f23 
f24 
f31 
f32 
f33 
f34 
f41 
f42 
f43 
f44 

openvrml::mat4f::mat4f const float  mat[16]  )  throw () [explicit]
 

Construct from an array of 16 values.

Parameters:
mat an array of values in row-major order.

openvrml::mat4f::mat4f const float &  mat[4][4]  )  throw () [explicit]
 

Construct from a 4x4 array.

Parameters:
mat a 4x4 array of elements in row-major order.

Member Function Documentation

float openvrml::mat4f::det  )  const throw ()
 

Return determinant of entire matrix.

Returns:
the determinant.

const mat4f openvrml::mat4f::inverse  )  const throw ()
 

Get the inverse of an affine matrix.

Returns:
the inverse of the matrix.
Precondition:
the current matrix must be affine.

mat4f & openvrml::mat4f::operator *= const mat4f mat  )  throw ()
 

Multiply by another matrix.

Sets the matrix equal to the matrix multiplied by mat.

Parameters:
mat the matrix by which to multiply.
Returns:
a reference to the object.

mat4f & openvrml::mat4f::operator *= float  scalar  )  throw ()
 

Multiply by a scalar.

Parameters:
scalar value by which to multiply.
Returns:
a reference to the object.

const mat4f openvrml::mat4f::rotation const quatf quat  )  throw () [static]
 

Create a rotation matrix.

Parameters:
quat a quaternion.
Returns:
a matrix representation of quat.

const mat4f openvrml::mat4f::rotation const openvrml::rotation rot  )  throw () [static]
 

Create a rotation matrix.

Parameters:
rot a rotation.
Returns:
a matrix representation of rot.

const mat4f openvrml::mat4f::scale const vec3f s  )  throw () [static]
 

Create a scale matrix.

Parameters:
s a vector.
Returns:
a scale matrix.

const mat4f openvrml::mat4f::scale float  s  )  throw () [static]
 

Create a uniform scale matrix.

Parameters:
s scale factor.
Returns:
a uniform scale matrix.

void openvrml::mat4f::transformation vec3f t,
openvrml::rotation r,
vec3f s,
vec3f shear
const throw ()
 

Get the translation, rotation, scale and shear from affine transformation matrix.

Here any projection information in matrix is ignored. As VRML allows non-uniform scaling, it is safe to call this routine. The caller is responsible for assuring that the transformation is in fact affine, otherwise the results are undefined.

Return values:
t translation.
r rotation.
s scale.
shear shear.

void openvrml::mat4f::transformation vec3f t,
openvrml::rotation r,
vec3f s
const throw ()
 

Get the translation, rotation and scale from the orthogonal transformation matrix.

Here any projection or shear information in the matrix is ignored. The caller is responsible for assuring that the transformation is in fact orthogonal, otherwise the results are undefined.

Return values:
t translation.
r rotation.
s scale.

const mat4f openvrml::mat4f::transformation const vec3f t,
const openvrml::rotation r,
const vec3f s,
const openvrml::rotation sr,
const vec3f c
throw () [static]
 

Create a transformation matrix from a translation, a rotation, a scale, a scaleOrientation, and a center.

Parameters:
t the translation.
r the rotation.
s the scale.
sr the scale orientation.
c the center.
Returns:
a transformation matrix.

const mat4f openvrml::mat4f::translation const vec3f t  )  throw () [static]
 

Create a translation matrix.

Parameters:
t translation vector.
Returns:
a translation matrix.

const mat4f openvrml::mat4f::transpose  )  const throw ()
 

Get the transposition of the matrix.

Returns:
a transposed copy of the matrix.

Friends And Related Function Documentation

const mat4f operator * const mat4f lhs,
const mat4f rhs
throw() [related]
 

Multiply two matrices.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
the result matrix.

const mat4f operator * const float  scalar,
const mat4f mat
throw() [related]
 

Multiply a scalar value by matrix.

Parameters:
scalar scalar.
mat matrix.
Returns:
the result matrix.

const mat4f operator * const mat4f mat,
const float  scalar
throw() [related]
 

Multiply a matrix by a scalar value.

Parameters:
mat matrix.
scalar scalar.
Returns:
the result matrix.

bool operator!= const mat4f lhs,
const mat4f rhs
throw() [related]
 

Inequality comparison operator.

Parameters:
lhs a matrix.
rhs a matrix.

std::ostream & operator<< std::ostream &  out,
const mat4f mat
[related]
 

Stream output.

Parameters:
out an output stream.
mat a matrix.
Returns:
out.

bool operator== const mat4f lhs,
const mat4f rhs
throw() [related]
 

Equality comparison operator.

All componenents must match exactly.

Parameters:
lhs a matrix.
rhs a matrix.

Member Data Documentation

float openvrml::mat4f::mat[4][4] [private]
 

4x4 float matrix.

For internal use only.