@@ -55,7 +55,7 @@ fn compute_polygon_vertex(triple: &[BackendCoord; 3], d: f64, buf: &mut Vec<Back
55
55
let b1 = -b_t. 1 ;
56
56
let c1 = b_p. 1 - a_p. 1 ;
57
57
58
- // If the determinant is 0, then we cannot actuall get a intersection point.
58
+ // If the determinant is 0, then we cannot actually get a intersection point.
59
59
// n that case, the two lines are parallel and we just emit the point a_p \approx b_p
60
60
if ( a0 * b1 - a1 * b0) . abs ( ) <= f64:: EPSILON {
61
61
buf. push ( ( a_p. 0 as i32 , a_p. 1 as i32 ) ) ;
@@ -67,14 +67,19 @@ fn compute_polygon_vertex(triple: &[BackendCoord; 3], d: f64, buf: &mut Vec<Back
67
67
let y = a_p. 1 + u * a_t. 1 ;
68
68
69
69
let cross_product = a_t. 0 * b_t. 1 - a_t. 1 * b_t. 0 ;
70
- if ( cross_product < 0.0 && d < 0.0 ) || ( cross_product > 0.0 && d > 0.0 ) {
70
+ let is_outside_the_angle = ( cross_product < 0.0 && d < 0.0 ) || ( cross_product > 0.0 && d > 0.0 ) ;
71
+ if is_outside_the_angle {
71
72
// Then we are at the outter side of the angle, so we need to consider a cap.
72
73
let dist_square = ( x - triple[ 1 ] . 0 as f64 ) . powi ( 2 ) + ( y - triple[ 1 ] . 1 as f64 ) . powi ( 2 ) ;
73
- // If the point is too far away from the line, we need to cap it.
74
- if dist_square > d * d * 16.0 {
74
+ let needs_capping = dist_square > d * d * 16.0 ;
75
+ if needs_capping {
76
+ // If the point is too far away from the line, we need to cap it to make it look okay
75
77
buf. push ( ( a_p. 0 . round ( ) as i32 , a_p. 1 . round ( ) as i32 ) ) ;
76
78
buf. push ( ( b_p. 0 . round ( ) as i32 , b_p. 1 . round ( ) as i32 ) ) ;
77
79
return ;
80
+ } else {
81
+ // We are at the outer side of the angle, at an appropriate distance, so we just emit the point.
82
+ buf. push ( ( x. round ( ) as i32 , y. round ( ) as i32 ) ) ;
78
83
}
79
84
} else {
80
85
// We are at the inner side of the angle, so we just emit the point.
0 commit comments