Okay, so I’m trying to get the angle of two quaternions, and it almost works perfectly, but then it jumps from:
evec angle: 237.44999653311922
evec angle: 119.60001380112993
Can someone tell me how to work past this bug? This is the code to make the bug show up:
FloatBuffer fb = BufferUtils.createFloatBuffer(16);
// get the current modelview matrix
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, fb);
Matrix4f mvm = new Matrix4f();
mvm.load(fb);
Quaternion qmv2 = new Quaternion();
Matrix4f imvm = new Matrix4f();
Matrix4f.invert(mvm, imvm);
qmv2.setFromMatrix(imvm);
qmv2.normalise();
Matrix3f nil = new Matrix3f();
nil.setIdentity();
Quaternion qnil = new Quaternion();
qnil.setFromMatrix(nil);
qnil.normalise();
float radAngle = (float) (2.0 * Math.acos(Quaternion.dot(qmv2, qnil)));
System.out.println("evec angle: " + Math.toDegrees(radAngle));
Also if I call fb.flip() after glGetFloatv(), but before mvm.load(fb) I get this error:
Exception in thread "main" java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Unknown Source)
at java.nio.DirectFloatBufferU.get(Unknown Source)
at org.lwjgl.util.vector.Matrix4f.load(Matrix4f.java:187)
at NeroEdge.renderGL(NeroEdge.java:424)
at NeroEdge.run(NeroEdge.java:101)
at NeroEdge.main(NeroEdge.java:855)