Bezier-rs: Add a pivot point to the 'rotate' function (#792)

* Add function to rotate around a point

* Update svg

* Improve rotation line-to-center styling

* Add second angle of lines

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Hannah Li
2022-11-06 20:52:58 -08:00
committed by Keavon Chambers
parent 9eb2b9f6a3
commit a695584d36
4 changed files with 40 additions and 6 deletions

View File

@@ -90,6 +90,12 @@ impl Bezier {
self.apply_transformation(&|point| rotation_matrix.mul_vec2(point))
}
/// Returns a Bezier curve that results from rotating the curve around the provided point by the given angle (in radians).
pub fn rotate_about_point(&self, angle: f64, pivot: DVec2) -> Bezier {
let rotation_matrix = DMat2::from_angle(angle);
self.apply_transformation(&|point| rotation_matrix.mul_vec2(point - pivot) + pivot)
}
/// Returns a Bezier curve that results from translating the curve by the given `DVec2`.
pub fn translate(&self, translation: DVec2) -> Bezier {
self.apply_transformation(&|point| point + translation)