X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e5d4c38a3881ac290689af3ddf2a96623d97683..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/common/affinematrix2d.cpp diff --git a/src/common/affinematrix2d.cpp b/src/common/affinematrix2d.cpp index 977f6834ad..5013b31f15 100644 --- a/src/common/affinematrix2d.cpp +++ b/src/common/affinematrix2d.cpp @@ -4,7 +4,7 @@ // Author: Based on wxTransformMatrix by Chris Breeze, Julian Smart // Created: 2011-04-05 // Copyright: (c) wxWidgets team -// Licence: wxWidgets licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -13,6 +13,8 @@ #pragma hdrstop #endif +#if wxUSE_GEOMETRY + #include "wx/affinematrix2d.h" #include "wx/math.h" @@ -104,10 +106,13 @@ bool wxAffineMatrix2D::IsEqual(const wxAffineMatrix2DBase& t) const // // add the translation to this matrix +// | 1 0 0 | | m_11 m_12 0 | +// | 0 1 0 | x | m_21 m_22 0 | +// | dx dy 1 | | m_tx m_ty 1 | void wxAffineMatrix2D::Translate(wxDouble dx, wxDouble dy) { - m_tx += dx; - m_ty += dy; + m_tx += m_11 * dx + m_21 * dy; + m_ty += m_12 * dx + m_22 * dy; } // add the scale to this matrix @@ -122,19 +127,19 @@ void wxAffineMatrix2D::Scale(wxDouble xScale, wxDouble yScale) m_22 *= yScale; } -// add the rotation to this matrix (counter clockwise, radians) -// | cos -sin 0 | | m_11 m_12 0 | -// | sin cos 0 | x | m_21 m_22 0 | +// add the rotation to this matrix (clockwise, radians) +// | cos sin 0 | | m_11 m_12 0 | +// | -sin cos 0 | x | m_21 m_22 0 | // | 0 0 1 | | m_tx m_ty 1 | -void wxAffineMatrix2D::Rotate(wxDouble ccRadians) +void wxAffineMatrix2D::Rotate(wxDouble cRadians) { - wxDouble c = cos(ccRadians); - wxDouble s = sin(ccRadians); + wxDouble c = cos(cRadians); + wxDouble s = sin(cRadians); - wxDouble e11 = c*m_11 - s*m_21; - wxDouble e12 = c*m_12 - s*m_22; - m_21 = s*m_11 + c*m_21; - m_22 = s*m_12 + c*m_22; + wxDouble e11 = c*m_11 + s*m_21; + wxDouble e12 = c*m_12 + s*m_22; + m_21 = c*m_21 - s*m_11; + m_22 = c*m_22 - s*m_12; m_11 = e11; m_12 = e12; } @@ -154,7 +159,7 @@ wxAffineMatrix2D::DoTransformPoint(const wxPoint2DDouble& src) const return src; return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21 + m_tx, - src.m_y * m_12 + src.m_y * m_22 + m_ty); + src.m_x * m_12 + src.m_y * m_22 + m_ty); } // applies the matrix except for translations @@ -168,7 +173,7 @@ wxAffineMatrix2D::DoTransformDistance(const wxPoint2DDouble& src) const return src; return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21, - src.m_y * m_12 + src.m_y * m_22); + src.m_x * m_12 + src.m_y * m_22); } bool wxAffineMatrix2D::IsIdentity() const @@ -177,3 +182,5 @@ bool wxAffineMatrix2D::IsIdentity() const m_21 == 0 && m_22 == 1 && m_tx == 0 && m_ty == 0; } + +#endif // wxUSE_GEOMETRY