X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/94e0018723919fe2ca2f5b5f0a42804c16dbf3a1..d57d0505d4c2186592833f18c3d40532d3a4bf0e:/src/common/affinematrix2d.cpp diff --git a/src/common/affinematrix2d.cpp b/src/common/affinematrix2d.cpp index b4605d4e53..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" @@ -106,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 @@ -124,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; } @@ -156,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 @@ -170,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