diff --git a/source/Math/Transform.cpp b/source/Math/Transform.cpp index 1a14d2b..189ef8c 100644 --- a/source/Math/Transform.cpp +++ b/source/Math/Transform.cpp @@ -52,11 +52,8 @@ Vector2f Transform::getRightVector() const Transform& Transform::translate(float x, float y) { - Transform t(1, 0, x, - 0, 1, y, - 0, 0, 1); - - return combine(t); + m_matrix *= math::translate(x, y); + return *this; } Transform& Transform::translate(Vector2f vec) @@ -66,25 +63,14 @@ Transform& Transform::translate(Vector2f vec) Transform& Transform::rotate(float theta) { - float a = math::deg2rad(theta); - float c = std::cos(a); - float s = std::sin(a); - - // Always rotate along z-axis in 2D. - Transform r(c, -s, 0, - s, c, 0, - 0, 0, 1); - - return combine(r); + m_matrix *= math::rotation(theta); + return *this; } Transform& Transform::scale(float x, float y) { - Transform s(x, 0, 0, - 0, y, 0, - 0, 0, 1); - - return combine(s); + m_matrix *= math::scale(x, y); + return *this; } Transform& Transform::scale(Vector2f vec)