aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs28
1 files changed, 6 insertions, 22 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9427061..c48285a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4665,37 +4665,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4665 public LSL_Vector llRot2Axis(LSL_Rotation rot) 4665 public LSL_Vector llRot2Axis(LSL_Rotation rot)
4666 { 4666 {
4667 m_host.AddScriptLPS(1); 4667 m_host.AddScriptLPS(1);
4668 double x,y,z; 4668 double x, y, z;
4669 4669
4670 if (rot.s > 1) // normalization needed 4670 if (Math.Abs(rot.s) > 1) // normalization needed
4671 { 4671 rot.Normalize();
4672 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
4673 rot.z * rot.z + rot.s * rot.s);
4674
4675 rot.x /= length;
4676 rot.y /= length;
4677 rot.z /= length;
4678 rot.s /= length;
4679
4680 }
4681 4672
4682 // double angle = 2 * Math.Acos(rot.s);
4683 double s = Math.Sqrt(1 - rot.s * rot.s); 4673 double s = Math.Sqrt(1 - rot.s * rot.s);
4684 if (s < 0.001) 4674 if (s < 0.001)
4685 { 4675 {
4686 x = 1; 4676 return new LSL_Vector(1, 0, 0);
4687 y = z = 0;
4688 } 4677 }
4689 else 4678 else
4690 { 4679 {
4691 x = rot.x / s; // normalise axis 4680 double invS = 1.0 / s;
4692 y = rot.y / s; 4681 return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS);
4693 z = rot.z / s;
4694 } 4682 }
4695 if ((double.IsNaN(x)) || double.IsInfinity(x)) x = 0;
4696 if ((double.IsNaN(y)) || double.IsInfinity(y)) y = 0;
4697 if ((double.IsNaN(z)) || double.IsInfinity(z)) z = 0;
4698 return new LSL_Vector(x,y,z);
4699 } 4683 }
4700 4684
4701 4685