Hi Amund,
matrix4f.rotY(angle);
does some thing like the following:
public final void rotY(float angle)  {
     float c = (float)Math.cos(angle);
     float s = (float)Math.sin(angle);
     m00 = c;      m01 = 0.0f; m02 = s;      m03 = 0.0f;
     m10 = 0.0f;  m11 = 1.0f; m12 = 0.0f;  m13 = 0.0f;
     m20 = -s;     m21 = 0.0f; m22 = c;      m23 = 0.0f;
     m30 = 0.0f;  m31 = 0.0f; m32 = 0.0f;  m33 = 1.0f;
}

as you can see m03, m13, m23 are reset to zero after this call. I have
attached a little doc that I had written which could
help you get a better understanding of Matrices. I definitely suggest that
you read it, but the general solution would be to
multiply another matrix that is at the origin and has the rotation that you
want into your moonMat.
delta.rotY(5 * PI/ 180);
moonMat.mul(delta);
(see the doc)

Take Care,
--------------------------------------------------------------------------
Syrus Mesdaghi              Fullsail Real World Education
3D Gaming instructor      Winter Park, FL
[EMAIL PROTECTED]       www.fullsail.com
--------------------------------------------------------------------------


----- Original Message -----
From: "Adriano Cavalcanti" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 29, 2001 3:24 AM
Subject: Re: [JAVA3D] Question about Rotations


> I have an example about it, but it's in OpenGL - C. If you find
interesting, I
> could send to you. :-)
>
> Zak schrieb:
>
> > I am trying to place an object in its own Locale at (2,2,2). Now I place
a
> > Rotation Interpolator on it and it goes to (0,0,0) and rotates.
> > I want to simulate the moon rotating on its own(in its own Locale), the
> > earth rotating on its own in its own Locale, while in the Universe
Locale.
> > Can I get the RoationInterpolator to Interpoloate on the Locale
Coordinate
> > System?
> >
> > Amund Ricto
> >
> >
===========================================================================
> > 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".



Important concepts that help you understand this documentation:

    NOTE:  the fields of matrices used in vecMath library are as follow
        m00 m01 m02 m03
        m10 m11 m12 m13
        m20 m21 m22 m23
        m30 m31 m32 m33

       in other matrix may be implemented based on column-first format instead.
        m00 m10 m20 m30
        m01 m11 m21 m31
        m02 m12 m22 m32
        m03 m13 m23 m33



    1) Assume that entityMat and delta are pointers to matrix4d:

        matrix4d    entityMat,
                    delta;



    2) entityMat.setIdentity();         resets the values in entityMat to become  1 0 
0 0
                                                                                  0 1 
0 0
                                                                                  0 0 
1 0
                                                                                  0 0 
0 1

       the Identity Matrix, represent a matrix that is at the origin (x = 0, y = 0, z 
= 0),
       has no scale (or skew), and is oriented in such way that its Y axis in up, X 
axis to the right, 
       and z axis along the Normal Vector of the screen (coming out of the screen). 
such orientation 
       is aligned with the Global axis. please note that GameCAD's Global axis are as 
follow:
            X positive is to the right
            Y positive is up
            Z positive is Out of screen 

       where as in Multigen/Creator, the global axis are:
            X positive is to the right
            Y positive is into the screen
            Z positive is up 




    3) there are 16 fields in a matrix4d object, as I mentioned, the values in an 
Identity Matrix
       are as follow:
       
           1 0 0 0
           0 1 0 0
           0 0 1 0
           0 0 0 1

       each on of these numbers are of type double. in order to change the values in a 
matrix directly,
       you have to modify the value of one or more variables that exist in the class 
matrix4d.  the name
       of these variables are m01, m02, ... m33.  the following diagram show the name 
of the variables and
       what they represent in the matrix.



                            1 (m00)         0 (m01)         0 (m02)         0 (m03)  
                              (X.x r&s)       (Y.x r&s)       (Z.x r&s)       (X 
position)


                            0 (m10)         1 (m11)         0 (m12)         0 (m13)  
                              (X.y r&s)       (Y.y r&s)       (Z.y r&s)       (Y 
position)


                            0 (m20)         0 (m21)         1 (m22)         0 (m23)
                              (X.z r&s)       (Y.z r&s)       (Z.z r&s)       (Z 
position)


                            0 (m30)         0 (m31)         0 (m32)         1 (m33)
                              (remains 0)     (remains 0)     (remains 0)     (remains 
1)



    to illustrate the values in an identity matrix lets try to write down the 
