I'm trying to rotate a vertex using the lwjgl Matrix4f class. I tried this code:
float rotY = (float) Math.toRadians(180);
Matrix4f transMat = new Matrix4f();
transMat.rotate(rotY, new Vector3f(0.0f, 1.0f, 0.0f));
transMat.translate(new Vector3f(1.0f, 0.0f, 0.0f));
Vector4f vecPosMod = new Vector4f(1.0f, 0.0f, 0.0f, 1.0f);
Matrix4f.transform(transMat, vecPosMod, vecPosMod);
It should rotate a Vector3f(1.0f, 0.0f, 0.0f)
by 180 degrees but unfortunately after all calculations vecPosMod is (-2.0, 0.0, 1.7484555E-7, 1.0)
. I want it to be (-1.0, 0.0, 0.0, 1.0)
. How?