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