Trans2DMatrix Class Reference

This transformation will perform any 2D matrix transformations such as :- Translate, Rotate, Scale and Shear. More...

#include <trans2d.h>

Inheritance diagram for Trans2DMatrix:

TransInvertable TransformBase CCObject SimpleCCObject List of all members.

Public Member Functions

 Trans2DMatrix ()
 Builds a 2D Tranform object of the identiry matrix (ie it has no effect).
 Trans2DMatrix (DocCoord CentreOfRot, ANGLE RotateBy)
 Creates a 2D Matrix transform object that will perform a rotation about the given point by the given number of degrees.
 Trans2DMatrix (INT32 TransX, INT32 TransY)
 Builds a 2D Tranform object that will perform a translation by an offset Transx, TransY.
 Trans2DMatrix (const Matrix &NewMatrix)
 constructor
 Trans2DMatrix (const Trans2DMatrix &)
 Copy constructor.
void InitDecomposedTransforms ()
 ensure all member vars are init'ed
void SetTransform ()
void SetTransform (DocCoord CentreOfRot, ANGLE RotateBy)
void SetTransform (INT32 TransX, INT32 TransY)
void SetTransform (const Matrix &NewMatrix)
void SetTransform (const Trans2DMatrix &)
virtual void Transform (DocCoord *Coords, INT32 NumPoints)
 Transform the coordinates in the array using the matrix in the transform object.
virtual BOOL IsInvertable ()
 To see if this transform is really invertable.
virtual void Invert ()
 Inverts the transformation matrix held by this transform object. future calls to the transform() member function will cause it to transform coordinates back to their original positions. ie, call Transform(), call Invert() and call Transform() again should give you the same set of coords as you started with.
virtual BOOL IsTranslation ()
 Determine whether the transformation is a simple translation.
INT32 GetWorkingQuadrant ()
 To find out which quadrant the current matrix is working in. OR To help find out if the matrix is flipping an object and in which way.
Trans2DMatrixoperator *= (const Trans2DMatrix &)
 Overloads the *= operator for Trans2DMatrix.
Trans2DMatrixoperator= (const Trans2DMatrix &)
 Overloads the = operator for Trans2DMatrix.
Matrix GetMatrix ()
MatrixGetpMatrix ()
void EnsureDecomposedTransformsCached ()
 ensures the decomposed transforms are cached
FIXED16 GetScale ()
 get the transform's scale component
FIXED16 GetAspect ()
 get the transform's Aspect component
ANGLE GetRotation ()
 get the transform's Rotation component
ANGLE GetSkew ()
 get the transform's Skew component
DocCoord GetTranslation ()
 get the transform's Translation component
virtual FIXED16 GetScalar ()
 get the transform's directionless scale component (used for scaling line widths, bevel widths, brush widths, etc.) For compatibility reasons this is defined to be the Y scale factor of the matrix!

Protected Attributes

Matrix TransMatrix
FIXED16 Scale
FIXED16 Aspect
ANGLE Rotation
ANGLE Skew
DocCoord Translation
FIXED16 ScaleY

Private Member Functions

 CC_DECLARE_DYNAMIC (Trans2DMatrix)

Detailed Description

This transformation will perform any 2D matrix transformations such as :- Translate, Rotate, Scale and Shear.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/02/94

Definition at line 126 of file trans2d.h.


Constructor & Destructor Documentation

Trans2DMatrix::Trans2DMatrix  ) 
 

Builds a 2D Tranform object of the identiry matrix (ie it has no effect).

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/95

Definition at line 140 of file trans2d.cpp.

00141 {
00142     SetTransform();
00143 }

Trans2DMatrix::Trans2DMatrix DocCoord  CentreOfRot,
ANGLE  RotateBy
 

Creates a 2D Matrix transform object that will perform a rotation about the given point by the given number of degrees.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/3/94
Parameters:
CentreOfRot - The centre of rotation [INPUTS] RotateBy - The angle of the rotation that this transform object will perform

Definition at line 170 of file trans2d.cpp.

