Hello!
I try to write a class that implements the mouseinterfaces. When the user moves the mouse the camera should update its viewing-angel.
To develop this I use a colorcube as stand in for the camera. I update the colorcubes angel at X and Y axles.
But now I have a problem when I try to update both the angel for looking up/down and looking left/right. I end up with a unwanted rotation around the Z-axle.
I attach my class for this. You should be able to just compile and test it.
I have "/* */" the code for rotating the cube in left to right. So when you try it it will just update the angel for looking up and down. When you enter the mouse it helps if you enters the mouse between 0 - 199 at Y-axel.
Uncomment the code for looking left to right and se what happens. It will also be a unwanted rotation around the z-axle.
So any help to solve this unwanted rotation around the z-axle would be great. Also suggestions for a better idee for this is appreciated.
Best regards Fredrik
=========================================================================== 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".
This is a common problem with Euler angles. For anything except simple rotations around an axis, they quickly become hard to wrok with.
You may want to investigate quaternions. There are Quat4f and Quat4d classes in J3D to help you. Quaternions let you rotate around any arbitrary axis and are the preferred way to implement complex rotations.
If v is a unit vector you want to rotate around by A degrees, then do:
Vector3d myAxis = new Vector3d(1, 1, 1); myAxis.normalize(); double sinA = Math.sin(A); double cosA = Math.cos(A); Quat4d myRot = new Quat4d(sinA * myAxis.x, sinA * myAxis.y, sinA * myAxis.z, cosA);
Plug this into a Transform3D, and you will be able to rotate by A degrees around (1, 1, 1).
Mark McKay
=========================================================================== 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".