affinematrix2d.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: affinematrix2d.h
  3. // Purpose: interface of wxAffineMatrix2D
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxAffineMatrix2D
  9. A 3x2 matrix representing an affine 2D transformation.
  10. @library{wxcore}
  11. @category{misc}
  12. @since 2.9.2
  13. */
  14. class wxAffineMatrix2D : public wxAffineMatrix2DBase
  15. {
  16. public:
  17. /**
  18. Default constructor.
  19. The matrix elements are initialize to the identity matrix.
  20. */
  21. wxAffineMatrix2D();
  22. /**
  23. Get the component values of the matrix.
  24. @param mat2D
  25. The rotational components of the matrix (upper 2 x 2), must be
  26. non-@NULL.
  27. @param tr
  28. The translational components of the matrix, may be @NULL.
  29. */
  30. void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const;
  31. /**
  32. Set all elements of this matrix.
  33. @param mat2D
  34. The rotational components of the matrix (upper 2 x 2).
  35. @param tr
  36. The translational components of the matrix.
  37. */
  38. void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr);
  39. /**
  40. Concatenate this matrix with another one.
  41. The parameter matrix is the multiplicand.
  42. @param t
  43. The multiplicand.
  44. @code
  45. // | t.m_11 t.m_12 0 | | m_11 m_12 0 |
  46. // matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 |
  47. // | t.m_tx t.m_ty 1 | | m_tx m_ty 1 |
  48. @endcode
  49. */
  50. void Concat(const wxAffineMatrix2DBase& t);
  51. /**
  52. Invert this matrix.
  53. If the matrix is not invertible, i.e. if its determinant is 0, returns
  54. false and doesn't modify it.
  55. @code
  56. // | m_11 m_12 0 |
  57. // Invert | m_21 m_22 0 |
  58. // | m_tx m_ty 1 |
  59. @endcode
  60. */
  61. bool Invert();
  62. /**
  63. Check if this is the identity matrix.
  64. */
  65. bool IsIdentity() const;
  66. //@{
  67. /**
  68. Check that this matrix is identical with @a t.
  69. @param t
  70. The matrix compared with this.
  71. */
  72. void IsEqual(const wxAffineMatrix2DBase& t);
  73. bool operator==(const wxAffineMatrix2DBase& t) const;
  74. //@}
  75. /**
  76. Check that this matrix differs from @a t.
  77. @param t
  78. The matrix compared with this.
  79. */
  80. bool operator!=(const wxAffineMatrix2DBase& t) const;
  81. /**
  82. Add the translation to this matrix.
  83. @param dx
  84. The translation in x direction.
  85. @param dy
  86. The translation in y direction.
  87. @code
  88. // | 1 0 0 | | m_11 m_12 0 |
  89. // matrix' = | 0 1 0 | x | m_21 m_22 0 |
  90. // | dx dy 1 | | m_tx m_ty 1 |
  91. @endcode
  92. */
  93. void Translate(wxDouble dx, wxDouble dy);
  94. /**
  95. Add scaling to this matrix.
  96. @param xScale
  97. Scaling in x direction.
  98. @param yScale
  99. Scaling in y direction.
  100. @code
  101. // | xScale 0 0 | | m_11 m_12 0 |
  102. // matrix' = | 0 yScale 0 | x | m_21 m_22 0 |
  103. // | 0 0 1 | | m_tx m_ty 1 |
  104. @endcode
  105. */
  106. void Scale(wxDouble xScale, wxDouble yScale);
  107. /**
  108. Add mirroring to this matrix.
  109. @param direction
  110. The direction(s) used for mirroring. One of wxHORIZONTAL,
  111. wxVERTICAL or their combination wxBOTH.
  112. */
  113. void Mirror(int direction = wxHORIZONTAL);
  114. /**
  115. Add clockwise rotation to this matrix.
  116. @param cRadians
  117. Rotation angle in radians, clockwise.
  118. @code
  119. // | cos sin 0 | | m_11 m_12 0 |
  120. // matrix' = | -sin cos 0 | x | m_21 m_22 0 |
  121. // | 0 0 1 | | m_tx m_ty 1 |
  122. @endcode
  123. */
  124. void Rotate(wxDouble cRadians);
  125. /**
  126. Applies this matrix to the point.
  127. @param p
  128. The point receiving the transformations.
  129. @return The point with the transformations applied.
  130. @code
  131. // | m_11 m_12 0 |
  132. // point' = | src.m_x src._my 1 | x | m_21 m_22 0 |
  133. // | m_tx m_ty 1 |
  134. @endcode
  135. */
  136. wxPoint2DDouble TransformPoint(const wxPoint2DDouble& p) const;
  137. void TransformPoint(wxDouble* x, wxDouble* y) const;
  138. /**
  139. Applies the linear part of this matrix, i.e.\ without translation.
  140. @param p
  141. The source receiving the transformations.
  142. @return The source with the transformations applied.
  143. @code
  144. // | m_11 m_12 0 |
  145. // dist' = | src.m_x src._my 0 | x | m_21 m_22 0 |
  146. // | m_tx m_ty 1 |
  147. @endcode
  148. */
  149. wxPoint2DDouble TransformDistance(const wxPoint2DDouble& p) const;
  150. void TransformDistance(wxDouble* dx, wxDouble* dy) const;
  151. };