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:21:43 EDT (-0400)
  Re: Trying to code an "offset rotation" for SL.  
From: scott
Date: 17 Jul 2008 03:08:54
Message: <487ef006$1@news.povray.org>
>        if (Rot.x > 359)
>        {
>            Rot.x = 0;
>        }

I think that previous line would be better written as:

if( Rot.x >= 360 )
{
 Rot.x = Rot.x - 360;
}

It will give the correct transition as it passes 360 degrees.

> However, I still get some real "odd" behavior if I try to do more than
> one direction at a time, like RotChange = <10,0,10>. Instead of
> following the expected path, it seems to curve off in the wrong
> direction,

OK, I missed the fact that your llEuler2Rot() function probably is expecting 
Euler angles, which are different from rotations about the global xyz axes 
(like POV uses for "rotate" and what you are doing in those 3 groups of trig 
functions).  To make matters worse, Euler angles are not a universally 
defined standard, does it say anything about the definition in the function 
help?

Try something like the following (hopefully no typos!), which rotates the 
point based on the most standard Euler angle system:

        float xx = llCos(RotAngle.x)*x - llSin(RotAngle.x)*y;
        float xy = llSin(RotAngle.x)*x + llCos(RotAngle.x)*y;
        float xz = z;

        float yx = xx;
        float yy = llCos(RotAngle.y)*xy - llSin(RotAngle.y)*xz;
        float yz = llSin(RotAngle.y)*xy + llCos(RotAngle.y)*xz;

        float zx = llCos(RotAngle.z)*yx - llSin(RotAngle.z)*yy;
        float zy = llSin(RotAngle.z)*yx + llCos(RotAngle.z)*yy;
        float zz = yz;
        npos = <zx,zy,zz>;

Hopefully that method of rotating will match up with the llEuler2Rot 
function.

As always, more info on Wikipedia about Euler angles:

http://en.wikipedia.org/wiki/Euler_angles


Post a reply to this message

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