diff options
author | Charles Krinke | 2008-07-19 14:45:10 +0000 |
---|---|---|
committer | Charles Krinke | 2008-07-19 14:45:10 +0000 |
commit | 9ff9279a7cd76a6a5aaf84ef759053d7bde4001a (patch) | |
tree | 3088a04210aabf2ae356ab56363265a55490239a /OpenSim/Region/ScriptEngine/Shared | |
parent | Update svn properties. Fix some inconsistent newlines. (diff) | |
download | opensim-SC_OLD-9ff9279a7cd76a6a5aaf84ef759053d7bde4001a.zip opensim-SC_OLD-9ff9279a7cd76a6a5aaf84ef759053d7bde4001a.tar.gz opensim-SC_OLD-9ff9279a7cd76a6a5aaf84ef759053d7bde4001a.tar.bz2 opensim-SC_OLD-9ff9279a7cd76a6a5aaf84ef759053d7bde4001a.tar.xz |
Mantis#1785. Thank you kindly, Junta_Kohime for a patch that"
llAxes2Rot now implemented. Important note: quaternion <x,y,z,s>
is equal to <-x,-y,-z,-s>. The result may be different from LSL
output, but it is correct. A problem of rounding caused an error
of square rooting of zero as negative number, corrected by squaring
again. Function tested 360° along 3 axes. Vector fwd, left and up
have to be normalized.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 33 |
1 files changed, 31 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 c3255b1..c597661 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -410,8 +410,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
410 | public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) | 410 | public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) |
411 | { | 411 | { |
412 | m_host.AddScriptLPS(1); | 412 | m_host.AddScriptLPS(1); |
413 | NotImplemented("llAxes2Rot"); | 413 | double x,y,z,s; |
414 | return new LSL_Types.Quaternion(); | 414 | int f=0; |
415 | // Important Note: q1=<x,y,z,s> is equal to q2=<-x,-y,-z,-s> | ||
416 | // Computing quaternion x,y,z,s values | ||
417 | x=((fwd.x-left.y-up.z+1)/4); | ||
418 | x*=x; | ||
419 | x=Math.Sqrt(Math.Sqrt(x)); | ||
420 | y=((1-up.z)/2-x*x); | ||
421 | y*=y; | ||
422 | y=Math.Sqrt(Math.Sqrt(y)); | ||
423 | z=((1-left.y)/2-x*x); | ||
424 | z*=z; | ||
425 | z=Math.Sqrt(Math.Sqrt(z)); | ||
426 | s=(1-x*x-y*y-z*z); | ||
427 | s*=s; | ||
428 | s=Math.Sqrt(Math.Sqrt(s)); | ||
429 | |||
430 | // Set f for signs detection | ||
431 | if (fwd.y+left.x >= 0){f+=1;} | ||
432 | if (fwd.z+up.x >= 0){f+=2;} | ||
433 | if (left.z-up.y >= 0){f+=4;} | ||
434 | // Set correct quaternion signs based on f value | ||
435 | if (f==0){x=-x;} | ||
436 | if (f==1){x=-x;y=-y;} | ||
437 | if (f==2){x=-x;z=-z;} | ||
438 | if (f==3){s=-s;} | ||
439 | if (f==4){x=-x;s=-s;} | ||
440 | if (f==5){z=-z;} | ||
441 | if (f==6){y=-y;} | ||
442 | return new LSL_Types.Quaternion(x, y, z, s); | ||
443 | |||
415 | } | 444 | } |
416 | 445 | ||
417 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) | 446 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) |