From 09699227c4e31076556f0ba54af2e0ce7a3ff002 Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Sat, 21 Sep 2019 17:19:40 +0200 Subject: [PATCH] ships flying true --- frontend/src/lib.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/frontend/src/lib.rs b/frontend/src/lib.rs index 431e9cb..2be137d 100644 --- a/frontend/src/lib.rs +++ b/frontend/src/lib.rs @@ -41,20 +41,21 @@ impl Circle { let r = q * 1.1; - let (x, y) = if true { - ( - x3 + (r.powi(2)-(q/2.0).powi(2)).sqrt() * (y1-y2)/q, - y3 + (r.powi(2)-(q/2.0).powi(2)).sqrt() * (x2-x1)/q - ) - } else { - ( - x3 - (r.powi(2)-(q/2.0).powi(2)).sqrt() * (y1-y2)/q, - y3 - (r.powi(2)-(q/2.0).powi(2)).sqrt() * (x2-x1)/q - ) - }; + let mut x = x3 + (r.powi(2)-(q/2.0).powi(2)).sqrt() * (y1-y2)/q; + let mut y = y3 + (r.powi(2)-(q/2.0).powi(2)).sqrt() * (x2-x1)/q; - let a1 = (y - y1).atan2(x - x1); - let a2 = (y - y2).atan2(x - x2); + + let mut a1 = (y - y1).atan2(x - x1); + let mut a2 = (y - y2).atan2(x - x2); + + if a2 < a1 { + + x = x3 - (r.powi(2)-(q/2.0).powi(2)).sqrt() * (y1-y2)/q; + y = y3 - (r.powi(2)-(q/2.0).powi(2)).sqrt() * (x2-x1)/q; + + a2 = (y - y1).atan2(x - x1); + a1 = (y - y2).atan2(x - x2); + } let distance = q.ceil() as usize + 1;