Hi,
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
used
transx.rotX(anglex);
transy.rotX(angley);
transz.rotX(anglez);
trans4m.set(transx);
trans4m.mul(transy);
trans4m.mul(transz);
transformGroup.setTransform(trans4m);
trans4m.mul(transy);
trans4m.mul(transz);
transformGroup.setTransform(trans4m);
which caused gimbal
lock
I then tried to use
public 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);
}
{
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.
regards
Stuart Cavill
email: S[EMAIL PROTECTED]