aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
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/Shared/Api
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/Shared/Api')
-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)