Implement Transform methods

This commit is contained in:
2023-12-29 12:38:50 -05:00
parent 17718fa409
commit c3053ceb3a
2 changed files with 17 additions and 4 deletions

View File

@@ -100,10 +100,8 @@ namespace LinearAlgebra {
// Transforms the given vectors by this matrix M, i.e. returns M * (x,y,z)
Vector2 Transform(const Vector2& vector) const;
Vector2 Transform(const Vector2& rhs) const;
Vector3 Transform(const Vector3& rhs) const;
Vector2 Transform(float x, float y) const;
Vector3 Transform(float x, float y, float z) const;

View File

@@ -156,7 +156,22 @@ namespace LinearAlgebra {
m00, m10, m20,
m01, m11, m21,
m02, m12, m22
}
};
}
Vector2 Matrix3x3::Transform(const Vector2 &rhs) const {
return {
At(0,0) * rhs.x + At(0, 1) * rhs.y,
At(1, 0) * rhs.x + At(1, 1) * rhs.y
};
}
Vector3 Matrix3x3::Transform(const Vector3 &rhs) const {
return {
At(0, 0) * rhs.x + At(0, 1) * rhs.y + At(0, 2) * rhs.z,
At(1, 0) * rhs.x + At(1, 1) * rhs.y + At(1, 2) * rhs.z,
At(2, 0) * rhs.x + At(2, 1) * rhs.y + At(2, 2) * rhs.z
};
}
}