Mako 7.5.0 API
Loading...
Searching...
No Matches
CTransformMatrix< TItem > Class Template Reference

Matrix class - special 3x2 matrix. More...

#include <edlgeom.h>

Public Types

enum  eOperationTypes { eDoesTranslate = 0x1 , eDoesScale = 0x2 , eDoesRotate = 0x4 , eIsComplex = 0x8 }
 Classification of operation type flags of the transform. More...
 

Public Member Functions

 CTransformMatrix ()
 Creates zero matrix.
 
 CTransformMatrix (TItem _xx, TItem _xy, TItem _yx, TItem _yy, TItem _dx, TItem _dy)
 Creates the matrix elementary.
 
 CTransformMatrix (const CTransformMatrix< TItem > &m)
 Copy constructor.
 
CTransformMatrixoperator= (const CTransformMatrix< TItem > &m)
 Assignment operator.
 
 CTransformMatrix (const RectTmpl< TItem > &sourceRect, const RectTmpl< TItem > &destRect)
 Creates a matrix that transforms from one rectangle to another.
 
void set (TItem _xx=1, TItem _xy=0, TItem _yx=0, TItem _yy=1, TItem _dx=0, TItem _dy=0)
 Create blank matrix.
 
TItem xx () const
 Returns xx component.
 
TItem xy () const
 Returns xy component.
 
TItem yx () const
 Returns yx component.
 
TItem yy () const
 Returns yy component.
 
TItem dx () const
 Returns dx component.
 
TItem dy () const
 Returns dy component.
 
void setXX (TItem x)
 Sets xx component.
 
void setXY (TItem x)
 Sets xy component.
 
void setYX (TItem x)
 Sets yx component.
 
void setYY (TItem x)
 Sets yy component.
 
void setDX (TItem x)
 Sets dx component.
 
void setDY (TItem x)
 Sets dy component.
 
bool equal (const CTransformMatrix< TItem > &matrix, bool ignoreDXDY=false) const
 Compare to another matrix.
 
bool identity (bool ignoreDXDY=false) const
 Determine if identity matrix.
 
CTransformMatrix< TItem > & preMul (const CTransformMatrix< TItem > &matrix)
 Premultiply by given matrix.
 
CTransformMatrix< TItem > & postMul (const CTransformMatrix< TItem > &matrix)
 Postmultiply by given matrix.
 
bool degenerate ()
 Check to see if the matrix is degenerate (0 scale)
 
bool invert ()
 Invert the matrix.
 
void transform (PointTmpl< TItem > &result, const PointTmpl< TItem > &point, bool ignoreDXDY=false) const
 Transform a point.
 
PointTmpl< TItem > transform (const PointTmpl< TItem > &point, bool ignoreDXDY=false) const
 Transform a point.
 
bool iTransform (PointTmpl< TItem > &result, const PointTmpl< TItem > &point, bool ignoreDXDY=false) const
 Transform a point by the inverse of the matrix.
 
std::pair< bool, PointTmpl< TItem > > iTransform (const PointTmpl< TItem > &point, bool ignoreDXDY=false) const
 Transform a point by the inverse of the matrix.
 
void rotate (double radians)
 Add a rotation, clockwise, in radians.
 
void scale (TItem xscale, TItem yscale)
 Scale.
 
void translate (TItem dx, TItem dy)
 Translate.
 
TItem determinant () const
 Find the determinant of the matrix.
 
void transformRect (RectTmpl< TItem > &rect, bool ignoreDXDY=false) const
 Transform a rectangle.
 
uint32 classify () const
 Classify the transform.
 
void decompose (PointTmpl< TItem > &translate, double &rotationAngle, double &shearAngle, FPoint &scale) const
 Similar to the other form of decompose, but does the decomposition in a different, potentially more useful order. It's designed to more naturally extract rotation information when objects are scaled in a rotated context.
 
void compose (const PointTmpl< TItem > &translateAmount, double rotationAngle, double shearAngle, const FPoint &scaleAmount)
 Undo the second form of decompose above. It starts with an identity matrix and applies the transforms in this order:
 
template<typename AType >
void asArray (AType *array) const
 Retrieve the matrix as an array of the given type.
 

Detailed Description

template<typename TItem>
class CTransformMatrix< TItem >

Matrix class - special 3x2 matrix.

Constructor & Destructor Documentation

◆ CTransformMatrix() [1/3]

template<typename TItem >
CTransformMatrix< TItem >::CTransformMatrix ( TItem _xx,
TItem _xy,
TItem _yx,
TItem _yy,
TItem _dx,
TItem _dy )
inline

Creates the matrix elementary.

Parameters
_xxxx component
_xyxy component
_yxyx component
_yyyy component
_dxdx component
_dydy component

◆ CTransformMatrix() [2/3]

