#include <AlTM.h>
class AlTM
inline AlTM() ;
inline ~AlTM() ;
AlTM( const AlTM& );
AlTM( const double[4][4] );
AlTM( const double d0,const double d1,const double d2,const double d3 );
inline double* operator []( int row )
inline const double* operator []( int row ) const
statusCode getTM( double[4][4] ) const;
statusCode setTM( const double[4][4] );
AlTM& operator =( const AlTM& );
AlTM& operator =( const double d );
int operator ==( const AlTM& ) const;
int operator !=( const AlTM& ) const;
AlTM operator +( const AlTM& ) const;
AlTM operator -( const AlTM& ) const;
AlTM operator *( const AlTM& ) const;
AlTM operator *( const double ) const;
friend AlTM operator *( const double d, const AlTM& tm );
AlTM& operator +=( const AlTM& );
AlTM& operator -=( const AlTM& );
AlTM& operator *=( const AlTM& );
AlTM& operator *=( const double );
statusCode transPoint( double d[4] ) const;
statusCode transPoint( const double pt[4], double transPt[4] ) const;
statusCode transPoint( double& x, double &y, double &z, double &w )
const;
statusCode transPoint( double& x, double &y, double &z ) const; //
assumes w = 1.0
statusCode transVector( double& x, double& y, double& z ) const;
statusCode transNormal( double& x, double& y, double& z ) const;
statusCode decompose ( double [3], double [3], double [3], double [3] )
const;
AlTM inverse( void ) const;
AlTM transpose( void ) const;
static AlTM identity( void );
static AlTM zero( void );
static AlTM diagonal( const double d0, const double d1, const double d2,
const double d3 );
// standard transformations
static AlTM scale( const double );
static AlTM scale_nonp( const double, const double, const double );
static AlTM translate( const double, const double, const double );
static AlTM rotateX( const double );
static AlTM rotateY( const double );
static AlTM rotateZ( const double );
static AlTM rotate( double x, double y, double z, double angle );
Tranformation matrices are used to perform linear transformations of a vector. Composite transformations are performed by multiplying the individual transformations together.
The matrix is ordered as AlTM[y][x]:
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
TM = | r00 r01 r02 0 |
| r10 r11 r12 0 |
| r20 r21 r22 0 |
| tx0 ty0 tz0 1 |
A point is transformed by considering the point to be a row vector of 4 elements and then post multiplying by the transformation matrix.
[x' y' z' w']
= [x y z w] | 00 01 02 03 |
| 10 11 12 13 |
| 20 21 22 23 |
| 30 31 32 33 |
The static functions at the end of the class are used to create typical tranformation matrices.
Note: the [] operator has been defined for the AlTM class. This means that the individual matrix elements can be addressed as if the AlTM were a standard 4x4 array of doubles. This eliminates the need to create a temporary 4x4 array to retrieve the values.
e.g. AlTM matrix; matrix[3][2] = 10.0;
Warning: for efficiency reasons, the matrix is NOT initialized by the default constructor. This has changed since the last release of OpenModel.
Use the AlTM(1,1,1,1) constructor to initialize the identity matrix (i.e. this sets the diagonal to 1's, and the rest of the matrix to 0)
Similarly, to initialize the matrix with all 0, use the constructor AlTM(0) or AlTM(0,0,0,0)
This initializes the matrix by making a copy of the given AlTM matrix 'tm'.
This initializes the matrix by making a copy of the given 4x4 array 'tm'.
sInvalidArgument - the pointer is NULL
sInvalidArgument - the pointer is NULL
This copies matrix B to matrix A.
Every entry in matrix A is set to the scalar value in 'd'.
Returns 1 if matrix A and B are equal, 0 otherwise.
Returns 1 if matrix A and B are not equal, 0 otherwise.
Returns the result of matrix B added to matrix A
Returns the result of matrix B subtracted from matrix A.
Returns the result of matrix A post multiplied by matrix B.
Returns the result of matrix A multiplied by the scalar value in 'd'.
Returns the result of matrix A multiplied by the scalar value in 'd'.
Adds matrix B to matrix A.
Subtracts matrix B from matrix A.
Post multiplies matrix A by matrix B.
Multiplies every entry in matrix A by the scalar value in 'd'.
The shears are saved as XY, XZ, and YZ in the return vector "shear". They may be ignored, but only at your peril! Alias transformation nodes can contain a shear despite the fact that there is no explicit shear operation (a two level dag with rotate and scale will do it).
> scale - vector to store scale in
> rotate - vector to store rotation in
> shear - vector to store shear in
sFailure - the matrix decomposition failed
Returns the inverse of matrix A.
If A is not invertible, then a zero matrix is returned (the result can be compared to the zero matrix ).
Returns the transpose of matrix A.
The following matrix is returned
[ d0 0 0 0 ]
[ 0 d1 0 0 ]
[ 0 0 d2 0 ]
[ 0 0 0 d3 ]
The following matrix is returned
[ d 0 0 0 ]
[ 0 d 0 0 ]
[ 0 0 d 0 ]
[ 0 0 0 1 ]
The following matrix is returned
[ sx 0 0 0 ]
[ 0 sy 0 0 ]
[ 0 0 sz 0 ]
[ 0 0 0 1 ]
< sy - scale of the y axis
< sz - scale of the z axis
< x,y,z - the axis to rotate about
NOTE: this function inverts the given matrix to perform the operation. This operation may not be numerically accurate. It is suggested that, for dag traversals, you use AlDagNode::inverseGlobalTransform to get the inverse of the transformation. Then take the transformation, then use transVector. e.g.
double normX, normY, normZ;
AlTM invTM;
dagNode->inverseGlobalTransformMatrix( invTM );
invTM.transpose().transVector( normX, normY, normZ );
It performs the operation
transPt[ x y z w ] = pt[ x y z w ] * matrix
> transPt - where to place the result
sInvalidArgument - one of the pointers was NULL
It performs the operation
pt[ x y z w ] = pt[ x y z w ] * matrix
sInvalidArgument - the pointer was NULL
It performs the operation
[ x y z w ] = [ x y z w ] * matrix
It performs the operation
[ x y z 1 ] = [ x y z 1 ] * matrix