POV-Ray : Newsgroups : povray.general : [math]: object rotation problem : Re: [math]: object rotation problem Server Time
16 Nov 2024 07:15:10 EST (-0500)
  Re: [math]: object rotation problem  
From: John VanSickle
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

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