POV-Ray : Newsgroups : povray.general : Rotation around an axis at the origin : Re: Rotation around an axis at the origin Server Time
7 Aug 2024 19:25:54 EDT (-0400)
  Re: Rotation around an axis at the origin  
From: Alberto
Date: 7 Jul 2001 16:03:43
Message: <3B476AB8.EF0FF378@usb.ve>
Glad it helped you.

Once you find how to rotate a vector around an axis, the rows of the
matrix are the rotation of the vectors x, y and z. Here is a shorter
code for the matrix

#macro matrot(axis ang)
  #local mv = vnormalize(axis); #local ma = radians(ang);
  #local a1 = mv.x;    #local a2 = mv.y;    #local a3 = mv.z;
  #local sa = sin(ma); #local ca = cos(ma); #local dc = 1 - ca;
  matrix <
    a1*a1*dc + ca,    a1*a2*dc + sa*a3, a1*a3*dc - sa*a2, 
    a2*a1*dc - sa*a3, a2*a2*dc + ca,    a2*a3*dc + sa*a1, 
    a3*a1*dc + sa*a2, a3*a2*dc - sa*a1, a3*a3*dc + ca, 
    0, 0, 0
  >
#end

Alberto.


Post a reply to this message

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