mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 01:05:33 +00:00
Added transformation by quaternion test.
This commit is contained in:
parent
7d846c4459
commit
a2a9c922d4
|
@ -684,7 +684,7 @@ module Vector3 =
|
|||
|
||||
[<Property>]
|
||||
let ``Unit one is correct`` =
|
||||
let unitOne = Vector3((float32)1, (float32)1, (float32)1)
|
||||
let unitOne = Vector3(1.0f, 1.0f, 1.0f)
|
||||
|
||||
Assert.Equal(Vector3.One, unitOne)
|
||||
|
||||
|
@ -696,4 +696,27 @@ module Vector3 =
|
|||
let expectedSize = sizeof<float32> * 3
|
||||
|
||||
Assert.Equal(expectedSize, Vector3.SizeInBytes)
|
||||
Assert.Equal(expectedSize, Marshal.SizeOf(Vector3()))
|
||||
Assert.Equal(expectedSize, Marshal.SizeOf(Vector3()))
|
||||
|
||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||
module Transformation =
|
||||
//
|
||||
[<Property>]
|
||||
let ``Transformation by quaternion is the same as multiplication by quaternion and its conjugate`` (v : Vector3, q : Quaternion) =
|
||||
let vectorQuat = Quaternion(v.X, v.Y, v.Z, 0.0f)
|
||||
let inverse = Quaternion.Invert(q)
|
||||
|
||||
let transformedQuat = q * vectorQuat * inverse
|
||||
let transformedVector = Vector3(transformedQuat.X, transformedQuat.Y, transformedQuat.Z)
|
||||
|
||||
Assert.Equal(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) =
|
||||
let vectorQuat = Quaternion(v.X, v.Y, v.Z, 0.0f)
|
||||
let inverse = Quaternion.Invert(q)
|
||||
|
||||
let transformedQuat = q * vectorQuat * inverse
|
||||
let transformedVector = Vector3(transformedQuat.X, transformedQuat.Y,transformedQuat.Z)
|
||||
|
||||
Assert.Equal(transformedVector, Vector3.Transform(ref v, ref q))
|
|
@ -806,4 +806,27 @@ module Vector4 =
|
|||
let expectedSize = sizeof<float32> * 4
|
||||
|
||||
Assert.Equal(expectedSize, Vector4.SizeInBytes)
|
||||
Assert.Equal(expectedSize, Marshal.SizeOf(Vector4()))
|
||||
Assert.Equal(expectedSize, Marshal.SizeOf(Vector4()))
|
||||
|
||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||
module Transformation =
|
||||
//
|
||||
[<Property>]
|
||||
let ``Transformation by quaternion is the same as multiplication by quaternion and its conjugate`` (v : Vector4, q : Quaternion) =
|
||||
let vectorQuat = Quaternion(v.X, v.Y, v.Z, v.W)
|
||||
let inverse = Quaternion.Invert(q)
|
||||
|
||||
let transformedQuat = q * vectorQuat * inverse
|
||||
let transformedVector = Vector4(transformedQuat.X, transformedQuat.Y, transformedQuat.Z, transformedQuat.W)
|
||||
|
||||
Assert.Equal(transformedVector, Vector4.Transform(v, q))
|
||||
|
||||
[<Property>]
|
||||
let ``Transformation by quaternion by reference is the same as multiplication by quaternion and its conjugate`` (v : Vector4, q : Quaternion) =
|
||||
let vectorQuat = Quaternion(v.X, v.Y, v.Z, v.W)
|
||||
let inverse = Quaternion.Invert(q)
|
||||
|
||||
let transformedQuat = q * vectorQuat * inverse
|
||||
let transformedVector = Vector4(transformedQuat.X, transformedQuat.Y,transformedQuat.Z, transformedQuat.W)
|
||||
|
||||
Assert.Equal(transformedVector, Vector4.Transform(ref v, ref q))
|
Loading…
Reference in a new issue