From 665cf0194afff36f7f4ceae80af83aa253ec61a2 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 7 Sep 2009 18:02:02 -0700 Subject: llRot2Euler() now returns angles -PI < angle < PI --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 077315e..f261c16 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -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 -- cgit v1.1