@@ -278,27 +278,20 @@ impl<ManipulatorGroupId: crate::Identifier> Subpath<ManipulatorGroupId> {
278
278
// if we had a segment from the last point back to the first.
279
279
280
280
// Position of first and last anchor points.
281
- let first = self . manipulator_groups . first ( ) . map ( |manipulator_group| manipulator_group. anchor ) ;
282
- let last = self . manipulator_groups . last ( ) . map ( |manipulator_group| manipulator_group. anchor ) ;
283
- let endpoints = first . zip ( last ) ;
281
+ let first_anchor_point = self . manipulator_groups . first ( ) . map ( |manipulator_group| manipulator_group. anchor ) ;
282
+ let last_anchor_point = self . manipulator_groups . last ( ) . map ( |manipulator_group| manipulator_group. anchor ) ;
283
+ let endpoints = first_anchor_point . zip ( last_anchor_point ) ;
284
284
285
285
// Weight interpolating location of first and last anchor points. Reject weights outside of [0, 1].
286
- let t = endpoints. map ( |( f , l ) | ( target_point. y - l . y ) / ( f . y - l . y ) ) . filter ( |t| ( 0.0 ..=1.0 ) . contains ( t) ) ;
286
+ let t = endpoints. map ( |( first , last ) | ( target_point. y - last . y ) / ( first . y - last . y ) ) . filter ( |t| ( 0.0 ..=1. ) . contains ( t) ) ;
287
287
// Compute point of intersection.
288
288
// Reject points that are right of the click location since we compute winding numbers by ray-casting left.
289
- let intersection_point = endpoints. zip ( t) . map ( |( ( f , l ) , t) | t * f + ( 1.0 - t) * l ) . filter ( |p| p. x <= target_point. x ) ;
290
- let winding_modification = first . zip ( intersection_point) . map_or_else (
291
- // None variant implies no modification to winding number.
289
+ let intersection_point = endpoints. zip ( t) . map ( |( ( first , last ) , t) | t * first + ( 1. - t) * last ) . filter ( |p| p. x <= target_point. x ) ;
290
+ let winding_modification = first_anchor_point . zip ( intersection_point) . map_or_else (
291
+ // None variant implies no intersection and no modification to winding number.
292
292
|| 0 ,
293
- |( f, p) | {
294
- if f. y >= p. y {
295
- // This is a clockwise intersection, so subtract from the winding number.
296
- -1
297
- } else {
298
- // This is a counterclockwise intersection, so add to the winding number.
299
- 1
300
- }
301
- } ,
293
+ // Clockwise (decrement winding number) and counterclockwise (increment winding number) intersection respectively.
294
+ |( f, p) | if f. y >= p. y { -1 } else { 1 } ,
302
295
) ;
303
296
304
297
// Add the winding modification to the winding number of the rest of the curve.
0 commit comments