Implement Matrix4x4::RotateX() RotateY() RotateZ()
This commit is contained in:
@@ -889,6 +889,49 @@ namespace J3ML::LinearAlgebra {
|
||||
return Matrix4x4::Translate(translate) * Matrix4x4(rotate) * Matrix4x4::Scale(scale);
|
||||
}
|
||||
|
||||
void Matrix4x4::SetCol3(int col, float x, float y, float z) {
|
||||
// TODO: implement assertations
|
||||
At(0, col) = x;
|
||||
At(1, col) = y;
|
||||
At(2, col) = z;
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RotateZ(float radians) {
|
||||
Matrix4x4 r;
|
||||
r.SetRotatePartZ(radians);
|
||||
r.SetRow(3, 0, 0, 0, 1);
|
||||
r.SetCol3(3, 0, 0, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RotateZ(float radians, const Vector3 &pointOnAxis) {
|
||||
return Matrix4x4::Translate(pointOnAxis) * RotateY(radians) * Matrix4x4::Translate(-pointOnAxis);
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RotateY(float radians) {
|
||||
Matrix4x4 r;
|
||||
r.SetRotatePartY(radians);
|
||||
r.SetRow(3, 0, 0, 0, 1);
|
||||
r.SetCol3(3, 0, 0, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RotateY(float radians, const Vector3 &pointOnAxis) {
|
||||
return Matrix4x4::Translate(pointOnAxis) * RotateY(radians) * Matrix4x4::Translate(-pointOnAxis);
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RotateX(float radians) {
|
||||
Matrix4x4 r;
|
||||
r.SetRotatePartX(radians);
|
||||
r.SetRow(3, 0, 0, 0, 1);
|
||||
r.SetCol3(3, 0, 0, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RotateX(float radians, const Vector3 &pointOnAxis) {
|
||||
return Matrix4x4::Translate(pointOnAxis) * RotateX(radians) * Matrix4x4::Translate(-pointOnAxis);
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::Scale(const Vector3 &scale) {
|
||||
Matrix4x4 m;
|
||||
m.SetRow(0, scale.x, 0, 0, 0);
|
||||
|
Reference in New Issue
Block a user