diff --git a/tools/transform.rs b/tools/transform.rs index 8f9b59c..4f6f5e8 100644 --- a/tools/transform.rs +++ b/tools/transform.rs @@ -242,7 +242,10 @@ fn from_polar(coord: Coord) -> Coord { fn to_polar(coord: Coord) -> Coord { let r = f64::sqrt(coord.x.powi(2) + coord.y.powi(2)); - let theta = f64::atan2(coord.y, coord.x); + let mut theta = f64::atan2(coord.y, coord.x); + if theta < 0.0 { + theta += 2.0 * std::f64::consts::PI; + } coord! { x: r, y: theta} }