From c64327b8a9148b86aae6052381a226e9e1bd5179 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Thu, 1 Jun 2017 23:22:57 +0200 Subject: [PATCH] Increased delta bits and changed quaternion generator. --- tests/OpenTK.Tests/Assertions.fs | 2 +- tests/OpenTK.Tests/Generators.fs | 4 ++-- tests/OpenTK.Tests/Vector3Tests.fs | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/OpenTK.Tests/Assertions.fs b/tests/OpenTK.Tests/Assertions.fs index 8b7a292c..e4e1c412 100644 --- a/tests/OpenTK.Tests/Assertions.fs +++ b/tests/OpenTK.Tests/Assertions.fs @@ -9,7 +9,7 @@ open OpenTK [] module private AssertHelpers = [] - let private BitAccuracy = 6 + let private BitAccuracy = 9 let approxEq a b = MathHelper.ApproximatelyEqual(a,b,BitAccuracy) diff --git a/tests/OpenTK.Tests/Generators.fs b/tests/OpenTK.Tests/Generators.fs index e7496c44..ec19a3c1 100644 --- a/tests/OpenTK.Tests/Generators.fs +++ b/tests/OpenTK.Tests/Generators.fs @@ -38,8 +38,8 @@ module private Generators = let quat = singleArb - |> Gen.four - |> Gen.map Quaternion + |> Gen.three + |> Gen.map (fun (x,y,z) -> Quaternion(x,y,z,0.0f) |> Quaternion.Normalize) |> Arb.fromGen let mat2 = diff --git a/tests/OpenTK.Tests/Vector3Tests.fs b/tests/OpenTK.Tests/Vector3Tests.fs index 14cf0422..37bac293 100644 --- a/tests/OpenTK.Tests/Vector3Tests.fs +++ b/tests/OpenTK.Tests/Vector3Tests.fs @@ -709,7 +709,7 @@ module Vector3 = let transformedQuat = q * vectorQuat * inverse let transformedVector = transformedQuat.Xyz - Assert.Equal(transformedVector, Vector3.Transform(v, q)) + Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(v, q)) [] let ``Transformation by quaternion by reference is the same as multiplication by quaternion and its conjugate`` (v : Vector3, q : Quaternion) = @@ -719,4 +719,17 @@ module Vector3 = let transformedQuat = q * vectorQuat * inverse let transformedVector = transformedQuat.Xyz - Assert.Equal(transformedVector, Vector3.Transform(ref v, ref q)) \ No newline at end of file + Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(ref v, ref q)) + + [] + let ``Transformation by identity quaternion does not alter vector`` (v : Vector3) = + let q = Quaternion.Identity + let vectorQuat = Quaternion(v.X, v.Y, v.Z, 0.0f) + let inverse = Quaternion.Invert(q) + + let transformedQuat = q * vectorQuat * inverse + let transformedVector = transformedQuat.Xyz + + Assert.ApproximatelyEqual(v, transformedVector) + Assert.ApproximatelyEqual(v, Vector3.Transform(v, q)) + Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(v, q)) \ No newline at end of file