POV-Ray : Newsgroups : povray.off-topic : Trying to code an "offset rotation" for SL. : Re: Trying to code an "offset rotation" for SL. Server Time
7 Sep 2024 07:22:15 EDT (-0400)
  Re: Trying to code an "offset rotation" for SL.  
From: scott
Date: 15 Jul 2008 03:01:34
Message: <487c4b4e@news.povray.org>
>        y = llCos(Rot.x)*y - llSin(Rot.x)*z;
>        z = llSin(Rot.x)*y + llCos(Rot.x)*z;

This is not going to work, because you are setting the new "y" value in the 
first line, then using it in the 2nd line (but you should be using the 
previous y value).

Try something like

x2 = x;
y2 = llCos(Rot.x)*y - llSin(Rot.x)*z;
z2 = llSin(Rot.x)*y + llCos(Rot.x)*z;

x = llSin(Rot.y)*z2 + llCos(Rot.y)*x2;
y = y2;
z = llCos(Rot.y)*z2 - llSin(Rot.y)*x2;

x2 = llCos(Rot.z)*x - llSin(Rot.z)*y;
y2 = llSin(Rot.z)*x + llCos(Rot.z)*y;
z2 = z;

npos = <x2,y2,z2>;


Post a reply to this message

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