Hi,
I think the quat q in the method Transform3D.get(Quat4d q) is
incorrectly calculated.
I use this method to retrieve the current orientation of the
viewplatform which was modified earlier by an interpolator. I found out
that the calculated orientation is wrong in some cases. I found another
source for calculating the quat myself, but this way has another
problem(a division by zero), but if I use the Transform3D-method in this
case, it seems to work.
Here's my hack:
public static Quat4d calculateQuat(Transform3D transform)
{
Matrix4d matrix = new Matrix4d();
transform.get(matrix);
double[] q = new double[4];
double t = matrix.m00 + matrix.m11 + matrix.m22 + 1;
if(t != 0.0) {
t = t / 4;
q[3] = Math.sqrt(t);
q[0] = (matrix.m21 - matrix.m12) / (4 * q[3]);
q[1] = (matrix.m02 - matrix.m20) / (4 * q[3]);
q[2] = (matrix.m10 - matrix.m01) / (4 * q[3]);
}
else {
Quat4d jquat = new Quat4d();
transform.get(jquat);
return jquat;
}
Quat4d quat = new Quat4d(q);
return quat;
}
I'm sorry that I couldn't explain it better, because I do not completely
understand the mathematic background of quaternions.
Is there anyone able to tell me if I'm wrong(but I don't think so) or if
I found a bug?
Regards,
Chris
Chris Wewerka
[EMAIL PROTECTED]
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/