Basic Interface to Alias transformation matrix.
#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 );
This class encapsulates the functionality for creating, manipulating and deleting Alias 4x4 transformation matrices.
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
The transformation matrix usually takes the form:
TM = | r00 r01 r02 0 |
| r10 r11 r12 0 |
| r20 r21 r22 0 |
| tx0 ty0 tz0 1 |
where tx0, ty0, tz0 are the aggregrate translations and r(xy) is the aggregate product of rotations, scales and shears.
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 |
If the w component is not specified, it is assumed to have a value of 1.
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;
Constructor for the AlTM. This initializes the matrix by setting the diagonal to (d0,d1,d2,d3)
Warning: for efficiency reasons, the matrix is NOT initialized by the default constructor.
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'.
Copies the contents of the AlTM into a 4x4 array 'tm'.
< tm - where to copy the transformation matrix to
sSuccess - the matrix was successfully copied
sInvalidArgument - the pointer is NULL
Copies the given matrix into the AlTM.
sSuccess - the matrix was successfully copied
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'.
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'.
Decomposes the transform into translate, rotate, scale, and shear components.
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).
> translate - vector to store translation in
> scale - vector to store scale in
> rotate - vector to store rotation in
> shear - vector to store shear in
sSuccess - the matrix decomposition worked
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.
AlTM::identity() returns the identity matrix.
AlTM::zero() returns a zero matrix.
Returns a zero matrix with diagonal values of 'd'.
The following matrix is returned:
[ d0 0 0 0 ] [ 0 d1 0 0 ] [ 0 0 d2 0 ] [ 0 0 0 d3 ]
< d - value to set the diagonal to
Returns a transformation matrix to scale a point [ x y z ] by a constant with value of 'd'.
The following matrix is returned:
[ d 0 0 0 ] [ 0 d 0 0 ] [ 0 0 d 0 ] [ 0 0 0 1 ]
< d - value to scale a point by
Returns a transformation matrix to nonproportionally scale a point [ x y z ] by sx in the x axis, sy in the y axis and sz in the z axis.
The following matrix is returned:
[ sx 0 0 0 ] [ 0 sy 0 0 ] [ 0 0 sz 0 ] [ 0 0 0 1 ]
Returns a transformation matrix to translate a point (x,y,z) by (tx, ty, tz).
< tx, ty, tz - the vector (tx, ty, tz) to translate the point by
Returns a transformation matrix to rotate about the X axis.
< rx - angle in radians to rotate about the x axis
Returns a transformation matrix to rotate about the Y axis.
< ry - angle in radians to rotate about the y axis
Returns a transformation matrix to rotate about the Z axis.
< rz - angle in radians to rotate about the z axis
Returns a transformation matrix to rotate counterclockwise about the axis (x,y,z).
< angle - angle in radians to rotate counterclockwise by
< x,y,z - the axis to rotate about
Transforms a normal. sFailure is returned if the upper 3x3 matrix is not invertible n' = n * trans(inv(M)).
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 );
Transforms a vector (assumes w=0).
Using the matrix, transforms the point in pt[] to transPt[].
transPt[ x y z w ] = pt[ x y z w ] * matrix
> transPt - where to place the result
sSuccess - the matrix was successfully copied
sInvalidArgument - one of the pointers was NULL
Using the matrix, transforms the point in pt[] to pt[].
pt[ x y z w ] = pt[ x y z w ] * matrix
<> pt - the point to transform
sSuccess - the vector was successfully transformed
sInvalidArgument - the pointer was NULL
Using the transformation matrix, transforms the point (x,y,z,w).
[ x y z w ] = [ x y z w ] * matrix
<> &x, &y, &z, &w - the row vector to transform
sSuccess - the vector was successfully transformed
Using the matrix, transforms the point (x, y, z, 1).
[ x y z 1 ] = [ x y z 1 ] * matrix
<> &x, &y, &z - the row vector to transform
sSuccess - the vector was successfully transformed