llRot2Euler() now returns angles -PI < angle < PI

remotes/origin/0.6.7-post-fixes
dahlia 2009-09-07 18:02:02 -07:00
parent 7a67b726d5
commit 665cf0194a
1 changed files with 8 additions and 3 deletions

View File

@ -476,9 +476,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// normalize an angle between -PI and PI (-180 to +180 degrees)
protected double NormalizeAngle(double angle)
{
angle = angle % (Math.PI * 2);
// if (angle < 0) angle = angle + Math.PI * 2;
return angle;
if (angle > -Math.PI && angle < Math.PI)
return angle;
int numPis = (int)(Math.PI / angle);
double remainder = angle - Math.PI * numPis;
if (numPis % 2 == 1)
return Math.PI - angle;
return remainder;
}
// Old implementation of llRot2Euler, now normalized