diff options
author | dahlia | 2013-06-10 16:42:49 -0700 |
---|---|---|
committer | dahlia | 2013-06-10 16:42:49 -0700 |
commit | a949556c4ea74c993fc15bcfdcbc672d9f971897 (patch) | |
tree | 30b62092d8e63f89b43f2a3d378b5fcf01fcccb7 /OpenSim/Region | |
parent | Add port numbers to poll service thread names so that we can tell which belon... (diff) | |
download | opensim-SC-a949556c4ea74c993fc15bcfdcbc672d9f971897.zip opensim-SC-a949556c4ea74c993fc15bcfdcbc672d9f971897.tar.gz opensim-SC-a949556c4ea74c993fc15bcfdcbc672d9f971897.tar.bz2 opensim-SC-a949556c4ea74c993fc15bcfdcbc672d9f971897.tar.xz |
add a Normalize() method for LSL_Rotation
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 9ca5ca9..f6d94a3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -371,6 +371,31 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
371 | 371 | ||
372 | #endregion | 372 | #endregion |
373 | 373 | ||
374 | #region Methods | ||
375 | public Quaternion Normalize() | ||
376 | { | ||
377 | double length = Math.Sqrt(x * x + y * y + z * z + s * s); | ||
378 | if (length < float.Epsilon) | ||
379 | { | ||
380 | x = 1; | ||
381 | y = 0; | ||
382 | z = 0; | ||
383 | s = 0; | ||
384 | } | ||
385 | else | ||
386 | { | ||
387 | |||
388 | double invLength = 1.0 / length; | ||
389 | x *= invLength; | ||
390 | y *= invLength; | ||
391 | z *= invLength; | ||
392 | s *= invLength; | ||
393 | } | ||
394 | |||
395 | return this; | ||
396 | } | ||
397 | #endregion | ||
398 | |||
374 | #region Overriders | 399 | #region Overriders |
375 | 400 | ||
376 | public override int GetHashCode() | 401 | public override int GetHashCode() |