what is the matrix ?

what is the matrix ?

Post by Raymond Pan » Mon, 10 Jan 2000 04:00:00



Dear all,

        What is the matrix form of rotation about a vector ?
For example, I would like to rotate A degree about vector (x,y,z) , what

is the matrix to do this ?
        I do know the matrix form for rotate about x, y or z axis, but I

had done my best to think and find the above one, and failed. I think it

will not be too difficult. Please help.

Thanks ,
Raymond Pang

 
 
 

what is the matrix ?

Post by SoRe » Mon, 10 Jan 2000 04:00:00



> Dear all,

>         What is the matrix form of rotation about a vector ?
> For example, I would like to rotate A degree about vector (x,y,z) , what

> is the matrix to do this ?
>         I do know the matrix form for rotate about x, y or z axis, but I

> had done my best to think and find the above one, and failed. I think it

with opengl I think you can use glRotate(angle,x,y,z)
where angle is the rotation angle and x,y,z your vector.
--
~
Luca 'Sore' Marchetti
ICQ  52464923



 
 
 

what is the matrix ?

Post by Hexide » Mon, 10 Jan 2000 04:00:00


Not sure if this is what you're after, since it seems a bit of a hack,
but there's notes about arbitrary axis rotation at:

http://www.maths.bath.ac.uk/~pjw/NOTES/graphics/node60.html

Howard Kistler



Quote:>Dear all,

>        What is the matrix form of rotation about a vector ?
>For example, I would like to rotate A degree about vector (x,y,z) , what

>is the matrix to do this ?
>        I do know the matrix form for rotate about x, y or z axis, but I

>had done my best to think and find the above one, and failed. I think it

>will not be too difficult. Please help.

>Thanks ,
>Raymond Pang

 
 
 

what is the matrix ?

Post by fungu » Mon, 10 Jan 2000 04:00:00



> Dear all,

>         What is the matrix form of rotation about a vector ?
> For example, I would like to rotate A degree about vector (x,y,z) , what

> is the matrix to do this ?
>         I do know the matrix form for rotate about x, y or z axis, but I

> had done my best to think and find the above one, and failed. I think it

> will not be too difficult. Please help.

Find the source code for mesa OpenGL...

--
<\___/>
/ O O \
\_____/  FTB.

 
 
 

what is the matrix ?

Post by Brett Keatin » Tue, 11 Jan 2000 04:00:00


Unfortunately, nobody can be told what the matrix is. However, if you eat
this pill I can show you...
 
 
 

what is the matrix ?

Post by Arndt Teiner » Tue, 11 Jan 2000 04:00:00




> > Dear all,

> >         What is the matrix form of rotation about a vector ?
> > For example, I would like to rotate A degree about vector (x,y,z) , what

> > is the matrix to do this ?
> >         I do know the matrix form for rotate about x, y or z axis, but I

> > had done my best to think and find the above one, and failed. I think it

> with opengl I think you can use glRotate(angle,x,y,z)
> where angle is the rotation angle and x,y,z your vector.
> --

this will rotate all objects around a vector (line) from the origin
(0,0,0) to the point x,y,z. in the case a rotation around a vector
(line) from x1,y1,z1 to x2,y2,z2 first translate then rotate:

glTranslate(x1,y1,z1)
glRotate(angle,x2,y2,z2)

 
 
 

what is the matrix ?

Post by Shane Lowr » Wed, 12 Jan 2000 04:00:00


somebody had to say it ... hehe

Shane
db_wolf

 
 
 

what is the matrix ?

Post by Johannes Gustafsso » Wed, 12 Jan 2000 04:00:00


I belive that the original question was how to construct the rotationmatrix
for it, not how to use an API-call.
Actually, I would like to know that to! :-)

/Johannes

 
 
 

what is the matrix ?

Post by T. Burg » Wed, 12 Jan 2000 04:00:00



> I belive that the original question was how to construct the rotationmatrix
> for it, not how to use an API-call.
> Actually, I would like to know that to! :-)

> /Johannes

I think this should work to create a rotation transformation that
carries a point a given angle around a given vector.  In this case a
vector named ptline.  Also check the handedness of your coordinate
system which will affect the plus and minus signs used.  The code below
was modified for a left-handed setup.  It's been a while since I wrote
this, so hopefully I got a good rev of the code:

   /* Calculate angle theta. */
   a = ((double)angle)*(PI/180.0);
   sina = sinf(a);
   cosa = cosf(a);

   l =
