Matrix3 Class Reference
[libbiarc]

The Matrix3 class is a 3x3 dimensional Matrix class with floating point entries. More...

#include <include/Matrix3.h>

List of all members.

Public Member Functions

 Matrix3 ()
 Matrix3 (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2)
 Matrix3 (const float &x00, const float &x01, const float &x02, const float &x10, const float &x11, const float &x12, const float &x20, const float &x21, const float &x22)
Matrix3zero ()
Vector3operator[] (int n)
const Vector3operator[] (int n) const
void setOne (const int c, const Vector3 &v)
void setOne (const int c, const float v1, const float v2, const float v3)
void setAll (const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
void setAll (const Vector3 *v)
Vector3 getOne (const int c)
void getAll (Vector3 &v1, Vector3 &v2, Vector3 &v3)
Matrix3id ()
Matrix3transpose ()
float det ()
Matrix3inv ()
Matrix3outer (const Vector3 &a, const Vector3 &b)
Matrix3vecCross (const Vector3 &v)
Matrix3cay (const Vector3 &v)
Matrix3rotAround (const Vector3 &v, float angle)
Matrix3 operator* (const Matrix3 &m)
Vector3 operator* (const Vector3 &v)
Matrix3 operator+ (const Matrix3 &m) const
Matrix3 operator- (const Matrix3 &m) const
Matrix3 operator- () const
Matrix3operator= (const Matrix3 &m)
Matrix3operator+= (const Matrix3 &m)
Matrix3operator-= (const Matrix3 &m)
Matrix3operator*= (const float s)
Matrix3operator/= (const float s)
int operator== (const Matrix3 &m) const
int operator!= (const Matrix3 &m) const
void print (ostream &out) const

Friends

Matrix3 operator* (const Matrix3 &m, float d)
Matrix3 operator* (float d, const Matrix3 &m)
Matrix3 operator/ (const Matrix3 &m, float d)
ostream & operator<< (ostream &out, const Matrix3 &m)


Detailed Description

The Matrix3 class is a 3x3 dimensional Matrix class with floating point entries.

This class provides storage for a 3x3 floating point table, representing a matrix. It is possible to compute determinant, inverse, transpose and other standart matrix operations.

A matrix is given by 3 Vector3 column vectors $v_0,v_1,v_2$ and has the form $M=\left( \begin{array}{ccc}v_{00} & v_{10} & v_{20} \\ v_{01} & v_{11} & v_{21} \\ v_{02} & v_{12} & v_{22} \end{array} \right) $

Caution : When accessing a matrix element by M[i][j], i is the column index, and j the row index! In the linear algebra literature most of the time this convention is the inverse. The structure is chosen like this such that a change of basis from a coordinate system A to a coordinate system B is given by the matrix M, composed by the basis column vectors of the final coordinate system.


Constructor & Destructor Documentation

Matrix3::Matrix3 (  ) 

The default constructor initializes all matrix elements to zero.

References Vector3::zero().

Referenced by operator+(), and operator-().

Matrix3::Matrix3 ( const Vector3 v0,
const Vector3 v1,
const Vector3 v2 
)

Constructs a Matrix3 given three row vectors v0, v1 and v2.

Matrix3::Matrix3 ( const float &  x00,
const float &  x01,
const float &  x02,
const float &  x10,
const float &  x11,
const float &  x12,
const float &  x20,
const float &  x21,
const float &  x22 
)

Constructs a Matrix3 from 9 floats. Given in row-first order.


Member Function Documentation

Matrix3 & Matrix3::zero (  ) 

Set all matrix elements to zero. Returns an instance to itself.

References Vector3::zero().

Referenced by Curve< Vector >::inertiaTensor().

Vector3 & Matrix3::operator[] ( int  n  )  [inline]

Index operator. Returns one of the three matrix columns as a Vector3 instance.

See also:
getOne(), getAll(), setOne(), setAll().

const Vector3 & Matrix3::operator[] ( int  n  )  const [inline]

Index operator. Returns one of the three matrix columns as a Vector3 instance.

See also:
getOne(), getAll(), setOne(), setAll().

void Matrix3::setOne ( const int  c,
const Vector3 v 
)

Fill matrix column c with the components of the vector v.

void Matrix3::setOne ( const int  c,
const float  v1,
const float  v2,
const float  v3 
)

Fill matrix column c from top to bottom with the values v1 to v3.

void Matrix3::setAll ( const Vector3 v1,
const Vector3 v2,
const Vector3 v3 
)

Reset the matrix by columns v1 to v3.

Referenced by id().

void Matrix3::setAll ( const Vector3 v  ) 

Fill the matrix with the array of Vector3 v.

Vector3 Matrix3::getOne ( const int  c  ) 

Returns matrix column c as a Vector3 instance.

void Matrix3::getAll ( Vector3 v1,
Vector3 v2,
Vector3 v3 
)

Put the matrix columns into the vectors v1 to v3.

Matrix3 & Matrix3::id (  ) 

Set the current matrix to the identity and return a reference to itself.

References setAll().

Referenced by cay(), and Curve< Vector >::principalAxis().

Matrix3 & Matrix3::transpose (  ) 

Set the current matrix to its transpose and return a reference to itself.

Columns become rows and rows become the columns. I.e, the transpose of a matrix $M=$ is

$M^t=\left( \begin{array}{ccc}v_{00} & v_{01} & v_{02} \\ v_{10} & v_{11} & v_{12} \\ v_{20} & v_{21} & v_{22} \end{array} \right) $

float Matrix3::det (  ) 

Computes and returns the determinant of the Matrix3.

Referenced by Matrix4::adjoint(), Matrix4::det(), and inv().

Matrix3 & Matrix3::inv (  ) 

Sets the current matrix to its inverse and return a reference to itself.

Given the matrix $A$, its inverse is the matrix B, satisfying the relation

$A\cdot B = id$,

where $id$ is the identity matrix.

If the matrix is hardly invertible, i.e. its determinant is close to zero, then a warning is posted to the error channel and the matrix itself is not changed.

References det().

Matrix3 & Matrix3::outer ( const Vector3 a,
const Vector3 b 
)

Computes the outer product between a vector a and a vector b and stores the result in the current Matrix3 object.

Formally we have the product between a column vector a with a row vector b.

$M=\left( \begin{array}{c}a_0 \\ a_1 \\ a_2 \end{array} \right) \cdot \left( \begin{array}{ccc}b_0 & b_1 & b_2 \end{array} \right)$

Referenced by Vector3::reflect().

Matrix3 & Matrix3::vecCross ( const Vector3 v  ) 

Constructs an skew-symmetric matrix from a vector v of the form

$M=\left( \begin{array}{ccc}0 & -v_3 & v_2 \\ v_3 & 0 & -v_1 \\ -v_2 & v_1 & 0 \end{array} \right) $

Applied to a vector, this matrix acts like a cross product between v and some other vector w. Therefore

$M\cdot w = v\times w$

Referenced by cay().

Matrix3 & Matrix3::cay ( const Vector3 v  ) 

Construct a Cayleigh rotation matrix, defined by

Cay Rotation Matrix "Cay(v)", where v are the components of the rot axis and |v| is magnitude of rotation

References id(), Vector3::norm2(), and vecCross().

Referenced by Tube< Vector >::makeMesh().

Matrix3 & Matrix3::rotAround ( const Vector3 v,
float  alpha 
)

Sets the current matrix to a rotation matrix. Where the rotation is in the positive trigonometric direction about the axis v by an angle alpha.

References Vector3::normalize().

Matrix3 Matrix3::operator* ( const Matrix3 m  ) 

Multiplies the current matrix on the right hand side by m and returns the result as a new Matrix3 instance.

Vector3 Matrix3::operator* ( const Vector3 v  ) 

Applies the current matrix on the left side of a column vector v and returns a vector with the result.

Matrix3 Matrix3::operator+ ( const Matrix3 m  )  const

Matrix summation. Returns a Matrix3 instance.

References Matrix3().

Matrix3 Matrix3::operator- ( const Matrix3 m  )  const

Matrix substraction. Returns a Matrix3 instance.

References Matrix3().

Matrix3 Matrix3::operator- (  )  const

Matrix negation. Returns a Matrix3 instance where all the elements have now switched their sign.

References Matrix3().

Matrix3 & Matrix3::operator= ( const Matrix3 m  ) 

Assign operator. Makes a copy of m. Returns an instance to itself.

Matrix3 & Matrix3::operator+= ( const Matrix3 m  ) 

Adds the matrix m to the current one. Returns an instance to itself.

Matrix3 & Matrix3::operator-= ( const Matrix3 m  ) 

Substracts the matrix m from the current one. Returns an instance to itself.

Matrix3 & Matrix3::operator*= ( const float  s  ) 

Multiplies all the elements of the current matrix by s and returns\ an instance to itself.

Matrix3 & Matrix3::operator/= ( const float  s  ) 

Divides all the elements of the current matrix by s and returns\ an instance to itself.

int Matrix3::operator== ( const Matrix3 m  )  const

Compare the current matrix to m. If all the elements are the same, the function return 1, 0 otherwise.

int Matrix3::operator!= ( const Matrix3 m  )  const

Compare the current matrix to m. Returns 1 if they are different. 0 if they are the same.

void Matrix3::print ( ostream &  out  )  const

Prints the components of this matrix in a formated way onto the stream out.


Friends And Related Function Documentation

Matrix3 operator* ( const Matrix3 m,
float  d 
) [friend]

Multiplies every element of the matrix m by a factor of d. and returns a Matrix3 object.

Matrix3 operator* ( float  d,
const Matrix3 m 
) [friend]

Multiplies every element of the matrix m by a factor of d. and returns a Matrix3 object.

Matrix3 operator/ ( const Matrix3 m,
float  d 
) [friend]

Divides every element of the matrix m by d. and returns a Matrix3 object.

ostream & Matrix3::operator<< ( ostream &  out,
const Matrix3 m 
) [friend]

Overloaded left shift operator. Returns the Matrix3 m as an ostream object that can be written to a file or to standart output.

See also:
print()


The documentation for this class was generated from the following files:

Generated on Mon Feb 8 17:22:36 2010 for libbiarc by  doxygen 1.5.6