aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
diff options
context:
space:
mode:
authorCharles Krinke2008-07-18 19:09:51 +0000
committerCharles Krinke2008-07-18 19:09:51 +0000
commitc0e389cfff1b43bce8fb8e706b6617bed95381a9 (patch)
tree87ae53aba26ff38432195af6495dd07012e08ce6 /OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
parentPatch adds bool IsManager(LLUUID) to IEstateModule. (diff)
downloadopensim-SC_OLD-c0e389cfff1b43bce8fb8e706b6617bed95381a9.zip
opensim-SC_OLD-c0e389cfff1b43bce8fb8e706b6617bed95381a9.tar.gz
opensim-SC_OLD-c0e389cfff1b43bce8fb8e706b6617bed95381a9.tar.bz2
opensim-SC_OLD-c0e389cfff1b43bce8fb8e706b6617bed95381a9.tar.xz
Mantis#1778. Thank you kindly, Junta_Kohime for a patch that:
llRot2Left and llRot2Up functions 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/LSL_BuiltIn_Commands.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs33
1 files changed, 31 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 42c5abc..cbd4db2 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -450,14 +450,43 @@ namespace OpenSim.Region.ScriptEngine.Common
450 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) 450 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r)
451 { 451 {
452 m_host.AddScriptLPS(1); 452 m_host.AddScriptLPS(1);
453 return (new LSL_Types.Vector3(0, 1, 0) * r); 453 double x,y,z,m;
454 m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s);
455 // m is always greater than zero
456 if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized
457 {
458 r.x/=m;
459 r.y/=m;
460 r.z/=m;
461 r.s/=m;
462 }
463 // Fast Algebric Calculations instead of Vectors & Quaternions Product
464 x = 2*(r.x*r.y-r.z*r.s);
465 y = -r.x*r.x+r.y*r.y-r.z*r.z+r.s*r.s;
466 z = 2*(r.x*r.s+r.y*r.z);
467 return (new LSL_Types.Vector3(x,y,z));
454 } 468 }
455 469
456 public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) 470 public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r)
457 { 471 {
458 m_host.AddScriptLPS(1); 472 m_host.AddScriptLPS(1);
459 return (new LSL_Types.Vector3(0, 0, 1) * r); 473 double x,y,z,m;
474 m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s);
475 // m is always greater than zero
476 if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized
477 {
478 r.x/=m;
479 r.y/=m;
480 r.z/=m;
481 r.s/=m;
482 }
483 // Fast Algebric Calculations instead of Vectors & Quaternions Product
484 x = 2*(r.x*r.z+r.y*r.s);
485 y = 2*(-r.x*r.s+r.y*r.z);
486 z = -r.x*r.x-r.y*r.y+r.z*r.z+r.s*r.s;
487 return (new LSL_Types.Vector3(x,y,z));
460 } 488 }
489
461 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b) 490 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
462 { 491 {
463 //A and B should both be normalized 492 //A and B should both be normalized