@@ -8,6 +8,7 @@ extern "C" {
88use chrono:: prelude:: * ;
99use chrono:: Local ;
1010use rand:: Rng ;
11+ use core:: fmt;
1112use std:: fs:: File ;
1213use std:: fs:: OpenOptions ;
1314use std:: io:: prelude:: * ;
@@ -2443,11 +2444,11 @@ fn check_single_sight_line(
24432444 ( center. 0 - endpoint1. 0 , center. 1 - endpoint1. 1 ) ,
24442445 ( endpoint2. 0 - endpoint1. 0 , endpoint2. 1 - endpoint1. 1 ) ,
24452446 ) ;
2446- let square_mag = get_length ( endpoint2. 0 - endpoint1. 0 , endpoint2. 0 - endpoint1. 0 ) ;
2447+ let square_mag = f32 :: powi ( endpoint2. 0 - endpoint1. 0 , 2 ) + f32 :: powi ( endpoint2. 1 - endpoint1. 1 , 2 ) ;
24472448
24482449 let t = dot_product / square_mag;
2449-
2450- let point_to_test;
2450+ log ( format ! ( "{}, {}" , dot_product , square_mag ) . as_str ( ) ) ;
2451+ let mut point_to_test;
24512452 if t <= 0.0 {
24522453 point_to_test = endpoint1;
24532454 } else if t >= 1.0 {
@@ -2459,10 +2460,15 @@ fn check_single_sight_line(
24592460 ) ;
24602461 }
24612462
2463+ point_to_test = ( endpoint1. 0 + point_to_test. 0 , endpoint1. 1 + point_to_test. 1 ) ;
2464+
24622465 let vec_from_center_to_test_point = ( center. 0 - point_to_test. 0 , center. 1 - point_to_test. 1 ) ;
24632466
2464- get_length (
2467+ let visible = get_length (
24652468 vec_from_center_to_test_point. 0 ,
24662469 vec_from_center_to_test_point. 1 ,
2467- ) < radius
2470+ ) <= radius;
2471+
2472+ log ( format ! ( "{}" , visible) . as_str ( ) ) ;
2473+ return visible;
24682474}
0 commit comments