|
|
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
|
|