|
1 | 1 | package dev.slimevr.unit |
2 | 2 |
|
3 | 3 | import com.jme3.math.FastMath |
| 4 | +import dev.slimevr.unit.TrackerTestUtils.assertAngleEquals |
4 | 5 | import dev.slimevr.unit.TrackerTestUtils.assertQuatEquals |
5 | 6 | import dev.slimevr.unit.TrackerTestUtils.assertQuatNotEquals |
| 7 | +import dev.slimevr.unit.TrackerTestUtils.quatApproxEqual |
6 | 8 | import io.github.axisangles.ktmath.EulerAngles |
7 | 9 | import io.github.axisangles.ktmath.EulerOrder |
8 | 10 | import io.github.axisangles.ktmath.Quaternion |
@@ -102,19 +104,20 @@ class ResetTheoryTests { |
102 | 104 | ) { |
103 | 105 | val boneOrientationA = (rawOrientation * attitudeAlign).toEulerAngles(EulerOrder.YZX) |
104 | 106 | val boneOrientationB = (headingCorrect * rawOrientation * attitudeAlign).toEulerAngles(EulerOrder.YZX) |
105 | | - assertEquals(boneOrientationA.x, boneOrientationB.x, FastMath.ZERO_TOLERANCE) |
106 | | - assertEquals(boneOrientationA.z, boneOrientationB.z, FastMath.ZERO_TOLERANCE) |
| 107 | + assertAngleEquals(boneOrientationA.x, boneOrientationB.x, FastMath.ZERO_TOLERANCE) |
| 108 | + assertAngleEquals(boneOrientationA.z, boneOrientationB.z, FastMath.ZERO_TOLERANCE) |
107 | 109 | // We can also show that we're calculating the right attitude alignment. |
108 | 110 | val attitudeAlignEul = attitudeAlign.toEulerAngles(EulerOrder.YZX) |
109 | | - assertEquals(attitudeAlignEul.x, boneOrientationA.x, FastMath.ZERO_TOLERANCE) |
110 | | - assertEquals(attitudeAlignEul.z, boneOrientationA.z, FastMath.ZERO_TOLERANCE) |
| 111 | + assertAngleEquals(attitudeAlignEul.x, boneOrientationA.x, FastMath.ZERO_TOLERANCE) |
| 112 | + assertAngleEquals(attitudeAlignEul.z, boneOrientationA.z, FastMath.ZERO_TOLERANCE) |
111 | 113 | } |
112 | 114 |
|
113 | 115 | @TestFactory |
114 | 116 | fun attitudeHeadingAlignDependenceTests(): List<DynamicTest> { |
115 | 117 | // Order doesn't matter if the attitude alignment has no attitude. |
116 | 118 | return roughAttitude.filterNot { FastMath.isApproxZero(it.x) && FastMath.isApproxZero(it.z) }.flatMap { aA -> |
117 | | - roughHeading.map { hA -> |
| 119 | + // Same for if heading alignment is the quaternion identity. |
| 120 | + roughHeading.filterNot { quatApproxEqual(it, Quaternion.IDENTITY) }.map { hA -> |
118 | 121 | DynamicTest.dynamicTest( |
119 | 122 | "testAttitudeHeadingAlignDependence( aA: $aA, hA: $hA )", |
120 | 123 | ) { |
|
0 commit comments