aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs27
1 files changed, 16 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 16dd834..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
@@ -497,9 +502,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
497 NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), 502 NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))),
498 NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); 503 NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))));
499 else if (n > 0) 504 else if (n > 0)
500 return new LSL_Vector(0.0, Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 505 return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
501 else 506 else
502 return new LSL_Vector(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 507 return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
503 } 508 }
504 509
505 /* From wiki: 510 /* From wiki:
@@ -553,12 +558,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
553 558
554 double x,y,z,s; 559 double x,y,z,s;
555 560
556 double c1 = Math.Cos(v.x/2.0); 561 double c1 = Math.Cos(v.x * 0.5);
557 double c2 = Math.Cos(v.y/2.0); 562 double c2 = Math.Cos(v.y * 0.5);
558 double c3 = Math.Cos(v.z/2.0); 563 double c3 = Math.Cos(v.z * 0.5);
559 double s1 = Math.Sin(v.x/2.0); 564 double s1 = Math.Sin(v.x * 0.5);
560 double s2 = Math.Sin(v.y/2.0); 565 double s2 = Math.Sin(v.y * 0.5);
561 double s3 = Math.Sin(v.z/2.0); 566 double s3 = Math.Sin(v.z * 0.5);
562 567
563 x = s1*c2*c3+c1*s2*s3; 568 x = s1*c2*c3+c1*s2*s3;
564 y = c1*s2*c3-s1*c2*s3; 569 y = c1*s2*c3-s1*c2*s3;