sqrt(ptLine[0]*ptLine[0]+ptLine[1]*ptLine[1]+ptLine[2]*ptLine[2]);
   if (l==0.0)
      return 1;  
   u1 = ptLine[X]/l;
   u2 = ptLine[Y]/l;
   u3 = ptLine[Z]/l;

   /* Should combine some multiplications in the code below. */
   matTrans[0][0] = u1*u1+cosa*(1-u1*u1);
   matTrans[0][1] = u1*u2*(1-cosa)+u3*sina;/* Note [FAUX79] had -sina.
*/
   matTrans[0][2] = u3*u1*(1-cosa)-u2*sina;/* Note [FAUX79] had +sina.
*/

   matTrans[1][0] = u1*u2*(1-cosa)-u3*sina;/* Note [FAUX79] had +sina.
*/
   matTrans[1][1] = u2*u2+cosa*(1-u2*u2);
   matTrans[1][2] = u2*u3*(1-cosa)+u1*sina;/* Note [FAUX79] had -sina.
*/

   matTrans[2][0] = u3*u1*(1-cosa)+u2*sina;/* Note [FAUX79] had -sina.
*/
   matTrans[2][1] = u2*u3*(1-cosa)-u1*sina;/* Note [FAUX79] had +sina.
*/
   matTrans[2][2] = u3*u3+cosa*(1-u3*u3);

   matTrans[0][3] = 0.0;
   matTrans[1][3] = 0.0;
   matTrans[2][3] = 0.0;

   matTrans[3][0] = 0.0;
   matTrans[3][1] = 0.0;
   matTrans[3][2] = 0.0;
   matTrans[3][3] = 1.0;

 
 
 

what is the matrix ?

Post by Andreas Bau » Thu, 13 Jan 2000 04:00:00



Quote:> Unfortunately, nobody can be told what the matrix is. However, if you eat
> this pill I can show you...

Darn... You beat me to it :)

--
 ----
    -----------------------------------------------------------------------
[Insert joke here.]                                                       ----
                                                                             --

 
 
 

what is the matrix ?

Post by fungu » Thu, 13 Jan 2000 04:00:00



> I belive that the original question was how to construct the rotationmatrix
> for it, not how to use an API-call.
> Actually, I would like to know that to! :-)

Why don't you download the source code for MESA?

--
<\___/>
/ O O \
\_____/  FTB.

 
 
 

what is the matrix ?

Post by Jukka Liimatt » Fri, 14 Jan 2000 04:00:00


Quote:> Unfortunately, nobody can be told what the matrix is. However, if you eat
> this pill I can show you...

Or, unfortunately, no one can be told what the matrix is. You have to RTFM
yourself. =^)

-jukka

 
 
 

what is the matrix ?

Post by jup » Sat, 15 Jan 2000 04:00:00



> Dear all,

>         What is the matrix form of rotation about a vector ?
> For example, I would like to rotate A degree about vector (x,y,z) , what

> is the matrix to do this ?
>         I do know the matrix form for rotate about x, y or z axis, but I

> had done my best to think and find the above one, and failed. I think it

> will not be too difficult. Please help.

> Thanks ,
> Raymond Pang

hi,
have a look at this page it might be helpfull

http://www.flipcode.com/documents/matrfaq.html

                      __
                     / /    __  _  _  _  _ __  __
                    / /__  / / / \// //_// \ \/ /           -o)
                   /____/ /_/ /_/\/ /___/  /_/\_\           /\\
                    ...for IQs GREATER than 98...          _\_v-

 
 
 

what is the matrix ?

Post by Richard John Cavel » Sun, 16 Jan 2000 04:00:00


Sorry, can't find the original thread, but I thought I could help.


> >         What is the matrix form of rotation about a vector ?

Firstly, let's understand that to rotate about a vector, you are actually
rotating along the surface of the plane perpendicular to that vector.  And
you are implicitly rotating about the origin.  The vector can only specify
direction, not position.  If you wish to rotate about any arbitrary point,
obviously you need to transform before and after the rotation about the
origin. But in any case this problem is : Rotate about the origin
within the plane perpendicular to (x,y,z).  I'm assuming that the point is
actually within that plane.  If it's not, then you should find the
simultaneous equation of the plane and the point's projection onto that
plane, to make it so.

Quote:> > For example, I would like to rotate A degree about vector (x,y,z) , what

> > is the matrix to do this ?
> >         I do know the matrix form for rotate about x, y or z axis, but I

> > had done my best to think and find the above one, and failed. I think it

> > will not be too difficult. Please help.

There is a matrix to do this, and I don't have it to hand.  But it is
derived from the common-sense method -

The vector defines the normal to a plane.  You are rotating on the surface
of that plane.  So you should transform your point from normal coordinates
into coordinates which transform the (x,y,z) plane into the xy plane (ie
z=0).

Now you have a new two-dimensional coordinate system where the z-axis is
perpendicular to the plane about which you rotate.  Note that the
z-dimension of your point must be zero (remember your point is on the
plane about which you are rotating - and if it's not then you need to
handle it separately, or else do the transform outside the rotate as I
suggested.

You then rotate about the z-axis using the conventional 2x2 matrix, then
transform the x and y coordinates back to the original coordinate system
again.  Separately, transform your z-coordinate back into normal
coordinates if your point wasn't on the original plane.

I don't know how to optimize this, but I'm sure it would be delightful
fun.  When you transform the points, you would shear rather than
calculate the plane equation.  All of your calculations would be linear
except for one trig look-up (for the rotation matrix)

This would work in all cases except where the vector about which you want
to rotate is in the xy plane (ie the point is on the z-axis).  In that
case, you would map the point onto the yz plane instead.

This sounds rather complex to me, but it's an exercise in visualisation.
Anytime you need to do tricky rotations, just transform until your
coordinate system is much simpler, then rotate, then transform back.

OpenGL would be able to do all of this automatically, of course, with a
series of modelview calls, so you don't need to know the actual matrix
formula - or you can do it yourself on paper if you can understand this
rant.

Richard.