XMatrix Class Reference

#include <xmatrix.h>

Inheritance diagram for XMatrix:

SimpleCCObject List of all members.

Public Member Functions

 XMatrix ()
 Default initialisation - sets up the identity matrix.
 XMatrix (const FIXED16 &, const FIXED16 &)
 Default initialisation - sets up the scale matrix.
 XMatrix (const ANGLE &theta)
 Default initialisation - sets up the rotation matrix.
 XMatrix (const WorkCoord &)
 Default initialisation - Sets up a translate matrix.
 XMatrix (const XLONG x, const XLONG y)
 Default initialisation - Sets up a translate matrix.
 XMatrix (const INT32 x, const INT32 y)
 XMatrix (const Matrix &)
 Default initialisation - copies elements from 32- to 64-bit matrix.
 XMatrix (const FIXED16 &ca, const FIXED16 &cb, const FIXED16 &cc, const FIXED16 &cd, const XLONG ce, const XLONG cf)
 Initialise a whole XMatrix.
void transform (WorkCoord *)
 Transforms a single point.
void transform (WorkCoord[], UINT32 count)
 Transforms a list of points.
void transform (WorkCoord[], const WorkCoord[], UINT32)
 Transforms a list of points.
XMatrixoperator= (const XMatrix &)
 Matrix assignment.
XMatrixoperator *= (const XMatrix &)
 Overloads the *= operator for Matrices.

Private Attributes

FIXED16 a
FIXED16 b
FIXED16 c
FIXED16 d
XLONG e
XLONG f

Friends

class OSRenderRegion
XMatrix operator * (const XMatrix &, const XMatrix &)
 Matrix multiplication. Cannot be used in a nested form as the result is contained in a static local (e.g. a = (b*c)*(d*e) will fail).

Detailed Description

Definition at line 124 of file xmatrix.h.


Constructor & Destructor Documentation

XMatrix::XMatrix  ) 
 

Default initialisation - sets up the identity matrix.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 136 of file xmatrix.cpp.

00137 {
00138     a = (FIXED16) 1;
00139     b = (FIXED16) 0;
00140     c = (FIXED16) 0;
00141     d = (FIXED16) 1;
00142     e = 0;
00143     f = 0;
00144 }

XMatrix::XMatrix const FIXED16 xScale,
const FIXED16 yScale
 

Default initialisation - sets up the scale matrix.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
Two fixed16s representing the x and y scale factors. [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 189 of file xmatrix.cpp.

00190 {
00191     a = xScale;
00192     b = (FIXED16) 0;
00193     c = (FIXED16) 0;
00194     d = yScale;
00195     e = 0;
00196     f = 0;
00197 }

XMatrix::XMatrix const ANGLE theta  ) 
 

Default initialisation - sets up the rotation matrix.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
An angle representing the degree of rotation. [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 217 of file xmatrix.cpp.

00218 {
00219 #if 0
00220     a = b = c = d = theta;
00221     
00222     a.Cos();
00223     b.Sin();
00224     c = -(c.Sin());
00225     d.Cos(); 
00226 #else
00227     double thetaradians = TORADIANS(theta.MakeDouble());
00228     FIXED16 costheta = cos(thetaradians);
00229     FIXED16 sintheta = sin(thetaradians);
00230     
00231     a = d = costheta;
00232     b = sintheta;
00233     c = -sintheta;
00234 #endif
00235     
00236     e = 0;
00237     f = 0;
00238 }

XMatrix::XMatrix const WorkCoord disp  ) 
 

