Crevaya 0.1-PreAlpha

AffineTransformMatrix Class Reference

A class to store a 3D affine transform matrix and provide operations upon. More...

#include <AffineTransformMatrix.h>

List of all members.

Public Member Functions

 AffineTransformMatrix ()
virtual ~AffineTransformMatrix ()
void TakeMatrixApart (void)
 Calculate rx,ry,rz,tx,ty,tz and sx,sy,sz from the matrix.
void PutMatrixTogether (void)
 Calculate the matrix from rx,ry,rz,tx,ty,tz and sx,sy,sz.
wxString ToString ()
 Generate a string containing the matrix.
void FromString (wxString const &string)
 Setup the matrix from a string.
AffineTransformMatrixoperator= (const AffineTransformMatrix &b)
void Set (AffineTransformMatrix const &b)
 Copies a matrix by inserting a given matrix into a.
AffineTransformMatrixoperator*= (const AffineTransformMatrix &b)
 Overloaded operator to allow correct multiplication of two matrices.
const AffineTransformMatrix operator* (const AffineTransformMatrix &b) const
 Overloaded operator to allow correct multiplication of two matrices.
AffineTransformMatrixoperator/= (const AffineTransformMatrix &b)
 Overloaded operator to allow correct division of two matrices.
const AffineTransformMatrix operator/ (const AffineTransformMatrix &b) const
Vector3 GetCenter (void) const
 Returns the center point of the matrix.
void SetIdentity ()
 Resets the matrix to the identity matrix.
const AffineTransformMatrix Inverse () const
 Inverts the matrix.
void TranslateGlobal (double const &x, double const &y, double const &z)
 Translate matrix in the global coordinate system.
void TranslateLocal (double const &x, double const &y, double const &z)
 Translate matrix in the local, rotated coordinate system.
void ScaleGlobal (double const &x, double const &y, double const &z)
 Scale matrix in the global coordinate system.
Vector3 Transform (Vector3 const &v) const
 Apply the transformation matrix on a given vector.
Vector3 TransformNoShift (Vector3 const &v) const
 Apply the transformation matrix on a given vector without shifting the vector.

Static Public Member Functions

static AffineTransformMatrix Identity ()
 Function returning an identity matrix.
static AffineTransformMatrix RotateAroundVector (Vector3 const &vector, double const &phi)
 Rotation around a given vector.
static AffineTransformMatrix RotateInterwoven (double const &x, double const &y, double const &z)
 An interwoven rotation.
static AffineTransformMatrix RotateXY (int const &x, int const &y, double const &scale)
 Rotation by mouse.
static AffineTransformMatrix RotateXYZ (double const &x, double const &y, double const &z)
 Rotation by the Z,Y,X rule.

Public Attributes

double a [16]
 The transformation matrix.
double rx
double ry
double rz
 Rotation after taking the matrix apart.
double tx
double ty
double tz
 Translation after taking the matrix apart.
double sx
double sy
double sz
 Scaling after taking the matrix apart.
bool linkScaling
 Force uniform scaling.

Detailed Description

A class to store a 3D affine transform matrix and provide operations upon.

This class stores and manages a 4x4 matrix. This matrix is organized the same way, the transformation matrices of OpenGL are:

R11 R12 R13 Tx
R21 R22 R23 Ty
R31 R32 R33 Tz
0 0 0 1

Where R is responsible for rotation and scaling and T for translation. The vector a is organized as follows:

0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15

Right handed coordinate system:
X to the right of the screen
Y to the top of the screen
Z towards the viewer


Constructor & Destructor Documentation

AffineTransformMatrix::AffineTransformMatrix ( )
AffineTransformMatrix::~AffineTransformMatrix ( ) [virtual]

Member Function Documentation

void AffineTransformMatrix::FromString ( wxString const &  string)

Setup the matrix from a string.

Vector3 AffineTransformMatrix::GetCenter ( void  ) const

Returns the center point of the matrix.

AffineTransformMatrix AffineTransformMatrix::Identity ( ) [static]

