Commit aaef7bb3 authored by Federico Mena Quintero's avatar Federico Mena Quintero

Merge branch 'normalize_angle-rounding-error' into 'master'

Fix rounding error on i386 (#455).

See merge request !209
parents 60b26b5a 5d74a582
Pipeline #74559 passed with stages
in 31 minutes and 13 seconds
...@@ -44,7 +44,9 @@ impl Angle { ...@@ -44,7 +44,9 @@ impl Angle {
// Normalizes an angle to [0.0, 2*PI) // Normalizes an angle to [0.0, 2*PI)
fn normalize(rad: f64) -> f64 { fn normalize(rad: f64) -> f64 {
let res = rad % (PI * 2.0); let res = rad % (PI * 2.0);
if res < 0.0 { if res.abs() < std::f64::EPSILON {
res.abs()
} else if res < 0.0 {
res + PI * 2.0 res + PI * 2.0
} else { } else {
res res
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment