1
0
Fork 0

Math/Transform.cpp: use transform/scale/ratation functions from Math.h

This commit is contained in:
Henrik Hautakoski 2020-02-14 23:31:15 +01:00
parent a6e6b915e6
commit a4a691fd48
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745

View file

@ -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)