Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbecabf

Browse files
committed
Small fixes
1 parent 8fcca6b commit fbecabf

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

server/core/src/test/java/dev/slimevr/unit/ResetTheoryTests.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package dev.slimevr.unit
22

33
import com.jme3.math.FastMath
4+
import dev.slimevr.unit.TrackerTestUtils.assertAngleEquals
45
import dev.slimevr.unit.TrackerTestUtils.assertQuatEquals
56
import dev.slimevr.unit.TrackerTestUtils.assertQuatNotEquals
7+
import dev.slimevr.unit.TrackerTestUtils.quatApproxEqual
68
import io.github.axisangles.ktmath.EulerAngles
79
import io.github.axisangles.ktmath.EulerOrder
810
import io.github.axisangles.ktmath.Quaternion
@@ -102,19 +104,20 @@ class ResetTheoryTests {
102104
) {
103105
val boneOrientationA = (rawOrientation * attitudeAlign).toEulerAngles(EulerOrder.YZX)
104106
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)
107109
// We can also show that we're calculating the right attitude alignment.
108110
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)
111113
}
112114

113115
@TestFactory
114116
fun attitudeHeadingAlignDependenceTests(): List<DynamicTest> {
115117
// Order doesn't matter if the attitude alignment has no attitude.
116118
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 ->
118121
DynamicTest.dynamicTest(
119122
"testAttitudeHeadingAlignDependence( aA: $aA, hA: $hA )",
120123
) {

0 commit comments

Comments
 (0)