Increased delta bits and changed quaternion generator.

This commit is contained in:
Jarl Gullberg 2017-06-01 23:22:57 +02:00
parent 5c4ef39c92
commit c64327b8a9
No known key found for this signature in database
GPG key ID: 750FF6F6BDA72D23
3 changed files with 18 additions and 5 deletions

View file

@ -9,7 +9,7 @@ open OpenTK
[<AutoOpen>]
module private AssertHelpers =
[<Literal>]
let private BitAccuracy = 6
let private BitAccuracy = 9
let approxEq a b = MathHelper.ApproximatelyEqual(a,b,BitAccuracy)

View file

@ -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 =

View file

@ -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))
[<Property>]
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))
Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(ref v, ref q))
[<Property>]
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))