POV-Ray : Newsgroups : povray.general : Local rotations : Re: Local rotations Server Time
31 Jul 2024 22:09:24 EDT (-0400)
  Re: Local rotations  
From: bapt
Date: 20 Aug 2010 15:15:00
Message: <web.4c6ed31798a8a381a3b8d9490@news.povray.org>
I came across this (very) old thread but eventually had to write my own
version of the rotation matrix. It follows the conventions from
http://mathworld.wolfram.com/EulerAngles.html and rotates by the angles
phi,theta,psi,

#macro Euler(A)
#local xp = vaxis_rotate(x,z,-A.x);
#local yp = vaxis_rotate(y,z, A.x);
#local ys = vaxis_rotate(yp,xp,A.y);
#local zs = vaxis_rotate(z,xp,A.y);
#local xt = vaxis_rotate(xp,zs,A.z);
#local yt = vaxis_rotate(ys,zs,A.z);

#local cosphi = vdot(xp,x);
#local sinphi = vdot(vcross(xp,x), z);
#local costheta = vdot(zs,z);
#local sintheta= vdot(vcross(zs,z), xp);
#local cospsi = vdot(xt,xp);
#local sinpsi = vdot(vcross(xt,xp), zs);

transform {
matrix < cospsi, sinpsi, 0,
-sinpsi, cospsi, 0,
0, 0, 1, 0,0,0 >
matrix < 1, 0, 0,
0, costheta, sintheta,
0, -sintheta, costheta, 0,0,0 >
matrix < cosphi, sinphi, 0,
-sinphi, cosphi, 0,
0, 0, 1, 0,0,0 >

}
#end

The three matrices could be combined into one, but it seems clearer that way.


Post a reply to this message

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