POV-Ray : Newsgroups : povray.advanced-users : Rotation mathematics Server Time
26 Nov 2024 04:30:53 EST (-0500)
  Rotation mathematics (Message 1 to 8 of 8)  
From: Simon Lemieux
Subject: Rotation mathematics
Date: 10 Jan 2001 17:08:25
Message: <3A5CDD81.33664EC6@yahoo.com>
Hi,
  just finished my session and learned quite a few interesting things... such as
2D rotations, where in radians (0 <= r <= 2pi):
x = cos(rad);
y = sin(rad);

Now, I was wondering how to add the Z coordinate? Is it possible? I guess a
better use would be to have different angles, rotating around a given axis and
use the cos&sin functions just like for x&y but substituting x&z for a yAxis
rotation, etc...

Is there any better math out there to help about rotations? Except for
matrixes...

-- 
+-------------------------+----------------------------------+
| Simon Lemieux           | http://www.666Mhz.net            |
| Email : Sin### [at] 666Mhznet |          Website in Beta Testing |
+-------------------------+----------------------------------+


Post a reply to this message

From: David Fontaine
Subject: Re: Rotation mathematics
Date: 10 Jan 2001 18:49:23
Message: <3A5CF3DE.8E0CD427@faricy.net>
Simon Lemieux wrote:

> Hi,
>   just finished my session and learned quite a few interesting things... such as
> 2D rotations, where in radians (0 <= r <= 2pi):
> x = cos(rad);
> y = sin(rad);
>
> Now, I was wondering how to add the Z coordinate? Is it possible? I guess a
> better use would be to have different angles, rotating around a given axis and
> use the cos&sin functions just like for x&y but substituting x&z for a yAxis
> rotation, etc...
>
> Is there any better math out there to help about rotations? Except for
> matrixes...

This is exactly what matrices are for! But here:

Rotate x: <x,y,z> -> <x,y*cos-z*sin,z*cos+y*sin>
Rotate y: <x,y,z> -> <x*cos+z*sin,y,z*cos-x*sin>
Rotate z: <x,y,z> -> <x*cos-y*sin,y*cos+x*sin,z>

--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: David Fontaine
Subject: Re: Rotation mathematics
Date: 10 Jan 2001 18:49:52
Message: <3A5CF3FC.27A61A74@faricy.net>
David Fontaine wrote:

> This is exactly what matrices are for! But here:
>
> Rotate x: <x,y,z> -> <x,y*cos-z*sin,z*cos+y*sin>
> Rotate y: <x,y,z> -> <x*cos+z*sin,y,z*cos-x*sin>
> Rotate z: <x,y,z> -> <x*cos-y*sin,y*cos+x*sin,z>

This is just for left-handed systems BTW.

--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Chris Colefax
Subject: Re: Rotation mathematics
Date: 10 Jan 2001 18:52:06
Message: <3a5cf5a6@news.povray.org>
Simon Lemieux <lem### [at] yahoocom> wrote:
>   just finished my session and learned quite a few interesting things...
such as
> 2D rotations, where in radians (0 <= r <= 2pi):
> x = cos(rad);
> y = sin(rad);
>
> Now, I was wondering how to add the Z coordinate? Is it possible? I guess
a
> better use would be to have different angles, rotating around a given axis
and
> use the cos&sin functions just like for x&y but substituting x&z for a
yAxis
> rotation, etc...
>
> Is there any better math out there to help about rotations? Except for
> matrixes...

All transformations in POV-Ray are ultimately represented as matrices,
because they offer the most general and compact form of the transformations
available in POV-Ray.  But POV-script is designed to be written and read by
people, not just computers, and the rotate, translate and scale commands
offer a much more intuitive way of performing transformations.  In other
words, don't feel obliged to learn matrices if the other three functions
allow you to do what you wish.

Regarding rotations - they are indeed performed, like you describe, as 2D
rotations about each of the three orthogonal axes, x, y, and z.  For
example, rotate <40, -20, 165> is interpreted as rotating 40 degrees about
the x-axis, followed by -20 degrees around the y-axis, followed by 165
degrees around the z-axis.  If you want to rotate around the y-axis, then
around the x-axis, you have to use two rotate commands, e.g. rotate y*45
rotate x*-90.

