Bézier-rs: Add utils to subpath (#1058)

* Add utils to bezier-rs subpath

* Apply code review changes

* Remove tan from constant

* Fix compile

* Fix tests
This commit is contained in:
0HyperCube
2023-03-02 16:48:09 +00:00
committed by Keavon Chambers
parent 7254c008f9
commit 66ec85a3c9
12 changed files with 206 additions and 10 deletions
@@ -2,6 +2,8 @@ use super::*;
use crate::utils::SubpathTValue;
use crate::utils::TValue;
use glam::DAffine2;
/// Helper function to ensure the index and t value pair is mapped within a maximum index value.
/// Allows for the point to be fetched without needing to handle an additional edge case.
/// - Ex. Via `subpath.iter().nth(index).evaluate(t);`
@@ -263,6 +265,13 @@ impl<ManipulatorGroupId: crate::Identifier> Subpath<ManipulatorGroupId> {
closed: false,
}
}
/// Apply a transformation to all of the [ManipulatorGroup]s in the [Subpath].
pub fn apply_transform(&mut self, affine_transform: DAffine2) {
for manipulator_group in &mut self.manipulator_groups {
manipulator_group.apply_transform(affine_transform);
}
}
}
#[cfg(test)]
@@ -719,4 +728,10 @@ mod tests {
assert!(result.manipulator_groups[0].out_handle.is_none());
assert_eq!(result.manipulator_groups.len(), 1);
}
fn transform_subpath() {
let mut subpath = set_up_open_subpath();
subpath.apply_transform(glam::DAffine2::IDENTITY);
assert_eq!(subpath, set_up_open_subpath());
}
}