# Rotate LWJGL 2 Vector4f by an angle around an axis

There is a method in LWJGL 2 to get the rotation Matrix around an axis with a certain angle- Matrix4f.rotate(angle, axis, dest, src). Is there a similar way to rotate a Vector4f around a Vector3f or Vector4f? What can I do to rotate around 2 axes? I am implementing an FPS Camera

What you will need to do is use LWJGL's Matrix4f.transform() method to transform your Vector4f by using a matrix with rotation information. This method takes in a Matrix4f and a vector. The vector can be whatever you want, but the matrix is what you really care about. You'll have to use LWJGL's rotate methods to rotate the matrix along whatever axis you want. On a side note, you can also do translations and scaling and other stuff as well. Once the matrix is done, you can transform your Vector4f using the matrix. Here's a quick demo

Vector4f toTransform = new Vector4f(0, 1, 0, 1);
Matrix4f matrix = new Matrix4f;
float rx = 90; //x axis rot in degrees
float ry = 0; //y axis rot
float rz = 0; //z axis rot
matrix.setIndentity();
Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1, 0, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0, 1, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0, 0, 1), matrix, matrix);
Vector4f rotated = matrix.transform(matrix, toTransform, toTransform);
Vector3f vec3 = new Vector3f(rotated.x, rotated.y, rotated.z);
etc..

System.out.println(rotated);


Outputs Vector4f[0, 0 (very small number), 1, 1], which is correct.