Added rotation on the z axis

This commit is contained in:
Antoine 2021-05-17 05:56:37 +02:00
parent 4c7e32f44b
commit e241c7c9b1

View File

@ -78,6 +78,21 @@ public class Matrix4f {
return result; return result;
} }
public static Matrix4f rotateZ(float angle){
Matrix4f result = identity();
float r = (float) Math.toRadians(angle);
float cos = (float) Math.cos(angle);
float sin = (float) Math.sin(angle);
result.elements[0 + 0 * 4] = cos;
result.elements[1 + 0 * 4] = -sin;
result.elements[0 + 1 * 4] = sin;
result.elements[2 + 1 * 4] = cos;
return result;
}
public Matrix4f multiply(Matrix4f matrix){ public Matrix4f multiply(Matrix4f matrix){
Matrix4f result = new Matrix4f(); Matrix4f result = new Matrix4f();
for (int y = 0; y< 4; y++){ for (int y = 0; y< 4; y++){