mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[wpimath] Prevent CoordinateSystem from accepting left-handed systems (#8750)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package org.wpilib.math.geometry;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.wpilib.math.util.Units;
|
||||
@@ -232,4 +233,17 @@ class CoordinateSystemTest {
|
||||
CoordinateSystem.EDN(),
|
||||
CoordinateSystem.NED());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLeftHandedSystemThrowsException() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new CoordinateSystem(CoordinateAxis.N(), CoordinateAxis.E(), CoordinateAxis.U()));
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new CoordinateSystem(CoordinateAxis.E(), CoordinateAxis.U(), CoordinateAxis.N()));
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new CoordinateSystem(CoordinateAxis.N(), CoordinateAxis.W(), CoordinateAxis.D()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,3 +155,15 @@ TEST(CoordinateSystemTest, Transform3dEDNtoNED) {
|
||||
Rotation3d{45_deg, 0_deg, 0_deg}},
|
||||
CoordinateSystem::EDN(), CoordinateSystem::NED());
|
||||
}
|
||||
|
||||
TEST(CoordinateSystemTest, LeftHandedSystemThrowsException) {
|
||||
EXPECT_THROW(CoordinateSystem(CoordinateAxis::N(), CoordinateAxis::E(),
|
||||
CoordinateAxis::U()),
|
||||
std::domain_error);
|
||||
EXPECT_THROW(CoordinateSystem(CoordinateAxis::E(), CoordinateAxis::U(),
|
||||
CoordinateAxis::N()),
|
||||
std::domain_error);
|
||||
EXPECT_THROW(CoordinateSystem(CoordinateAxis::N(), CoordinateAxis::W(),
|
||||
CoordinateAxis::D()),
|
||||
std::domain_error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user