Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Matrix3 Class Reference
[Data classes]

A three-by-three matrix class using double-precision. More...

#include <Matrix3.h>

Inheritance diagram for Matrix3:

BaseType List of all members.

Public Methods

virtual std::string asString () const
 String representation.

virtual std::string typeString () const
 Type representation.

virtual void serialize (Archive &)
 Serialize to or from a data archive.

virtual void parseXML (const char *cdata)
 Extract the matrix values from XML character data.

 Matrix3 ()
 Default constructor.

 Matrix3 (const Matrix3 &other)
 Copy constructor.

 Matrix3 (double const *const def)
 Construct and initialize a matrix from a double[9] array.

 Matrix3 (double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21, double a22)
 Matrix3 (const Vector3 &col0, const Vector3 &col1, const Vector3 &col2)
 Construct and initialize a matrix from three column vectors.

 ~Matrix3 ()
 Destructor.

int compare (const Matrix3 &m) const
 Compare two matrices.

bool operator== (const Matrix3 &m) const
 Compare two matrices for (byte) equality.

bool operator!= (const Matrix3 &m) const
 Compare two matrices for (byte) inequality.

double & operator() (int row_, int col_)
 Get the value (reference) of a matrix element.

double operator() (int row_, int col_) const
 Get the (const) value of a matrix element.

double getElement (int row_, int col_)
 Get the value of a matrix element.

void setElement (int row_, int col_, double value)
 Set the value of a matrix element.

bool valid () const
 Return true if all elements are valid floating point numbers.

bool isNaN () const
 Return true if any elements are NaN (not-a-number).

Matrix3 & operator= (const Matrix3 &other)
 Copy operator.

void set (const Matrix3 &other)
 Set this matrix from another matrix.

void set (double const *const ptr_)
 Set this matrix from a double[9] array.

void set (double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21, double a22)
 Set this matrix from a list of element values.

std::vector< double > getElements () const
 Get the matrix elements as a vector<double>.

void setElements (std::vector< double > const &v) const
 Set this matrix from a vector<double>.

Vector3 getRow (int i)
 Get a row vector of this matrix.

Vector3 getCol (int i)
 Get a column vector of this matrix.

void setRow (int i, const Vector3 &v)
 Set a row of this matrix from a vector.

void setCol (int i, const Vector3 &v)
 Set a column of this matrix from a vector.

double * row (int i)
 Get a pointer to a row of this matrix.

double * ptr ()
 Get a pointer to the first element of this matrix.

double const * ptr () const
 Get a const pointer to the first element of this matrix.

void makeIdentity ()
 Set this matrix equal to the identity matrix.

void makeZero ()
 Set all matrix elements to zero.

void makeScale (const Vector3 &v)
 Set this matrix to a scaling matrix.

void makeScale (double, double, double)
 Set this matrix to a scaling matrix.

void makeRotate (const Vector3 &from, const Vector3 &to)
 Make a rotation matrix to transform one vector into another.

void makeRotate (double angle, const Vector3 &axis)
 Make a rotation matrix to rotate around a given axis.

void makeRotate (double angle, double x, double y, double z)
 Make a rotation matrix to rotate around a given axis.

void makeRotate (const Quat &)
 Make a rotation matrix from a quaternion.

void makeRotate (double roll, double pitch, double yaw)
 Make a rotation matrix from euler angles.

void makeRotate (double angle1, const Vector3 &axis1, double angle2, const Vector3 &axis2, double angle3, const Vector3 &axis3)
 Make a rotation from combining three rotations.

bool invert (const Matrix3 &m, double tolerance=1e-12)
 Construct the inverse of a matrix.

bool invert (double tolerance=1e-12)
 Invert this matrix.

void transpose (const Matrix3 &other)
 Construct the transpose of a matrix.

void transpose ()
 Transpose this matrix.

Matrix3 getInverse (double tolerance=1e-12) const
 Get the inverse of this matrix.

Matrix3 getTranspose () const
 Get the transpose of this matrix.

