Vladimir,
As I said...
DS> I wouldn't claim to be
DS> able to explain the details of the algorithm off the top of my head, so
if
DS> you have questions or issues I suggest you consult the FAQ and your
nearest
DS> friendly mathematician (always a good person to know!).
We have used the code below in the following situation:
The user can interactively rotate an object in the 3D scene using a
MouseRotateBehavior. Once the user finishes rotating the object we display
the X, Y, Z rotation angles for the object in its new position in a JPanel.
I haven't noticed anything wrong with the method, the values returned "make
sense", and if you *reapply* the values to the object's Transform3D using
rotX etc. the object's rotation is unchanged.
I may not be a mathematician, but I know enough about mathematics to know
not to answer a question like:
"Hey, Daniel, does this really work in ANY case?"
;-)
It was good enough for our purposes, other people's mileage may vary.
Sincerely,
Daniel Selman
[EMAIL PROTECTED]
http://www.tornadolabs.com
-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Vladimir Olenin
Sent: 03 December 1999 10:27
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] getting rotation angles from transform3D: does
this really work?
Hey, Daniel, does this really work in ANY case? Correct me if i'm
wrong, but wouldn't this code work ONLY in case the figure was rotated
ONCE only around each axis? As soon as we apply one more rotation to
(RotX * RotY * RotZ) matrix, the value in (2, 0) cell, where normally
sin(yAngle) IS stored, could definitely change to some other value
(multiple of sin(yAngle) to cos(yAngle2), etc). At least this can be
concluded from the way the final rotation matrix is formed.
Does this code REALLY works in ABSOLUTELY ANY case? (That's have u
tested it?) Even if u do several _consequent_ (without loosing the
initial rotation) rotations around each axis?
vladimir
-=V=-
>-------<=============>-------<
Join in Java community now!
http://JavaCafe.VirtualAve.net/
>-------<=============>-------<
In your previous letter u wrote:
--------------------------------
DS> Eric,
DS> As was pointed out (several times) this is a tricky topic, but here is
some
DS> code that we have used successfully. The code is based on an algorithm
from
DS> the Matrix and Quaternion FAQ (search the web). I have posted this code
to
DS> the list before.
DS> The M+Q FAQ is an excellent reference for these types of questions, as
no
DS> one can remember this kind of thing for very long! I wouldn't claim to
be
DS> able to explain the details of the algorithm off the top of my head, so
if
DS> you have questions or issues I suggest you consult the FAQ and your
nearest
DS> friendly mathematician (always a good person to know!).
DS> Note that the return value is three rotation angles *in radians*. You
can
DS> ignore (or better, implement!) the ASSERT methods. As you can see the
method
DS> is peppered with trigonometric functions, so I wouldn't go using it on
every
DS> frame or anything... Now, who would go and do a thing like that! Mr.
DS> Billboard behavior. ;-)
DS> Sincerely,
DS> Daniel Selman
DS> [EMAIL PROTECTED]
DS> http://www.tornadolabs.com
DS> static Point3d GetEulerRotation( Transform3D t3d )
DS> {
DS> Point3d Rotation = new Point3d();
DS> Matrix3d m1 = new Matrix3d();
DS> t3d.get( m1 );
DS> // extract the rotation angles from the upper 3x3 rotation
DS> // component of the 4x4 transformation matrix
DS> Rotation.y = -java.lang.Math.asin( m1.getElement( 2, 0 ) );
DS> double c = java.lang.Math.cos( Rotation.y );
DS> double tRx, tRy, tRz;
DS> if( java.lang.Math.abs( Rotation.y ) > 0.00001 )
DS> {
DS> tRx = m1.getElement( 2, 2 ) / c;
DS> tRy = -m1.getElement( 2, 1 ) / c;
DS> Rotation.x = java.lang.Math.atan2( tRy, tRx );
DS> tRx = m1.getElement( 0, 0 ) / c;
DS> tRy = -m1.getElement( 1, 0 ) / c;
DS> Rotation.z = java.lang.Math.atan2( tRy, tRx );
DS> }
DS> else
DS> {
DS> Rotation.x = 0.0;
DS> tRx = m1.getElement( 1, 1 );
DS> tRy = m1.getElement( 0, 1 );
DS> Rotation.z = java.lang.Math.atan2( tRy, tRx );
DS> }
DS> Rotation.x = -Rotation.x;
DS> Rotation.z = -Rotation.z;
DS> // now try to ensure that the values are positive by adding 2PI
if
DS> necessary...
DS> if( Rotation.x < 0.0 )
DS> Rotation.x += 2 * java.lang.Math.PI;
DS> if( Rotation.y < 0.0 )
DS> Rotation.y += 2 * java.lang.Math.PI;
DS> if( Rotation.z < 0.0 )
DS> Rotation.z += 2 * java.lang.Math.PI;
DS> ASSERT( Rotation.x >= 0.0 && Rotation.x <= 2 *
java.lang.Math.PI );
DS> ASSERT( Rotation.y >= 0.0 && Rotation.y <= 2 *
java.lang.Math.PI );
DS> ASSERT( Rotation.z >= 0.0 && Rotation.z <= 2 *
java.lang.Math.PI );
DS> return Rotation;
DS> }
DS> -----Original Message-----
DS> From: Discussion list for Java 3D API
DS> [mailto:[EMAIL PROTECTED]]On Behalf Of Eric Reiss
DS> Sent: 03 December 1999 01:40
DS> To: [EMAIL PROTECTED]
DS> Subject: [JAVA3D] geting rotation angles from transform3D
DS> I was wondering if you ever got an answer to the question you posted to
the
DS> list:
DS> "Is there a way to determine the exact rotation angles for each axes
from a
DS> given Transform3D?"
DS> This seems to be a common issue and I am fighting with it now.
DS> ***********************************************************************
DS> Eric Reiss - http://www.sigda.acm.org/Eric/
DS> Email: [EMAIL PROTECTED]
DS> SIGDA Internet Server Manager - http://www.sigda.acm.org/
DS> Assistant Systems Manager - School of Engineering
DS> University of Pittsburgh
DS> ***********************************************************************
DS>
===========================================================================
DS> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
DS> of the message "signoff JAVA3D-INTEREST". For general help, send email
to
DS> [EMAIL PROTECTED] and include in the body of the message "help".
DS>
===========================================================================
DS> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
DS> of the message "signoff JAVA3D-INTEREST". For general help, send email
to
DS> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
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".
===========================================================================
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".