Thanks!
After reading a Math paper I ended up with the following code, which works quite nicely and solved my larger problem interfacing with OdeJava:
After reading a Math paper I ended up with the following code, which works quite nicely and solved my larger problem interfacing with OdeJava:
Code Select
protected Matrix Quat4fToMatrix(javax.vecmath.Quat4f input)
{
float[] MatrixDump = new float[16];
float xx = input.x * input.x;
float xy = input.x * input.y;
float xz = input.x * input.z;
float xw = input.x * input.w;
float yy = input.y * input.y;
float yz = input.y * input.z;
float yw = input.y * input.w;
float zz = input.z * input.z;
float zw = input.z * input.w;
MatrixDump[0] = 1 - 2 * ( yy + zz );
MatrixDump[4] = 2 * ( xy - zw );
MatrixDump[8] = 2 * ( xz + yw );
MatrixDump[1] = 2 * ( xy + zw );
MatrixDump[5] = 1 - 2 * ( xx + zz );
MatrixDump[9] = 2 * ( yz - xw );
MatrixDump[2] = 2 * ( xz - yw );
MatrixDump[6] = 2 * ( yz + xw );
MatrixDump[10] = 1 - 2 * ( xx + yy );
MatrixDump[15] = 1;
Matrix buffer = new Matrix();
buffer.setDump(MatrixDump);
return buffer;
}