mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
@@ -10,6 +10,24 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
TEST(Pose2dTest, RotateBy) {
|
||||
constexpr auto x = 1_m;
|
||||
constexpr auto y = 2_m;
|
||||
const Pose2d initial{x, y, 45_deg};
|
||||
|
||||
const Rotation2d rotation{5_deg};
|
||||
const auto rotated = initial.RotateBy(rotation);
|
||||
|
||||
// Translation is rotated by CCW rotation matrix
|
||||
double c = rotation.Cos();
|
||||
double s = rotation.Sin();
|
||||
EXPECT_DOUBLE_EQ(c * x.value() - s * y.value(), rotated.X().value());
|
||||
EXPECT_DOUBLE_EQ(s * x.value() + c * y.value(), rotated.Y().value());
|
||||
EXPECT_DOUBLE_EQ(
|
||||
initial.Rotation().Degrees().value() + rotation.Degrees().value(),
|
||||
rotated.Rotation().Degrees().value());
|
||||
}
|
||||
|
||||
TEST(Pose2dTest, TransformBy) {
|
||||
const Pose2d initial{1_m, 2_m, 45_deg};
|
||||
const Transform2d transform{Translation2d{5_m, 0_m}, 5_deg};
|
||||
|
||||
Reference in New Issue
Block a user