mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpiutil] Deprecate wpi::math constants in favor of wpi::numbers (#3383)
The constants were moved from std::math to std::numbers before ratification in C++20.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <wpi/math>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -14,8 +14,8 @@ using namespace frc;
|
||||
static constexpr double kEpsilon = 1E-9;
|
||||
|
||||
TEST(Rotation2dTest, RadiansToDegrees) {
|
||||
const Rotation2d rot1{units::radian_t(wpi::math::pi / 3)};
|
||||
const Rotation2d rot2{units::radian_t(wpi::math::pi / 4)};
|
||||
const Rotation2d rot1{units::radian_t(wpi::numbers::pi / 3)};
|
||||
const Rotation2d rot2{units::radian_t(wpi::numbers::pi / 4)};
|
||||
|
||||
EXPECT_NEAR(rot1.Degrees().to<double>(), 60.0, kEpsilon);
|
||||
EXPECT_NEAR(rot2.Degrees().to<double>(), 45.0, kEpsilon);
|
||||
@@ -25,15 +25,15 @@ TEST(Rotation2dTest, DegreesToRadians) {
|
||||
const auto rot1 = Rotation2d(45.0_deg);
|
||||
const auto rot2 = Rotation2d(30.0_deg);
|
||||
|
||||
EXPECT_NEAR(rot1.Radians().to<double>(), wpi::math::pi / 4.0, kEpsilon);
|
||||
EXPECT_NEAR(rot2.Radians().to<double>(), wpi::math::pi / 6.0, kEpsilon);
|
||||
EXPECT_NEAR(rot1.Radians().to<double>(), wpi::numbers::pi / 4.0, kEpsilon);
|
||||
EXPECT_NEAR(rot2.Radians().to<double>(), wpi::numbers::pi / 6.0, kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Rotation2dTest, RotateByFromZero) {
|
||||
const Rotation2d zero;
|
||||
auto sum = zero + Rotation2d(90.0_deg);
|
||||
|
||||
EXPECT_NEAR(sum.Radians().to<double>(), wpi::math::pi / 2.0, kEpsilon);
|
||||
EXPECT_NEAR(sum.Radians().to<double>(), wpi::numbers::pi / 2.0, kEpsilon);
|
||||
EXPECT_NEAR(sum.Degrees().to<double>(), 90.0, kEpsilon);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <wpi/math>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "frc/geometry/Pose2d.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -23,8 +23,8 @@ TEST(Twist2dTest, Straight) {
|
||||
}
|
||||
|
||||
TEST(Twist2dTest, QuarterCircle) {
|
||||
const Twist2d quarterCircle{5.0_m / 2.0 * wpi::math::pi, 0_m,
|
||||
units::radian_t(wpi::math::pi / 2.0)};
|
||||
const Twist2d quarterCircle{5.0_m / 2.0 * wpi::numbers::pi, 0_m,
|
||||
units::radian_t(wpi::numbers::pi / 2.0)};
|
||||
const auto quarterCirclePose = Pose2d().Exp(quarterCircle);
|
||||
|
||||
EXPECT_NEAR(quarterCirclePose.X().to<double>(), 5.0, kEpsilon);
|
||||
@@ -60,7 +60,7 @@ TEST(Twist2dTest, Pose2dLog) {
|
||||
|
||||
const auto twist = start.Log(end);
|
||||
|
||||
EXPECT_NEAR(twist.dx.to<double>(), 5 / 2.0 * wpi::math::pi, kEpsilon);
|
||||
EXPECT_NEAR(twist.dx.to<double>(), 5 / 2.0 * wpi::numbers::pi, kEpsilon);
|
||||
EXPECT_NEAR(twist.dy.to<double>(), 0.0, kEpsilon);
|
||||
EXPECT_NEAR(twist.dtheta.to<double>(), wpi::math::pi / 2.0, kEpsilon);
|
||||
EXPECT_NEAR(twist.dtheta.to<double>(), wpi::numbers::pi / 2.0, kEpsilon);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user