diff options
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 28 |
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 f5d5bc6..c315d03 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -5123,37 +5123,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5123 | public LSL_Vector llRot2Axis(LSL_Rotation rot) | 5123 | public LSL_Vector llRot2Axis(LSL_Rotation rot) |
5124 | { | 5124 | { |
5125 | m_host.AddScriptLPS(1); | 5125 | m_host.AddScriptLPS(1); |
5126 | double x,y,z; | 5126 | double x, y, z; |
5127 | 5127 | ||
5128 | if (rot.s > 1) // normalization needed | 5128 | if (Math.Abs(rot.s) > 1) // normalization needed |
5129 | { | 5129 | rot.Normalize(); |
5130 | double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y + | ||
5131 | rot.z * rot.z + rot.s * rot.s); | ||
5132 | |||
5133 | rot.x /= length; | ||
5134 | rot.y /= length; | ||
5135 | rot.z /= length; | ||
5136 | rot.s /= length; | ||
5137 | |||
5138 | } | ||
5139 | 5130 | ||
5140 | // double angle = 2 * Math.Acos(rot.s); | ||
5141 | double s = Math.Sqrt(1 - rot.s * rot.s); | 5131 | double s = Math.Sqrt(1 - rot.s * rot.s); |
5142 | if (s < 0.001) | 5132 | if (s < 0.001) |
5143 | { | 5133 | { |
5144 | x = 1; | 5134 | return new LSL_Vector(1, 0, 0); |
5145 | y = z = 0; | ||
5146 | } | 5135 | } |
5147 | else | 5136 | else |
5148 | { | 5137 | { |
5149 | x = rot.x / s; // normalise axis | 5138 | double invS = 1.0 / s; |
5150 | y = rot.y / s; | 5139 | return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); |
5151 | z = rot.z / s; | ||
5152 | } | 5140 | } |
5153 | if ((double.IsNaN(x)) || double.IsInfinity(x)) x = 0; | ||
5154 | if ((double.IsNaN(y)) || double.IsInfinity(y)) y = 0; | ||
5155 | if ((double.IsNaN(z)) || double.IsInfinity(z)) z = 0; | ||
5156 | return new LSL_Vector(x,y,z); | ||
5157 | } | 5141 | } |
5158 | 5142 | ||
5159 | 5143 | ||