coordinates
    of the tip of each lines below. lets assume the intersection of the three lines to 
be 
    at  x=0, y=0, z=0 and that the length of each line is exactly 1. keep in mind that 
X 
    positive is to the right, Y positive is up, and that Z positive is Out of screen 
(the 
    slanted line represents a line coming out of the screen). 

             *2  
             |  
             |
             |
            / -----*1  
          /
         *3 

        *1 : x=1, y=0, z=0  :   1 0 0
        *2 : x=0, y=1, z=0  :   0 1 0
        *3 : x=0, y=0, z=1  :   0 0 1
    
    as you can see these values are the same as the upper left (3x3) values in an 
identity 
    matrix which represent it's Rotation and Scale (r&s). since we assumed that the
    intersection of the three lines are at 0,0,0 , we can place these values to the 
right of
    the values we have. we can also insert the bottom row that should not be touched.

    1 0 0  0(x position, m03)
    0 1 0  0(y position, m13) 
    0 0 1  0(z position, m23)

    0 0 0  1  (this row should remain untouched)






    lets see how we can manipulate a matrix:

    
    IMPORTANT:
    * the order in which you perform your translations and rotation can result in 
completely 
    * different results

    * It is very important that you set a matrix to identity when needed. Not paying 
attention to 
    * to this fact can introduce very tough BUGS!

    * All vecmath functions are based on radians. In order to convert dx from degrees 
to radians
    * you can:   (dx * PI)/ 180                In order to convert dx from radians to 
degrees
    * you can:   (dx * 180)/ PI                where PI = 3.14159 

    


    1) Translation:
       ============
        a) Global:
            if entityMat is the matrix of the model,  
                entityMat.m03 += 1         will move the object closer to the right 
edge of the monitor
                entityMat.m13 += 1         will move the object closer to the top   
edge of the monitor
                entityMat.m23 += 1         will move the object closer to our eye


        b) Local:
            if delta is a temporary matrix,  
                delta.m03 += 1         will move the object 1 unit in it's x-positive 
direction
                delta.m13 += 1         will move the object 1 unit in it's y-positive 
direction
                delta.m23 += 1         will move the object 1 unit in it's z-positive 
direction

                (Note that the above calls were global transformation for delta)

            now, we should multiply delta by entityMat in order to cause entityMat to 
transform locally 
                entityMat.mul(delta); 



    2) Rotation:
       =========
       * Note that when calling rotX, rotY, and rotZ the fields of the matrix will be 
set to 
       * thoss of an identity matrix.  After calling delta.rotX(.f), the delta will 
seem to 
       * be set to identity and then rotated 0.1 radians.
       *  
       * It is very important that you set a matrix to identity when needed. Not 
paying attention to 
       * to this fact can introduce very tough BUGS!

       Note: the order by which you multiply two matrices determines whether the 
rotation is local or global 

        a) Global:
            delta.rotY(.5);
            delta.mul(entityMat);
            entityMat.set(delta);

            Note:  the reason why I did not say entityMat.rotY(.5) is because, the 
rotY() method
                   rotates the matrix BUT resets any other current information in the 
matrix. for example,
                   if you also had rotation around X, it would be reset when you call 
rotY()


        b) Local:
            delta.rotY(.5);
            entityMat.mul(delta);



    3) Scale:
       ======
        a) Global:
           the following block causes the entityMat to Scale up Globally with respect 
to Z-axis
                entityMat.m20 *= 1.25;
                entityMat.m21 *= 1.25;
                entityMat.m22 *= 1.25;

           the following block causes the entityMat to Scale Down Globally with 
respect to X-axis
                entityMat.m00 *= 0.8;
                entityMat.m01 *= 0.8;
                entityMat.m02 *= 0.8;


        b) Local:
           the following block causes the entityMat to Scale up Locally with respect 
to Z-axis:
                entityMat.m02 *= 1.25;
                entityMat.m12 *= 1.25;
                entityMat.m22 *= 1.25;

           the following block causes the entityMat to Scale down Locally with respect 
to Y-axis:
                entityMat.m01 *= 0.8;
                entityMat.m11 *= 0.8;
                entityMat.m21 *= 0.8;




********************************************************************************************************

    if you have any questions/corrections you can e-mail me:
    Syrus Mesdaghi
    [EMAIL PROTECTED]

********************************************************************************************************



Reply via email to