aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs32
1 files changed, 30 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e396bb4..decd2d0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -437,13 +437,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
437 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) 437 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r)
438 { 438 {
439 m_host.AddScriptLPS(1); 439 m_host.AddScriptLPS(1);
440 return (new LSL_Types.Vector3(0, 1, 0) * r); 440 double x,y,z,m;
441 m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s);
442 // m is always greater than zero
443 if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized
444 {
445 r.x/=m;
446 r.y/=m;
447 r.z/=m;
448 r.s/=m;
449 }
450 // Fast Algebric Calculations instead of Vectors & Quaternions Product
451 x = 2*(r.x*r.y-r.z*r.s);
452 y = -r.x*r.x+r.y*r.y-r.z*r.z+r.s*r.s;
453 z = 2*(r.x*r.s+r.y*r.z);
454 return (new LSL_Types.Vector3(x,y,z));
441 } 455 }
442 456
443 public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) 457 public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r)
444 { 458 {
445 m_host.AddScriptLPS(1); 459 m_host.AddScriptLPS(1);
446 return (new LSL_Types.Vector3(0, 0, 1) * r); 460 double x,y,z,m;
461 m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s);
462 // m is always greater than zero
463 if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized
464 {
465 r.x/=m;
466 r.y/=m;
467 r.z/=m;
468 r.s/=m;
469 }
470 // Fast Algebric Calculations instead of Vectors & Quaternions Product
471 x = 2*(r.x*r.z+r.y*r.s);
472 y = 2*(-r.x*r.s+r.y*r.z);
473 z = -r.x*r.x-r.y*r.y+r.z*r.z+r.s*r.s;
474 return (new LSL_Types.Vector3(x,y,z));
447 } 475 }
448 476
449 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b) 477 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b)