diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 2eb50ef5f4..dbb61fddc6 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -562,7 +562,15 @@ namespace OpenSim.Region.ScriptEngine.Common LSL_Types.Vector3 axis = LSL_Types.Vector3.Norm(crossProduct); double s = Math.Sin(angle / 2); - return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2)); + double x = axis.x * s; + double y = axis.y * s; + double z = axis.z * s; + double w = Math.Cos(angle / 2); + + if(Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) + return new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + + return new LSL_Types.Quaternion((float)x, (float)y, (float)z, (float)w); } public void llWhisper(int channelID, string text) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 758cf4bde2..bff63f1006 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -581,7 +581,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Types.Vector3 axis = LSL_Types.Vector3.Norm(crossProduct); double s = Math.Sin(angle / 2); - return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2)); + double x = axis.x * s; + double y = axis.y * s; + double z = axis.z * s; + double w = Math.Cos(angle / 2); + + if(Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) + return new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + + return new LSL_Types.Quaternion((float)x, (float)y, (float)z, (float)w); } public void llWhisper(int channelID, string text)