Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

# openvrml::mat4f Struct Reference

A POD-struct comprising a 4x4 matrix. More...

`#include <openvrml/basetypes.h>`

List of all members.

## Public Member Functions

mat4f & | operator*= (float scalar) throw ()
| Multiply by a scalar.
mat4f & | operator*= (const mat4f &mat) throw ()
| Multiply by another matrix.
float(& | operator[] (const std::size_t index) throw())[4]
| Row access.
const float(& | operator[] (const std::size_t index) const throw())[4]
void | transformation (vec3f &t, rotation &r, vec3f &s) const throw ()
| Get the translation, rotation and scale from the orthogonal transformation matrix.
void | transformation (vec3f &t, rotation &r, vec3f &s, vec3f &shear) const throw ()
| Get the translation, rotation, scale and shear from an 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 ()
| Determinant.

## Public Attributes

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

## Related Functions

(Note that these are not member functions.)
const openvrml::mat4f | make_rotation_mat4f (const rotation &rot) throw()
| Create a rotation matrix.
const openvrml::mat4f | make_rotation_mat4f (const quatf &quat) throw()
| Create a rotation matrix.
const openvrml::mat4f | make_scale_mat4f (const vec3f &s) throw()
| Create a scale matrix.
const openvrml::mat4f | make_scale_mat4f (const float s) throw()
| Create a uniform scale matrix.
const openvrml::mat4f | make_translation_mat4f (const vec3f &t) throw()
| Create a translation matrix.
const openvrml::mat4f | make_transformation_mat4f (const vec3f &t, const rotation &r, const vec3f &s, const rotation &sr, const vec3f &c) throw()
| Create a transformation matrix from a translation, a rotation, a scale, a scaleOrientation, and a center.
const openvrml::mat4f | make_mat4f (const float f11, const float f12, const float f13, const float f14, const float f21, const float f22, const float f23, const float f24, const float f31, const float f32, const float f33, const float f34, const float f41, const float f42, const float f43, const float f44) throw()
| Create a `mat4f` with given 16 elements in row-major order.
const openvrml::mat4f | make_mat4f () throw()
| Create an identity matrix.
const openvrml::mat4f | make_mat4f (const float mat[16]) throw()
| Create a matrix from an array of 16 values.
const openvrml::mat4f | make_mat4f (const float(&mat)[4][4]) throw()
| Create a matrix from a 4x4 array.
const openvrml::mat4f | operator* (const mat4f &mat, const float scalar) throw()
| Multiply a matrix by a scalar value.
const openvrml::mat4f | operator* (const float scalar, const mat4f &mat) throw()
| Multiply a scalar value by matrix.
const openvrml::mat4f | operator* (const mat4f &lhs, const mat4f &rhs) throw()
| Multiply two matrices.
std::istream & | operator>> (std::istream &in, mat4f &m)
| Stream input.
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 POD-struct comprising a 4x4 matrix.

Matrices are stored in row-major order.

## Member Function Documentation

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

Multiply by a scalar.

Parameters:

  `[in]` | scalar | value by which to multiply.

Returns:
  a reference to the object.

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

Multiply by another matrix.

Sets the matrix equal to the matrix multiplied by `mat`.

Parameters:

  `[in]` | mat | the matrix by which to multiply.

Returns:
  a reference to the object.

const float(& openvrml::mat4f::operator[] | ( | const std::size_t | index | ) | )[4]`[inline]`

Row access.

Parameters:

  `[in]` | index | row index.

Returns:
  row `index`.

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

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

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.

Parameters:

  `[out]` | t | translation.
  `[out]` | r | rotation.
  `[out]` | s | scale.

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

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

Any projection information in the 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 matrix is in fact affine; otherwise the results are undefined.

Parameters:

  `[out]` | t | translation.
  `[out]` | r | rotation.
  `[out]` | s | scale.
  `[out]` | shear | shear.

const openvrml::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.

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

Get the transposition of the matrix.

Returns:
  a transposed copy of the matrix.

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

Determinant.

Returns:
  the determinant.

## Friends And Related Function Documentation

const openvrml::mat4f make_rotation_mat4f | ( | const rotation & | rot | ) | throw()`[related]`

Create a rotation matrix.

Parameters:

  `[in]` | rot | a rotation.

Returns:
  a matrix representation of `rot`.

const openvrml::mat4f make_rotation_mat4f | ( | const quatf & | quat | ) | throw()`[related]`

Create a rotation matrix.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

  `[in]` | quat | a quaternion.

Returns:
  a matrix representation of `quat`.

const openvrml::mat4f make_scale_mat4f | ( | const vec3f & | s | ) | throw()`[related]`

Create a scale matrix.

Parameters:

  `[in]` | s | a vector.

Returns:
  a scale matrix.

const openvrml::mat4f make_scale_mat4f | ( | const float | s | ) | throw()`[related]`

Create a uniform scale matrix.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

  `[in]` | s | scale factor.

