ranim_core/traits/transform/rotate.rs
1use glam::DVec3;
2
3/// Rotating operations.
4///
5/// This trait is blanket-implemented for all `T: ApplyTransform<Rigid>`
6/// (see [`super::ApplyTransform`]).
7pub trait RotateTransform {
8 /// Rotate the item by a given angle about a given axis.
9 fn rotate_on_axis(&mut self, axis: DVec3, angle: f64) -> &mut Self;
10 /// Rotate the item by a given angle about the X axis.
11 fn rotate_on_x(&mut self, angle: f64) -> &mut Self {
12 self.rotate_on_axis(DVec3::X, angle)
13 }
14 /// Rotate the item by a given angle about the Y axis.
15 fn rotate_on_y(&mut self, angle: f64) -> &mut Self {
16 self.rotate_on_axis(DVec3::Y, angle)
17 }
18 /// Rotate the item by a given angle about the Z axis.
19 fn rotate_on_z(&mut self, angle: f64) -> &mut Self {
20 self.rotate_on_axis(DVec3::Z, angle)
21 }
22}