aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorMicheil Merlin2010-11-20 17:04:59 -0600
committerJustin Clark-Casey (justincc)2010-11-27 01:29:55 +0000
commita8a8fb6e1380c37b64963d0968c5af4f64e6f25e (patch)
tree8219a3cac6693dfe0732e979e697dfdef4ab176c /OpenSim/Region/ScriptEngine
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-a8a8fb6e1380c37b64963d0968c5af4f64e6f25e.zip
opensim-SC_OLD-a8a8fb6e1380c37b64963d0968c5af4f64e6f25e.tar.gz
opensim-SC_OLD-a8a8fb6e1380c37b64963d0968c5af4f64e6f25e.tar.bz2
opensim-SC_OLD-a8a8fb6e1380c37b64963d0968c5af4f64e6f25e.tar.xz
llVecNorm nant test
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index dfc9aa3..1d55b95 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
47 { 47 {
48 48
49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; 49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
50 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
50 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
51 52
52 [SetUp] 53 [SetUp]
@@ -164,5 +165,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
164 Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail"); 165 Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail");
165 Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail"); 166 Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail");
166 } 167 }
168
169 [Test]
170 // llVecNorm test.
171 public void TestllVecNorm()
172 {
173 // Check special case for normalizing zero vector.
174 CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d));
175 // Check various vectors.
176 CheckllVecNorm(new LSL_Types.Vector3(10.0d, 25.0d, 0.0d), new LSL_Types.Vector3(0.371391d, 0.928477d, 0.0d));
177 CheckllVecNorm(new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), new LSL_Types.Vector3(1.0d, 0.0d, 0.0d));
178 CheckllVecNorm(new LSL_Types.Vector3(-90.0d, 55.0d, 2.0d), new LSL_Types.Vector3(-0.853128d, 0.521356d, 0.018958d));
179 CheckllVecNorm(new LSL_Types.Vector3(255.0d, 255.0d, 255.0d), new LSL_Types.Vector3(0.577350d, 0.577350d, 0.577350d));
180 }
181
182 public void CheckllVecNorm(LSL_Types.Vector3 vec, LSL_Types.Vector3 vecNormCheck)
183 {
184 // Call LSL function to normalize the vector.
185 LSL_Types.Vector3 vecNorm = m_lslApi.llVecNorm(vec);
186 // Check each vector component against expected result.
187 Assert.AreEqual(vecNorm.x, vecNormCheck.x, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on x component");
188 Assert.AreEqual(vecNorm.y, vecNormCheck.y, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on y component");
189 Assert.AreEqual(vecNorm.z, vecNormCheck.z, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on z component");
190 }
167 } 191 }
168} 192}