Add C++20 std::math constants shim (#1788)

Based on http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0631r7.pdf
This commit is contained in:
Tyler Veness
2019-07-31 22:15:22 -07:00
committed by Peter Johnson
parent dd43109596
commit 37d316aa09
11 changed files with 119 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -9,9 +9,9 @@
#include <cmath>
using namespace frc;
#include <wpi/math>
constexpr double kPi = 3.14159265358979323846;
using namespace frc;
Vector2d::Vector2d(double x, double y) {
this->x = x;
@@ -19,8 +19,8 @@ Vector2d::Vector2d(double x, double y) {
}
void Vector2d::Rotate(double angle) {
double cosA = std::cos(angle * (kPi / 180.0));
double sinA = std::sin(angle * (kPi / 180.0));
double cosA = std::cos(angle * (wpi::math::pi / 180.0));
double sinA = std::sin(angle * (wpi::math::pi / 180.0));
double out[2];
out[0] = x * cosA - y * sinA;
out[1] = x * sinA + y * cosA;