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:
@@ -7,7 +7,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/math>
|
||||
#include <wpi/numbers>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -114,5 +114,5 @@ double Joystick::GetDirectionRadians() const {
|
||||
}
|
||||
|
||||
double Joystick::GetDirectionDegrees() const {
|
||||
return (180 / wpi::math::pi) * GetDirectionRadians();
|
||||
return (180 / wpi::numbers::pi) * GetDirectionRadians();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/math>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
@@ -37,12 +37,12 @@ KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
: m_leftMotor(&leftMotor),
|
||||
m_rightMotor(&rightMotor),
|
||||
m_backMotor(&backMotor) {
|
||||
m_leftVec = {std::cos(leftMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(leftMotorAngle * (wpi::math::pi / 180.0))};
|
||||
m_rightVec = {std::cos(rightMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(rightMotorAngle * (wpi::math::pi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(backMotorAngle * (wpi::math::pi / 180.0))};
|
||||
m_leftVec = {std::cos(leftMotorAngle * (wpi::numbers::pi / 180.0)),
|
||||
std::sin(leftMotorAngle * (wpi::numbers::pi / 180.0))};
|
||||
m_rightVec = {std::cos(rightMotorAngle * (wpi::numbers::pi / 180.0)),
|
||||
std::sin(rightMotorAngle * (wpi::numbers::pi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (wpi::numbers::pi / 180.0)),
|
||||
std::sin(backMotorAngle * (wpi::numbers::pi / 180.0))};
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, m_leftMotor);
|
||||
registry.AddChild(this, m_rightMotor);
|
||||
@@ -81,8 +81,8 @@ void KilloughDrive::DrivePolar(double magnitude, double angle,
|
||||
reported = true;
|
||||
}
|
||||
|
||||
DriveCartesian(magnitude * std::sin(angle * (wpi::math::pi / 180.0)),
|
||||
magnitude * std::cos(angle * (wpi::math::pi / 180.0)),
|
||||
DriveCartesian(magnitude * std::sin(angle * (wpi::numbers::pi / 180.0)),
|
||||
magnitude * std::cos(angle * (wpi::numbers::pi / 180.0)),
|
||||
zRotation, 0.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/math>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/drive/Vector2d.h"
|
||||
@@ -73,8 +73,8 @@ void MecanumDrive::DrivePolar(double magnitude, double angle,
|
||||
reported = true;
|
||||
}
|
||||
|
||||
DriveCartesian(magnitude * std::cos(angle * (wpi::math::pi / 180.0)),
|
||||
magnitude * std::sin(angle * (wpi::math::pi / 180.0)),
|
||||
DriveCartesian(magnitude * std::cos(angle * (wpi::numbers::pi / 180.0)),
|
||||
magnitude * std::sin(angle * (wpi::numbers::pi / 180.0)),
|
||||
zRotation, 0.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <wpi/math>
|
||||
#include <wpi/numbers>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -16,8 +16,8 @@ Vector2d::Vector2d(double x, double y) {
|
||||
}
|
||||
|
||||
void Vector2d::Rotate(double angle) {
|
||||
double cosA = std::cos(angle * (wpi::math::pi / 180.0));
|
||||
double sinA = std::sin(angle * (wpi::math::pi / 180.0));
|
||||
double cosA = std::cos(angle * (wpi::numbers::pi / 180.0));
|
||||
double sinA = std::sin(angle * (wpi::numbers::pi / 180.0));
|
||||
double out[2];
|
||||
out[0] = x * cosA - y * sinA;
|
||||
out[1] = x * sinA + y * cosA;
|
||||
|
||||
Reference in New Issue
Block a user