1
0
Fork 0

Math/Math: translate/scale functions should not accept vectors, but rather individual parameters.

This is "low level" functions. Used by other math classes/functions.
This commit is contained in:
Henrik Hautakoski 2020-02-12 19:42:50 +01:00
parent 18ea713445
commit 532c6dafaf
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
2 changed files with 9 additions and 9 deletions

View file

@ -36,10 +36,10 @@ namespace sp { namespace math
Matrix4f rotation(float theta);
// Create a 2D translation matrix.
Matrix4f translate(const Vector2f& v);
Matrix4f translate(float x, float y);
// Create a 2D scale matrix.
Matrix4f scale(const Vector2f& f);
Matrix4f scale(float x, float y);
// Get translation part of a matrix.
Vector3f getTranslate(const Matrix4f matrix);

View file

@ -60,21 +60,21 @@ namespace sp { namespace math
0.0f, 0.0f, 0.0f, 1.0f);
}
Matrix4f translate(const Vector2f& v) {
Matrix4f translate(float x, float y) {
return Matrix4f(
1.0f, 0.0f, 0.0f, v.x,
0.0f, 1.0f, 0.0f, v.y,
1.0f, 0.0f, 0.0f, x,
0.0f, 1.0f, 0.0f, y,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
}
Matrix4f scale(const Vector2f& f) {
Matrix4f scale(float x, float y) {
return Matrix4f(
f.x , 0.0f, 0.0f, 0.0f,
0.0f, f.y , 0.0f, 0.0f,
x , 0.0f, 0.0f, 0.0f,
0.0f, y , 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
}