diff options
author | dahlia | 2009-09-07 18:02:02 -0700 |
---|---|---|
committer | dahlia | 2009-09-07 18:02:02 -0700 |
commit | 665cf0194afff36f7f4ceae80af83aa253ec61a2 (patch) | |
tree | cae476fff643101039463e0ddccfd9eedae5ac38 /OpenSim/Region/ScriptEngine | |
parent | random drive-by maths optimization in llRot2Euler() and llEuler2Rot() (diff) | |
download | opensim-SC_OLD-665cf0194afff36f7f4ceae80af83aa253ec61a2.zip opensim-SC_OLD-665cf0194afff36f7f4ceae80af83aa253ec61a2.tar.gz opensim-SC_OLD-665cf0194afff36f7f4ceae80af83aa253ec61a2.tar.bz2 opensim-SC_OLD-665cf0194afff36f7f4ceae80af83aa253ec61a2.tar.xz |
llRot2Euler() now returns angles -PI < angle < PI
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 11 |
1 files 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 | |||
476 | // normalize an angle between -PI and PI (-180 to +180 degrees) | 476 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
477 | protected double NormalizeAngle(double angle) | 477 | protected double NormalizeAngle(double angle) |
478 | { | 478 | { |
479 | angle = angle % (Math.PI * 2); | 479 | if (angle > -Math.PI && angle < Math.PI) |
480 | // if (angle < 0) angle = angle + Math.PI * 2; | 480 | return angle; |
481 | return angle; | 481 | |
482 | int numPis = (int)(Math.PI / angle); | ||
483 | double remainder = angle - Math.PI * numPis; | ||
484 | if (numPis % 2 == 1) | ||
485 | return Math.PI - angle; | ||
486 | return remainder; | ||
482 | } | 487 | } |
483 | 488 | ||
484 | // Old implementation of llRot2Euler, now normalized | 489 | // Old implementation of llRot2Euler, now normalized |