Returns:
  a uniform scale matrix.

const openvrml::mat4f make_translation_mat4f | ( | const vec3f & | t | ) | throw()`[related]`

Create a translation matrix.

Parameters:

  `[in]` | t | translation vector.

Returns:
  a translation matrix.

const openvrml::mat4f make_transformation_mat4f | ( | const vec3f & | t,
|  | const rotation & | r,
|  | const vec3f & | s,
|  | const rotation & | sr,
|  | const vec3f & | c |
| ) |  |  | throw()`[related]`

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

Parameters:

  `[in]` | t | the translation.
  `[in]` | r | the rotation.
  `[in]` | s | the scale.
  `[in]` | sr | the scale orientation.
  `[in]` | c | the center.

Returns:
  a transformation matrix.

const openvrml::mat4f make_mat4f | ( | const float | f11,
|  | const float | f12,
|  | const float | f13,
|  | const float | f14,
|  | const float | f21,
|  | const float | f22,
|  | const float | f23,
|  | const float | f24,
|  | const float | f31,
|  | const float | f32,
|  | const float | f33,
|  | const float | f34,
|  | const float | f41,
|  | const float | f42,
|  | const float | f43,
|  | const float | f44 |
| ) |  |  | throw()`[related]`

Create a `mat4f` with given 16 elements in row-major order.

Parameters:

  `[in]` | f11 |
  `[in]` | f12 |
  `[in]` | f13 |
  `[in]` | f14 |
  `[in]` | f21 |
  `[in]` | f22 |
  `[in]` | f23 |
  `[in]` | f24 |
  `[in]` | f31 |
  `[in]` | f32 |
  `[in]` | f33 |
  `[in]` | f34 |
  `[in]` | f41 |
  `[in]` | f42 |
  `[in]` | f43 |
  `[in]` | f44 |

Returns:
  a `mat4f` with given 16 elements in row-major order.

const openvrml::mat4f make_mat4f | ( |  | ) | throw()`[related]`

Create an identity matrix.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns:
  an identity matrix.

const openvrml::mat4f make_mat4f | ( | const float | mat[16] | ) | throw()`[related]`

Create a matrix from an array of 16 values.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Precondition:
  `mat` points to a sequence of at least 16 `float` values.

Parameters:

  `[in]` | mat | a pointer to a sequence of 16 `float` values in row-major order.

Returns:
  a `mat4f` containing the values in `mat`.

const openvrml::mat4f make_mat4f | ( | const float(&) | mat[4][4] | ) | throw()`[related]`

Create a matrix from a 4x4 array.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

  `[in]` | mat | a 4x4 array of elements in row-major order.

Returns:
  a `mat4f` containing the values in `mat`.

const openvrml::mat4f operator* | ( | const mat4f & | mat,
|  | const float | scalar |
| ) |  |  | throw()`[related]`

Multiply a matrix by a scalar value.

Parameters:

  `[in]` | mat | matrix.
  `[in]` | scalar | scalar.

Returns:
  the result matrix.

const openvrml::mat4f operator* | ( | const float | scalar,
|  | const mat4f & | mat |
| ) |  |  | throw()`[related]`

Multiply a scalar value by matrix.

Parameters:

  `[in]` | scalar | scalar.
  `[in]` | mat | matrix.

Returns:
  the result matrix.

const openvrml::mat4f operator* | ( | const mat4f & | lhs,
|  | const mat4f & | rhs |
| ) |  |  | throw()`[related]`

Multiply two matrices.

Parameters:

  `[in]` | lhs | left-hand operand.
  `[in]` | rhs | right-hand operand.

Returns:
  the result matrix.

std::istream & operator>> | ( | std::istream & | in,
|  | mat4f & | m |
| ) |  |  | `[related]`

Stream input.

Consistent with the VRML97 convention, commas (“``,”) in the input are treated as whitespace.

Optionally, brackets may be used in the input to group the rows; i.e., the following syntaxes are accepted:

- [ f11, ... f14 ], ... [ f41, ... f44 ]
- f11, f12, ... f44

Parameters:

  `[in,out]` | in | input stream.
  `[out]` | m | a matrix.

Returns:
  `in`.

std::ostream & operator<< | ( | std::ostream & | out,
|  | const mat4f & | mat |
| ) |  |  | `[related]`

Stream output.

Parameters:

  `[in,out]` | out | an output stream.
  `[in]` | mat | a matrix.

Returns:
  `out`.

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

Equality comparison operator.

All componenents must match exactly.

Parameters:

  `[in]` | lhs | a matrix.
  `[in]` | rhs | a matrix.

Returns:
  `true` if `lhs` and `rhs` are equivalent; `false` otherwise.

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

Inequality comparison operator.

Parameters:

  `[in]` | lhs | a matrix.
  `[in]` | rhs | a matrix.

Returns:
  `true` if `lhs` and `rhs` are not equivalent; `false` otherwise.

## Member Data Documentation

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

4x4 float matrix.