double determinant () const
 Compute the determinant of this matrix.

void getRotate (double angle, Vector3 &axis) const
 Get the rotation angle and axis of this matrix.

void getEulerAngles (double &roll, double &pitch, double &yaw)
 Get the Euler angles of this matrix.

Vector3 preMult (const Vector3 &v) const
 Multiply this matrix by a row vector (v*M).

Vector3 postMult (const Vector3 &v) const
 Multiply this matrix by a column vector (M*v).

Vector3 operator * (const Vector3 &v) const
 Multiply this matrix by a column vector (M*v).

Vector3 getScale () const
 Get the diagonal elements of this matrix as a vector.

double getTrace () const
 Get the trace of this matrix.

void mult (const Matrix3 &, const Matrix3 &)
 Matrix multipliation (M*M).

void preMult (const Matrix3 &)
 Multiply this matrix by another matrix on the left.

void postMult (const Matrix3 &)
 Multiply this matrix by another matrix on the right.

void operator *= (const Matrix3 &other)
 Multiply this matrix by another matrix on the right.

Matrix3 operator * (const Matrix3 &m) const
 Get the product of this matrix and another matrix.

const Matrix3 & operator+= (const Matrix3 &rhs)
 Add another matrix to this matrix.

const Matrix3 & operator-= (const Matrix3 &rhs)
 Subtract another matrix from this matrix.

const Matrix3 & operator *= (const double rhs)
 Multiply this matrix by a scalar.

const Matrix3 & operator/= (const double rhs)
 Divide this matrix by a scalar.

Matrix3 operator+ (const Matrix3 &rhs) const
 Get the sum of this matrix and another matrix.

Matrix3 operator- (const Matrix3 &rhs) const
 Get the difference of this matrix and another matrix.

Matrix3 operator * (double rhs) const
 Get the product of this matrix and a scalar.

Matrix3 operator/ (double rhs) const
 Get the quotient of this matrix and a scalar.

Matrix3 operator- () const
 Get this matrix with each element negated.

virtual void convertXML ()
 Convert XML data to internal format prior to serialization.


Static Public Methods

Matrix3 const & identity (void)
 Create a new identity matrix.

Matrix3 scale (const Vector3 &sv)
 Create a new scaling matrix.

Matrix3 scale (double sx, double sy, double sz)
 Create a new scaling matrix.

Matrix3 rotate (const Vector3 &from, const Vector3 &to)
 Create a new rotation matrix.

Matrix3 rotate (double angle, double x, double y, double z)
 Create a new rotation matrix.

Matrix3 rotate (double angle, const Vector3 &axis)
 Create a new rotation matrix.

Matrix3 rotate (double angle1, const Vector3 &axis1, double angle2, const Vector3 &axis2, double angle3, const Vector3 &axis3)
 Create a new rotation matrix.

Matrix3 rotate (double roll, double pitch, double yaw)
 Create a new rotation matrix.

Matrix3 rotate (const Quat &quat)
 Create a new rotation matrix.

Matrix3 inverse (const Matrix3 &matrix, double tolerance=1e-12)
 Get the inverse of a matrix.

Matrix3 tensor (const Vector3 &a, const Vector3 &b)
 Get the tensor product of two vectors.


Static Public Attributes

const Matrix3 ZERO
 Null matrix.

const Matrix3 IDENTITY
 Identity matrix.


Protected Attributes

double _mat [3][3]
 The matrix elements.


Friends

Vector3 operator * (const Vector3 &v, const Matrix3 &m)
 Multiply a matrix by a row vector (v*M).

Matrix3 operator * (double lhs, const Matrix3 &rhs)
 Multiply a matrix by a scalar on the left (s*M).

SIMDATA_EXPORT std::ostream & operator<< (std::ostream &os, const Matrix3 &m)
 Format this matrix for an output stream.


Detailed Description

A three-by-three matrix class using double-precision.


Constructor & Destructor Documentation

Matrix3::Matrix3   [inline]
 

Default constructor.