Default initialisation - Sets up a translate matrix.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
Displacement of translation. [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 258 of file xmatrix.cpp.

00259 {
00260     a = (FIXED16) 1;
00261     b = (FIXED16) 0;
00262     c = (FIXED16) 0;
00263     d = (FIXED16) 1;
00264     e = disp.x;
00265     f = disp.y;
00266 }

XMatrix::XMatrix const XLONG  x,
const XLONG  y
 

Default initialisation - Sets up a translate matrix.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
Displacement of translation. [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 284 of file xmatrix.cpp.

00285 {
00286     a = (FIXED16) 1;
00287     b = (FIXED16) 0;
00288     c = (FIXED16) 0;
00289     d = (FIXED16) 1;
00290     e = x;
00291     f = y;
00292 }

XMatrix::XMatrix const INT32  x,
const INT32  y
 

Definition at line 295 of file xmatrix.cpp.

00296 {
00297     a = (FIXED16) 1;
00298     b = (FIXED16) 0;
00299     c = (FIXED16) 0;
00300     d = (FIXED16) 1;
00301     e = x;
00302     f = y;
00303 }

XMatrix::XMatrix const Matrix mat32  ) 
 

Default initialisation - copies elements from 32- to 64-bit matrix.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
Matrix (32-bit flavour) [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 160 of file xmatrix.cpp.

00161 {
00162     a = mat32.a;
00163     b = mat32.b;
00164     c = mat32.c;
00165     d = mat32.d;
00166     e = mat32.e;
00167     f = mat32.f;
00168 }

XMatrix::XMatrix const FIXED16 ca,
const FIXED16 cb,
const FIXED16 cc,
const FIXED16 cd,
const XLONG  ce,
const XLONG  cf
 

Initialise a whole XMatrix.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/7/93
Parameters:
All six parameters which make up an Xmatrix [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 325 of file xmatrix.cpp.

00332 {
00333     a = ca;
00334     b = cb;
00335     c = cc;
00336     d = cd;
00337     e = ce;
00338     f = cf;
00339 }


Member Function Documentation

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

Overloads the *= operator for Matrices.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
Matrix to be multiplied. [INPUTS]
None. [OUTPUTS] Friend: Matrix
Returns:
result of multiplication.

Errors: None.

Definition at line 487 of file xmatrix.cpp.

00488 {
00489     XMatrix temp;
00490     
00491     temp.a =  ((a * op.a) + (b * op.c));
00492     temp.b =  ((a * op.b) + (b * op.d));
00493     temp.c =  ((c * op.a) + (d * op.c));
00494     temp.d =  ((c * op.b) + (d * op.d));
00495     XMatrixCalc(op.a, e, op.c, f, RESULT temp.e);
00496     temp.e += op.e;
00497     XMatrixCalc(op.b, e, op.d, f, RESULT temp.f);
00498     temp.f += op.f;
00499     
00500     *this = temp;
00501     
00502     return *this;
00503 }

XMatrix & XMatrix::operator= const XMatrix rhs  ) 
 

Matrix assignment.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
rhs - matrix to be assigned. [INPUTS]
None. [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 425 of file xmatrix.cpp.

00426 {
00427     this->a = rhs.a;
00428     this->b = rhs.b;
00429     this->c = rhs.c;
00430     this->d = rhs.d;
00431     this->e = rhs.e;
00432     this->f = rhs.f;
00433                  
00434     return *this;
00435 }                

void XMatrix::transform WorkCoord  pts[],
const WorkCoord  input[],
UINT32  count
 

Transforms a list of points.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
input - points to be translated. [INPUTS] count - number of points.
result points translated. [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 394 of file xmatrix.cpp.

00395 {
00396     UINT32 i;
00397     
00398     for (i = 0; i < count; i++)
00399     {
00400         XMatrixCalc(a, input[i].x, c, input[i].y, RESULT pts[i].x);  
00401         pts[i].x += e;
00402         XMatrixCalc(b, input[i].x, d, input[i].y, RESULT pts[i].y);
00403         pts[i].y += f;
00404     }
00405 }

void XMatrix::transform WorkCoord  pts[],
UINT32  count
 

Transforms a list of points.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
result - points to be translated. [INPUTS] count - number of points.
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 360 of file xmatrix.cpp.

00361 {                    
00362     UINT32 i;
00363     XLONG tx;       // Holds INPUT value of pts[i].x for use in second MatrixCalc
00364     
00365     for (i = 0; i < count; i++)
00366     {
00367         tx = pts[i].x;
00368         XMatrixCalc(a, tx, c, pts[i].y, RESULT pts[i].x);
00369         pts[i].x += e;
00370         XMatrixCalc(b, tx, d, pts[i].y, RESULT pts[i].y);
00371         pts[i].y += f;
00372     }
00373 }

void XMatrix::transform WorkCoord pt  ) 
 

Transforms a single point.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
result - points to be transformed. [INPUTS]
None [OUTPUTS]
Returns:
None.

Errors: None.

Definition at line 521 of file xmatrix.cpp.

00522 {                    
00523     XLONG tx = pt->x;       // Holds INPUT value of x for use in second MatrixCalc
00524 
00525     XMatrixCalc(a, tx, c, pt->y, RESULT pt->x);  
00526     pt->x += e;
00527     XMatrixCalc(b, tx, d, pt->y, RESULT pt->y);
00528     pt->y += f;
00529 }


Friends And Related Function Documentation

XMatrix operator * const XMatrix op1,
const XMatrix op2
[friend]
 

Matrix multiplication. Cannot be used in a nested form as the result is contained in a static local (e.g. a = (b*c)*(d*e) will fail).

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
Two matrices to be multiplied. [INPUTS]
None. [OUTPUTS] Friend: Matrix
Returns:
result of multiplication.

Errors: None.

Definition at line 454 of file xmatrix.cpp.

00455 {
00456     static XMatrix result;
00457     
00458     result.a = ((op1.a * op2.a) + (op1.b * op2.c));
00459     result.b = ((op1.a * op2.b) + (op1.b * op2.d));
00460     result.c = ((op1.c * op2.a) + (op1.d * op2.c));
00461     result.d = ((op1.c * op2.b) + (op1.d * op2.d));
00462 
00463     XMatrixCalc(op2.a, op1.e, op2.c, op1.f, RESULT result.e);
00464     result.e += op2.e;
00465     XMatrixCalc(op2.b, op1.e, op2.d, op1.f, RESULT result.f);
00466     result.f += op2.f;
00467             
00468     return result;  
00469 }                   

friend class OSRenderRegion [friend]
 

Definition at line 126 of file xmatrix.h.


Member Data Documentation

FIXED16 XMatrix::a [private]
 

Definition at line 129 of file xmatrix.h.

FIXED16 XMatrix::b [private]
 

Definition at line 130 of file xmatrix.h.

FIXED16 XMatrix::c [private]
 

Definition at line 131 of file xmatrix.h.

FIXED16 XMatrix::d [private]
 

Definition at line 132 of file xmatrix.h.

XLONG XMatrix::e [private]
 

Definition at line 133 of file xmatrix.h.

XLONG XMatrix::f [private]
 

Definition at line 134 of file xmatrix.h.


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