Crevaya 0.1-PreAlpha
|
A class to store a 3D affine transform matrix and provide operations upon. More...
#include <AffineTransformMatrix.h>
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. | |
AffineTransformMatrix & | operator= (const AffineTransformMatrix &b) |
void | Set (AffineTransformMatrix const &b) |
Copies a matrix by inserting a given matrix into a. | |
AffineTransformMatrix & | operator*= (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. | |
AffineTransformMatrix & | operator/= (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. |
A class to store a 3D affine transform matrix and provide operations upon.
#include "AffineTransformMatrix.h"
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
AffineTransformMatrix::AffineTransformMatrix | ( | ) |
AffineTransformMatrix::~AffineTransformMatrix | ( | ) | [virtual] |
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,
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.
vector | Axis of rotation. |
phi | Angle of rotation. |
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.
x | Movement of mouse in x direction (=xnew-xold). |
y | Movement of mouse in y direction (=ynew-yold). |
scale | Scaling of the movement. |
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.
matrix | The 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.
Apply the transformation matrix on a given vector.
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.
double AffineTransformMatrix::a[16] |
The transformation matrix.
Force uniform scaling.
double AffineTransformMatrix::rx |
double AffineTransformMatrix::ry |
double AffineTransformMatrix::rz |
Rotation after taking the matrix apart.
double AffineTransformMatrix::sx |
double AffineTransformMatrix::sy |
double AffineTransformMatrix::sz |
Scaling after taking the matrix apart.
double AffineTransformMatrix::tx |
double AffineTransformMatrix::ty |
double AffineTransformMatrix::tz |
Translation after taking the matrix apart.