From e241c7c9b150b3f844d64c7e95cbc1ad6e6479e0 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 17 May 2021 05:56:37 +0200 Subject: [PATCH] Added rotation on the z axis --- src/engine/math/Matrix4f.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/engine/math/Matrix4f.java b/src/engine/math/Matrix4f.java index 45fc12c..441237e 100644 --- a/src/engine/math/Matrix4f.java +++ b/src/engine/math/Matrix4f.java @@ -78,6 +78,21 @@ public class Matrix4f { 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){ Matrix4f result = new Matrix4f(); for (int y = 0; y< 4; y++){