00171 {
00172     SetTransform(CentreOfRot,RotateBy);
00173 }

Trans2DMatrix::Trans2DMatrix INT32  TransX,
INT32  TransY
 

Builds a 2D Tranform object that will perform a translation by an offset Transx, TransY.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/3/94
Parameters:
TransX - The X translation [INPUTS] TransY - The Y translation

Definition at line 209 of file trans2d.cpp.

00210 {
00211     SetTransform(TransX,TransY);
00212 }

Trans2DMatrix::Trans2DMatrix const Matrix NewMatrix  ) 
 

constructor

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/02/94
Parameters:
NewMatrix - The transformation matrix that you wish to apply [INPUTS]

Definition at line 238 of file trans2d.cpp.

00239 {
00240     SetTransform(NewMatrix);
00241 }

Trans2DMatrix::Trans2DMatrix const Trans2DMatrix Other  ) 
 

Copy constructor.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/94
Parameters:
Other - The other trans2dmatrix to copy [INPUTS]

Definition at line 267 of file trans2d.cpp.

00268 {
00269     SetTransform(Other);
00270 }


Member Function Documentation

Trans2DMatrix::CC_DECLARE_DYNAMIC Trans2DMatrix   )  [private]
 

void Trans2DMatrix::EnsureDecomposedTransformsCached  ) 
 

ensures the decomposed transforms are cached

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Definition at line 452 of file trans2d.cpp.

00453 {
00454     if (Scale==0)
00455     {
00456         GetpMatrix()->Decompose(&Scale, &Aspect, &Rotation, &Skew, &Translation, &ScaleY);
00457         Rotation = (Rotation*180)/PI;   
00458         Skew     = (Skew    *180)/PI;   // convert to degrees!?
00459     }
00460 }

FIXED16 Trans2DMatrix::GetAspect void   ) 
 

get the transform's Aspect component

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Definition at line 486 of file trans2d.cpp.

00487 {
00488     EnsureDecomposedTransformsCached();
00489     return Aspect;
00490 }

Matrix Trans2DMatrix::GetMatrix  )  [inline]
 

Definition at line 158 of file trans2d.h.

00158 { return  TransMatrix; }

Matrix* Trans2DMatrix::GetpMatrix  )  [inline]
 

Definition at line 159 of file trans2d.h.

00159 { return &TransMatrix; }

ANGLE Trans2DMatrix::GetRotation  ) 
 

get the transform's Rotation component

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Definition at line 501 of file trans2d.cpp.

00502 {
00503     EnsureDecomposedTransformsCached();
00504     return Rotation;
00505 }

FIXED16 Trans2DMatrix::GetScalar  )  [virtual]
 

get the transform's directionless scale component (used for scaling line widths, bevel widths, brush widths, etc.) For compatibility reasons this is defined to be the Y scale factor of the matrix!

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Reimplemented from TransformBase.

Definition at line 550 of file trans2d.cpp.

00551 {
00552     EnsureDecomposedTransformsCached();
00553     return ScaleY;
00554 }

FIXED16 Trans2DMatrix::GetScale  ) 
 

get the transform's scale component

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Definition at line 471 of file trans2d.cpp.

00472 {
00473     EnsureDecomposedTransformsCached();
00474     return Scale;
00475 }

ANGLE Trans2DMatrix::GetSkew  ) 
 

get the transform's Skew component

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Definition at line 516 of file trans2d.cpp.

00517 {
00518     EnsureDecomposedTransformsCached();
00519     return Skew;
00520 }

DocCoord Trans2DMatrix::GetTranslation  ) 
 

get the transform's Translation component

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6/95

Definition at line 531 of file trans2d.cpp.

00532 {
00533     EnsureDecomposedTransformsCached();
00534     return Translation;
00535 }

INT32 Trans2DMatrix::GetWorkingQuadrant  ) 
 

To find out which quadrant the current matrix is working in. OR To help find out if the matrix is flipping an object and in which way.