template<typename TItem >
CTransformMatrix< TItem >::CTransformMatrix ( const CTransformMatrix< TItem > & m)
inline

Copy constructor.

Parameters
mTransform matrix

◆ CTransformMatrix() [3/3]

template<typename TItem >
CTransformMatrix< TItem >::CTransformMatrix ( const RectTmpl< TItem > & sourceRect,
const RectTmpl< TItem > & destRect )
inline

Creates a matrix that transforms from one rectangle to another.

Parameters
sourceRectSource rectangle
destRectDestination rectangle

Member Function Documentation

◆ asArray()

template<typename TItem >
template<typename AType >
void CTransformMatrix< TItem >::asArray ( AType * array) const
inline

Retrieve the matrix as an array of the given type.

Parameters
arrayPointer to a six-entry array of the given type

◆ classify()

template<typename TItem >
uint32 CTransformMatrix< TItem >::classify ( ) const
inline

Classify the transform.

Returns
uint32 Operation flags

◆ compose()

template<typename TItem >
void CTransformMatrix< TItem >::compose ( const PointTmpl< TItem > & translateAmount,
double rotationAngle,
double shearAngle,
const FPoint & scaleAmount )
inline

Undo the second form of decompose above. It starts with an identity matrix and applies the transforms in this order:

  • Translate
  • Rotate
  • Shear
  • Scale
Parameters
translateAmountThe desired translation component in x and y.
rotationAngleThe desired rotation angle in radians.
shearAngleThe desired shear angle in radians.
scaleAmountThe desired scale in x and y.

◆ decompose()

template<typename TItem >
void CTransformMatrix< TItem >::decompose ( PointTmpl< TItem > & translate,
double & rotationAngle,
double & shearAngle,
FPoint & scale ) const
inline

Similar to the other form of decompose, but does the decomposition in a different, potentially more useful order. It's designed to more naturally extract rotation information when objects are scaled in a rotated context.

Here, once decomposed, the original matrix (within the limitations of floating point roundoff and trig functions) can be reconstructed through successive premultiplies in the following order:

  • Translate
  • Rotate
  • Shear
  • Scale

See compose, which demonstrates how to perform these steps.

Parameters
translateReference to receive the translation component in x and y.
rotationAngleReference to receive the rotation angle in radians. Please note that the rotation direction is not the same as the other decompose method, and instead uses the same semantics as the rotate member function (clockwise).
shearAngleReference to receive the shear angle in radians.
scaleReference to receive the scale component in x and y.

◆ degenerate()

template<typename TItem >
bool CTransformMatrix< TItem >::degenerate ( )
inline

Check to see if the matrix is degenerate (0 scale)

Returns
bool True if matrix is degenerate, false otherwise.

◆ determinant()

template<typename TItem >
TItem CTransformMatrix< TItem >::determinant ( ) const
inline

Find the determinant of the matrix.

Returns
TItem the determinant

◆ dx()

template<typename TItem >
TItem CTransformMatrix< TItem >::dx ( ) const
inline

Returns dx component.

Returns
TItem dx component

◆ dy()

template<typename TItem >
TItem CTransformMatrix< TItem >::dy ( ) const
inline

Returns dy component.

Returns
TItem dy component

◆ equal()

template<typename TItem >
bool CTransformMatrix< TItem >::equal ( const CTransformMatrix< TItem > & matrix,
bool ignoreDXDY = false ) const
inline

Compare to another matrix.

Parameters
matrixMatrix to compare current instance to
ignoreDXDYIgnore DX & DY for this comparison
Returns
bool True if equal, false if not

◆ identity()

template<typename TItem >
bool CTransformMatrix< TItem >::identity ( bool ignoreDXDY = false) const
inline

Determine if identity matrix.

Parameters
ignoreDXDYIgnore DX & DY for this operation
Returns
bool True if identity matrix, false if not

◆ invert()

template<typename TItem >
bool CTransformMatrix< TItem >::invert ( )
inline

Invert the matrix.

Returns
bool True if matrix was inverted, false if inversion was not possible

◆ iTransform() [1/2]

template<typename TItem >
std::pair< bool, PointTmpl< TItem > > CTransformMatrix< TItem >::iTransform ( const PointTmpl< TItem > & point,
bool ignoreDXDY = false ) const
inline

Transform a point by the inverse of the matrix.

Parameters
pointThe point
ignoreDXDYIgnore DX & DY for this operation
Returns
std::pair<bool, PointTmpl<TItem> > A pair whose first element is true if the point was transformed while the second element is the resulting point

◆ iTransform() [2/2]

template<typename TItem >
bool CTransformMatrix< TItem >::iTransform ( PointTmpl< TItem > & result,
const PointTmpl< TItem > & point,
bool ignoreDXDY = false ) const
inline

Transform a point by the inverse of the matrix.

