Bezier-rs: Add self_intersection to subpath (#1035)

* add self-intersection to subpath, rebased old work onto master

* fix interactive website after rebase

* fix rustdoc iframe placement

* remove double comment

* address comments

* revert evaluate change

* address comment + fix assert statement bug

* update function comments
This commit is contained in:
Thomas Cheng
2023-02-21 17:08:55 -05:00
committed by Keavon Chambers
parent 4797aed05b
commit f2d35f50de
6 changed files with 164 additions and 66 deletions
+6 -2
View File
@@ -359,13 +359,17 @@ impl Bezier {
let (self2, self2_t_values) = (self1.clone(), self1_t_values.clone());
let num_curves = self1.len();
// Adjacent reduced curves cannot intersect
if num_curves <= 2 {
return vec![];
}
// Create iterators that combine a subcurve with the `t` value pair that it was trimmed with
let combined_iterator1 = self1.into_iter().zip(self1_t_values.windows(2).map(|t_pair| Range { start: t_pair[0], end: t_pair[1] }));
// Second one needs to be a list because Iterator does not implement copy
let combined_list2: Vec<(Bezier, Range<f64>)> = self2.into_iter().zip(self2_t_values.windows(2).map(|t_pair| Range { start: t_pair[0], end: t_pair[1] })).collect();
// Adjacent reduced curves cannot intersect
// So for each curve, look for intersections with every curve that is at least 2 indices away
// For each curve, look for intersections with every curve that is at least 2 indices away
combined_iterator1
.take(num_curves - 2)
.enumerate()