Note:
The default constructor does not initialize the matrix for the sake of efficiency. If you do not explicitly set the matrix, the elements will generally assume random values.

Matrix3::Matrix3 const Matrix3 &    other [inline]
 

Copy constructor.

Matrix3::Matrix3 double const *const    def [inline, explicit]
 

Construct and initialize a matrix from a double[9] array.

Matrix3::Matrix3 double    a00,
double    a01,
double    a02,
double    a10,
double    a11,
double    a12,
double    a20,
double    a21,
double    a22
[inline]
 

Matrix3::Matrix3 const Vector3   col0,
const Vector3   col1,
const Vector3   col2
 

Construct and initialize a matrix from three column vectors.

Matrix3::~Matrix3   [inline]
 

Destructor.


Member Function Documentation

std::string Matrix3::asString   [virtual]
 

String representation.

Implements BaseType.

int Matrix3::compare const Matrix3 &    m const [inline]
 

Compare two matrices.

Compares two matrices byte-by-byte. The sign of the return value is useless, since the byte comparisons are inequivalent to floating point comparisions. Used only to test for equality.

Returns:
0 if equal, non-zero if unequal.

void BaseType::convertXML   [virtual, inherited]
 

Convert XML data to internal format prior to serialization.

This method is currently only called by the XML parser for Object classes. If another BaseType class requires this method, a call must be added to the appropriate XML handler in the parser.

double Matrix3::determinant  
 

Compute the determinant of this matrix.

Vector3 Matrix3::getCol int    i [inline]
 

Get a column vector of this matrix.

double Matrix3::getElement int    row_,
int    col_
[inline]
 

Get the value of a matrix element.

std::vector< double > Matrix3::getElements  
 

Get the matrix elements as a vector<double>.

void Matrix3::getEulerAngles double &    roll,
double &    pitch,
double &    yaw
 

Get the Euler angles of this matrix.

Matrix3 Matrix3::getInverse double    tolerance = 1e-12 const [inline]
 

Get the inverse of this matrix.

See invert(double).

void Matrix3::getRotate double    angle,
Vector3   axis
const
 

Get the rotation angle and axis of this matrix.

Vector3 Matrix3::getRow int    i [inline]
 

Get a row vector of this matrix.

Vector3 Matrix3::getScale   const [inline]
 

Get the diagonal elements of this matrix as a vector.

double Matrix3::getTrace   const [inline]
 

Get the trace of this matrix.

Matrix3 Matrix3::getTranspose   const [inline]
 

Get the transpose of this matrix.

Matrix3 const& Matrix3::identity void    [inline, static]
 

Create a new identity matrix.

Matrix3 Matrix3::inverse const Matrix3 &    matrix,
double    tolerance = 1e-12
[inline, static]
 

Get the inverse of a matrix.

bool Matrix3::invert double    tolerance = 1e-12 [inline]
 

Invert this matrix.

Parameters:
tolerance  The minimum value of the deteriminant.
Returns:
false if the deteriminant less than the tolerance, true otherwise. If false, the matrix elements are unchanged.

bool Matrix3::invert const Matrix3 &    m,
double    tolerance = 1e-12
 

Construct the inverse of a matrix.

Parameters:
m  The input matrix.
tolerance  The minimum value of the deteriminant.
Returns:
false if the deteriminant less than the tolerance, true otherwise. If false, the matrix elements are copied directly from the input matrx.

bool Matrix3::isNaN  
 

Return true if any elements are NaN (not-a-number).

void Matrix3::makeIdentity   [inline]
 

Set this matrix equal to the identity matrix.

void Matrix3::makeRotate double    angle1,
const Vector3   axis1,
double    angle2,
const Vector3   axis2,
double    angle3,
const Vector3   axis3
 

Make a rotation from combining three rotations.

Parameters:
angle1  The angle of the first rotation.
axis1  The axis of the first rotation.
angle2  The angle of the second rotation.
axis2  The axis of the second rotation.
angle3  The angle of the third rotation.
axis3  The axis of the third rotation.