Parameters
resultPointTmpl<TItem> to accept result
pointThe point
ignoreDXDYIgnore DX & DY for this operation
Returns
bool True if point was transformed, false if transformation was not possible

◆ operator=()

template<typename TItem >
CTransformMatrix & CTransformMatrix< TItem >::operator= ( const CTransformMatrix< TItem > & m)
inline

Assignment operator.

Parameters
mTransform matrix

◆ postMul()

template<typename TItem >
CTransformMatrix< TItem > & CTransformMatrix< TItem >::postMul ( const CTransformMatrix< TItem > & matrix)
inline

Postmultiply by given matrix.

Parameters
matrixMatrix postmultiplier
Returns
CTransformMatrix<TItem> Resulting matrix

◆ preMul()

template<typename TItem >
CTransformMatrix< TItem > & CTransformMatrix< TItem >::preMul ( const CTransformMatrix< TItem > & matrix)
inline

Premultiply by given matrix.

Parameters
matrixMatrix premultiplier
Returns
CTransformMatrix<TItem> Resulting matrix

◆ rotate()

template<typename TItem >
void CTransformMatrix< TItem >::rotate ( double radians)
inline

Add a rotation, clockwise, in radians.

Parameters
radiansAngle in radians

◆ scale()

template<typename TItem >
void CTransformMatrix< TItem >::scale ( TItem xscale,
TItem yscale )
inline

Scale.

Parameters
xscaleX-axis scaling factor
yscaleY-axis scaling factor

◆ set()

template<typename TItem >
void CTransformMatrix< TItem >::set ( TItem _xx = 1,
TItem _xy = 0,
TItem _yx = 0,
TItem _yy = 1,
TItem _dx = 0,
TItem _dy = 0 )
inline

Create blank matrix.

Parameters
_xxxx component
_xyxy component
_yxyx component
_yyyy component
_dxdx component
_dydy component

◆ setDX()

template<typename TItem >
void CTransformMatrix< TItem >::setDX ( TItem x)
inline

Sets dx component.

Parameters
xvalue to set

◆ setDY()

template<typename TItem >
void CTransformMatrix< TItem >::setDY ( TItem x)
inline

Sets dy component.

Parameters
xvalue to set

◆ setXX()

template<typename TItem >
void CTransformMatrix< TItem >::setXX ( TItem x)
inline

Sets xx component.

Parameters
xvalue to set

◆ setXY()

template<typename TItem >
void CTransformMatrix< TItem >::setXY ( TItem x)
inline

Sets xy component.

Parameters
xvalue to set

◆ setYX()

template<typename TItem >
void CTransformMatrix< TItem >::setYX ( TItem x)
inline

Sets yx component.

Parameters
xvalue to set

◆ setYY()

template<typename TItem >
void CTransformMatrix< TItem >::setYY ( TItem x)
inline

Sets yy component.

Parameters
xvalue to set

◆ transform() [1/2]

template<typename TItem >
PointTmpl< TItem > CTransformMatrix< TItem >::transform ( const PointTmpl< TItem > & point,
bool ignoreDXDY = false ) const
inline

Transform a point.

Parameters
pointThe point before transformation
ignoreDXDYIgnore DX & DY for this operation
Returns
CTransformMatrix<TItem> Resulting matrix

◆ transform() [2/2]

template<typename TItem >
void CTransformMatrix< TItem >::transform ( PointTmpl< TItem > & result,
const PointTmpl< TItem > & point,
bool ignoreDXDY = false ) const
inline

Transform a point.

Parameters
resultThe point after transformation
pointThe point before transformation
ignoreDXDYIgnore DX & DY for this operation

◆ transformRect()

template<typename TItem >
void CTransformMatrix< TItem >::transformRect ( RectTmpl< TItem > & rect,
bool ignoreDXDY = false ) const
inline

Transform a rectangle.

Transform a rectangle

Parameters
rectRectangle to transform
ignoreDXDYIgnore DX & DY for this operation

◆ translate()

template<typename TItem >
void CTransformMatrix< TItem >::translate ( TItem dx,
TItem dy )
inline

Translate.

Parameters
dxx-axis transformation value
dyy-axis transformation value

◆ xx()

template<typename TItem >
TItem CTransformMatrix< TItem >::xx ( ) const
inline

Returns xx component.

Returns
TItem xx component

◆ xy()

template<typename TItem >
TItem CTransformMatrix< TItem >::xy ( ) const
inline

Returns xy component.

Returns
TItem xy component

◆ yx()

template<typename TItem >
TItem CTransformMatrix< TItem >::yx ( ) const
inline

Returns yx component.

Returns
TItem yx component

◆ yy()

template<typename TItem >
TItem CTransformMatrix< TItem >::yy ( ) const
inline

Returns yy component.

Returns
TItem yy component

The documentation for this class was generated from the following file: