Rotate camera around z

This commit is contained in:
Hanno Braun 2024-10-31 21:14:52 +01:00
parent 7c2bffcf2c
commit cbd4f9e216

View File

@ -217,6 +217,7 @@ impl Mat4x4 {
Self::perspective()
* Self::translation([0., 0., -2.])
* Self::rotation_x(PI / 4.)
* Self::rotation_z(PI / 4.)
}
pub fn perspective() -> Self {
@ -263,6 +264,19 @@ impl Mat4x4 {
],
}
}
pub fn rotation_z(angle: f32) -> Self {
let (sin, cos) = angle.sin_cos();
Self {
columns: [
[cos, -sin, 0., 0.],
[sin, cos, 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.],
],
}
}
}
impl Mul<Self> for Mat4x4 {