Author:
Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/07/00
1 | 2 --------- 4 | 3

Quadrant 1: A > 0 && D > 0 Quadrant 2: A < 0 && D > 0 Quadrant 4: A > 0 && D < 0 Quadrant 3: A < 0 && D < 0

The return value is the quadrant in which the matrix is working in.

Definition at line 360 of file trans2d.cpp.

00361 {
00362     FIXED16 ZERO = 0;
00363     FIXED16 ABCD[4];
00364     INT32 XY[2];
00365 
00366     TransMatrix.GetComponents(&ABCD[0],&XY[0]);
00367 
00368     if(ABCD[3] >= ZERO)
00369     {
00370         // either 1 or 2
00371         if(ABCD[0] >= ZERO)
00372             return 1;
00373         else
00374             return 2;
00375     }
00376     else
00377     {
00378         // either 3 or 4
00379         if(ABCD[0] >= ZERO)
00380             return 4;
00381         else
00382             return 3;
00383     }
00384     
00385     return 1;
00386 }

void Trans2DMatrix::InitDecomposedTransforms  ) 
 

ensure all member vars are init'ed

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/6//95

Definition at line 122 of file trans2d.cpp.

00123 {
00124     Scale       = 0;    // 0 indicates cached values invalid
00125     Aspect      = 1;
00126     Rotation    = 0;
00127     Skew        = 0;
00128     Translation = DocCoord(0,0);
00129 }

void Trans2DMatrix::Invert  )  [virtual]
 

Inverts the transformation matrix held by this transform object. future calls to the transform() member function will cause it to transform coordinates back to their original positions. ie, call Transform(), call Invert() and call Transform() again should give you the same set of coords as you started with.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/02/94

Implements TransInvertable.

Definition at line 316 of file trans2d.cpp.

00317 {
00318     // Invert the transformation matrix
00319     TransMatrix = TransMatrix.Inverse();
00320 
00321     InitDecomposedTransforms();
00322 }

BOOL Trans2DMatrix::IsInvertable  )  [virtual]
 

To see if this transform is really invertable.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/1/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this transform can be inverted; FALSE if not.
See also:
TransformBase::IsInvertable

Reimplemented from TransInvertable.

Definition at line 568 of file trans2d.cpp.

00569 {
00570     if (TransMatrix.Type == TRANS_IDENTITY)
00571         return TRUE;
00572     
00573     // The inverse has failed if we get an identity matrix
00574     Matrix Inversed = TransMatrix.Inverse();
00575 
00576     return (Inversed.Type != TRANS_IDENTITY);
00577 }

BOOL Trans2DMatrix::IsTranslation  )  [virtual]
 

Determine whether the transformation is a simple translation.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/12/2004

Reimplemented from TransformBase.

Definition at line 333 of file trans2d.cpp.

00334 {
00335     return TransMatrix.IsTranslation();
00336 }

Trans2DMatrix & Trans2DMatrix::operator *= const Trans2DMatrix op  ) 
 

Overloads the *= operator for Trans2DMatrix.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/11/94
Parameters:
Trans2DMatrix to be multiplied [INPUTS]
None. [OUTPUTS]
Returns:
result of multiplication.

Errors: None.

Definition at line 407 of file trans2d.cpp.

00408 {
00409     TransMatrix*=op.TransMatrix; 
00410     InitDecomposedTransforms();
00411     return *this; 
00412 } 

Trans2DMatrix & Trans2DMatrix::operator= const Trans2DMatrix rhs  ) 
 

Overloads the = operator for Trans2DMatrix.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/1/95
Parameters:
Trans2DMatrix to be copied into this object [INPUTS]
None. [OUTPUTS]
Returns:
result of assignment

Errors: None.

Definition at line 430 of file trans2d.cpp.

00431 {
00432     TransMatrix = rhs.TransMatrix; 
00433 
00434     //Graham 12/8/96: Added these because, well, you need them
00435     //Fixes bug 4938
00436     TransLines = rhs.TransLines;
00437     TransFills = rhs.TransFills;
00438 
00439     InitDecomposedTransforms();
00440     return *this; 
00441 } 

