Matrix Class Reference

#include <Matrix.h>

List of all members.

Public Member Functions

 Matrix ()
 Matrix (const float f)
 Matrix (const float x, const float y, const float z)
 Matrix (const Vec3f &t)
 Matrix (const float angle, const Vec3f &axis)
void set (int x, int y, float value)
float get (int x, int y) const
Matrixoperator *= (const Matrix &m)
Vec3f transformVector (const Vec3f &vector) const

Private Attributes

float mValues [4][4]
 all the values

Friends

Matrix operator * (const Matrix &m, const float f)
Matrix operator * (const float f, const Matrix &m)
Vec3f operator * (const Matrix &m, const Vec3f &v)
Vec3f operator * (const Vec3f &v, const Matrix &m)
Ray operator * (const Matrix &m, const Ray &r)
Ray operator * (const Ray &r, const Matrix &m)
Matrix operator * (const Matrix &m1, const Matrix &m2)
std::ostream & operator<< (std::ostream &o, const Matrix &m)


Detailed Description

4x4 matrix class

Author:
Alex Busenius

Definition at line 15 of file Matrix.h.


Constructor & Destructor Documentation

Matrix::Matrix (  )  [inline]

Default constructor, constructing identity matrix (Einheitsmatrix)

1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

Definition at line 35 of file Matrix.h.

References mValues.

Matrix::Matrix ( const float  f  )  [inline]

Construct with every value set to f

f f f f f f f f f f f f f f f f

Definition at line 57 of file Matrix.h.

References mValues.

Matrix::Matrix ( const float  x,
const float  y,
const float  z 
) [inline]

Construct a scale matrix

x 0 0 0 0 y 0 0 0 0 z 0 0 0 0 1

Parameters:
x Scaling factor in x-direction
y Scaling factor in y-direction
z Scaling factor in z-direction

Definition at line 79 of file Matrix.h.

References mValues.

Matrix::Matrix ( const Vec3f t  )  [inline]

Construct a translation matrix

1 0 0 t.x 0 1 0 t.y 0 0 1 t.z 0 0 0 1

Parameters:
t Translation vector

Definition at line 104 of file Matrix.h.

References mValues, Vec3f::x(), Vec3f::y(), and Vec3f::z().

Matrix::Matrix ( const float  angle,
const Vec3f axis 
) [inline]

Construct a rotation matrix

x^2(1-c)+c xy(1-c)-zs xz(1-c)+ys 0 yx(1-c)+zs y^2(1-c)+c yz(1-c)-xs 0 xz(1-c)-ys yz(1-c)+xs z^2(1-c)+c 0 0 0 0 1

Where c = cos(angle), s = sin(angle) and (x,y,z).length() == 1

This rotation follows the right-hand rule, so if the vector axis points toward the user, the rotation will be counterclockwise.

Parameters:
angle Rotation angle in radian
axis Rotation axis vector, normalized if needed

Definition at line 137 of file Matrix.h.

References mValues, and Vec3f::normal().


Member Function Documentation

void Matrix::set ( int  x,
int  y,
float  value 
) [inline]

Set the value

Parameters:
x Row (Zeile)
y Column (Spalte)
value value to set

Definition at line 170 of file Matrix.h.

References mValues.

float Matrix::get ( int  x,
int  y 
) const [inline]

Get a value

(0,0) (0,1) (0,2) (0,3) (1,0) (1,1) (1,2) (1,3) (2,0) (2,1) (2,2) (2,3) (3,0) (3,1) (3,2) (3,3)

Parameters:
x Row (Zeile)
y Column (Spalte)
Returns:
the value in the matrix

Definition at line 189 of file Matrix.h.

References mValues.

Matrix& Matrix::operator *= ( const Matrix m  )  [inline]

Multiply and assign a matrix

Definition at line 199 of file Matrix.h.

Vec3f Matrix::transformVector ( const Vec3f vector  )  const [inline]

Multiply with given vector handling them as a _vector_ and NOT as point. Correctly transforms 3D -> 4D -> 3D

Definition at line 208 of file Matrix.h.

References mValues.

Referenced by CameraInstructionMove::execute(), operator *(), PhysicalObject::toGlobalCoordinates(), and PhysicalObject::toLocalCoordinates().


Friends And Related Function Documentation

Matrix operator * ( const Matrix m,
const float  f 
) [friend]

Multiply matrix with float

Definition at line 230 of file Matrix.h.

Matrix operator * ( const float  f,
const Matrix m 
) [friend]

Multiply matrix with float

Definition at line 246 of file Matrix.h.

Vec3f operator * ( const Matrix m,
const Vec3f v 
) [friend]

Multiply a matrix with a 3D point (and doing the right transformation from 4 dim to 3 dim)

Definition at line 262 of file Matrix.h.

Vec3f operator * ( const Vec3f v,
const Matrix m 
) [friend]

Multiply a 3D point with a matrix (and doing the right transformation from 4 dim to 3 dim)

Definition at line 281 of file Matrix.h.

Ray operator * ( const Matrix m,
const Ray r 
) [friend]

Multiply a matrix with a ray. This transforms the ray's coordinate system as given by the matrix. All attributes are either transformed accordingly or preserved.

Parameters:
m Matrix discribing coordinate system
r Ray to transform
Returns:
Transformed ray

Definition at line 306 of file Matrix.h.

Ray operator * ( const Ray r,
const Matrix m 
) [friend]

Multiply a ray with a matrix. This operation does not make any sense

Definition at line 326 of file Matrix.h.

Matrix operator * ( const Matrix m1,
const Matrix m2 
) [friend]

Multiply matrix with matrix

Definition at line 336 of file Matrix.h.

std::ostream& operator<< ( std::ostream &  o,
const Matrix m 
) [friend]

Output operator

Definition at line 10 of file Matrix.cpp.


Member Data Documentation

float Matrix::mValues[4][4] [private]

all the values

Definition at line 224 of file Matrix.h.

Referenced by get(), Matrix(), operator *(), operator<<(), set(), and transformVector().


The documentation for this class was generated from the following file:
Generated on Fri Feb 1 00:02:19 2008 for Grayfall by  doxygen 1.5.1