mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpimath] Rotation2d: Only use gcem::hypot when constexpr evaluated (#5419)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user