mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[wpimath] Rename FindNearestPoint() to Nearest() (#7513)
This is easier to type and follows the naming of Pose2d::Nearest(). Since Ellipse2d and Rectangle2d were added for the 2025 season, we don't need to add deprecation notices.
This commit is contained in:
@@ -16,7 +16,7 @@ TEST(Ellipse2dTest, FocalPoints) {
|
||||
EXPECT_EQ(frc::Translation2d(4_m, 2_m), b);
|
||||
}
|
||||
|
||||
TEST(Ellipse2dTest, IntersectsPoint) {
|
||||
TEST(Ellipse2dTest, Intersects) {
|
||||
constexpr frc::Pose2d center{1_m, 2_m, 0_deg};
|
||||
constexpr frc::Ellipse2d ellipse{center, 2_m, 1_m};
|
||||
|
||||
@@ -27,7 +27,7 @@ TEST(Ellipse2dTest, IntersectsPoint) {
|
||||
EXPECT_FALSE(ellipse.Intersects(pointB));
|
||||
}
|
||||
|
||||
TEST(Ellipse2dTest, ContainsPoint) {
|
||||
TEST(Ellipse2dTest, Contains) {
|
||||
constexpr frc::Pose2d center{-1_m, -2_m, 45_deg};
|
||||
constexpr frc::Ellipse2d ellipse{center, 2_m, 1_m};
|
||||
|
||||
@@ -38,7 +38,7 @@ TEST(Ellipse2dTest, ContainsPoint) {
|
||||
EXPECT_FALSE(ellipse.Contains(pointB));
|
||||
}
|
||||
|
||||
TEST(Ellipse2dTest, DistanceToPoint) {
|
||||
TEST(Ellipse2dTest, Distance) {
|
||||
constexpr double kEpsilon = 1E-9;
|
||||
|
||||
constexpr frc::Pose2d center{1_m, 2_m, 270_deg};
|
||||
@@ -57,29 +57,29 @@ TEST(Ellipse2dTest, DistanceToPoint) {
|
||||
EXPECT_NEAR(0.19210128384806818, ellipse.Distance(point4).value(), kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Ellipse2dTest, FindNearestPoint) {
|
||||
TEST(Ellipse2dTest, Nearest) {
|
||||
constexpr double kEpsilon = 1E-9;
|
||||
|
||||
constexpr frc::Pose2d center{1_m, 2_m, 270_deg};
|
||||
constexpr frc::Ellipse2d ellipse{center, 1_m, 2_m};
|
||||
|
||||
constexpr frc::Translation2d point1{2.5_m, 2_m};
|
||||
auto nearestPoint1 = ellipse.FindNearestPoint(point1);
|
||||
auto nearestPoint1 = ellipse.Nearest(point1);
|
||||
EXPECT_NEAR(2.5, nearestPoint1.X().value(), kEpsilon);
|
||||
EXPECT_NEAR(2.0, nearestPoint1.Y().value(), kEpsilon);
|
||||
|
||||
constexpr frc::Translation2d point2{1_m, 2_m};
|
||||
auto nearestPoint2 = ellipse.FindNearestPoint(point2);
|
||||
auto nearestPoint2 = ellipse.Nearest(point2);
|
||||
EXPECT_NEAR(1.0, nearestPoint2.X().value(), kEpsilon);
|
||||
EXPECT_NEAR(2.0, nearestPoint2.Y().value(), kEpsilon);
|
||||
|
||||
constexpr frc::Translation2d point3{1_m, 1_m};
|
||||
auto nearestPoint3 = ellipse.FindNearestPoint(point3);
|
||||
auto nearestPoint3 = ellipse.Nearest(point3);
|
||||
EXPECT_NEAR(1.0, nearestPoint3.X().value(), kEpsilon);
|
||||
EXPECT_NEAR(1.0, nearestPoint3.Y().value(), kEpsilon);
|
||||
|
||||
constexpr frc::Translation2d point4{-1_m, 2.5_m};
|
||||
auto nearestPoint4 = ellipse.FindNearestPoint(point4);
|
||||
auto nearestPoint4 = ellipse.Nearest(point4);
|
||||
EXPECT_NEAR(-0.8512799937611617, nearestPoint4.X().value(), kEpsilon);
|
||||
EXPECT_NEAR(2.378405333174535, nearestPoint4.Y().value(), kEpsilon);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ TEST(Rectangle2dTest, NewWithCorners) {
|
||||
EXPECT_EQ(4.0, rect.Center().Y().value());
|
||||
}
|
||||
|
||||
TEST(Rectangle2dTest, IntersectsPoint) {
|
||||
TEST(Rectangle2dTest, Intersects) {
|
||||
constexpr frc::Pose2d center{4_m, 3_m, 90_deg};
|
||||
constexpr frc::Rectangle2d rect{center, 2_m, 3_m};
|
||||
|
||||
@@ -28,7 +28,7 @@ TEST(Rectangle2dTest, IntersectsPoint) {
|
||||
EXPECT_FALSE(rect.Intersects(frc::Translation2d{4_m, 3.5_m}));
|
||||
}
|
||||
|
||||
TEST(Rectangle2dTest, ContainsPoint) {
|
||||
TEST(Rectangle2dTest, Contains) {
|
||||
constexpr frc::Pose2d center{2_m, 3_m, 45_deg};
|
||||
constexpr frc::Rectangle2d rect{center, 3_m, 1_m};
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST(Rectangle2dTest, ContainsPoint) {
|
||||
EXPECT_FALSE(rect.Contains(frc::Translation2d{3_m, 3_m}));
|
||||
}
|
||||
|
||||
TEST(Rectangle2dTest, DistanceToPoint) {
|
||||
TEST(Rectangle2dTest, Distance) {
|
||||
constexpr double kEpsilon = 1E-9;
|
||||
|
||||
constexpr frc::Pose2d center{1_m, 2_m, 270_deg};
|
||||
@@ -56,19 +56,19 @@ TEST(Rectangle2dTest, DistanceToPoint) {
|
||||
EXPECT_NEAR(1, rect.Distance(point4).value(), kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Rectangle2dTest, FindNearestPoint) {
|
||||
TEST(Rectangle2dTest, Nearest) {
|
||||
constexpr double kEpsilon = 1E-9;
|
||||
|
||||
constexpr frc::Pose2d center{1_m, 1_m, 90_deg};
|
||||
constexpr frc::Rectangle2d rect{center, 3_m, 4_m};
|
||||
|
||||
constexpr frc::Translation2d point1{1_m, 3_m};
|
||||
auto nearestPoint1 = rect.FindNearestPoint(point1);
|
||||
auto nearestPoint1 = rect.Nearest(point1);
|
||||
EXPECT_NEAR(1.0, nearestPoint1.X().value(), kEpsilon);
|
||||
EXPECT_NEAR(2.5, nearestPoint1.Y().value(), kEpsilon);
|
||||
|
||||
constexpr frc::Translation2d point2{0_m, 0_m};
|
||||
auto nearestPoint2 = rect.FindNearestPoint(point2);
|
||||
auto nearestPoint2 = rect.Nearest(point2);
|
||||
EXPECT_NEAR(0.0, nearestPoint2.X().value(), kEpsilon);
|
||||
EXPECT_NEAR(0.0, nearestPoint2.Y().value(), kEpsilon);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user