diff options
author | Charles Krinke | 2008-07-18 19:09:51 +0000 |
---|---|---|
committer | Charles Krinke | 2008-07-18 19:09:51 +0000 |
commit | c0e389cfff1b43bce8fb8e706b6617bed95381a9 (patch) | |
tree | 87ae53aba26ff38432195af6495dd07012e08ce6 | |
parent | Patch adds bool IsManager(LLUUID) to IEstateModule. (diff) | |
download | opensim-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 '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 33 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 32 |
2 files changed, 61 insertions, 4 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 |
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) |