diff options
author | UbitUmarov | 2018-04-03 23:00:37 +0100 |
---|---|---|
committer | UbitUmarov | 2018-04-03 23:00:37 +0100 |
commit | e031d79d48cb4cb42ccb160d2894d078f835eb10 (patch) | |
tree | cecf42bc736df641d480edfc1fe6de760b918cff /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |
parent | try fix git (diff) | |
download | opensim-SC-e031d79d48cb4cb42ccb160d2894d078f835eb10.zip opensim-SC-e031d79d48cb4cb42ccb160d2894d078f835eb10.tar.gz opensim-SC-e031d79d48cb4cb42ccb160d2894d078f835eb10.tar.bz2 opensim-SC-e031d79d48cb4cb42ccb160d2894d078f835eb10.tar.xz |
add auxiliar functions float osVecMagSquare(a), float osVecDistSquare(vector a), float osAngleBetween(vector a, vector b) and float osRound(ffloat value, integer ndigits)
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e156582..51b289b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -4804,5 +4804,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4804 | return -1; | 4804 | return -1; |
4805 | return sog.GetLinkNumber(name); | 4805 | return sog.GetLinkNumber(name); |
4806 | } | 4806 | } |
4807 | |||
4808 | // rounds to the nearest number with provided number of decimal places | ||
4809 | public LSL_Float osRound(LSL_Float value, LSL_Integer ndigits) | ||
4810 | { | ||
4811 | if(ndigits <= 0) | ||
4812 | return Math.Round(value, MidpointRounding.AwayFromZero); | ||
4813 | if(ndigits > 15) | ||
4814 | ndigits = 15; | ||
4815 | return Math.Round(value, ndigits, MidpointRounding.AwayFromZero); | ||
4816 | } | ||
4817 | |||
4818 | public LSL_Float osVecMagSquare(LSL_Vector a) | ||
4819 | { | ||
4820 | return LSL_Vector.MagSquare(a); | ||
4821 | } | ||
4822 | |||
4823 | public LSL_Float osVecDistSquare(LSL_Vector a, LSL_Vector b) | ||
4824 | { | ||
4825 | return LSL_Vector.MagSquare(a - b); | ||
4826 | } | ||
4827 | |||
4828 | // returns the angle between 2 vectors -pi to pi | ||
4829 | public LSL_Float osAngleBetween(LSL_Vector a, LSL_Vector b) | ||
4830 | { | ||
4831 | double dot = LSL_Vector.Dot(a,b); | ||
4832 | double mcross = LSL_Vector.Mag(LSL_Vector.Cross(a,b)); | ||
4833 | return Math.Atan2(mcross, dot); | ||
4834 | } | ||
4807 | } | 4835 | } |
4808 | } | 4836 | } |