X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d9384bfb6d08a112b1ec096030f2939ae255cc5a..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/common/affinematrix2d.cpp diff --git a/src/common/affinematrix2d.cpp b/src/common/affinematrix2d.cpp index 5df1bac1e6..5013b31f15 100644 --- a/src/common/affinematrix2d.cpp +++ b/src/common/affinematrix2d.cpp @@ -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