I think that this is an area where the Java3D team have, for one reason or
another, ignored the conventional approach and it seems to lead to more
questions over the months, that any other.

The transform3D can handle a rotation about an arbitrary axis.  The methods
for setting it up cannot [or couldn't last time I looked (well you can push
the values into the matrix yourself...)].  These easiest way is then to set
up three transforms (shift, rotation, shift) and then combine them before
using the resulting transform.  All standard text book stuff but it could
have been made much easier.

Actually there ARE uses of quaternions that can do clever things to help but
NOT as simple as vector X Y Z and angle!  Glib references in documentation
expecting people to know about quaternions doesn't help as these are a
general mathematical concept and the specific usage in context needs to be
made clear.

However, where the rotation that you want is not an internal application
usage but part of your UI and is therefore to be applied via the mouse then
things are easier! [well different!]  After all you don't need to apply the
mouse behaviour to your bottom level entity.

The shift, rotate, shift can be represented by tree layers of transform and
you can attach the mouse behaviour to the middle one.  (actually this can be
reduced to two - a shift and rotation and a separate shift.

Have fun

        Alex



-----Original Message-----
From:   Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]]
On Behalf Of Kynn Jones
Sent:   27 June 2001 07:56
To:     [EMAIL PROTECTED]
Subject:        Re: [JAVA3D] [Q] Mouse-rotation around fixed arbitrary axis

I think you have misunderstood me.  I do not "want quaternions" (I am
quite familiar with them in any case).  What I want is code that does
for fixed-axis rotations what MouseRotate does for rotations around a
single point.  (I think I can write such code myself, but I would
prefer to use something that has already been debugged and tested.)

KJ


   Date:         Wed, 27 Jun 2001 13:44:46 +0800
   From: Chris Thorne <[EMAIL PROTECTED]>

   So you want quaternions: where you specify a vector (axis) [X Y Z] and an
angle W to
   rotate about the axis.
   I don't have this code (I'm sure a few on this list do) but you can look
at:
   http://www.cs.berkeley.edu/~laura/cs184/quat/quaternion.html
   http://skal.planet-d.net/demo/matrixfaq.htm#Q45

   This bit seems to be what you want:

   Q47. How do I convert a quaternion to a rotation matrix?
   --------------------------------------------------------

     Assuming that a quaternion has been created in the form:

       Q = |X Y Z W|

     Then the quaternion can then be converted into a 4x4 rotation
     matrix using the following expression:


           |       2     2                                |
           | 1 - 2Y  - 2Z    2XY - 2ZW      2XZ + 2YW     |
           |                                              |
           |                       2     2                |
       M = | 2XY + 2ZW       1 - 2X  - 2Z   2YZ - 2XW     |
           |                                              |
           |                                      2     2 |
           | 2XZ - 2YW       2YZ + 2XW      1 - 2X  - 2Y  |
           |                                              |


     If a 4x4 matrix is required, then the bottom row and right-most column
     may be added.

     The matrix may be generated using the following expression:

       ----------------

       xx      = X * X;
       xy      = X * Y;
       xz      = X * Z;
       xw      = X * W;

       yy      = Y * Y;
       yz      = Y * Z;
       yw      = Y * W;

       zz      = Z * Z;
       zw      = Z * W;

       mat[0]  = 1 - 2 * ( yy + zz );
       mat[1]  =     2 * ( xy - zw );
       mat[2]  =     2 * ( xz + yw );

       mat[4]  =     2 * ( xy + zw );
       mat[5]  = 1 - 2 * ( xx + zz );
       mat[6]  =     2 * ( yz - xw );

       mat[8]  =     2 * ( xz - yw );
       mat[9]  =     2 * ( yz + xw );
       mat[10] = 1 - 2 * ( xx + yy );

       mat[3]  = mat[7] = mat[11 = mat[12] = mat[13] = mat[14] = 0;
       mat[15] = 1;

       ----------------



   Chris





   -------------------------------------------------------------------------
---
   -------------------------------------------------------------------------
---
   This Email may contain confidential and/or privileged information and is
   intended solely for the addressee(s) named. If you have received this
   information in error, or are advised that you have been posted this Email
by
   accident, please notify the sender by return Email, do not redistribute
it,
   delete the Email and keep no copies.


===========================================================================
   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".

===========================================================================
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".

Reply via email to