void Matrix3::makeRotate double    roll,
double    pitch,
double    yaw
 

Make a rotation matrix from euler angles.

Parameters:
roll  the x-axis rotation.
pitch  the y-axis rotation.
yaw  the z-axis rotation.

void Matrix3::makeRotate const Quat  
 

Make a rotation matrix from a quaternion.

void Matrix3::makeRotate double    angle,
double    x,
double    y,
double    z
 

Make a rotation matrix to rotate around a given axis.

See makeRotate(double angle, const Vector3& axis).

void Matrix3::makeRotate double    angle,
const Vector3   axis
 

Make a rotation matrix to rotate around a given axis.

Parameters:
angle  The angle of rotation.
axis  The axis of rotation.

void Matrix3::makeRotate const Vector3   from,
const Vector3   to
 

Make a rotation matrix to transform one vector into another.

The resulting matrix will rotate the from vector into the to vector.

void Matrix3::makeScale double   ,
double   ,
double   
 

Set this matrix to a scaling matrix.

See makeScale(const Vector3&).

void Matrix3::makeScale const Vector3   v [inline]
 

Set this matrix to a scaling matrix.

The resulting matrix has the components of the input vector along the diagonal, with all off-diagonal elements equal to zero.

Parameters:
v  A vector specifying the scale factor for each axis.

void Matrix3::makeZero   [inline]
 

Set all matrix elements to zero.

void Matrix3::mult const Matrix3 &   ,
const Matrix3 &   
 

Matrix multipliation (M*M).

Matrix3 Matrix3::operator * double    rhs const [inline]
 

Get the product of this matrix and a scalar.

Matrix3 Matrix3::operator * const Matrix3 &    m const [inline]
 

Get the product of this matrix and another matrix.

Vector3 Matrix3::operator * const Vector3   v const [inline]
 

Multiply this matrix by a column vector (M*v).

const Matrix3& Matrix3::operator *= const double    rhs [inline]
 

Multiply this matrix by a scalar.

void Matrix3::operator *= const Matrix3 &    other [inline]
 

Multiply this matrix by another matrix on the right.

bool Matrix3::operator!= const Matrix3 &    m const [inline]
 

Compare two matrices for (byte) inequality.

double Matrix3::operator() int    row_,
int    col_
const [inline]
 

Get the (const) value of a matrix element.

double& Matrix3::operator() int    row_,
int    col_
[inline]
 

Get the value (reference) of a matrix element.

Matrix3 Matrix3::operator+ const Matrix3 &    rhs const [inline]
 

Get the sum of this matrix and another matrix.

const Matrix3& Matrix3::operator+= const Matrix3 &    rhs [inline]
 

Add another matrix to this matrix.

Matrix3 Matrix3::operator-   const [inline]
 

Get this matrix with each element negated.

Matrix3 Matrix3::operator- const Matrix3 &    rhs const [inline]
 

Get the difference of this matrix and another matrix.

const Matrix3& Matrix3::operator-= const Matrix3 &    rhs [inline]
 

Subtract another matrix from this matrix.

Matrix3 Matrix3::operator/ double    rhs const [inline]
 

Get the quotient of this matrix and a scalar.

const Matrix3& Matrix3::operator/= const double    rhs [inline]
 

Divide this matrix by a scalar.

Matrix3& Matrix3::operator= const Matrix3 &    other [inline]
 

Copy operator.

bool Matrix3::operator== const Matrix3 &    m const [inline]
 

Compare two matrices for (byte) equality.

void Matrix3::parseXML const char *    cdata [virtual]
 

Extract the matrix values from XML character data.

The nine values should be separated by white-space and arranged in order (0,0), (0,1), (0,2), (1,0), etc.

Reimplemented from BaseType.

void Matrix3::postMult const Matrix3 &   
 

Multiply this matrix by another matrix on the right.

Vector3 Matrix3::postMult const Vector3   v const [inline]
 

Multiply this matrix by a column vector (M*v).

