2011-04-16 20:09:56 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: affinematrix2d.h
|
|
|
|
// Purpose: interface of wxAffineMatrix2D
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxAffineMatrix2D
|
|
|
|
|
|
|
|
A 3x2 matrix representing an affine 2D transformation.
|
|
|
|
|
|
|
|
@library{wxcore}
|
|
|
|
@category{misc}
|
|
|
|
|
|
|
|
@since 2.9.2
|
|
|
|
*/
|
2012-04-04 19:22:53 -04:00
|
|
|
class wxAffineMatrix2D : public wxAffineMatrix2DBase
|
2011-04-16 20:09:56 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
|
|
|
|
The matrix elements are initialize to the identity matrix.
|
|
|
|
*/
|
|
|
|
wxAffineMatrix2D();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Get the component values of the matrix.
|
|
|
|
|
|
|
|
@param mat2D
|
|
|
|
The rotational components of the matrix (upper 2 x 2), must be
|
|
|
|
non-@NULL.
|
|
|
|
@param tr
|
|
|
|
The translational components of the matrix, may be @NULL.
|
|
|
|
*/
|
|
|
|
void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set all elements of this matrix.
|
|
|
|
|
|
|
|
@param mat2D
|
|
|
|
The rotational components of the matrix (upper 2 x 2).
|
|
|
|
@param tr
|
|
|
|
The translational components of the matrix.
|
|
|
|
*/
|
|
|
|
void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Concatenate this matrix with another one.
|
|
|
|
|
|
|
|
The parameter matrix is the multiplicand.
|
|
|
|
|
2011-04-23 10:53:42 -04:00
|
|
|
@param t
|
2011-04-16 20:09:56 -04:00
|
|
|
The multiplicand.
|
|
|
|
|
|
|
|
@code
|
|
|
|
// | t.m_11 t.m_12 0 | | m_11 m_12 0 |
|
|
|
|
// matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 |
|
|
|
|
// | t.m_tx t.m_ty 1 | | m_tx m_ty 1 |
|
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
void Concat(const wxAffineMatrix2DBase& t);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Invert this matrix.
|
|
|
|
|
|
|
|
If the matrix is not invertible, i.e. if its determinant is 0, returns
|
|
|
|
false and doesn't modify it.
|
|
|
|
|
|
|
|
@code
|
|
|
|
// | m_11 m_12 0 |
|
|
|
|
// Invert | m_21 m_22 0 |
|
|
|
|
// | m_tx m_ty 1 |
|
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
bool Invert();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Check if this is the identity matrix.
|
|
|
|
*/
|
|
|
|
bool IsIdentity() const;
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2013-08-21 11:26:34 -04:00
|
|
|
Check that this matrix is identical with @a t.
|
2011-04-16 20:09:56 -04:00
|
|
|
|
2011-04-23 10:53:42 -04:00
|
|
|
@param t
|
2011-04-16 20:09:56 -04:00
|
|
|
The matrix compared with this.
|
|
|
|
*/
|
|
|
|
void IsEqual(const wxAffineMatrix2DBase& t);
|
|
|
|
bool operator==(const wxAffineMatrix2DBase& t) const;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2013-08-21 11:26:34 -04:00
|
|
|
Check that this matrix differs from @a t.
|
2011-04-16 20:09:56 -04:00
|
|
|
|
2011-04-23 10:53:42 -04:00
|
|
|
@param t
|
2011-04-16 20:09:56 -04:00
|
|
|
The matrix compared with this.
|
|
|
|
*/
|
|
|
|
bool operator!=(const wxAffineMatrix2DBase& t) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Add the translation to this matrix.
|
|
|
|
|
|
|
|
@param dx
|
|
|
|
The translation in x direction.
|
|
|
|
@param dy
|
|
|
|
The translation in y direction.
|
2012-05-25 05:48:09 -04:00
|
|
|
|
|
|
|
@code
|
|
|
|
// | 1 0 0 | | m_11 m_12 0 |
|
|
|
|
// matrix' = | 0 1 0 | x | m_21 m_22 0 |
|
|
|
|
// | dx dy 1 | | m_tx m_ty 1 |
|
|
|
|
@endcode
|
2011-04-16 20:09:56 -04:00
|
|
|
*/
|
|
|
|
void Translate(wxDouble dx, wxDouble dy);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Add scaling to this matrix.
|
|
|
|
|
|
|
|
@param xScale
|
|
|
|
Scaling in x direction.
|
|
|
|
@param yScale
|
|
|
|
Scaling in y direction.
|
2012-05-25 05:48:09 -04:00
|
|
|
|
|
|
|
@code
|
|
|
|
// | xScale 0 0 | | m_11 m_12 0 |
|
|
|
|
// matrix' = | 0 yScale 0 | x | m_21 m_22 0 |
|
|
|
|
// | 0 0 1 | | m_tx m_ty 1 |
|
|
|
|
@endcode
|
2011-04-16 20:09:56 -04:00
|
|
|
*/
|
|
|
|
void Scale(wxDouble xScale, wxDouble yScale);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Add mirroring to this matrix.
|
|
|
|
|
|
|
|
@param direction
|
|
|
|
The direction(s) used for mirroring. One of wxHORIZONTAL,
|
|
|
|
wxVERTICAL or their combination wxBOTH.
|
|
|
|
*/
|
|
|
|
void Mirror(int direction = wxHORIZONTAL);
|
|
|
|
|
|
|
|
/**
|
2012-05-25 05:48:09 -04:00
|
|
|
Add clockwise rotation to this matrix.
|
2011-04-16 20:09:56 -04:00
|
|
|
|
2012-05-25 05:48:09 -04:00
|
|
|
@param cRadians
|
|
|
|
Rotation angle in radians, clockwise.
|
|
|
|
|
|
|
|
@code
|
|
|
|
// | cos sin 0 | | m_11 m_12 0 |
|
|
|
|
// matrix' = | -sin cos 0 | x | m_21 m_22 0 |
|
|
|
|
// | 0 0 1 | | m_tx m_ty 1 |
|
|
|
|
@endcode
|
2011-04-16 20:09:56 -04:00
|
|
|
*/
|
2012-05-25 05:48:09 -04:00
|
|
|
void Rotate(wxDouble cRadians);
|
2011-04-16 20:09:56 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Applies this matrix to the point.
|
|
|
|
|
2011-04-23 10:53:42 -04:00
|
|
|
@param p
|
2011-04-16 20:09:56 -04:00
|
|
|
The point receiving the transformations.
|
|
|
|
|
|
|
|
@return The point with the transformations applied.
|
2012-05-25 05:48:09 -04:00
|
|
|
|
|
|
|
@code
|
|
|
|
// | m_11 m_12 0 |
|
|
|
|
// point' = | src.m_x src._my 1 | x | m_21 m_22 0 |
|
|
|
|
// | m_tx m_ty 1 |
|
|
|
|
@endcode
|
2011-04-16 20:09:56 -04:00
|
|
|
*/
|
|
|
|
wxPoint2DDouble TransformPoint(const wxPoint2DDouble& p) const;
|
|
|
|
void TransformPoint(wxDouble* x, wxDouble* y) const;
|
|
|
|
|
|
|
|
/**
|
2012-11-30 19:14:07 -05:00
|
|
|
Applies the linear part of this matrix, i.e.\ without translation.
|
2011-04-16 20:09:56 -04:00
|
|
|
|
2011-04-23 10:53:42 -04:00
|
|
|
@param p
|
2011-04-16 20:09:56 -04:00
|
|
|
The source receiving the transformations.
|
|
|
|
|
|
|
|
@return The source with the transformations applied.
|
2012-05-25 05:48:09 -04:00
|
|
|
|
|
|
|
@code
|
|
|
|
// | m_11 m_12 0 |
|
|
|
|
// dist' = | src.m_x src._my 0 | x | m_21 m_22 0 |
|
|
|
|
// | m_tx m_ty 1 |
|
|
|
|
@endcode
|
2011-04-16 20:09:56 -04:00
|
|
|
*/
|
|
|
|
wxPoint2DDouble TransformDistance(const wxPoint2DDouble& p) const;
|
|
|
|
void TransformDistance(wxDouble* dx, wxDouble* dy) const;
|
|
|
|
};
|