Hi,
I
think maybe the way you create the Quat4f is not correct.
This
code works fine in my application:
public
void setRotation(float[] rotation)
{
/*Converts rotation angles into quaternions*/
axisAngleX.set(1.0f, 0.0f, 0.0f, (float)Math.toRadians(rotation[0]));
quatX.set(axisAngleX);
axisAngleY.set(0.0f, 1.0f, 0.0f, (float)Math.toRadians(rotation[1] ));
quatY.set(axisAngleY);
axisAngleZ.set(0.0f, 0.0f, 1.0f, (float)Math.toRadians(rotation[2]));
quatZ.set(axisAngleZ);
quat.mul(quatY,quatX);
quat.mul(quatZ);
transform3D.setRotation(quat);
/*Converts rotation angles into quaternions*/
axisAngleX.set(1.0f, 0.0f, 0.0f, (float)Math.toRadians(rotation[0]));
quatX.set(axisAngleX);
axisAngleY.set(0.0f, 1.0f, 0.0f, (float)Math.toRadians(rotation[1] ));
quatY.set(axisAngleY);
axisAngleZ.set(0.0f, 0.0f, 1.0f, (float)Math.toRadians(rotation[2]));
quatZ.set(axisAngleZ);
quat.mul(quatY,quatX);
quat.mul(quatZ);
transform3D.setRotation(quat);
}
Hope
it helps,
Regards
Asle
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".-----Original Message-----
From: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]On Behalf Of Cavill, SA (Stuart)
Sent: 25. august 2004 15:19
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Gimbal lockHi,I'm having problems with Gimbal Lock in my JAVA 3D code ( all I need to do is rotate a simple cube in 3 dimensions).I initially usedtransx.rotX(anglex);transy.rotX(angley);transz.rotX(anglez);trans4m.set(transx);
trans4m.mul(transy);
trans4m.mul(transz);
transformGroup.setTransform(trans4m);which caused gimbal lockI then tried to usepublic Quat4f setQ(float pitch, float yaw, float roll)
{
Quat4f qx =new Quat4f((float) Math.cos(pitch/2f),(float)Math.sin(pitch/2f),0,0);
Quat4f qy =new Quat4f((float) Math.cos(yaw/2f),0,(float)Math.sin(yaw/2f),0);
Quat4f qz =new Quat4f((float) Math.cos(roll/2f),0,0,(float)Math.sin(roll/2f));
Quat4f qt =new Quat4f();
qt.set(qx);
qt.mul(qy);
qt.mul(qz);
return(qt);
}trans4m.set(q2);transformGroup.setTransform(trans4m);but again gimbal lock occurred.I would appreciate any comments on what I am doing wrong or seeing an example of the correct way to go about this problem without gimbal lock occurring.Any help would be greatly appreciated.regardsStuart Cavillemail: S[EMAIL PROTECTED]
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".