From c928f46f7c21bfe7431c027595471592563165bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 15 Feb 2022 17:50:04 +0100 Subject: [PATCH] Make all angles be between 0 and 2*Pi, to ensure pathfinding points are laid out correctly --- rust/src/pathfinder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/pathfinder.rs b/rust/src/pathfinder.rs index 1aeb1a2..0c7392e 100644 --- a/rust/src/pathfinder.rs +++ b/rust/src/pathfinder.rs @@ -164,7 +164,7 @@ impl Pathfinder { } let x_diff = wall.p2.x - wall.p1.x; let y_diff = wall.p2.y - wall.p1.y; - let p1_angle = y_diff.atan2(x_diff); + let p1_angle = y_diff.atan2(x_diff).rem_euclid(2.0 * PI); let p2_angle = (p1_angle + PI).rem_euclid(2.0 * PI); for (point, angle) in [(wall.p1, p1_angle), (wall.p2, p2_angle)] { let angles = endpoints.entry(point).or_insert_with(Vec::new);