diff --git a/src/traits/rotation.rs b/src/traits/rotation.rs index 1aa548e7..a83ff469 100644 --- a/src/traits/rotation.rs +++ b/src/traits/rotation.rs @@ -35,10 +35,10 @@ pub trait Rotate * - `point`: the center of rotation. */ #[inline] -pub fn rotate_wrt_point, - M2: Rotation + Translation, - LV: Neg, - AV> +pub fn rotated_wrt_point, + M2: Rotation + Translation, + LV: Neg, + AV> (m: &M, ammount: &AV, center: &LV) -> M2 { let mut res = m.translated(&-center); @@ -49,6 +49,17 @@ pub fn rotate_wrt_point, res } +#[inline] +pub fn rotate_wrt_point + Translation, + LV: Neg, + AV> + (m: &mut M, ammount: &AV, center: &LV) +{ + m.translate_by(&-center); + m.rotate_by(ammount); + m.translate_by(center); +} + /** * Applies a rotation centered on the input translation. * @@ -56,9 +67,26 @@ pub fn rotate_wrt_point, * - `ammount`: the rotation to apply. */ #[inline] -pub fn rotate_wrt_center + Translation, - M2: Rotation + Translation, +pub fn rotated_wrt_center + Translation, + M2: Rotation + Translation, + LV: Neg, + AV> + (m: &M, ammount: &AV) -> M2 +{ rotated_wrt_point(m, ammount, &m.translation()) } + +/** + * Applies a rotation centered on the input translation. + * + * - `m`: the object to be rotated. + * - `ammount`: the rotation to apply. + */ +#[inline] +pub fn rotate_wrt_center + Translation + Rotation, LV: Neg, AV> - (m: &M, ammount: &AV) -> M2 -{ rotate_wrt_point(m, ammount, &m.translation()) } + (m: &mut M, ammount: &AV) +{ + let t = m.translation(); + + rotate_wrt_point(m, ammount, &t) +}