void Trans2DMatrix::SetTransform const Trans2DMatrix  ) 
 

Definition at line 272 of file trans2d.cpp.

00273 {
00274     // Copy all the elements from the other trans2dmatrix to this new one.
00275     TransMatrix = Other.TransMatrix;
00276     TransLines = Other.TransLines;
00277     TransFills = Other.TransFills;
00278     InitDecomposedTransforms();
00279 }

void Trans2DMatrix::SetTransform const Matrix NewMatrix  ) 
 

Definition at line 243 of file trans2d.cpp.

00244 {
00245     // Take a copy of the matrix
00246     TransMatrix = NewMatrix;
00247 
00248     // Set the flags
00249     TransLines = FALSE;
00250     TransFills = TRUE;
00251     InitDecomposedTransforms();
00252 }

void Trans2DMatrix::SetTransform INT32  TransX,
INT32  TransY
 

Definition at line 214 of file trans2d.cpp.

00215 {
00216     // Build the translation matrix
00217     TransMatrix = Matrix(TransX, TransY);
00218 
00219     // Set the flags
00220     TransLines = FALSE;
00221     TransFills = TRUE;
00222     InitDecomposedTransforms();
00223 }

void Trans2DMatrix::SetTransform DocCoord  CentreOfRot,
ANGLE  RotateBy
 

Definition at line 175 of file trans2d.cpp.

00176 {
00177     // Build the matricies we need
00178     Matrix RotateIt(RotateBy);
00179     Matrix TransFromOrigin( CentreOfRot.x, CentreOfRot.y );
00180     
00181     // need to translate the centre of rotation to the origin
00182     TransMatrix = Matrix( -CentreOfRot.x, -CentreOfRot.y );
00183 
00184     // rotate about the origin
00185     TransMatrix *= RotateIt;
00186 
00187     // translate back to the centre of rotation
00188     TransMatrix *= TransFromOrigin;
00189 
00190     // Set the flags
00191     TransLines = FALSE;
00192     TransFills = TRUE;
00193     InitDecomposedTransforms();
00194 }

void Trans2DMatrix::SetTransform  ) 
 

Definition at line 145 of file trans2d.cpp.

00146 {
00147     // Build the translation matrix
00148     TransMatrix = Matrix();
00149 
00150     // Set the flags
00151     TransLines = FALSE;
00152     TransFills = TRUE;
00153     InitDecomposedTransforms();
00154 }

void Trans2DMatrix::Transform DocCoord Coords,
INT32  NumCoords
[virtual]
 

Transform the coordinates in the array using the matrix in the transform object.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/02/94
Parameters:
Coords - Pointer to an array of coodinates to transform [INPUTS] NumCoords - the number of coodinates in the array
Coords - The coordinates in the array will have been transformed [OUTPUTS]

Implements TransformBase.

Definition at line 295 of file trans2d.cpp.

00296 {
00297     // Get the matrix to transform all the coords passed in
00298     TransMatrix.transform( (Coord*)Coords, NumCoords );
00299     InitDecomposedTransforms();
00300 }


Member Data Documentation

FIXED16 Trans2DMatrix::Aspect [protected]
 

Definition at line 174 of file trans2d.h.

ANGLE Trans2DMatrix::Rotation [protected]
 

Definition at line 175 of file trans2d.h.

FIXED16 Trans2DMatrix::Scale [protected]
 

Definition at line 173 of file trans2d.h.

FIXED16 Trans2DMatrix::ScaleY [protected]
 

Definition at line 178 of file trans2d.h.

ANGLE Trans2DMatrix::Skew [protected]
 

Definition at line 176 of file trans2d.h.

DocCoord Trans2DMatrix::Translation [protected]
 

Definition at line 177 of file trans2d.h.

Matrix Trans2DMatrix::TransMatrix [protected]
 

Definition at line 171 of file trans2d.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:12 2007 for Camelot by  doxygen 1.4.4