Added rotation on the x and y axis
This commit is contained in:
parent
565bc5edfe
commit
4c7e32f44b
@ -48,17 +48,32 @@ public class Matrix4f {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix4f rotate(float angle){
|
||||
public static Matrix4f rotateX(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[1 + 1 * 4] = cos;
|
||||
result.elements[2 + 1 * 4] = -sin;
|
||||
|
||||
result.elements[1 + 2 * 4] = sin;
|
||||
result.elements[2 + 2 * 4] = cos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix4f rotateY(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[2 + 0 * 4] = sin;
|
||||
|
||||
result.elements[0 + 1 * 4] = -sin;
|
||||
result.elements[1 + 1 * 4] = cos;
|
||||
result.elements[0 + 2 * 4] = -sin;
|
||||
result.elements[2 + 2 * 4] = cos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user