aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorCharles Krinke2008-07-18 01:20:06 +0000
committerCharles Krinke2008-07-18 01:20:06 +0000
commitbc24c0e5d7f40abd1d0f1c02bb88f35cdd6c9bcf (patch)
tree414054b839f2365525a799c47fab40e53bfaab0f /OpenSim/Region/ScriptEngine/Shared/Api
parentrefactor - commenting out needsMeshing() and all references as createMesh() h... (diff)
downloadopensim-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/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 260457b..e7313e1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -417,7 +417,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
417 public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) 417 public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r)
418 { 418 {
419 m_host.AddScriptLPS(1); 419 m_host.AddScriptLPS(1);
420 return (new LSL_Types.Vector3(1,0,0) * r); 420 double x,y,z,m;
421 m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s);
422 // m is always greater than zero
423 if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized
424 {
425 r.x/=m;
426 r.y/=m;
427 r.z/=m;
428 r.s/=m;
429 }
430 // Fast Algebric Calculations instead of Vectors & Quaternions Product
431 x = r.x*r.x-r.y*r.y-r.z*r.z+r.s*r.s;
432 y = 2*(r.x*r.y+r.z*r.s);
433 z = 2*(r.x*r.z-r.y*r.s);
434 return (new LSL_Types.Vector3(x,y,z));
421 } 435 }
422 436
423 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) 437 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r)