Math/Transform.cpp: use transform/scale/ratation functions from Math.h
This commit is contained in:
parent
a6e6b915e6
commit
a4a691fd48
1 changed files with 6 additions and 20 deletions
|
|
@ -52,11 +52,8 @@ Vector2f Transform::getRightVector() const
|
||||||
|
|
||||||
Transform& Transform::translate(float x, float y)
|
Transform& Transform::translate(float x, float y)
|
||||||
{
|
{
|
||||||
Transform t(1, 0, x,
|
m_matrix *= math::translate(x, y);
|
||||||
0, 1, y,
|
return *this;
|
||||||
0, 0, 1);
|
|
||||||
|
|
||||||
return combine(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform& Transform::translate(Vector2f vec)
|
Transform& Transform::translate(Vector2f vec)
|
||||||
|
|
@ -66,25 +63,14 @@ Transform& Transform::translate(Vector2f vec)
|
||||||
|
|
||||||
Transform& Transform::rotate(float theta)
|
Transform& Transform::rotate(float theta)
|
||||||
{
|
{
|
||||||
float a = math::deg2rad(theta);
|
m_matrix *= math::rotation(theta);
|
||||||
float c = std::cos(a);
|
return *this;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform& Transform::scale(float x, float y)
|
Transform& Transform::scale(float x, float y)
|
||||||
{
|
{
|
||||||
Transform s(x, 0, 0,
|
m_matrix *= math::scale(x, y);
|
||||||
0, y, 0,
|
return *this;
|
||||||
0, 0, 1);
|
|
||||||
|
|
||||||
return combine(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform& Transform::scale(Vector2f vec)
|
Transform& Transform::scale(Vector2f vec)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue