From 9d9b9d4938687f97ac82fc22917471f22198ef12 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 10 Jun 2013 17:11:49 -0700 Subject: llRot2Angle now checks absolute value of s rotation component before normalizing --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c48285a..39bac82 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4688,19 +4688,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (rot.s > 1) // normalization needed - { - double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y + - rot.z * rot.z + rot.s * rot.s); - - rot.x /= length; - rot.y /= length; - rot.z /= length; - rot.s /= length; - } + if (Math.Abs(rot.s) > 1) // normalization needed + rot.Normalize(); double angle = 2 * Math.Acos(rot.s); - if ((double.IsNaN(angle)) || double.IsInfinity(angle)) angle = 0; + return angle; } -- cgit v1.1 From ba84074468e0805e0a378bf31fc580437e7ce015 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 10 Jun 2013 17:54:14 -0700 Subject: LSL_Rotation.Normalize() now returns 0,0,0,1 for x,y,z,s when normalization fails --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index f6d94a3..50f9377 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -377,10 +377,10 @@ namespace OpenSim.Region.ScriptEngine.Shared double length = Math.Sqrt(x * x + y * y + z * z + s * s); if (length < float.Epsilon) { - x = 1; + x = 0; y = 0; z = 0; - s = 0; + s = 1; } else { -- cgit v1.1 From ed950e6c7444510c7171c1b7829eedbf731e218a Mon Sep 17 00:00:00 2001 From: dahlia Date: Tue, 11 Jun 2013 00:29:40 -0700 Subject: Adjust output of llRot2Axis and llRot2Angle to match domains SL(tm) uses. Addresses Mantis #0006671 --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 39bac82..e1630b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4678,6 +4678,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { double invS = 1.0 / s; + if (rot.s < 0) invS = -invS; return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); } } @@ -4692,6 +4693,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rot.Normalize(); double angle = 2 * Math.Acos(rot.s); + if (angle > Math.PI) + angle = 2 * Math.PI - angle; return angle; } -- cgit v1.1