Function returning an identity matrix.

const AffineTransformMatrix AffineTransformMatrix::Inverse ( ) const

Inverts the matrix.

The transform used in here is optimized for matrices with 0,0,0,1 in the last row. It would not give the correct results for other matrices,

Returns:
Inverted matrix.
const AffineTransformMatrix AffineTransformMatrix::operator* ( const AffineTransformMatrix b) const

Overloaded operator to allow correct multiplication of two matrices.

AffineTransformMatrix & AffineTransformMatrix::operator*= ( const AffineTransformMatrix b)

Overloaded operator to allow correct multiplication of two matrices.

const AffineTransformMatrix AffineTransformMatrix::operator/ ( const AffineTransformMatrix b) const
AffineTransformMatrix & AffineTransformMatrix::operator/= ( const AffineTransformMatrix b)

Overloaded operator to allow correct division of two matrices.

The division is done by inverting the second matrix and the multiplying both.

AffineTransformMatrix & AffineTransformMatrix::operator= ( const AffineTransformMatrix b)
void AffineTransformMatrix::PutMatrixTogether ( void  )

Calculate the matrix from rx,ry,rz,tx,ty,tz and sx,sy,sz.

AffineTransformMatrix AffineTransformMatrix::RotateAroundVector ( Vector3 const &  vector,
double const &  phi 
) [static]

Rotation around a given vector.

Generates a rotation matrix around a given vector.

Parameters:
vectorAxis of rotation.
phiAngle of rotation.
Returns:
Rotation matrix.
AffineTransformMatrix AffineTransformMatrix::RotateInterwoven ( double const &  x,
double const &  y,
double const &  z 
) [static]

An interwoven rotation.

Generates a rotation matrix around x,y,z. In this case the rotations are interwoven:

Every rotation (around x, around y and around z) is done in infinitesimal small steps. On step around x, one step around y, ...

This results in a rotation as expected from a 6 DOF controller.

AffineTransformMatrix AffineTransformMatrix::RotateXY ( int const &  x,
int const &  y,
double const &  scale 
) [static]

Rotation by mouse.

This function is only a drop in until the RotateByTrackball function works.

Parameters:
xMovement of mouse in x direction (=xnew-xold).
yMovement of mouse in y direction (=ynew-yold).
scaleScaling of the movement.
Returns:
Rotation matrix.
AffineTransformMatrix AffineTransformMatrix::RotateXYZ ( double const &  x,
double const &  y,
double const &  z 
) [static]

Rotation by the Z,Y,X rule.

void AffineTransformMatrix::ScaleGlobal ( double const &  x,
double const &  y,
double const &  z 
)

Scale matrix in the global coordinate system.

void AffineTransformMatrix::Set ( AffineTransformMatrix const &  b)

Copies a matrix by inserting a given matrix into a.

Parameters:
matrixThe matrix to copy.
void AffineTransformMatrix::SetIdentity ( )

Resets the matrix to the identity matrix.

void AffineTransformMatrix::TakeMatrixApart ( void  )

Calculate rx,ry,rz,tx,ty,tz and sx,sy,sz from the matrix.

wxString AffineTransformMatrix::ToString ( )

Generate a string containing the matrix.

Vector3 AffineTransformMatrix::Transform ( Vector3 const &  v) const

Apply the transformation matrix on a given vector.

Vector3 AffineTransformMatrix::TransformNoShift ( Vector3 const &  v) const

Apply the transformation matrix on a given vector without shifting the vector.

void AffineTransformMatrix::TranslateGlobal ( double const &  x,
double const &  y,
double const &  z 
)

Translate matrix in the global coordinate system.

void AffineTransformMatrix::TranslateLocal ( double const &  x,
double const &  y,
double const &  z 
)

Translate matrix in the local, rotated coordinate system.


Member Data Documentation

The transformation matrix.

Force uniform scaling.

Rotation after taking the matrix apart.

Scaling after taking the matrix apart.

Translation after taking the matrix apart.


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