POV-Ray : Newsgroups : povray.general : [math]: object rotation problem : Re: [math]: object rotation problem Server Time
13 Aug 2024 11:19:19 EDT (-0400)
  Re: [math]: object rotation problem  
From: sulfugor
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

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