mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Add distance/angle constructor to Translation2d (#2791)
This commit is contained in:
committed by
GitHub
parent
b66fcdb3f7
commit
17698af5e3
@@ -88,3 +88,13 @@ TEST(Translation2dTest, Inequality) {
|
||||
const Translation2d two{9_m, 5.7_m};
|
||||
EXPECT_TRUE(one != two);
|
||||
}
|
||||
|
||||
TEST(Translation2dTest, PolarConstructor) {
|
||||
Translation2d one{std::sqrt(2) * 1_m, Rotation2d(45_deg)};
|
||||
EXPECT_NEAR(one.X().to<double>(), 1.0, kEpsilon);
|
||||
EXPECT_NEAR(one.Y().to<double>(), 1.0, kEpsilon);
|
||||
|
||||
Translation2d two{2_m, Rotation2d(60_deg)};
|
||||
EXPECT_NEAR(two.X().to<double>(), 1.0, kEpsilon);
|
||||
EXPECT_NEAR(two.Y().to<double>(), std::sqrt(3.0), kEpsilon);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user