Skip to content

Commit 9d9f5ae

Browse files
slayydenKeavon
authored andcommitted
Cleaned up formatting and updated variable names.
1 parent d7eb66c commit 9d9f5ae

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

libraries/bezier-rs/src/subpath/solvers.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,27 +278,20 @@ impl<ManipulatorGroupId: crate::Identifier> Subpath<ManipulatorGroupId> {
278278
// if we had a segment from the last point back to the first.
279279

280280
// 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);
284284

285285
// 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));
287287
// Compute point of intersection.
288288
// 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.
292292
|| 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 },
302295
);
303296

304297
// Add the winding modification to the winding number of the rest of the curve.

0 commit comments

Comments
 (0)