#[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; use num::{Zero, One}; use rand::{Rng, Rand}; use alga::general::ClosedAdd; use core::{ColumnVector, Scalar}; use core::dimension::{DimName, U1, U2, U3, U4, U5, U6}; use core::storage::OwnedStorage; use core::allocator::OwnedAllocator; use geometry::TranslationBase; impl TranslationBase where N: Scalar + Zero, S: OwnedStorage, S::Alloc: OwnedAllocator { /// Creates a new square identity rotation of the given `dimension`. #[inline] pub fn identity() -> TranslationBase { Self::from_vector(ColumnVector::::from_element(N::zero())) } } impl One for TranslationBase where N: Scalar + Zero + ClosedAdd, S: OwnedStorage, S::Alloc: OwnedAllocator { #[inline] fn one() -> Self { Self::identity() } } impl Rand for TranslationBase where N: Scalar + Rand, S: OwnedStorage, S::Alloc: OwnedAllocator { #[inline] fn rand(rng: &mut G) -> Self { Self::from_vector(rng.gen()) } } #[cfg(feature = "arbitrary")] impl Arbitrary for TranslationBase where N: Scalar + Arbitrary + Send, S: OwnedStorage + Send, S::Alloc: OwnedAllocator { #[inline] fn arbitrary(rng: &mut G) -> Self { Self::from_vector(Arbitrary::arbitrary(rng)) } } /* * * Small translation construction from components. * */ macro_rules! componentwise_constructors_impl( ($($D: ty, $($args: ident:$irow: expr),*);* $(;)*) => {$( impl TranslationBase where N: Scalar, S: OwnedStorage, S::Alloc: OwnedAllocator { /// Initializes this matrix from its components. #[inline] pub fn new($($args: N),*) -> Self { Self::from_vector(ColumnVector::::new($($args),*)) } } )*} ); componentwise_constructors_impl!( U1, x:0; U2, x:0, y:1; U3, x:0, y:1, z:2; U4, x:0, y:1, z:2, w:3; U5, x:0, y:1, z:2, w:3, a:4; U6, x:0, y:1, z:2, w:3, a:4, b:5; );