Bezier-rs: Add SubpathTValue and euclidean parameterization for subpaths (#1027)

* Added SubpathTValue and euclidean parameterization for subpaths

* Small fix

* Added bounds checking to get_segment

* Code review

* code review nit for clarity

---------

Co-authored-by: Hannah Li <hannahli2010@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Rob Nadal
2023-02-17 15:33:52 -05:00
committed by Keavon Chambers
co-authored by Hannah Li Keavon Chambers
parent 344f243432
commit 9a52cae9b9
10 changed files with 334 additions and 247 deletions
+10
View File
@@ -18,6 +18,16 @@ pub enum TValue {
EuclideanWithinError { t: f64, error: f64 },
}
#[derive(Copy, Clone, PartialEq)]
pub enum SubpathTValue {
Parametric { segment_index: usize, t: f64 },
GlobalParametric(f64),
Euclidean { segment_index: usize, t: f64 },
GlobalEuclidean(f64),
EuclideanWithinError { segment_index: usize, t: f64, error: f64 },
GlobalEuclideanWithinError { t: f64, error: f64 },
}
/// Helper to perform the computation of a and c, where b is the provided point on the curve.
/// Given the correct power of `t` and `(1-t)`, the computation is the same for quadratic and cubic cases.
/// Relevant derivation and the definitions of a, b, and c can be found in [the projection identity section](https://pomax.github.io/bezierinfo/#abc) of Pomax's bezier curve primer.