use crate::allocator::Allocator; use crate::geometry::{Rotation, UnitComplex, UnitQuaternion}; use crate::{DefaultAllocator, DimName, Point, RealField, Scalar, VectorN, U2, U3}; use simba::scalar::ClosedMul; pub trait AbstractRotation: PartialEq + ClosedMul + Clone { fn identity() -> Self; fn inverse(&self) -> Self; fn inverse_mut(&mut self); fn transform_vector(&self, v: &VectorN) -> VectorN where DefaultAllocator: Allocator; fn transform_point(&self, p: &Point) -> Point where DefaultAllocator: Allocator; fn inverse_transform_vector(&self, v: &VectorN) -> VectorN where DefaultAllocator: Allocator; fn inverse_transform_point(&self, p: &Point) -> Point where DefaultAllocator: Allocator; } impl AbstractRotation for Rotation where DefaultAllocator: Allocator { #[inline] fn identity() -> Self { Self::identity() } #[inline] fn inverse(&self) -> Self { self.inverse() } #[inline] fn inverse_mut(&mut self) { self.inverse_mut() } #[inline] fn transform_vector(&self, v: &VectorN) -> VectorN where DefaultAllocator: Allocator { self * v } #[inline] fn transform_point(&self, p: &Point) -> Point where DefaultAllocator: Allocator { self * p } #[inline] fn inverse_transform_vector(&self, v: &VectorN) -> VectorN where DefaultAllocator: Allocator { self.inverse_transform_vector(v) } #[inline] fn inverse_transform_point(&self, p: &Point) -> Point where DefaultAllocator: Allocator { self.inverse_transform_point(p) } } impl AbstractRotation for UnitQuaternion { #[inline] fn identity() -> Self { Self::identity() } #[inline] fn inverse(&self) -> Self { self.inverse() } #[inline] fn inverse_mut(&mut self) { self.inverse_mut() } #[inline] fn transform_vector(&self, v: &VectorN) -> VectorN { self * v } #[inline] fn transform_point(&self, p: &Point) -> Point { self * p } #[inline] fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { self.inverse_transform_vector(v) } #[inline] fn inverse_transform_point(&self, p: &Point) -> Point { self.inverse_transform_point(p) } } impl AbstractRotation for UnitComplex { #[inline] fn identity() -> Self { Self::identity() } #[inline] fn inverse(&self) -> Self { self.inverse() } #[inline] fn inverse_mut(&mut self) { self.inverse_mut() } #[inline] fn transform_vector(&self, v: &VectorN) -> VectorN { self * v } #[inline] fn transform_point(&self, p: &Point) -> Point { self * p } #[inline] fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { self.inverse_transform_vector(v) } #[inline] fn inverse_transform_point(&self, p: &Point) -> Point { self.inverse_transform_point(p) } }