[wpimath] Rotation2d: Only use gcem::hypot when constexpr evaluated (#5419)

This commit is contained in:
Peter Johnson
2023-07-04 12:05:55 -06:00
committed by GitHub
parent 96145de7db
commit 3a61deedde

View File

@@ -23,7 +23,8 @@ constexpr Rotation2d::Rotation2d(units::degree_t value)
: Rotation2d(units::radian_t{value}) {}
constexpr Rotation2d::Rotation2d(double x, double y) {
const auto magnitude = gcem::hypot(x, y);
double magnitude =
std::is_constant_evaluated() ? gcem::hypot(x, y) : std::hypot(x, y);
if (magnitude > 1e-6) {
m_sin = y / magnitude;
m_cos = x / magnitude;