POV-Ray : Newsgroups : povray.general : [math]: object rotation problem Server Time
16 Nov 2024 09:19:24 EST (-0500)
  [math]: object rotation problem (Message 1 to 7 of 7)  
From: sulfugor
Subject: [math]: object rotation problem
Date: 10 Sep 1998 10:52:30
Message: <35F7DB81.29A1@aei.ca>
This is my situation.
I have an object that uses  3 basis vectors to orient itself, let's call
them FRONT,TOP,LEFT.
at the beginning of my animation the basis vectors are aligned with  the
x,y,z axes, but during the course of the animation i change the
orientation of the TOP vector. I managed to make the Front and left
vectors follow the Top one while it moves.. but im having tremendous
difficulties making my objects rotate the right way.

.THE QUESTION : 

How do i rotate an arbitrary object around an arbitrary axis ?
I've tried various combinations of rotate but they don't work.
I imagine i need to use a matrix, but linear algebra was a long time ago
and i'm at loss. Can someone please help me ?

I know mr. VanSickle is the matrix master around here, so i hope to hear
from you :)


-- 
	====================  Sulfugor ============================
  remove "spamkiller" from sul### [at] aeispamkillerca
  Web den: http://www.geocities.com/Area51/Station/3930/index.htm
  grafx  :
http://www.geocities.com/Area51/Station/3930/grafx.htm              
   
	"The stars that saw the birth of our ancestors shall watch
	our descendant's last steps on Earth ..  " 
                                      -AT THE GATES(RIP)


Post a reply to this message

From: Johannes Hubert
Subject: Re: [math]: object rotation problem
Date: 10 Sep 1998 11:12:39
Message: <35f7de57.0@news.povray.org>
Hi!

>.THE QUESTION :
>
>How do i rotate an arbitrary object around an arbitrary axis ?
>I've tried various combinations of rotate but they don't work.
>I imagine i need to use a matrix, but linear algebra was a long time ago
>and i'm at loss. Can someone please help me ?


In general:
Translate the object until the rotation axis runs through the origin. Rotate
two times now, each time around one of the main axis (different ones) until
the rotation axis falls into one of the three main-axis. Then do the
rotation for the desired angle around this axis. And repeat everything
backwards...

I have appended C++ source-code which shows you how to rotate a point around
an arbitrary axis. With a little work you should be able to convert it into
POV code. When using POV 3.1, you could even make a macro out of it:
Macro for rotation of an object around  an arbitrary axis! Now, wouldn't
that be something POV-users would like?
Maybe somebody else would like to do it?

Greetings,
Johannes.


Post a reply to this message


Attachments:
Download 'rotation.txt' (13 KB)

From: Peter Popov
Subject: Re: [math]: object rotation problem
Date: 10 Sep 1998 11:40:37
Message: <35f7e4e5.0@news.povray.org>
http://www.erols.com/vansickl/matrix.htm contains a great tutorial for the
usage of the matrix keyword... I think I saw the solution of your problem
there, as well as a lot of other useful applications of linear algebra and
alanytic geometry.

Peter


Post a reply to this message

From: John VanSickle
Subject: Re: [math]: object rotation problem
Date: 11 Sep 1998 17:30:44
Message: <35F99671.7E88888F@kosher.erols.com>
sulfugor wrote:
> 
> .THE QUESTION :
> 
> How do i rotate an arbitrary object around an arbitrary axis ?
> I've tried various combinations of rotate but they don't work.
> I imagine i need to use a matrix, but linear algebra was a long time ago
> and i'm at loss. Can someone please help me ?
> 
> I know mr. VanSickle is the matrix master around here, so i hope to hear
> from you :)

And yes, here I am!

To rotate an object around an arbitrary axis, use the following POV
code:

  #declare VX = vnormalize(V) // assuming that V is the axis of rotation
  #declare VY = vnormalize(vcross(VX,<VX.y,VX.z,-VX.x>))
  #declare VZ = vnormalize(vcross(VX,VY))

  object { MyObject
    matrix < VX.x,VY.x,VZ.x,
             VX.y,VY.y,VZ.y,
             VX.z,VY.z,VZ.z,
                0,   0,   0 >

    rotate x*Angle // here Angle is your angle of rotation

    matrix < VX.x,VX.y,VX.z,
             VY.x,VY.y,VY.z,
             VZ.x,VZ.y,VZ.z,
                0,   0,   0 >
  }

Note that the vector components are arranged differently in each matrix.

Hope this helps,
John


Post a reply to this message

From: sulfugor
Subject: Re: [math]: object rotation problem
Date: 12 Sep 1998 13:50:20
Message: <35FAA84D.6F21@aei.ca>
John VanSickle wrote:
> 
> sulfugor wrote:
> >
> > .THE QUESTION :
> >
> > How do i rotate an arbitrary object around an arbitrary axis ?
> > I've tried various combinations of rotate but they don't work.
> > I imagine i need to use a matrix, but linear algebra was a long time ago
> > and i'm at loss. Can someone please help me ?
> >
> > I know mr. VanSickle is the matrix master around here, so i hope to hear
> > from you :)
> 
> And yes, here I am!
> 
> To rotate an object around an arbitrary axis, use the following POV
> code:
> 
>   #declare VX = vnormalize(V) // assuming that V is the axis of rotation
>   #declare VY = vnormalize(vcross(VX,<VX.y,VX.z,-VX.x>))
>   #declare VZ = vnormalize(vcross(VX,VY))
> 
>   object { MyObject
>     matrix < VX.x,VY.x,VZ.x,
>              VX.y,VY.y,VZ.y,
>              VX.z,VY.z,VZ.z,
>                 0,   0,   0 >
> 
>     rotate x*Angle // here Angle is your angle of rotation
> 
>     matrix < VX.x,VX.y,VX.z,
>              VY.x,VY.y,VY.z,
>              VZ.x,VZ.y,VZ.z,
>                 0,   0,   0 >
>   }
> 
> Note that the vector components are arranged differently in each matrix.



this seems to be a simpler (?) version of the code posted on your page.
I tried the code on the page.There are some problematic If statements .
it works on MOST cases, except when the Axis of rotation happens to be
colinear with the X axis. I always got errors from that. It's essential
that the code work for absolutely any axis, including X. I will try this
new code and hope it will work.
Thanks for the help.


sulfugor
> 
> Hope this helps,
> John

-- 
	====================  Sulfugor ============================


Post a reply to this message

From: John VanSickle
Subject: Re: [math]: object rotation problem
Date: 12 Sep 1998 18:05:09
Message: <35FAEFEA.5016CE1F@kosher.erols.com>
sulfugor wrote:
> 
> this seems to be a simpler (?) version of the code posted on your page.
> I tried the code on the page.There are some problematic If statements .

The code that precedes the matrix is supposed to find two vectors that are
perpendicular to each other and to the axis of rotation.  The new code is
just a simpler way of doing it.

Regards,
John


Post a reply to this message

From: JK
Subject: Re: [math]: object rotation problem
Date: 13 Sep 1998 18:19:14
Message: <35fc36d1.0@news.povray.org>
>How do i rotate an arbitrary object around an arbitrary
axis ?

Maybe I'm missing the point here, but erm... can't you just
rotate the object around the x,y or z axis and then
translate and rotate it again to make the alignment
different? And if everything moves around a certain axis,
maybe you can just change the location and look_at of the
camera.

>I've tried various combinations of rotate but they don't
work.

I'm wondering what you tried here.

Good luck,

JK


Post a reply to this message

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