Problem is, it never returns angles >180 or <0. Here's a sample script:
float dot(vector a,vector b)
{
return (a.x*b.x+a.y*b.y+a.z*b.z);
}
default
{
state_entry()
{
rotation rot=llEuler2Rot(<0,0,10.*DEG_TO_RAD>
; //rotate in 10 degree stepsvector vec=<10.,0.,0.>; //start with any vector at 0 degrees
integer i;
for (i=10;i<=360;i+=10) //just a loop counter, no math using i
{
vec=vec*rot; //rotate 10 more degrees
//convert back to degrees from vector
float theta=llAcos(dot(vec,<1.,0.,0.>
/llVecMag(vec))*RAD_TO_DEG;llOwnerSay((string)vec+" angle="+(string)theta);
} //for
} //state_entry
} //default
The angle is supposed to increase from 10 to 360 degrees, but it increases to 180 and then starts back down again. In this case, I could check the sign of vec.y and flip the sign of the angle, but this only works when the second vector is on the X axis. How do I do that for two arbitrary angles?
takes a dot product when the factors are two vectors. So 'vecA*vecB' is a float that is equal to the dot product of vector vecA and vector vecB.