Another common method of expressing rotations in 3D space are quaternions -
these are rotations around arbitratry axes, rather than just the x, y, and z
axes.  For example, you might want to spin an object around the diagonal
axis <1, 1, 1>.  Quaternions are often used when interpolating objects from
one orientation to another, as they provide a smoother result than limiting
yourself to the x, y, and z rotational axes.


Post a reply to this message

From: Simon Lemieux
Subject: Re: Rotation mathematics
Date: 15 Jan 2001 12:35:31
Message: <3A63353D.89EC1BCC@yahoo.com>
> > Rotate x: <x,y,z> -> <x,y*cos-z*sin,z*cos+y*sin>
> > Rotate y: <x,y,z> -> <x*cos+z*sin,y,z*cos-x*sin>
> > Rotate z: <x,y,z> -> <x*cos-y*sin,y*cos+x*sin,z>
> 
> This is just for left-handed systems BTW.

Thanks a lot! Is there a difference between left and right-handed systems?


-- 
+-------------------------+----------------------------------+
| Simon Lemieux           | http://www.666Mhz.net            |
| Email : Sin### [at] 666Mhznet |        Povray and OpenGL Gallery |
+-------------------------+----------------------------------+


Post a reply to this message

From: Alan Kong
Subject: Re: Rotation mathematics
Date: 15 Jan 2001 19:20:13
Message: <0t476tgk7ku9npt3ag4c8hvuusnklirks1@4ax.com>
On Mon, 15 Jan 2001 12:37:01 -0500 Simon Lemieux wrote:

>Thanks a lot! Is there a difference between left and right-handed systems?

  See POV-Ray docs, section 2.1.1 "Understanding POV-Ray's Coordinate
System".

  I John VanSickle's FlipYZ macro can handle easy right to left-handed
conversion within a scene file. Here is where to find John's macros:

http://enphilistor.users4.50megs.com/macs.htm


-- 
Alan - ako### [at] povrayorg - a k o n g <at> p o v r a y <dot> o r g
http://www.povray.org - Home of the Persistence of Vision Ray Tracer


Post a reply to this message

From: Francois Labreque
Subject: Re: Rotation mathematics
Date: 15 Jan 2001 19:48:04
Message: <3A6399B6.69F204D3@videotron.ca>
Simon Lemieux wrote:
> 
> > > Rotate x: <x,y,z> -> <x,y*cos-z*sin,z*cos+y*sin>
> > > Rotate y: <x,y,z> -> <x*cos+z*sin,y,z*cos-x*sin>
> > > Rotate z: <x,y,z> -> <x*cos-y*sin,y*cos+x*sin,z>
> >
> > This is just for left-handed systems BTW.
> 
> Thanks a lot! Is there a difference between left and right-handed systems?

Yes.  Take you thumb as the Y axis.  your fingers wrap toward a positive
rotation.

As you ca see, the rotations are oppsoite depending on whether you have
a LHS or a RHS.

As for the matrices go,

For a LHS:

      -               -
     |  1    0     0   |
Rx = |  0   cos   sin  |
     |  0  -sin   cos  |
      -               -

And for a RHS:

      -               -
     |  1    0     0   |
Rx = |  0   cos  -sin  |
     |  0   sin   cos  |
      -               -

(As you can see the sign of the sine changes)

-- 
Francois Labreque | Unfortunately, there's no such thing as a snooze
    flabreque     | button on a cat who wants breakfast.
        @         |      - Unattributed quote from rec.humor.funny
   videotron.ca


Post a reply to this message

From: David Fontaine
Subject: Re: Rotation mathematics
Date: 15 Jan 2001 21:28:45
Message: <3A63B0A4.806011C2@faricy.net>
Simon Lemieux wrote:

> > > Rotate x: <x,y,z> -> <x,y*cos-z*sin,z*cos+y*sin>
> > > Rotate y: <x,y,z> -> <x*cos+z*sin,y,z*cos-x*sin>
> > > Rotate z: <x,y,z> -> <x*cos-y*sin,y*cos+x*sin,z>
> >
> > This is just for left-handed systems BTW.
>
> Thanks a lot! Is there a difference between left and right-handed systems?

If you know what the graphs of sine and cosine look like, you can mimic the
rotations with your hand and it should be apparent where these formulas come
from.

For a left or right handed system, thumb pointing out is x, index finger
pointing straight is y, and middle finger pointing perpendicular to palm is z.
So swap y and z from the left-handed system and you get a right-handed system.
In either system, point your thumb along the axis of rotation and your fingers
will curl in the direction of rotation.

--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.