void Matrix3::preMult const Matrix3 &   
 

Multiply this matrix by another matrix on the left.

Vector3 Matrix3::preMult const Vector3   v const [inline]
 

Multiply this matrix by a row vector (v*M).

double const* Matrix3::ptr   const [inline]
 

Get a const pointer to the first element of this matrix.

double* Matrix3::ptr   [inline]
 

Get a pointer to the first element of this matrix.

Matrix3 Matrix3::rotate const Quat   quat [inline, static]
 

Create a new rotation matrix.

Matrix3 Matrix3::rotate double    roll,
double    pitch,
double    yaw
[inline, static]
 

Create a new rotation matrix.

Matrix3 Matrix3::rotate double    angle1,
const Vector3   axis1,
double    angle2,
const Vector3   axis2,
double    angle3,
const Vector3   axis3
[inline, static]
 

Create a new rotation matrix.

Matrix3 Matrix3::rotate double    angle,
const Vector3   axis
[inline, static]
 

Create a new rotation matrix.

Matrix3 Matrix3::rotate double    angle,
double    x,
double    y,
double    z
[inline, static]
 

Create a new rotation matrix.

Matrix3 Matrix3::rotate const Vector3   from,
const Vector3   to
[inline, static]
 

Create a new rotation matrix.

double* Matrix3::row int    i [inline]
 

Get a pointer to a row of this matrix.

Matrix3 Matrix3::scale double    sx,
double    sy,
double    sz
[inline, static]
 

Create a new scaling matrix.

Matrix3 Matrix3::scale const Vector3   sv [inline, static]
 

Create a new scaling matrix.

void Matrix3::serialize Archive   [virtual]
 

Serialize to or from a data archive.

Reimplemented from BaseType.

void Matrix3::set double    a00,
double    a01,
double    a02,
double    a10,
double    a11,
double    a12,
double    a20,
double    a21,
double    a22
[inline]
 

Set this matrix from a list of element values.

void Matrix3::set double const *const    ptr_ [inline]
 

Set this matrix from a double[9] array.

void Matrix3::set const Matrix3 &    other [inline]
 

Set this matrix from another matrix.

void Matrix3::setCol int    i,
const Vector3   v
[inline]
 

Set a column of this matrix from a vector.

void Matrix3::setElement int    row_,
int    col_,
double    value
[inline]
 

Set the value of a matrix element.

void Matrix3::setElements std::vector< double > const &    v const
 

Set this matrix from a vector<double>.

void Matrix3::setRow int    i,
const Vector3   v
[inline]
 

Set a row of this matrix from a vector.

Matrix3 Matrix3::tensor const Vector3   a,
const Vector3   b
[inline, static]
 

Get the tensor product of two vectors.

void Matrix3::transpose   [inline]
 

Transpose this matrix.

void Matrix3::transpose const Matrix3 &    other
 

Construct the transpose of a matrix.

Parameters:
other  The input matrix to transpose.

virtual std::string Matrix3::typeString   const [inline, virtual]
 

Type representation.

Implements BaseType.

bool Matrix3::valid   const [inline]
 

Return true if all elements are valid floating point numbers.


Friends And Related Function Documentation

Matrix3 operator * double    lhs,
const Matrix3 &    rhs
[friend]
 

Multiply a matrix by a scalar on the left (s*M).

Vector3 operator * const Vector3   v,
const Matrix3 &    m
[friend]
 

Multiply a matrix by a row vector (v*M).

SIMDATA_EXPORT std::ostream& operator<< std::ostream &    os,
const Matrix3 &    m
[friend]
 

Format this matrix for an output stream.


Member Data Documentation

double Matrix3::_mat[3][3] [protected]
 

The matrix elements.

const Matrix3 Matrix3::IDENTITY [static]
 

Identity matrix.

NAMESPACE_SIMDATA const Matrix3 Matrix3::ZERO [static]
 

Null matrix.


The documentation for this class was generated from the following files:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:41 2003, using Doxygen 1.2.18.

[SF.net]