diff options
author | Charles Krinke | 2008-07-18 01:20:06 +0000 |
---|---|---|
committer | Charles Krinke | 2008-07-18 01:20:06 +0000 |
commit | bc24c0e5d7f40abd1d0f1c02bb88f35cdd6c9bcf (patch) | |
tree | 414054b839f2365525a799c47fab40e53bfaab0f /OpenSim/Region/ScriptEngine/Common | |
parent | refactor - commenting out needsMeshing() and all references as createMesh() h... (diff) | |
download | opensim-SC_OLD-bc24c0e5d7f40abd1d0f1c02bb88f35cdd6c9bcf.zip opensim-SC_OLD-bc24c0e5d7f40abd1d0f1c02bb88f35cdd6c9bcf.tar.gz opensim-SC_OLD-bc24c0e5d7f40abd1d0f1c02bb88f35cdd6c9bcf.tar.bz2 opensim-SC_OLD-bc24c0e5d7f40abd1d0f1c02bb88f35cdd6c9bcf.tar.xz |
Mantis#1768. Thank you kindly, Junta_Kohime for a patch that:
llRot2Fwd function modified, using fast algebric calculations
instead of vectors and quaternions products. The accuracy is
the same. Normalization is now implemented.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index b53f6c0..3ae1f3a 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -430,7 +430,21 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
430 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) | 430 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) |
431 | { | 431 | { |
432 | m_host.AddScriptLPS(1); | 432 | m_host.AddScriptLPS(1); |
433 | return (new LSL_Types.Vector3(1,0,0) * r); | 433 | double x,y,z,m; |
434 | m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s); | ||
435 | // m is always greater than zero | ||
436 | if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized | ||
437 | { | ||
438 | r.x/=m; | ||
439 | r.y/=m; | ||
440 | r.z/=m; | ||
441 | r.s/=m; | ||
442 | } | ||
443 | // Fast Algebric Calculations instead of Vectors & Quaternions Product | ||
444 | x = r.x*r.x-r.y*r.y-r.z*r.z+r.s*r.s; | ||
445 | y = 2*(r.x*r.y+r.z*r.s); | ||
446 | z = 2*(r.x*r.z-r.y*r.s); | ||
447 | return (new LSL_Types.Vector3(x,y,z)); | ||
434 | } | 448 | } |
435 | 449 | ||
436 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) | 450 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) |