aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
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)