diff --git a/src/base/cg.rs b/src/base/cg.rs index 8ffec5cf..2464bce1 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -11,8 +11,8 @@ use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameDiff, DimNameSub, U1}; use crate::base::storage::{Storage, StorageMut}; use crate::base::{ - DefaultAllocator, Matrix3, Matrix4, MatrixN, Scalar, SquareMatrix, Unit, Vector, Vector2, - Vector3, VectorN, + Const, DefaultAllocator, Matrix3, Matrix4, MatrixN, Scalar, SquareMatrix, Unit, Vector, + Vector2, Vector3, VectorN, }; use crate::geometry::{ Isometry, IsometryMatrix3, Orthographic3, Perspective3, Point, Point2, Point3, Rotation2, @@ -411,18 +411,33 @@ where transform * v } +} +impl, Const<3>>> SquareMatrix, S> { /// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates. #[inline] - pub fn transform_point( - &self, - pt: &Point::USIZE }>, - ) -> Point::USIZE }> { - let transform = self.fixed_slice::, DimNameDiff>(0, 0); - let translation = self.fixed_slice::, U1>(0, D::dim() - 1); - let normalizer = self.fixed_slice::>(D::dim() - 1, 0); - let n = normalizer.tr_dot(&pt.coords) - + unsafe { *self.get_unchecked((D::dim() - 1, D::dim() - 1)) }; + pub fn transform_point(&self, pt: &Point) -> Point { + let transform = self.fixed_slice::, Const<2>>(0, 0); + let translation = self.fixed_slice::, U1>(0, 2); + let normalizer = self.fixed_slice::>(2, 0); + let n = normalizer.tr_dot(&pt.coords) + unsafe { *self.get_unchecked((2, 2)) }; + + if !n.is_zero() { + (transform * pt + translation) / n + } else { + transform * pt + translation + } + } +} + +impl, Const<4>>> SquareMatrix, S> { + /// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates. + #[inline] + pub fn transform_point(&self, pt: &Point) -> Point { + let transform = self.fixed_slice::, Const<3>>(0, 0); + let translation = self.fixed_slice::, U1>(0, 3); + let normalizer = self.fixed_slice::>(3, 0); + let n = normalizer.tr_dot(&pt.coords) + unsafe { *self.get_unchecked((3, 3)) }; if !n.is_zero() { (transform * pt + translation) / n diff --git a/src/geometry/abstract_rotation.rs b/src/geometry/abstract_rotation.rs index 2c44e46d..749d7473 100644 --- a/src/geometry/abstract_rotation.rs +++ b/src/geometry/abstract_rotation.rs @@ -39,7 +39,6 @@ pub trait AbstractRotation: PartialEq + ClosedMul + C impl AbstractRotation for Rotation where N::Element: SimdRealField, - // DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 144f86b9..065800d4 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -59,14 +59,14 @@ use crate::geometry::{AbstractRotation, Point, Translation}; #[cfg_attr( feature = "serde-serialize", serde(bound(serialize = "R: Serialize, - DefaultAllocator: Allocator, - Owned: Serialize")) + DefaultAllocator: Allocator>, + Owned>: Serialize")) )] #[cfg_attr( feature = "serde-serialize", serde(bound(deserialize = "R: Deserialize<'de>, - DefaultAllocator: Allocator, - Owned: Deserialize<'de>")) + DefaultAllocator: Allocator>, + Owned>: Deserialize<'de>")) )] pub struct Isometry // where @@ -84,7 +84,6 @@ where N: SimdRealField, R: Abomonation, Translation: Abomonation, - // DefaultAllocator: Allocator, { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { self.rotation.entomb(writer)?; @@ -104,7 +103,6 @@ where impl hash::Hash for Isometry where - // DefaultAllocator: Allocator, Owned>: hash::Hash, { fn hash(&self, state: &mut H) { @@ -114,7 +112,6 @@ where } impl Copy for Isometry where - // DefaultAllocator: Allocator, Owned>: Copy { } @@ -163,7 +160,6 @@ impl, const D: usize> Isometry impl, const D: usize> Isometry where N::Element: SimdRealField, - // DefaultAllocator: Allocator, { /// Inverts `self`. /// @@ -318,7 +314,6 @@ where impl, const D: usize> Isometry where N::Element: SimdRealField, - // DefaultAllocator: Allocator, { /// Transform the given point by this isometry. /// @@ -504,14 +499,13 @@ impl Isometry } impl Eq for Isometry where - R: AbstractRotation + Eq // DefaultAllocator: Allocator, + R: AbstractRotation + Eq { } impl PartialEq for Isometry where R: AbstractRotation + PartialEq, - // DefaultAllocator: Allocator, { #[inline] fn eq(&self, right: &Self) -> bool { @@ -522,7 +516,6 @@ where impl AbsDiffEq for Isometry where R: AbstractRotation + AbsDiffEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { type Epsilon = N::Epsilon; @@ -542,7 +535,6 @@ where impl RelativeEq for Isometry where R: AbstractRotation + RelativeEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -568,7 +560,6 @@ where impl UlpsEq for Isometry where R: AbstractRotation + UlpsEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -592,7 +583,6 @@ where impl fmt::Display for Isometry where R: fmt::Display, - // DefaultAllocator: Allocator + Allocator, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let precision = f.precision().unwrap_or(3); diff --git a/src/geometry/isometry_construction.rs b/src/geometry/isometry_construction.rs index 7a6b870f..60b5f6e2 100644 --- a/src/geometry/isometry_construction.rs +++ b/src/geometry/isometry_construction.rs @@ -13,19 +13,17 @@ use rand::{ use simba::scalar::SupersetOf; use simba::simd::SimdRealField; -use crate::base::dimension::U2; use crate::base::{Vector2, Vector3}; use crate::{ - AbstractRotation, Isometry, Isometry2, Isometry3, IsometryMatrix2, IsometryMatrix3, Point, - Point3, Rotation, Rotation3, Scalar, Translation, Translation2, Translation3, UnitComplex, - UnitQuaternion, + AbstractRotation, Const, Isometry, Isometry2, Isometry3, IsometryMatrix2, IsometryMatrix3, + Point, Point3, Rotation, Rotation3, Scalar, Translation, Translation2, Translation3, + UnitComplex, UnitQuaternion, }; impl, const D: usize> Isometry where N::Element: SimdRealField, - // DefaultAllocator: Allocator, { /// Creates a new identity isometry. /// @@ -73,7 +71,6 @@ where impl, const D: usize> One for Isometry where N::Element: SimdRealField, - // DefaultAllocator: Allocator, { /// Creates a new identity isometry. #[inline] @@ -87,7 +84,6 @@ impl Distribution> for where R: AbstractRotation, Standard: Distribution + Distribution, - // DefaultAllocator: Allocator, { #[inline] fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Isometry { @@ -101,8 +97,7 @@ where N: SimdRealField + Arbitrary + Send, N::Element: SimdRealField, R: AbstractRotation + Arbitrary + Send, - Owned: Send, - // DefaultAllocator: Allocator, + Owned>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { @@ -136,10 +131,7 @@ where /// ``` #[inline] pub fn new(translation: Vector2, angle: N) -> Self { - Self::from_parts( - Translation::from(translation), - Rotation::::new(angle), - ) + Self::from_parts(Translation::from(translation), Rotation::::new(angle)) } /// Creates a new isometry from the given translation coordinates. diff --git a/src/geometry/isometry_conversion.rs b/src/geometry/isometry_conversion.rs index e75570c2..235b120e 100644 --- a/src/geometry/isometry_conversion.rs +++ b/src/geometry/isometry_conversion.rs @@ -27,7 +27,6 @@ where N2: RealField + SupersetOf, R1: AbstractRotation + SubsetOf, R2: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Isometry { @@ -63,7 +62,7 @@ where #[inline] fn is_in_subset(dq: &UnitDualQuaternion) -> bool { crate::is_convertible::<_, UnitQuaternion>(&dq.rotation()) - && crate::is_convertible::<_, Translation>(&dq.translation()) + && crate::is_convertible::<_, Translation>(&dq.translation()) } #[inline] @@ -79,7 +78,6 @@ where N2: RealField + SupersetOf, R1: AbstractRotation + SubsetOf, R2: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Similarity { @@ -154,8 +152,8 @@ where #[inline] fn is_in_subset(m: &MatrixN, U1>>) -> bool { - let rot = m.fixed_slice::(0, 0); - let bottom = m.fixed_slice::(D, 0); + let rot = m.fixed_slice::, Const>(0, 0); + let bottom = m.fixed_slice::>(D, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && @@ -167,7 +165,7 @@ where #[inline] fn from_superset_unchecked(m: &MatrixN, U1>>) -> Self { - let t = m.fixed_slice::(0, D).into_owned(); + let t = m.fixed_slice::, U1>(0, D).into_owned(); let t = Translation { vector: crate::convert_unchecked(t), }; @@ -208,7 +206,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Copy, R::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Isometry; 2]) -> Self { @@ -227,7 +224,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Copy, R::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Isometry; 4]) -> Self { @@ -256,7 +252,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Copy, R::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Isometry; 8]) -> Self { @@ -293,7 +288,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Copy, R::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Isometry; 16]) -> Self { diff --git a/src/geometry/isometry_ops.rs b/src/geometry/isometry_ops.rs index ecca9bb2..f6fff378 100644 --- a/src/geometry/isometry_ops.rs +++ b/src/geometry/isometry_ops.rs @@ -5,8 +5,8 @@ use simba::scalar::{ClosedAdd, ClosedMul}; use simba::simd::SimdRealField; use crate::base::allocator::Allocator; -use crate::base::dimension::{DimName, U1, U2, U3, U4}; -use crate::base::{DefaultAllocator, Unit, VectorN}; +use crate::base::dimension::{U1, U2, U3}; +use crate::base::{CVectorN, Const, DefaultAllocator, Unit}; use crate::Scalar; use crate::geometry::{ @@ -68,10 +68,9 @@ macro_rules! isometry_binop_impl( ($Op: ident, $op: ident; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty; $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N: SimdRealField, D: DimName, R> $Op<$Rhs> for $Lhs + impl<$($lives ,)* N: SimdRealField, R, const D: usize> $Op<$Rhs> for $Lhs where N::Element: SimdRealField, - R: AbstractRotation, - DefaultAllocator: Allocator { + R: AbstractRotation, { type Output = $Output; #[inline] @@ -116,20 +115,18 @@ macro_rules! isometry_binop_assign_impl_all( $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty; [val] => $action_val: expr; [ref] => $action_ref: expr;) => { - impl $OpAssign<$Rhs> for $Lhs + impl $OpAssign<$Rhs> for $Lhs where N::Element: SimdRealField, - R: AbstractRotation, - DefaultAllocator: Allocator { + R: AbstractRotation { #[inline] fn $op_assign(&mut $lhs, $rhs: $Rhs) { $action_val } } - impl<'b, N: SimdRealField, D: DimName, R> $OpAssign<&'b $Rhs> for $Lhs + impl<'b, N: SimdRealField, R, const D: usize> $OpAssign<&'b $Rhs> for $Lhs where N::Element: SimdRealField, - R: AbstractRotation, - DefaultAllocator: Allocator { + R: AbstractRotation { #[inline] fn $op_assign(&mut $lhs, $rhs: &'b $Rhs) { $action_ref @@ -142,7 +139,7 @@ macro_rules! isometry_binop_assign_impl_all( // Isometry ÷ Isometry isometry_binop_impl_all!( Mul, mul; - self: Isometry, rhs: Isometry, Output = Isometry; + self: Isometry, rhs: Isometry, Output = Isometry; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -157,7 +154,7 @@ isometry_binop_impl_all!( isometry_binop_impl_all!( Div, div; - self: Isometry, rhs: Isometry, Output = Isometry; + self: Isometry, rhs: Isometry, Output = Isometry; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -167,7 +164,7 @@ isometry_binop_impl_all!( // Isometry ×= Translation isometry_binop_assign_impl_all!( MulAssign, mul_assign; - self: Isometry, rhs: Translation; + self: Isometry, rhs: Translation; [val] => *self *= &rhs; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { let shift = self.rotation.transform_vector(&rhs.vector); @@ -179,7 +176,7 @@ isometry_binop_assign_impl_all!( // Isometry ÷= Isometry isometry_binop_assign_impl_all!( MulAssign, mul_assign; - self: Isometry, rhs: Isometry; + self: Isometry, rhs: Isometry; [val] => *self *= &rhs; [ref] => { let shift = self.rotation.transform_vector(&rhs.translation.vector); @@ -190,7 +187,7 @@ isometry_binop_assign_impl_all!( isometry_binop_assign_impl_all!( DivAssign, div_assign; - self: Isometry, rhs: Isometry; + self: Isometry, rhs: Isometry; [val] => *self /= &rhs; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; ); @@ -199,16 +196,18 @@ isometry_binop_assign_impl_all!( // Isometry ÷= R md_assign_impl_all!( MulAssign, mul_assign where N: SimdRealField for N::Element: SimdRealField; - (D, U1), (D, D) for D: DimName; - self: Isometry>, rhs: Rotation; + (Const, U1), (Const, Const) + const D; for; where; + self: Isometry, D>, rhs: Rotation; [val] => self.rotation *= rhs; [ref] => self.rotation *= rhs.clone(); ); md_assign_impl_all!( DivAssign, div_assign where N: SimdRealField for N::Element: SimdRealField; - (D, U1), (D, D) for D: DimName; - self: Isometry>, rhs: Rotation; + (Const, U1), (Const, Const) + const D; for; where; + self: Isometry, D>, rhs: Rotation; // TODO: don't invert explicitly? [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -216,16 +215,18 @@ md_assign_impl_all!( md_assign_impl_all!( MulAssign, mul_assign where N: SimdRealField for N::Element: SimdRealField; - (U3, U3), (U3, U3) for; - self: Isometry>, rhs: UnitQuaternion; + (U3, U3), (U3, U3) + const; for; where; + self: Isometry, 3>, rhs: UnitQuaternion; [val] => self.rotation *= rhs; [ref] => self.rotation *= *rhs; ); md_assign_impl_all!( DivAssign, div_assign where N: SimdRealField for N::Element: SimdRealField; - (U3, U3), (U3, U3) for; - self: Isometry>, rhs: UnitQuaternion; + (U3, U3), (U3, U3) + const; for; where; + self: Isometry, 3>, rhs: UnitQuaternion; // TODO: don't invert explicitly? [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -233,16 +234,18 @@ md_assign_impl_all!( md_assign_impl_all!( MulAssign, mul_assign where N: SimdRealField for N::Element: SimdRealField; - (U2, U2), (U2, U2) for; - self: Isometry>, rhs: UnitComplex; + (U2, U2), (U2, U2) + const; for; where; + self: Isometry, 2>, rhs: UnitComplex; [val] => self.rotation *= rhs; [ref] => self.rotation *= *rhs; ); md_assign_impl_all!( DivAssign, div_assign where N: SimdRealField for N::Element: SimdRealField; - (U2, U2), (U2, U2) for; - self: Isometry>, rhs: UnitComplex; + (U2, U2), (U2, U2) + const; for; where; + self: Isometry, 2>, rhs: UnitComplex; // TODO: don't invert explicitly? [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -251,7 +254,7 @@ md_assign_impl_all!( // Isometry × Point isometry_binop_impl_all!( Mul, mul; - self: Isometry, right: Point, Output = Point; + self: Isometry, right: Point, Output = Point; [val val] => self.translation * self.rotation.transform_point(&right); [ref val] => &self.translation * self.rotation.transform_point(&right); [val ref] => self.translation * self.rotation.transform_point(right); @@ -263,7 +266,7 @@ isometry_binop_impl_all!( Mul, mul; // TODO: because of `transform_vector`, we cant use a generic storage type for the rhs vector, // i.e., right: Vector where S: Storage. - self: Isometry, right: VectorN, Output = VectorN; + self: Isometry, right: CVectorN, Output = CVectorN; [val val] => self.rotation.transform_vector(&right); [ref val] => self.rotation.transform_vector(&right); [val ref] => self.rotation.transform_vector(right); @@ -275,7 +278,7 @@ isometry_binop_impl_all!( Mul, mul; // TODO: because of `transform_vector`, we cant use a generic storage type for the rhs vector, // i.e., right: Vector where S: Storage. - self: Isometry, right: Unit>, Output = Unit>; + self: Isometry, right: Unit>, Output = Unit>; [val val] => Unit::new_unchecked(self.rotation.transform_vector(right.as_ref())); [ref val] => Unit::new_unchecked(self.rotation.transform_vector(right.as_ref())); [val ref] => Unit::new_unchecked(self.rotation.transform_vector(right.as_ref())); @@ -285,7 +288,7 @@ isometry_binop_impl_all!( // Isometry × Translation isometry_binop_impl_all!( Mul, mul; - self: Isometry, right: Translation, Output = Isometry; + self: Isometry, right: Translation, Output = Isometry; [val val] => &self * &right; [ref val] => self * &right; [val ref] => &self * right; @@ -299,7 +302,7 @@ isometry_binop_impl_all!( // Translation × Isometry isometry_binop_impl_all!( Mul, mul; - self: Translation, right: Isometry, Output = Isometry; + self: Translation, right: Isometry, Output = Isometry; [val val] => Isometry::from_parts(self * right.translation, right.rotation); [ref val] => Isometry::from_parts(self * &right.translation, right.rotation); [val ref] => Isometry::from_parts(self * &right.translation, right.rotation.clone()); @@ -308,13 +311,11 @@ isometry_binop_impl_all!( macro_rules! isometry_from_composition_impl( ($Op: ident, $op: ident; - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(for $Dims: ident: $DimsBound: ident),*; + $($Dims: ident),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty; $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N: SimdRealField $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs - where N::Element: SimdRealField, - DefaultAllocator: Allocator + - Allocator { + impl<$($lives ,)* N: SimdRealField $(, const $Dims: usize)*> $Op<$Rhs> for $Lhs + where N::Element: SimdRealField { type Output = $Output; #[inline] @@ -327,7 +328,7 @@ macro_rules! isometry_from_composition_impl( macro_rules! isometry_from_composition_impl_all( ($Op: ident, $op: ident; - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(for $Dims: ident: $DimsBound: ident),*; + $($Dims: ident),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty; [val val] => $action_val_val: expr; [ref val] => $action_ref_val: expr; @@ -336,25 +337,25 @@ macro_rules! isometry_from_composition_impl_all( isometry_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: $Lhs, $rhs: $Rhs, Output = $Output; $action_val_val; ); isometry_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: &'a $Lhs, $rhs: $Rhs, Output = $Output; $action_ref_val; 'a); isometry_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: $Lhs, $rhs: &'b $Rhs, Output = $Output; $action_val_ref; 'b); isometry_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: &'a $Lhs, $rhs: &'b $Rhs, Output = $Output; $action_ref_ref; 'a, 'b); } @@ -363,8 +364,8 @@ macro_rules! isometry_from_composition_impl_all( // Rotation × Translation isometry_from_composition_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName; - self: Rotation, right: Translation, Output = Isometry>; + D; + self: Rotation, right: Translation, Output = Isometry, D>; [val val] => Isometry::from_parts(Translation::from(&self * right.vector), self); [ref val] => Isometry::from_parts(Translation::from(self * right.vector), self.clone()); [val ref] => Isometry::from_parts(Translation::from(&self * &right.vector), self); @@ -374,9 +375,9 @@ isometry_from_composition_impl_all!( // UnitQuaternion × Translation isometry_from_composition_impl_all!( Mul, mul; - (U4, U1), (U3, U1); - self: UnitQuaternion, right: Translation, - Output = Isometry>; + ; + self: UnitQuaternion, right: Translation, + Output = Isometry, 3>; [val val] => Isometry::from_parts(Translation::from(&self * right.vector), self); [ref val] => Isometry::from_parts(Translation::from( self * right.vector), *self); [val ref] => Isometry::from_parts(Translation::from(&self * &right.vector), self); @@ -386,9 +387,9 @@ isometry_from_composition_impl_all!( // Isometry × Rotation isometry_from_composition_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName; - self: Isometry>, rhs: Rotation, - Output = Isometry>; + D; + self: Isometry, D>, rhs: Rotation, + Output = Isometry, D>; [val val] => Isometry::from_parts(self.translation, self.rotation * rhs); [ref val] => Isometry::from_parts(self.translation.clone(), self.rotation.clone() * rhs); // TODO: do not clone. [val ref] => Isometry::from_parts(self.translation, self.rotation * rhs.clone()); @@ -398,9 +399,9 @@ isometry_from_composition_impl_all!( // Rotation × Isometry isometry_from_composition_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName; - self: Rotation, right: Isometry>, - Output = Isometry>; + D; + self: Rotation, right: Isometry, D>, + Output = Isometry, D>; [val val] => &self * &right; [ref val] => self * &right; [val ref] => &self * right; @@ -413,9 +414,9 @@ isometry_from_composition_impl_all!( // Isometry ÷ Rotation isometry_from_composition_impl_all!( Div, div; - (D, D), (D, U1) for D: DimName; - self: Isometry>, rhs: Rotation, - Output = Isometry>; + D; + self: Isometry, D>, rhs: Rotation, + Output = Isometry, D>; [val val] => Isometry::from_parts(self.translation, self.rotation / rhs); [ref val] => Isometry::from_parts(self.translation.clone(), self.rotation.clone() / rhs); // TODO: do not clone. [val ref] => Isometry::from_parts(self.translation, self.rotation / rhs.clone()); @@ -425,9 +426,9 @@ isometry_from_composition_impl_all!( // Rotation ÷ Isometry isometry_from_composition_impl_all!( Div, div; - (D, D), (D, U1) for D: DimName; - self: Rotation, right: Isometry>, - Output = Isometry>; + D; + self: Rotation, right: Isometry, D>, + Output = Isometry, D>; // TODO: don't call inverse explicitly? [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; @@ -438,9 +439,9 @@ isometry_from_composition_impl_all!( // Isometry × UnitQuaternion isometry_from_composition_impl_all!( Mul, mul; - (U4, U1), (U3, U1); - self: Isometry>, rhs: UnitQuaternion, - Output = Isometry>; + ; + self: Isometry, 3>, rhs: UnitQuaternion, + Output = Isometry, 3>; [val val] => Isometry::from_parts(self.translation, self.rotation * rhs); [ref val] => Isometry::from_parts(self.translation.clone(), self.rotation * rhs); // TODO: do not clone. [val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs); @@ -450,9 +451,9 @@ isometry_from_composition_impl_all!( // UnitQuaternion × Isometry isometry_from_composition_impl_all!( Mul, mul; - (U4, U1), (U3, U1); - self: UnitQuaternion, right: Isometry>, - Output = Isometry>; + ; + self: UnitQuaternion, right: Isometry, 3>, + Output = Isometry, 3>; [val val] => &self * &right; [ref val] => self * &right; [val ref] => &self * right; @@ -465,9 +466,9 @@ isometry_from_composition_impl_all!( // Isometry ÷ UnitQuaternion isometry_from_composition_impl_all!( Div, div; - (U4, U1), (U3, U1); - self: Isometry>, rhs: UnitQuaternion, - Output = Isometry>; + ; + self: Isometry, 3>, rhs: UnitQuaternion, + Output = Isometry, 3>; [val val] => Isometry::from_parts(self.translation, self.rotation / rhs); [ref val] => Isometry::from_parts(self.translation.clone(), self.rotation / rhs); // TODO: do not clone. [val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs); @@ -477,9 +478,9 @@ isometry_from_composition_impl_all!( // UnitQuaternion ÷ Isometry isometry_from_composition_impl_all!( Div, div; - (U4, U1), (U3, U1); - self: UnitQuaternion, right: Isometry>, - Output = Isometry>; + ; + self: UnitQuaternion, right: Isometry, 3>, + Output = Isometry, 3>; // TODO: don't call inverse explicitly? [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; @@ -490,8 +491,8 @@ isometry_from_composition_impl_all!( // Translation × Rotation isometry_from_composition_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName; - self: Translation, right: Rotation, Output = Isometry>; + D; + self: Translation, right: Rotation, Output = Isometry, D>; [val val] => Isometry::from_parts(self, right); [ref val] => Isometry::from_parts(self.clone(), right); [val ref] => Isometry::from_parts(self, right.clone()); @@ -501,8 +502,8 @@ isometry_from_composition_impl_all!( // Translation × UnitQuaternion isometry_from_composition_impl_all!( Mul, mul; - (U4, U1), (U3, U1); - self: Translation, right: UnitQuaternion, Output = Isometry>; + ; + self: Translation, right: UnitQuaternion, Output = Isometry, 3>; [val val] => Isometry::from_parts(self, right); [ref val] => Isometry::from_parts(self.clone(), right); [val ref] => Isometry::from_parts(self, *right); @@ -512,9 +513,9 @@ isometry_from_composition_impl_all!( // Isometry × UnitComplex isometry_from_composition_impl_all!( Mul, mul; - (U2, U1), (U2, U1); - self: Isometry>, rhs: UnitComplex, - Output = Isometry>; + ; + self: Isometry, 2>, rhs: UnitComplex, + Output = Isometry, 2>; [val val] => Isometry::from_parts(self.translation, self.rotation * rhs); [ref val] => Isometry::from_parts(self.translation.clone(), self.rotation * rhs); // TODO: do not clone. [val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs); @@ -524,9 +525,9 @@ isometry_from_composition_impl_all!( // Isometry ÷ UnitComplex isometry_from_composition_impl_all!( Div, div; - (U2, U1), (U2, U1); - self: Isometry>, rhs: UnitComplex, - Output = Isometry>; + ; + self: Isometry, 2>, rhs: UnitComplex, + Output = Isometry, 2>; [val val] => Isometry::from_parts(self.translation, self.rotation / rhs); [ref val] => Isometry::from_parts(self.translation.clone(), self.rotation / rhs); // TODO: do not clone. [val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs); diff --git a/src/geometry/isometry_simba.rs b/src/geometry/isometry_simba.rs index 1db8dd43..1ba8b765 100755 --- a/src/geometry/isometry_simba.rs +++ b/src/geometry/isometry_simba.rs @@ -9,7 +9,6 @@ where N::Element: SimdRealField, R: SimdValue + AbstractRotation, R::Element: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { type Element = Isometry; type SimdBool = N::SimdBool; diff --git a/src/geometry/op_macros.rs b/src/geometry/op_macros.rs index 5a9cfa00..05194fd2 100644 --- a/src/geometry/op_macros.rs +++ b/src/geometry/op_macros.rs @@ -7,21 +7,25 @@ macro_rules! md_impl( // Operator, operator method, and scalar bounds. $Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)*; // Storage dimensions, and dimension bounds. - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),+ - // [Optional] Extra allocator bounds. - $(where $ConstraintType: ty: $ConstraintBound: ident<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*> )*; + ($R1: ty, $C1: ty),($R2: ty, $C2: ty) + // Const type declaration + const $($D: ident),*; + // Other generic type declarations. + for $($DimsDecl: ident),*; + // Where clause. + where $($ConstraintType: ty: $ConstraintBound: ident$(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)*),*; // Argument identifiers and types + output. $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; // Operator actual implementation. $action: expr; // Lifetime. $($lives: tt),*) => { - impl<$($lives ,)* N $(, $Dims: $DimsBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs + impl<$($lives ,)* N $(, $DimsDecl)* $(, const $D: usize)*> $Op<$Rhs> for $Lhs where N: Scalar + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, DefaultAllocator: Allocator + Allocator + Allocator, - $( $ConstraintType: $ConstraintBound<$( $ConstraintBoundParams $( = $EqBound )*),*> ),* + $( $ConstraintType: $ConstraintBound$(<$( $ConstraintBoundParams $( = $EqBound )*),*>)* ),* { type Output = $Result; @@ -40,9 +44,13 @@ macro_rules! md_impl_all( // Operator, operator method, and scalar bounds. $Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)*; // Storage dimensions, and dimension bounds. - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),+ - // [Optional] Extra allocator bounds. - $(where $ConstraintType: ty: $ConstraintBound: ident<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*> )*; + ($R1: ty, $C1: ty),($R2: ty, $C2: ty) + // Const type declaration + const $($D: ident),*; + // Other generic type declarations. + for $($DimsDecl: ident),*; + // Where clause. + where $($ConstraintType: ty: $ConstraintBound: ident$(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)*),*; // Argument identifiers and types + output. $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; // Operators actual implementations. @@ -53,29 +61,37 @@ macro_rules! md_impl_all( md_impl!( $Op, $op $(where N: $($ScalarBounds),*)*; - ($R1, $C1),($R2, $C2) for $($Dims: $DimsBound $(<$($BoundParam),*>)*),+ - $(where $ConstraintType: $ConstraintBound<$($ConstraintBoundParams $( = $EqBound )*),*>)*; + ($R1, $C1),($R2, $C2) + const $($D),*; + for $($DimsDecl),*; + where $($ConstraintType: $ConstraintBound$(<$($ConstraintBoundParams $( = $EqBound )*),*>)*),*; $lhs: $Lhs, $rhs: $Rhs, Output = $Result; $action_val_val; ); md_impl!( $Op, $op $(where N: $($ScalarBounds),*)*; - ($R1, $C1),($R2, $C2) for $($Dims: $DimsBound $(<$($BoundParam),*>)*),+ - $(where $ConstraintType: $ConstraintBound<$($ConstraintBoundParams $( = $EqBound )*),*>)*; + ($R1, $C1),($R2, $C2) + const $($D),*; + for $($DimsDecl),*; + where $($ConstraintType: $ConstraintBound$(<$($ConstraintBoundParams $( = $EqBound )*),*>)*),*; $lhs: &'a $Lhs, $rhs: $Rhs, Output = $Result; $action_ref_val; 'a); md_impl!( $Op, $op $(where N: $($ScalarBounds),*)*; - ($R1, $C1),($R2, $C2) for $($Dims: $DimsBound $(<$($BoundParam),*>)*),+ - $(where $ConstraintType: $ConstraintBound<$($ConstraintBoundParams $( = $EqBound )*),*>)*; + ($R1, $C1),($R2, $C2) + const $($D),*; + for $($DimsDecl),*; + where $($ConstraintType: $ConstraintBound$(<$($ConstraintBoundParams $( = $EqBound )*),*>)*),*; $lhs: $Lhs, $rhs: &'b $Rhs, Output = $Result; $action_val_ref; 'b); md_impl!( $Op, $op $(where N: $($ScalarBounds),*)*; - ($R1, $C1),($R2, $C2) for $($Dims: $DimsBound $(<$($BoundParam),*>)*),+ - $(where $ConstraintType: $ConstraintBound<$($ConstraintBoundParams $( = $EqBound )*),*>)*; + ($R1, $C1),($R2, $C2) + const $($D),*; + for $($DimsDecl),*; + where $($ConstraintType: $ConstraintBound$(<$($ConstraintBoundParams $( = $EqBound )*),*>)*),*; $lhs: &'a $Lhs, $rhs: &'b $Rhs, Output = $Result; $action_ref_ref; 'a, 'b); } @@ -85,18 +101,22 @@ macro_rules! md_impl_all( macro_rules! md_assign_impl( ( // Operator, operator method, and scalar bounds. - $Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)* $(for N::Element: $ElementBounds: ident)*; + $Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)* $(for N::Element: $($ElementBounds: ident),*)*; // Storage dimensions, and dimension bounds. - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),* - // [Optional] Extra allocator bounds. - $(where $ConstraintType: ty: $ConstraintBound: ident $(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)* )*; + ($R1: ty, $C1: ty),($R2: ty, $C2: ty) + // Const type declaration + const $($D: ident),*; + // Other generic type declarations. + for $($DimsDecl: ident),*; + // Where clause. + where $($ConstraintType: ty: $ConstraintBound: ident$(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)*),*; // Argument identifiers and types. $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty; // Actual implementation and lifetimes. $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N $(, $Dims: $DimsBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs + impl<$($lives ,)* N $(, $DimsDecl)* $(, const $D: usize)*> $Op<$Rhs> for $Lhs where N: Scalar + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, - $(N::Element: $ElementBounds,)* + $($(N::Element: $ElementBounds,)*)* DefaultAllocator: Allocator + Allocator, $( $ConstraintType: $ConstraintBound $(<$( $ConstraintBoundParams $( = $EqBound )*),*>)* ),* @@ -116,9 +136,13 @@ macro_rules! md_assign_impl_all( // Operator, operator method, and scalar bounds. $Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)* $(for N::Element: $($ElementBounds: ident),*)*; // Storage dimensions, and dimension bounds. - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),* - // [Optional] Extra allocator bounds. - $(where $ConstraintType: ty: $ConstraintBound: ident$(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)* )*; + ($R1: ty, $C1: ty),($R2: ty, $C2: ty) + // Const type declaration + const $($D: ident),*; + // Other generic type declarations. + for $($DimsDecl: ident),*; + // Where clause. + where $($ConstraintType: ty: $ConstraintBound: ident$(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)*),*; // Argument identifiers and types. $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty; // Actual implementation and lifetimes. @@ -126,15 +150,19 @@ macro_rules! md_assign_impl_all( [ref] => $action_ref: expr;) => { md_assign_impl!( $Op, $op $(where N: $($ScalarBounds),*)* $(for N::Element: $($ElementBounds),*)*; - ($R1, $C1),($R2, $C2) for $($Dims: $DimsBound $(<$($BoundParam),*>)*),* - $(where $ConstraintType: $ConstraintBound $(<$($ConstraintBoundParams $( = $EqBound )*),*>)*)*; + ($R1, $C1),($R2, $C2) + const $($D),*; + for $($DimsDecl),*; + where $($ConstraintType: $ConstraintBound$(<$($ConstraintBoundParams $( = $EqBound )*),*>)*),*; $lhs: $Lhs, $rhs: $Rhs; $action_val; ); md_assign_impl!( $Op, $op $(where N: $($ScalarBounds),*)* $(for N::Element: $($ElementBounds),*)*; - ($R1, $C1),($R2, $C2) for $($Dims: $DimsBound $(<$($BoundParam),*>)*),* - $(where $ConstraintType: $ConstraintBound $(<$($ConstraintBoundParams $( = $EqBound )*),*>)*)*; + ($R1, $C1),($R2, $C2) + const $($D),*; + for $($DimsDecl),*; + where $($ConstraintType: $ConstraintBound$(<$($ConstraintBoundParams $( = $EqBound )*),*>)*),*; $lhs: $Lhs, $rhs: &'b $Rhs; $action_ref; 'b); } @@ -144,16 +172,23 @@ macro_rules! md_assign_impl_all( /// Macro for the implementation of addition and subtraction. macro_rules! add_sub_impl( ($Op: ident, $op: ident, $bound: ident; - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(-> ($RRes: ty))* for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),+; + ($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(-> ($RRes: ty))* + // Const type declaration + const $($D: ident),*; + // Other generic type declarations. + for $($DimsDecl: ident),*; + // Where clause. + where $($ConstraintType: ty: $ConstraintBound: ident$(<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*>)*),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N $(, $Dims: $DimsBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs + impl<$($lives ,)* N $(, $DimsDecl)* $(, const $D: usize)*> $Op<$Rhs> for $Lhs where N: Scalar + $bound, DefaultAllocator: Allocator + Allocator + SameShapeAllocator, ShapeConstraint: SameNumberOfRows<$R1, $R2 $(, Representative = $RRes)*> + - SameNumberOfColumns<$C1, $C2> { + SameNumberOfColumns<$C1, $C2>, + $( $ConstraintType: $ConstraintBound$(<$( $ConstraintBoundParams $( = $EqBound )*),*>)* ),* { type Output = $Result; #[inline] @@ -168,14 +203,11 @@ macro_rules! add_sub_impl( /// Macro for the implementation of assignment-addition and assignment-subtraction. macro_rules! add_sub_assign_impl( ($Op: ident, $op: ident, $bound: ident; - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident),+; + $(const $D: ident),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty; $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs - where N: Scalar + $bound, - DefaultAllocator: Allocator + - Allocator, - ShapeConstraint: SameNumberOfRows<$R1, $R2> + SameNumberOfColumns<$C1, $C2> { + impl<$($lives ,)* N $(, const $D: usize),*> $Op<$Rhs> for $Lhs + where N: Scalar + $bound { #[inline] fn $op(&mut $lhs, $rhs: $Rhs) { $action diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 307f0b17..4944e158 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -17,7 +17,7 @@ use simba::simd::SimdPartialOrd; use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; use crate::base::iter::{MatrixIter, MatrixIterMut}; -use crate::base::{Const, DefaultAllocator, Scalar, VectorN}; +use crate::base::{CVectorN, Const, DefaultAllocator, Scalar, VectorN}; /// A point in an euclidean space. /// @@ -64,7 +64,7 @@ impl Copy for Point #[cfg(feature = "bytemuck")] unsafe impl bytemuck::Zeroable for Point where - VectorN>: bytemuck::Zeroable // DefaultAllocator: Allocator, + VectorN>: bytemuck::Zeroable { } @@ -73,17 +73,11 @@ unsafe impl bytemuck::Pod for Point where N: Copy, VectorN>: bytemuck::Pod, - // DefaultAllocator: Allocator, - // >::Buffer: Copy, { } #[cfg(feature = "serde-serialize")] -impl Serialize for Point -// where -// DefaultAllocator: Allocator, -// >::Buffer: Serialize, -{ +impl Serialize for Point { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -93,16 +87,12 @@ impl Serialize for Point } #[cfg(feature = "serde-serialize")] -impl<'a, N: Scalar, const D: usize> Deserialize<'a> for Point -// where -// DefaultAllocator: Allocator, -// >::Buffer: Deserialize<'a>, -{ +impl<'a, N: Scalar + Deserialize<'a>, const D: usize> Deserialize<'a> for Point { fn deserialize(deserializer: Des) -> Result where Des: Deserializer<'a>, { - let coords = VectorN::::deserialize(deserializer)?; + let coords = CVectorN::::deserialize(deserializer)?; Ok(Self::from(coords)) } @@ -113,7 +103,6 @@ impl Abomonation for Point where N: Scalar, VectorN>: Abomonation, - // DefaultAllocator: Allocator, { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { self.coords.entomb(writer) @@ -312,7 +301,6 @@ impl Point impl AbsDiffEq for Point where - // DefaultAllocator: Allocator, N::Epsilon: Copy, { type Epsilon = N::Epsilon; @@ -330,7 +318,6 @@ where impl RelativeEq for Point where - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -352,7 +339,6 @@ where impl UlpsEq for Point where - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 4ddaf1f9..6d58dd87 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -10,10 +10,10 @@ use rand::{ use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::{DefaultAllocator, Scalar, VectorN}; +use crate::base::{CVectorN, DefaultAllocator, Scalar}; use crate::{ Const, Point1, Point2, Point3, Point4, Point5, Point6, Vector1, Vector2, Vector3, Vector4, - Vector5, Vector6, + Vector5, Vector6, VectorN, }; use simba::scalar::{ClosedDiv, SupersetOf}; @@ -52,7 +52,7 @@ impl Point where N: Zero, { - Self::from(VectorN::from_element(N::zero())) + Self::from(CVectorN::from_element(N::zero())) } /// Creates a new point from a slice. @@ -71,7 +71,7 @@ impl Point /// ``` #[inline] pub fn from_slice(components: &[N]) -> Self { - Self::from(VectorN::from_row_slice(components)) + Self::from(CVectorN::from_row_slice(components)) } /// Creates a new point from its homogeneous vector representation. @@ -131,7 +131,6 @@ impl Point pub fn cast(self) -> Point where Point: SupersetOf, - // DefaultAllocator: Allocator, { crate::convert(self) } @@ -148,37 +147,35 @@ impl Bounded for Point { #[inline] fn max_value() -> Self { - Self::from(VectorN::max_value()) + Self::from(CVectorN::max_value()) } #[inline] fn min_value() -> Self { - Self::from(VectorN::min_value()) + Self::from(CVectorN::min_value()) } } #[cfg(feature = "rand-no-std")] impl Distribution> for Standard where - // DefaultAllocator: Allocator, Standard: Distribution, { /// Generate a `Point` where each coordinate is an independent variate from `[0, 1)`. #[inline] fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Point { - Point::from(rng.gen::>()) + Point::from(rng.gen::>()) } } #[cfg(feature = "arbitrary")] impl Arbitrary for Point where - // DefaultAllocator: Allocator, >>::Buffer: Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { - Self::from(VectorN::arbitrary(g)) + Self::from(CVectorN::arbitrary(g)) } } diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index e301f948..43cc7bc7 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -20,7 +20,6 @@ impl SubsetOf> for Point where N1: Scalar, N2: Scalar + SupersetOf, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Point { @@ -58,12 +57,12 @@ where #[inline] fn is_in_subset(v: &VectorN, U1>>) -> bool { - crate::is_convertible::<_, VectorN>>(v) && !v[D].is_zero() + crate::is_convertible::<_, VectorN, U1>>>(v) && !v[D].is_zero() } #[inline] fn from_superset_unchecked(v: &VectorN, U1>>) -> Self { - let coords = v.fixed_slice::(0, 0) / v[D].inlined_clone(); + let coords = v.fixed_slice::, U1>(0, 0) / v[D].inlined_clone(); Self { coords: crate::convert_unchecked(coords), } @@ -97,7 +96,6 @@ impl From<[Point::Element; 2]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, >>::Buffer: Copy, { #[inline] @@ -111,7 +109,6 @@ impl From<[Point::Element; 4]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, >>::Buffer: Copy, { #[inline] @@ -130,7 +127,6 @@ impl From<[Point::Element; 8]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, >>::Buffer: Copy, { #[inline] @@ -153,7 +149,6 @@ impl From<[Point::Element; 16]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, >>::Buffer: Copy, { #[inline] diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index 48af3a8d..4702b5bb 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -9,7 +9,7 @@ use crate::base::allocator::{Allocator, SameShapeAllocator}; use crate::base::constraint::{ AreMultipliable, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint, }; -use crate::base::dimension::{Dim, DimName, U1}; +use crate::base::dimension::{Dim, U1}; use crate::base::storage::Storage; use crate::base::{Const, DefaultAllocator, Matrix, Scalar, Vector, VectorSum}; @@ -79,74 +79,101 @@ impl<'a, N: Scalar + ClosedNeg, const D: usize> Neg for &'a Point // Point - Point add_sub_impl!(Sub, sub, ClosedSub; - (D, U1), (D, U1); - self: &'a Point, right: &'b Point, Output = VectorSum; + (Const, U1), (Const, U1) + const D; for; where; + self: &'a Point, right: &'b Point, Output = VectorSum, Const>; &self.coords - &right.coords; 'a, 'b); add_sub_impl!(Sub, sub, ClosedSub; - (D, U1), (D, U1); - self: &'a Point, right: Point, Output = VectorSum; + (Const, U1), (Const, U1) + const D; for; where; + self: &'a Point, right: Point, Output = VectorSum, Const>; &self.coords - right.coords; 'a); add_sub_impl!(Sub, sub, ClosedSub; - (D, U1), (D, U1); - self: Point, right: &'b Point, Output = VectorSum; + (Const, U1), (Const, U1) + const D; for; where; + self: Point, right: &'b Point, Output = VectorSum, Const>; self.coords - &right.coords; 'b); add_sub_impl!(Sub, sub, ClosedSub; - (D, U1), (D, U1); - self: Point, right: Point, Output = VectorSum; + (Const, U1), (Const, U1) + const D; for; where; + self: Point, right: Point, Output = VectorSum, Const>; self.coords - right.coords; ); // Point - Vector add_sub_impl!(Sub, sub, ClosedSub; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: &'a Point, right: &'b Vector, Output = Point; Self::Output::from(&self.coords - right); 'a, 'b); add_sub_impl!(Sub, sub, ClosedSub; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: &'a Point, right: Vector, Output = Point; Self::Output::from(&self.coords - &right); 'a); // TODO: should not be a ref to `right`. add_sub_impl!(Sub, sub, ClosedSub; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: Point, right: &'b Vector, Output = Point; Self::Output::from(self.coords - right); 'b); add_sub_impl!(Sub, sub, ClosedSub; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: Point, right: Vector, Output = Point; Self::Output::from(self.coords - right); ); // Point + Vector add_sub_impl!(Add, add, ClosedAdd; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: &'a Point, right: &'b Vector, Output = Point; Self::Output::from(&self.coords + right); 'a, 'b); add_sub_impl!(Add, add, ClosedAdd; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: &'a Point, right: Vector, Output = Point; Self::Output::from(&self.coords + &right); 'a); // TODO: should not be a ref to `right`. add_sub_impl!(Add, add, ClosedAdd; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: Point, right: &'b Vector, Output = Point; Self::Output::from(self.coords + right); 'b); add_sub_impl!(Add, add, ClosedAdd; - (D1, U1), (D2, U1) -> (D1) for D1: DimName, D2: Dim, SB: Storage; + (Const, U1), (D2, U1) -> (Const) + const D1; + for D2, SB; + where D2: Dim, SB: Storage; self: Point, right: Vector, Output = Point; Self::Output::from(self.coords + right); ); -// XXX: replace by the shared macro: add_sub_assign_impl +// TODO: replace by the shared macro: add_sub_assign_impl? macro_rules! op_assign_impl( ($($TraitAssign: ident, $method_assign: ident, $bound: ident);* $(;)*) => {$( impl<'b, N, D2: Dim, SB, const D1: usize> $TraitAssign<&'b Vector> for Point where N: Scalar + $bound, SB: Storage, - // DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, D2> { #[inline] @@ -158,8 +185,7 @@ macro_rules! op_assign_impl( impl $TraitAssign> for Point where N: Scalar + $bound, SB: Storage, - // DefaultAllocator: Allocator, - ShapeConstraint: SameNumberOfRows { + ShapeConstraint: SameNumberOfRows, D2> { #[inline] fn $method_assign(&mut self, right: Vector) { @@ -181,9 +207,12 @@ op_assign_impl!( */ md_impl_all!( Mul, mul; - (R1, C1), (D2, U1) for R1: DimName, C1: Dim, D2: DimName, SA: Storage - where ShapeConstraint: AreMultipliable; - self: Matrix, right: Point, Output = Point; + (Const, Const), (Const, U1) + const D2, R1, C1; + for SA; + where SA: Storage, Const>, + ShapeConstraint: AreMultipliable, Const, Const, U1>; + self: Matrix, Const, SA>, right: Point, Output = Point; [val val] => Point::from(self * right.coords); [ref val] => Point::from(self * right.coords); [val ref] => Point::from(self * &right.coords); diff --git a/src/geometry/point_simba.rs b/src/geometry/point_simba.rs index c597d142..b5f25be0 100644 --- a/src/geometry/point_simba.rs +++ b/src/geometry/point_simba.rs @@ -7,7 +7,6 @@ use crate::geometry::Point; impl SimdValue for Point where N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { type Element = Point; type SimdBool = N::SimdBool; diff --git a/src/geometry/quaternion_ops.rs b/src/geometry/quaternion_ops.rs index f9205874..c19984f3 100644 --- a/src/geometry/quaternion_ops.rs +++ b/src/geometry/quaternion_ops.rs @@ -54,10 +54,9 @@ use std::ops::{ Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign, }; -use crate::base::allocator::Allocator; -use crate::base::dimension::{U1, U3, U4}; +use crate::base::dimension::U3; use crate::base::storage::Storage; -use crate::base::{DefaultAllocator, Scalar, Unit, Vector, Vector3}; +use crate::base::{Const, Scalar, Unit, Vector, Vector3}; use crate::SimdRealField; use crate::geometry::{Point3, Quaternion, Rotation, UnitQuaternion}; @@ -80,14 +79,11 @@ impl IndexMut for Quaternion { macro_rules! quaternion_op_impl( ($Op: ident, $op: ident; - ($LhsRDim: ident, $LhsCDim: ident), ($RhsRDim: ident, $RhsCDim: ident) - $(for $Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*; - $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty $(=> $VDimA: ty, $VDimB: ty)*; + $($Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*; + $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; $action: expr; $($lives: tt),*) => { impl<$($lives ,)* N: SimdRealField $(, $Storage: $StoragesBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs - where N::Element: SimdRealField, - DefaultAllocator: Allocator + - Allocator { + where N::Element: SimdRealField { type Output = $Result; #[inline] @@ -101,63 +97,63 @@ macro_rules! quaternion_op_impl( // Quaternion + Quaternion quaternion_op_impl!( Add, add; - (U4, U1), (U4, U1); + ; self: &'a Quaternion, rhs: &'b Quaternion, Output = Quaternion; Quaternion::from(&self.coords + &rhs.coords); 'a, 'b); quaternion_op_impl!( Add, add; - (U4, U1), (U4, U1); + ; self: &'a Quaternion, rhs: Quaternion, Output = Quaternion; Quaternion::from(&self.coords + rhs.coords); 'a); quaternion_op_impl!( Add, add; - (U4, U1), (U4, U1); + ; self: Quaternion, rhs: &'b Quaternion, Output = Quaternion; Quaternion::from(self.coords + &rhs.coords); 'b); quaternion_op_impl!( Add, add; - (U4, U1), (U4, U1); + ; self: Quaternion, rhs: Quaternion, Output = Quaternion; Quaternion::from(self.coords + rhs.coords); ); // Quaternion - Quaternion quaternion_op_impl!( Sub, sub; - (U4, U1), (U4, U1); + ; self: &'a Quaternion, rhs: &'b Quaternion, Output = Quaternion; Quaternion::from(&self.coords - &rhs.coords); 'a, 'b); quaternion_op_impl!( Sub, sub; - (U4, U1), (U4, U1); + ; self: &'a Quaternion, rhs: Quaternion, Output = Quaternion; Quaternion::from(&self.coords - rhs.coords); 'a); quaternion_op_impl!( Sub, sub; - (U4, U1), (U4, U1); + ; self: Quaternion, rhs: &'b Quaternion, Output = Quaternion; Quaternion::from(self.coords - &rhs.coords); 'b); quaternion_op_impl!( Sub, sub; - (U4, U1), (U4, U1); + ; self: Quaternion, rhs: Quaternion, Output = Quaternion; Quaternion::from(self.coords - rhs.coords); ); // Quaternion × Quaternion quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: &'a Quaternion, rhs: &'b Quaternion, Output = Quaternion; Quaternion::new( self[3] * rhs[3] - self[0] * rhs[0] - self[1] * rhs[1] - self[2] * rhs[2], @@ -168,218 +164,218 @@ quaternion_op_impl!( quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: &'a Quaternion, rhs: Quaternion, Output = Quaternion; self * &rhs; 'a); quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: Quaternion, rhs: &'b Quaternion, Output = Quaternion; &self * rhs; 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: Quaternion, rhs: Quaternion, Output = Quaternion; &self * &rhs; ); // UnitQuaternion × UnitQuaternion quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: &'a UnitQuaternion, rhs: &'b UnitQuaternion, Output = UnitQuaternion; UnitQuaternion::new_unchecked(self.quaternion() * rhs.quaternion()); 'a, 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: &'a UnitQuaternion, rhs: UnitQuaternion, Output = UnitQuaternion; self * &rhs; 'a); quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: UnitQuaternion, rhs: &'b UnitQuaternion, Output = UnitQuaternion; &self * rhs; 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U4, U1); + ; self: UnitQuaternion, rhs: UnitQuaternion, Output = UnitQuaternion; &self * &rhs; ); // UnitQuaternion ÷ UnitQuaternion quaternion_op_impl!( Div, div; - (U4, U1), (U4, U1); + ; self: &'a UnitQuaternion, rhs: &'b UnitQuaternion, Output = UnitQuaternion; #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; 'a, 'b); quaternion_op_impl!( Div, div; - (U4, U1), (U4, U1); + ; self: &'a UnitQuaternion, rhs: UnitQuaternion, Output = UnitQuaternion; self / &rhs; 'a); quaternion_op_impl!( Div, div; - (U4, U1), (U4, U1); + ; self: UnitQuaternion, rhs: &'b UnitQuaternion, Output = UnitQuaternion; &self / rhs; 'b); quaternion_op_impl!( Div, div; - (U4, U1), (U4, U1); + ; self: UnitQuaternion, rhs: UnitQuaternion, Output = UnitQuaternion; &self / &rhs; ); // UnitQuaternion × Rotation quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U3); - self: &'a UnitQuaternion, rhs: &'b Rotation, - Output = UnitQuaternion => U3, U3; - // TODO: can we avoid the conversion from a rotation matrix? + ; + self: &'a UnitQuaternion, rhs: &'b Rotation, + Output = UnitQuaternion; + // TODO: can we avoid the conversion from a rotation matrix? self * UnitQuaternion::::from_rotation_matrix(rhs); 'a, 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U3); - self: &'a UnitQuaternion, rhs: Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: &'a UnitQuaternion, rhs: Rotation, + Output = UnitQuaternion; self * UnitQuaternion::::from_rotation_matrix(&rhs); 'a); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: &'b Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: UnitQuaternion, rhs: &'b Rotation, + Output = UnitQuaternion; self * UnitQuaternion::::from_rotation_matrix(rhs); 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: UnitQuaternion, rhs: Rotation, + Output = UnitQuaternion; self * UnitQuaternion::::from_rotation_matrix(&rhs); ); // UnitQuaternion ÷ Rotation quaternion_op_impl!( Div, div; - (U4, U1), (U3, U3); - self: &'a UnitQuaternion, rhs: &'b Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: &'a UnitQuaternion, rhs: &'b Rotation, + Output = UnitQuaternion; // TODO: can we avoid the conversion to a rotation matrix? self / UnitQuaternion::::from_rotation_matrix(rhs); 'a, 'b); quaternion_op_impl!( Div, div; - (U4, U1), (U3, U3); - self: &'a UnitQuaternion, rhs: Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: &'a UnitQuaternion, rhs: Rotation, + Output = UnitQuaternion; self / UnitQuaternion::::from_rotation_matrix(&rhs); 'a); quaternion_op_impl!( Div, div; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: &'b Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: UnitQuaternion, rhs: &'b Rotation, + Output = UnitQuaternion; self / UnitQuaternion::::from_rotation_matrix(rhs); 'b); quaternion_op_impl!( Div, div; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: Rotation, - Output = UnitQuaternion => U3, U3; + ; + self: UnitQuaternion, rhs: Rotation, + Output = UnitQuaternion; self / UnitQuaternion::::from_rotation_matrix(&rhs); ); // Rotation × UnitQuaternion quaternion_op_impl!( Mul, mul; - (U3, U3), (U4, U1); - self: &'a Rotation, rhs: &'b UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: &'a Rotation, rhs: &'b UnitQuaternion, + Output = UnitQuaternion; // TODO: can we avoid the conversion from a rotation matrix? UnitQuaternion::::from_rotation_matrix(self) * rhs; 'a, 'b); quaternion_op_impl!( Mul, mul; - (U3, U3), (U4, U1); - self: &'a Rotation, rhs: UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: &'a Rotation, rhs: UnitQuaternion, + Output = UnitQuaternion; UnitQuaternion::::from_rotation_matrix(self) * rhs; 'a); quaternion_op_impl!( Mul, mul; - (U3, U3), (U4, U1); - self: Rotation, rhs: &'b UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: Rotation, rhs: &'b UnitQuaternion, + Output = UnitQuaternion; UnitQuaternion::::from_rotation_matrix(&self) * rhs; 'b); quaternion_op_impl!( Mul, mul; - (U3, U3), (U4, U1); - self: Rotation, rhs: UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: Rotation, rhs: UnitQuaternion, + Output = UnitQuaternion; UnitQuaternion::::from_rotation_matrix(&self) * rhs; ); // Rotation ÷ UnitQuaternion quaternion_op_impl!( Div, div; - (U3, U3), (U4, U1); - self: &'a Rotation, rhs: &'b UnitQuaternion, - Output = UnitQuaternion => U3, U3; - // TODO: can we avoid the conversion from a rotation matrix? + ; + self: &'a Rotation, rhs: &'b UnitQuaternion, + Output = UnitQuaternion; + // TODO: can we avoid the conversion from a rotation matrix? UnitQuaternion::::from_rotation_matrix(self) / rhs; 'a, 'b); quaternion_op_impl!( Div, div; - (U3, U3), (U4, U1); - self: &'a Rotation, rhs: UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: &'a Rotation, rhs: UnitQuaternion, + Output = UnitQuaternion; UnitQuaternion::::from_rotation_matrix(self) / rhs; 'a); quaternion_op_impl!( Div, div; - (U3, U3), (U4, U1); - self: Rotation, rhs: &'b UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: Rotation, rhs: &'b UnitQuaternion, + Output = UnitQuaternion; UnitQuaternion::::from_rotation_matrix(&self) / rhs; 'b); quaternion_op_impl!( Div, div; - (U3, U3), (U4, U1); - self: Rotation, rhs: UnitQuaternion, - Output = UnitQuaternion => U3, U3; + ; + self: Rotation, rhs: UnitQuaternion, + Output = UnitQuaternion; UnitQuaternion::::from_rotation_matrix(&self) / rhs; ); // UnitQuaternion × Vector quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; - self: &'a UnitQuaternion, rhs: &'b Vector, - Output = Vector3 => U3, U4; + SB: Storage> ; + self: &'a UnitQuaternion, rhs: &'b Vector, SB>, + Output = Vector3; { let two: N = crate::convert(2.0f64); let t = self.as_ref().vector().cross(rhs) * two; @@ -391,89 +387,89 @@ quaternion_op_impl!( quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: &'a UnitQuaternion, rhs: Vector, - Output = Vector3 => U3, U4; + Output = Vector3; self * &rhs; 'a); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: UnitQuaternion, rhs: &'b Vector, - Output = Vector3 => U3, U4; + Output = Vector3; &self * rhs; 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: UnitQuaternion, rhs: Vector, - Output = Vector3 => U3, U4; + Output = Vector3; &self * &rhs; ); // UnitQuaternion × Point quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1); + ; self: &'a UnitQuaternion, rhs: &'b Point3, - Output = Point3 => U3, U4; + Output = Point3; Point3::from(self * &rhs.coords); 'a, 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1); + ; self: &'a UnitQuaternion, rhs: Point3, - Output = Point3 => U3, U4; + Output = Point3; Point3::from(self * rhs.coords); 'a); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1); + ; self: UnitQuaternion, rhs: &'b Point3, - Output = Point3 => U3, U4; + Output = Point3; Point3::from(self * &rhs.coords); 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1); + ; self: UnitQuaternion, rhs: Point3, - Output = Point3 => U3, U4; + Output = Point3; Point3::from(self * rhs.coords); ); // UnitQuaternion × Unit quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: &'a UnitQuaternion, rhs: &'b Unit>, - Output = Unit> => U3, U4; + Output = Unit>; Unit::new_unchecked(self * rhs.as_ref()); 'a, 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: &'a UnitQuaternion, rhs: Unit>, - Output = Unit> => U3, U4; + Output = Unit>; Unit::new_unchecked(self * rhs.into_inner()); 'a); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: UnitQuaternion, rhs: &'b Unit>, - Output = Unit> => U3, U4; + Output = Unit>; Unit::new_unchecked(self * rhs.as_ref()); 'b); quaternion_op_impl!( Mul, mul; - (U4, U1), (U3, U1) for SB: Storage ; + SB: Storage> ; self: UnitQuaternion, rhs: Unit>, - Output = Unit> => U3, U4; + Output = Unit>; Unit::new_unchecked(self * rhs.into_inner()); ); macro_rules! scalar_op_impl( @@ -564,13 +560,10 @@ where macro_rules! quaternion_op_impl( ($OpAssign: ident, $op_assign: ident; - ($LhsRDim: ident, $LhsCDim: ident), ($RhsRDim: ident, $RhsCDim: ident); $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty $(=> $VDimA: ty, $VDimB: ty)*; $action: expr; $($lives: tt),*) => { impl<$($lives ,)* N: SimdRealField> $OpAssign<$Rhs> for $Lhs - where N::Element: SimdRealField, - DefaultAllocator: Allocator + - Allocator { + where N::Element: SimdRealField { #[inline] fn $op_assign(&mut $lhs, $rhs: $Rhs) { @@ -583,35 +576,30 @@ macro_rules! quaternion_op_impl( // Quaternion += Quaternion quaternion_op_impl!( AddAssign, add_assign; - (U4, U1), (U4, U1); self: Quaternion, rhs: &'b Quaternion; self.coords += &rhs.coords; 'b); quaternion_op_impl!( AddAssign, add_assign; - (U4, U1), (U4, U1); self: Quaternion, rhs: Quaternion; self.coords += rhs.coords; ); // Quaternion -= Quaternion quaternion_op_impl!( SubAssign, sub_assign; - (U4, U1), (U4, U1); self: Quaternion, rhs: &'b Quaternion; self.coords -= &rhs.coords; 'b); quaternion_op_impl!( SubAssign, sub_assign; - (U4, U1), (U4, U1); self: Quaternion, rhs: Quaternion; self.coords -= rhs.coords; ); // Quaternion ×= Quaternion quaternion_op_impl!( MulAssign, mul_assign; - (U4, U1), (U4, U1); self: Quaternion, rhs: &'b Quaternion; { let res = &*self * rhs; @@ -622,14 +610,12 @@ quaternion_op_impl!( quaternion_op_impl!( MulAssign, mul_assign; - (U4, U1), (U4, U1); self: Quaternion, rhs: Quaternion; *self *= &rhs; ); // UnitQuaternion ×= UnitQuaternion quaternion_op_impl!( MulAssign, mul_assign; - (U4, U1), (U4, U1); self: UnitQuaternion, rhs: &'b UnitQuaternion; { let res = &*self * rhs; @@ -639,14 +625,12 @@ quaternion_op_impl!( quaternion_op_impl!( MulAssign, mul_assign; - (U4, U1), (U4, U1); self: UnitQuaternion, rhs: UnitQuaternion; *self *= &rhs; ); // UnitQuaternion ÷= UnitQuaternion quaternion_op_impl!( DivAssign, div_assign; - (U4, U1), (U4, U1); self: UnitQuaternion, rhs: &'b UnitQuaternion; { let res = &*self / rhs; @@ -656,15 +640,13 @@ quaternion_op_impl!( quaternion_op_impl!( DivAssign, div_assign; - (U4, U1), (U4, U1); self: UnitQuaternion, rhs: UnitQuaternion; *self /= &rhs; ); // UnitQuaternion ×= Rotation quaternion_op_impl!( MulAssign, mul_assign; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: &'b Rotation => U3, U3; + self: UnitQuaternion, rhs: &'b Rotation; { let res = &*self * rhs; self.as_mut_unchecked().coords.copy_from(&res.as_ref().coords); @@ -673,15 +655,13 @@ quaternion_op_impl!( quaternion_op_impl!( MulAssign, mul_assign; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: Rotation => U3, U3; + self: UnitQuaternion, rhs: Rotation; *self *= &rhs; ); // UnitQuaternion ÷= Rotation quaternion_op_impl!( DivAssign, div_assign; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: &'b Rotation => U3, U3; + self: UnitQuaternion, rhs: &'b Rotation; { let res = &*self / rhs; self.as_mut_unchecked().coords.copy_from(&res.as_ref().coords); @@ -690,6 +670,5 @@ quaternion_op_impl!( quaternion_op_impl!( DivAssign, div_assign; - (U4, U1), (U3, U3); - self: UnitQuaternion, rhs: Rotation => U3, U3; + self: UnitQuaternion, rhs: Rotation; *self /= &rhs; ); diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 498886d3..2783f9b1 100755 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -64,7 +64,6 @@ pub struct Rotation impl hash::Hash for Rotation where - // DefaultAllocator: Allocator, , Const>>::Buffer: hash::Hash, { fn hash(&self, state: &mut H) { @@ -73,14 +72,12 @@ where } impl Copy for Rotation where - // DefaultAllocator: Allocator, , Const>>::Buffer: Copy { } impl Clone for Rotation where - // DefaultAllocator: Allocator, , Const>>::Buffer: Clone, { #[inline] @@ -93,8 +90,7 @@ where impl Abomonation for Rotation where N: Scalar, - CMatrixN>: Abomonation, - // DefaultAllocator: Allocator, + CMatrixN: Abomonation, { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { self.matrix.entomb(writer) @@ -112,8 +108,7 @@ where #[cfg(feature = "serde-serialize")] impl Serialize for Rotation where - // DefaultAllocator: Allocator, - Owned: Serialize, + Owned, Const>: Serialize, { fn serialize(&self, serializer: S) -> Result where @@ -126,8 +121,7 @@ where #[cfg(feature = "serde-serialize")] impl<'a, N: Scalar, const D: usize> Deserialize<'a> for Rotation where - // DefaultAllocator: Allocator, - Owned: Deserialize<'a>, + Owned, Const>: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result where @@ -286,8 +280,9 @@ impl Rotation // We could use `CMatrixN::to_homogeneous()` here, but that would imply // adding the additional traits `DimAdd` and `IsNotStaticOne`. Maybe // these things will get nicer once specialization lands in Rust. - let mut res = MatrixN::>::identity(); - res.fixed_slice_mut::(0, 0).copy_from(&self.matrix); + let mut res = MatrixN::, U1>>::identity(); + res.fixed_slice_mut::, Const>(0, 0) + .copy_from(&self.matrix); res } @@ -405,7 +400,6 @@ impl Rotation impl Rotation where N::Element: SimdRealField, - // DefaultAllocator: Allocator + Allocator, { /// Rotate the given point. /// @@ -521,7 +515,6 @@ impl PartialEq for Rotation impl AbsDiffEq for Rotation where N: Scalar + AbsDiffEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { type Epsilon = N::Epsilon; @@ -540,7 +533,6 @@ where impl RelativeEq for Rotation where N: Scalar + RelativeEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -563,7 +555,6 @@ where impl UlpsEq for Rotation where N: Scalar + UlpsEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -585,7 +576,6 @@ where impl fmt::Display for Rotation where N: RealField + fmt::Display, - // DefaultAllocator: Allocator + Allocator, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let precision = f.precision().unwrap_or(3); diff --git a/src/geometry/rotation_construction.rs b/src/geometry/rotation_construction.rs index a144a537..0db4997a 100644 --- a/src/geometry/rotation_construction.rs +++ b/src/geometry/rotation_construction.rs @@ -2,7 +2,7 @@ use num::{One, Zero}; use simba::scalar::{ClosedAdd, ClosedMul, SupersetOf}; -use crate::base::{MatrixN, Scalar}; +use crate::base::{CMatrixN, Scalar}; use crate::geometry::Rotation; @@ -10,7 +10,6 @@ use crate::geometry::Rotation; impl Rotation where N: Scalar + Zero + One, - // DefaultAllocator: Allocator, { /// Creates a new square identity rotation of the given `dimension`. /// @@ -25,7 +24,7 @@ where /// ``` #[inline] pub fn identity() -> Rotation { - Self::from_matrix_unchecked(MatrixN::::identity()) + Self::from_matrix_unchecked(CMatrixN::::identity()) } } @@ -45,7 +44,6 @@ impl Rotation pub fn cast(self) -> Rotation where Rotation: SupersetOf, - // DefaultAllocator: Allocator, { crate::convert(self) } @@ -54,7 +52,6 @@ impl Rotation impl One for Rotation where N: Scalar + Zero + One + ClosedAdd + ClosedMul, - // DefaultAllocator: Allocator, { #[inline] fn one() -> Self { diff --git a/src/geometry/rotation_conversion.rs b/src/geometry/rotation_conversion.rs index 14cb296b..02285419 100644 --- a/src/geometry/rotation_conversion.rs +++ b/src/geometry/rotation_conversion.rs @@ -5,7 +5,7 @@ use simba::simd::{PrimitiveSimdValue, SimdValue}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimMin, DimNameAdd, DimNameSum, U1}; -use crate::base::{Const, DefaultAllocator, Matrix2, Matrix3, Matrix4, MatrixN, Scalar}; +use crate::base::{CMatrixN, Const, DefaultAllocator, Matrix2, Matrix3, Matrix4, MatrixN, Scalar}; use crate::geometry::{ AbstractRotation, Isometry, Rotation, Rotation2, Rotation3, Similarity, SuperTCategoryOf, @@ -31,7 +31,6 @@ impl SubsetOf> for Rotation where N1: RealField, N2: RealField + SupersetOf, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Rotation { @@ -40,7 +39,7 @@ where #[inline] fn is_in_subset(rot: &Rotation) -> bool { - crate::is_convertible::<_, MatrixN>(rot.matrix()) + crate::is_convertible::<_, CMatrixN>(rot.matrix()) } #[inline] @@ -125,7 +124,6 @@ where N1: RealField, N2: RealField + SupersetOf, R: AbstractRotation + SupersetOf, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Isometry { @@ -148,7 +146,6 @@ where N1: RealField, N2: RealField + SupersetOf, R: AbstractRotation + SupersetOf, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Similarity { @@ -213,8 +210,8 @@ where #[inline] fn is_in_subset(m: &MatrixN, U1>>) -> bool { - let rot = m.fixed_slice::(0, 0); - let bottom = m.fixed_slice::(D, 0); + let rot = m.fixed_slice::, Const>(0, 0); + let bottom = m.fixed_slice::>(D, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && @@ -226,7 +223,7 @@ where #[inline] fn from_superset_unchecked(m: &MatrixN, U1>>) -> Self { - let r = m.fixed_slice::(0, 0); + let r = m.fixed_slice::, Const>(0, 0); Self::from_matrix_unchecked(crate::convert_unchecked(r.into_owned())) } } @@ -264,7 +261,6 @@ impl From<[Rotation::Element; 2]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Rotation; 2]) -> Self { @@ -280,7 +276,6 @@ impl From<[Rotation::Element; 4]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Rotation; 4]) -> Self { @@ -298,7 +293,6 @@ impl From<[Rotation::Element; 8]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Rotation; 8]) -> Self { @@ -320,7 +314,6 @@ impl From<[Rotation::Element; 16]>, N::Element: Scalar + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Rotation; 16]) -> Self { diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index ae66c02e..4821328d 100644 --- a/src/geometry/rotation_ops.rs +++ b/src/geometry/rotation_ops.rs @@ -24,16 +24,15 @@ use simba::scalar::{ClosedAdd, ClosedMul}; use crate::base::allocator::Allocator; use crate::base::constraint::{AreMultipliable, ShapeConstraint}; -use crate::base::dimension::{Dim, DimName, U1}; +use crate::base::dimension::{Dim, U1}; use crate::base::storage::Storage; -use crate::base::{DefaultAllocator, Matrix, MatrixMN, Scalar, Unit, Vector, VectorN}; +use crate::base::{ + CMatrixMN, CVectorN, Const, DefaultAllocator, Matrix, MatrixMN, Scalar, Unit, Vector, +}; use crate::geometry::{Point, Rotation}; -impl Index<(usize, usize)> for Rotation -where - DefaultAllocator: Allocator, -{ +impl Index<(usize, usize)> for Rotation { type Output = N; #[inline] @@ -45,7 +44,10 @@ where // Rotation × Rotation md_impl_all!( Mul, mul; - (D, D), (D, D) for D: DimName; + (Const, Const), (Const, Const) + const D; + for; + where; self: Rotation, right: Rotation, Output = Rotation; [val val] => Rotation::from_matrix_unchecked(self.into_inner() * right.into_inner()); [ref val] => Rotation::from_matrix_unchecked(self.matrix() * right.into_inner()); @@ -57,7 +59,10 @@ md_impl_all!( // TODO: instead of calling inverse explicitly, could we just add a `mul_tr` or `mul_inv` method? md_impl_all!( Div, div; - (D, D), (D, D) for D: DimName; + (Const, Const), (Const, Const) + const D; + for; + where; self: Rotation, right: Rotation, Output = Rotation; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; @@ -68,10 +73,13 @@ md_impl_all!( // Rotation × Matrix md_impl_all!( Mul, mul; - (D1, D1), (R2, C2) for D1: DimName, R2: Dim, C2: Dim, SB: Storage - where DefaultAllocator: Allocator - where ShapeConstraint: AreMultipliable; - self: Rotation, right: Matrix, Output = MatrixMN; + (Const, Const), (R2, C2) + const D1; + for R2, C2, SB; + where R2: Dim, C2: Dim, SB: Storage, + DefaultAllocator: Allocator, C2>, + ShapeConstraint: AreMultipliable, Const, R2, C2>; + self: Rotation, right: Matrix, Output = MatrixMN, C2>; [val val] => self.into_inner() * right; [ref val] => self.matrix() * right; [val ref] => self.into_inner() * right; @@ -81,10 +89,13 @@ md_impl_all!( // Matrix × Rotation md_impl_all!( Mul, mul; - (R1, C1), (D2, D2) for R1: Dim, C1: Dim, D2: DimName, SA: Storage - where DefaultAllocator: Allocator - where ShapeConstraint: AreMultipliable; - self: Matrix, right: Rotation, Output = MatrixMN; + (R1, C1), (Const, Const) + const D2; + for R1, C1, SA; + where R1: Dim, C1: Dim, SA: Storage, + DefaultAllocator: Allocator>, + ShapeConstraint: AreMultipliable, Const>; + self: Matrix, right: Rotation, Output = MatrixMN>; [val val] => self * right.into_inner(); [ref val] => self * right.into_inner(); [val ref] => self * right.matrix(); @@ -94,10 +105,13 @@ md_impl_all!( // Matrix ÷ Rotation md_impl_all!( Div, div; - (R1, C1), (D2, D2) for R1: Dim, C1: Dim, D2: DimName, SA: Storage - where DefaultAllocator: Allocator - where ShapeConstraint: AreMultipliable; - self: Matrix, right: Rotation, Output = MatrixMN; + (R1, C1), (Const, Const) + const D2; + for R1, C1, SA; + where R1: Dim, C1: Dim, SA: Storage, + DefaultAllocator: Allocator>, + ShapeConstraint: AreMultipliable, Const>; + self: Matrix, right: Rotation, Output = MatrixMN>; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; @@ -109,9 +123,10 @@ md_impl_all!( // behavior? md_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName - where DefaultAllocator: Allocator - where ShapeConstraint: AreMultipliable; + (Const, Const), (Const, U1) + const D; + for; + where ShapeConstraint: AreMultipliable, Const, Const, U1>; self: Rotation, right: Point, Output = Point; [val val] => self.into_inner() * right; [ref val] => self.matrix() * right; @@ -122,10 +137,12 @@ md_impl_all!( // Rotation × Unit md_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName, S: Storage - where DefaultAllocator: Allocator - where ShapeConstraint: AreMultipliable; - self: Rotation, right: Unit>, Output = Unit>; + (Const, Const), (Const, U1) + const D; + for S; + where S: Storage>, + ShapeConstraint: AreMultipliable, Const, Const, U1>; + self: Rotation, right: Unit, S>>, Output = Unit>; [val val] => Unit::new_unchecked(self.into_inner() * right.into_inner()); [ref val] => Unit::new_unchecked(self.matrix() * right.into_inner()); [val ref] => Unit::new_unchecked(self.into_inner() * right.as_ref()); @@ -137,7 +154,8 @@ md_impl_all!( md_assign_impl_all!( MulAssign, mul_assign; - (D, D), (D, D) for D: DimName; + (Const, Const), (Const, Const) + const D; for; where; self: Rotation, right: Rotation; [val] => self.matrix_mut_unchecked().mul_assign(right.into_inner()); [ref] => self.matrix_mut_unchecked().mul_assign(right.matrix()); @@ -145,7 +163,8 @@ md_assign_impl_all!( md_assign_impl_all!( DivAssign, div_assign; - (D, D), (D, D) for D: DimName; + (Const, Const), (Const, Const) + const D; for; where; self: Rotation, right: Rotation; [val] => self.matrix_mut_unchecked().mul_assign(right.inverse().into_inner()); [ref] => self.matrix_mut_unchecked().mul_assign(right.inverse().matrix()); @@ -159,16 +178,18 @@ md_assign_impl_all!( md_assign_impl_all!( MulAssign, mul_assign; - (R1, C1), (C1, C1) for R1: DimName, C1: DimName; - self: MatrixMN, right: Rotation; + (Const, Const), (Const, Const) + const R1, C1; for; where; + self: CMatrixMN, right: Rotation; [val] => self.mul_assign(right.into_inner()); [ref] => self.mul_assign(right.matrix()); ); md_assign_impl_all!( DivAssign, div_assign; - (R1, C1), (C1, C1) for R1: DimName, C1: DimName; - self: MatrixMN, right: Rotation; + (Const, Const), (Const, Const) + const R1, C1; for; where; + self: CMatrixMN, right: Rotation; [val] => self.mul_assign(right.inverse().into_inner()); [ref] => self.mul_assign(right.inverse().matrix()); ); diff --git a/src/geometry/rotation_simba.rs b/src/geometry/rotation_simba.rs index 319fcc3c..cb0aa13b 100755 --- a/src/geometry/rotation_simba.rs +++ b/src/geometry/rotation_simba.rs @@ -8,7 +8,6 @@ impl SimdValue for Rotation where N: Scalar + SimdValue, N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { type Element = Rotation; type SimdBool = N::SimdBool; diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index 81203fb9..8e813456 100755 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -29,15 +29,15 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation}; feature = "serde-serialize", serde(bound(serialize = "N: Serialize, R: Serialize, - DefaultAllocator: Allocator, - Owned: Serialize")) + DefaultAllocator: Allocator>, + Owned>: Serialize")) )] #[cfg_attr( feature = "serde-serialize", serde(bound(deserialize = "N: Deserialize<'de>, R: Deserialize<'de>, - DefaultAllocator: Allocator, - Owned: Deserialize<'de>")) + DefaultAllocator: Allocator>, + Owned>: Deserialize<'de>")) )] pub struct Similarity // where @@ -52,7 +52,6 @@ pub struct Similarity impl Abomonation for Similarity where Isometry: Abomonation, - // DefaultAllocator: Allocator, { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { self.isometry.entomb(writer) @@ -69,7 +68,6 @@ where impl hash::Hash for Similarity where - // DefaultAllocator: Allocator, Owned>: hash::Hash, { fn hash(&self, state: &mut H) { @@ -81,7 +79,6 @@ where impl + Copy, const D: usize> Copy for Similarity where - // DefaultAllocator: Allocator, Owned>: Copy, { } @@ -100,7 +97,6 @@ impl + Clone, const D: usize> Clone impl Similarity where R: AbstractRotation, - // DefaultAllocator: Allocator, { /// Creates a new similarity from its rotational and translational parts. #[inline] @@ -143,7 +139,6 @@ impl Similarity where N::Element: SimdRealField, R: AbstractRotation, - // DefaultAllocator: Allocator, { /// Creates a new similarity that applies only a scaling factor. #[inline] @@ -345,7 +340,7 @@ impl Similarity { let mut res = self.isometry.to_homogeneous(); - for e in res.fixed_slice_mut::(0, 0).iter_mut() { + for e in res.fixed_slice_mut::, Const>(0, 0).iter_mut() { *e *= self.scaling } @@ -354,14 +349,13 @@ impl Similarity } impl Eq for Similarity where - R: AbstractRotation + Eq // DefaultAllocator: Allocator, + R: AbstractRotation + Eq { } impl PartialEq for Similarity where R: AbstractRotation + PartialEq, - // DefaultAllocator: Allocator, { #[inline] fn eq(&self, right: &Self) -> bool { @@ -372,7 +366,6 @@ where impl AbsDiffEq for Similarity where R: AbstractRotation + AbsDiffEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { type Epsilon = N::Epsilon; @@ -392,7 +385,6 @@ where impl RelativeEq for Similarity where R: AbstractRotation + RelativeEq, - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -441,7 +433,6 @@ impl fmt::Display for Similarity where N: RealField + fmt::Display, R: AbstractRotation + fmt::Display, - // DefaultAllocator: Allocator + Allocator, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let precision = f.precision().unwrap_or(3); diff --git a/src/geometry/similarity_construction.rs b/src/geometry/similarity_construction.rs index 91e4c228..00847367 100644 --- a/src/geometry/similarity_construction.rs +++ b/src/geometry/similarity_construction.rs @@ -16,7 +16,7 @@ use simba::simd::SimdRealField; use crate::base::{Vector2, Vector3}; use crate::{ - AbstractRotation, Isometry, Point, Point3, Rotation2, Rotation3, Scalar, Similarity, + AbstractRotation, Const, Isometry, Point, Point3, Rotation2, Rotation3, Scalar, Similarity, Translation, UnitComplex, UnitQuaternion, }; @@ -24,7 +24,6 @@ impl Similarity where N::Element: SimdRealField, R: AbstractRotation, - // DefaultAllocator: Allocator, { /// Creates a new identity similarity. /// @@ -51,7 +50,6 @@ impl One for Similarity where N::Element: SimdRealField, R: AbstractRotation, - // DefaultAllocator: Allocator, { /// Creates a new identity similarity. #[inline] @@ -64,7 +62,6 @@ where impl Distribution> for Standard where R: AbstractRotation, - // DefaultAllocator: Allocator, Standard: Distribution + Distribution, { /// Generate an arbitrary random variate for testing purposes. @@ -83,7 +80,6 @@ impl Similarity where N::Element: SimdRealField, R: AbstractRotation, - // DefaultAllocator: Allocator, { /// The similarity that applies the scaling factor `scaling`, followed by the rotation `r` with /// its axis passing through the point `p`. @@ -113,8 +109,7 @@ where N: crate::RealField + Arbitrary + Send, N::Element: crate::RealField, R: AbstractRotation + Arbitrary + Send, - // DefaultAllocator: Allocator, - Owned: Send, + Owned>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { @@ -394,7 +389,7 @@ macro_rules! similarity_construction_impl( up: &Vector3, scaling: N) -> Self { - Self::from_isometry(Isometry::<_, $Rot, _>::look_at_lh(eye, target, up), scaling) + Self::from_isometry(Isometry::<_, $Rot, 3>::look_at_lh(eye, target, up), scaling) } } } diff --git a/src/geometry/similarity_conversion.rs b/src/geometry/similarity_conversion.rs index 723d27dd..d22d4e3e 100644 --- a/src/geometry/similarity_conversion.rs +++ b/src/geometry/similarity_conversion.rs @@ -26,7 +26,6 @@ where N2: RealField + SupersetOf, R1: AbstractRotation + SubsetOf, R2: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Similarity { @@ -106,7 +105,7 @@ where #[inline] fn is_in_subset(m: &MatrixN, U1>>) -> bool { - let mut rot = m.fixed_slice::(0, 0).clone_owned(); + let mut rot = m.fixed_slice::, Const>(0, 0).clone_owned(); if rot .fixed_columns_mut::(0) .try_normalize_mut(N2::zero()) @@ -128,7 +127,7 @@ where rot.fixed_columns_mut::(2).neg_mut(); } - let bottom = m.fixed_slice::(D, 0); + let bottom = m.fixed_slice::>(D, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && // The normalized block part is a rotation. @@ -143,22 +142,22 @@ where #[inline] fn from_superset_unchecked(m: &MatrixN, U1>>) -> Self { let mut mm = m.clone_owned(); - let na = mm.fixed_slice_mut::(0, 0).normalize_mut(); - let nb = mm.fixed_slice_mut::(0, 1).normalize_mut(); - let nc = mm.fixed_slice_mut::(0, 2).normalize_mut(); + let na = mm.fixed_slice_mut::, U1>(0, 0).normalize_mut(); + let nb = mm.fixed_slice_mut::, U1>(0, 1).normalize_mut(); + let nc = mm.fixed_slice_mut::, U1>(0, 2).normalize_mut(); let mut scale = (na + nb + nc) / crate::convert(3.0); // We take the mean, for robustness. // TODO: could we avoid the explicit computation of the determinant? // (its sign is needed to see if the scaling factor is negative). - if mm.fixed_slice::(0, 0).determinant() < N2::zero() { - mm.fixed_slice_mut::(0, 0).neg_mut(); - mm.fixed_slice_mut::(0, 1).neg_mut(); - mm.fixed_slice_mut::(0, 2).neg_mut(); + if mm.fixed_slice::, Const>(0, 0).determinant() < N2::zero() { + mm.fixed_slice_mut::, U1>(0, 0).neg_mut(); + mm.fixed_slice_mut::, U1>(0, 1).neg_mut(); + mm.fixed_slice_mut::, U1>(0, 2).neg_mut(); scale = -scale; } - let t = m.fixed_slice::(0, D).into_owned(); + let t = m.fixed_slice::, U1>(0, D).into_owned(); let t = Translation { vector: crate::convert_unchecked(t), }; @@ -192,7 +191,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Zero + Copy, R::Element: Scalar + Zero + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Similarity; 2]) -> Self { @@ -211,7 +209,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Zero + Copy, R::Element: Scalar + Zero + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Similarity; 4]) -> Self { @@ -240,7 +237,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Zero + Copy, R::Element: Scalar + Zero + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Similarity; 8]) -> Self { @@ -277,7 +273,6 @@ where R::Element: AbstractRotation, N::Element: Scalar + Zero + Copy, R::Element: Scalar + Zero + Copy, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Similarity; 16]) -> Self { diff --git a/src/geometry/similarity_ops.rs b/src/geometry/similarity_ops.rs index 4c821e21..b1818f4a 100644 --- a/src/geometry/similarity_ops.rs +++ b/src/geometry/similarity_ops.rs @@ -5,8 +5,8 @@ use simba::scalar::{ClosedAdd, ClosedMul}; use simba::simd::SimdRealField; use crate::base::allocator::Allocator; -use crate::base::dimension::{DimName, U1, U2, U3, U4}; -use crate::base::{DefaultAllocator, Scalar, VectorN}; +use crate::base::dimension::{U1, U2, U3}; +use crate::base::{CVectorN, Const, DefaultAllocator, Scalar}; use crate::geometry::{ AbstractRotation, Isometry, Point, Rotation, Similarity, Translation, UnitComplex, @@ -70,10 +70,9 @@ macro_rules! similarity_binop_impl( ($Op: ident, $op: ident; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty; $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N: SimdRealField, D: DimName, R> $Op<$Rhs> for $Lhs + impl<$($lives ,)* N: SimdRealField, R, const D: usize> $Op<$Rhs> for $Lhs where N::Element: SimdRealField, - R: AbstractRotation, - DefaultAllocator: Allocator { + R: AbstractRotation { type Output = $Output; #[inline] @@ -118,20 +117,18 @@ macro_rules! similarity_binop_assign_impl_all( $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty; [val] => $action_val: expr; [ref] => $action_ref: expr;) => { - impl $OpAssign<$Rhs> for $Lhs + impl $OpAssign<$Rhs> for $Lhs where N::Element: SimdRealField, - R: AbstractRotation, - DefaultAllocator: Allocator { + R: AbstractRotation{ #[inline] fn $op_assign(&mut $lhs, $rhs: $Rhs) { $action_val } } - impl<'b, N: SimdRealField, D: DimName, R> $OpAssign<&'b $Rhs> for $Lhs + impl<'b, N: SimdRealField, R, const D: usize> $OpAssign<&'b $Rhs> for $Lhs where N::Element: SimdRealField, - R: AbstractRotation, - DefaultAllocator: Allocator { + R: AbstractRotation { #[inline] fn $op_assign(&mut $lhs, $rhs: &'b $Rhs) { $action_ref @@ -220,16 +217,18 @@ similarity_binop_assign_impl_all!( // Similarity ÷= R md_assign_impl_all!( MulAssign, mul_assign where N: SimdRealField for N::Element: SimdRealField; - (D, U1), (D, D) for D: DimName; - self: Similarity>, rhs: Rotation; + (Const, U1), (Const, Const) + const D; for; where; + self: Similarity, D>, rhs: Rotation; [val] => self.isometry.rotation *= rhs; [ref] => self.isometry.rotation *= rhs.clone(); ); md_assign_impl_all!( DivAssign, div_assign where N: SimdRealField for N::Element: SimdRealField; - (D, U1), (D, D) for D: DimName; - self: Similarity>, rhs: Rotation; + (Const, U1), (Const, Const) + const D; for; where; + self: Similarity, D>, rhs: Rotation; // TODO: don't invert explicitly? [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -237,7 +236,8 @@ md_assign_impl_all!( md_assign_impl_all!( MulAssign, mul_assign where N: SimdRealField for N::Element: SimdRealField; - (U3, U3), (U3, U3) for; + (U3, U3), (U3, U3) + const; for; where; self: Similarity, 3>, rhs: UnitQuaternion; [val] => self.isometry.rotation *= rhs; [ref] => self.isometry.rotation *= *rhs; @@ -245,7 +245,8 @@ md_assign_impl_all!( md_assign_impl_all!( DivAssign, div_assign where N: SimdRealField for N::Element: SimdRealField; - (U3, U3), (U3, U3) for; + (U3, U3), (U3, U3) + const; for; where; self: Similarity, 3>, rhs: UnitQuaternion; // TODO: don't invert explicitly? [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -254,16 +255,18 @@ md_assign_impl_all!( md_assign_impl_all!( MulAssign, mul_assign where N: SimdRealField for N::Element: SimdRealField; - (U2, U2), (U2, U2) for; - self: Similarity>, rhs: UnitComplex; + (U2, U2), (U2, U2) + const; for; where; + self: Similarity, 2>, rhs: UnitComplex; [val] => self.isometry.rotation *= rhs; [ref] => self.isometry.rotation *= *rhs; ); md_assign_impl_all!( DivAssign, div_assign where N: SimdRealField for N::Element: SimdRealField; - (U2, U2), (U2, U2) for; - self: Similarity>, rhs: UnitComplex; + (U2, U2), (U2, U2) + const; for; where; + self: Similarity, 2>, rhs: UnitComplex; // TODO: don't invert explicitly? [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -347,7 +350,7 @@ similarity_binop_impl_all!( // Similarity × Vector similarity_binop_impl_all!( Mul, mul; - self: Similarity, right: VectorN, Output = VectorN; + self: Similarity, right: CVectorN, Output = CVectorN; [val val] => self.isometry.rotation.transform_vector(&right) * self.scaling(); [ref val] => self.isometry.rotation.transform_vector(&right) * self.scaling(); [val ref] => self.isometry.rotation.transform_vector(right) * self.scaling(); @@ -389,13 +392,11 @@ similarity_binop_impl_all!( macro_rules! similarity_from_composition_impl( ($Op: ident, $op: ident; - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(for $Dims: ident: $DimsBound: ident),*; + $($Dims: ident),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty; $action: expr; $($lives: tt),*) => { - impl<$($lives ,)* N: SimdRealField $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs - where N::Element: SimdRealField, - DefaultAllocator: Allocator + - Allocator { + impl<$($lives ,)* N: SimdRealField $(, const $Dims: usize)*> $Op<$Rhs> for $Lhs + where N::Element: SimdRealField { type Output = $Output; #[inline] @@ -408,7 +409,7 @@ macro_rules! similarity_from_composition_impl( macro_rules! similarity_from_composition_impl_all( ($Op: ident, $op: ident; - ($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(for $Dims: ident: $DimsBound: ident),*; + $($Dims: ident),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty; [val val] => $action_val_val: expr; [ref val] => $action_ref_val: expr; @@ -417,25 +418,25 @@ macro_rules! similarity_from_composition_impl_all( similarity_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: $Lhs, $rhs: $Rhs, Output = $Output; $action_val_val; ); similarity_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: &'a $Lhs, $rhs: $Rhs, Output = $Output; $action_ref_val; 'a); similarity_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: $Lhs, $rhs: &'b $Rhs, Output = $Output; $action_val_ref; 'b); similarity_from_composition_impl!( $Op, $op; - ($R1, $C1),($R2, $C2) $(for $Dims: $DimsBound),*; + $($Dims),*; $lhs: &'a $Lhs, $rhs: &'b $Rhs, Output = $Output; $action_ref_ref; 'a, 'b); } @@ -444,9 +445,9 @@ macro_rules! similarity_from_composition_impl_all( // Similarity × Rotation similarity_from_composition_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName; - self: Similarity>, rhs: Rotation, - Output = Similarity>; + D; + self: Similarity, D>, rhs: Rotation, + Output = Similarity, D>; [val val] => { let scaling = self.scaling(); Similarity::from_isometry(self.isometry * rhs, scaling) @@ -462,9 +463,9 @@ similarity_from_composition_impl_all!( // Rotation × Similarity similarity_from_composition_impl_all!( Mul, mul; - (D, D), (D, U1) for D: DimName; - self: Rotation, right: Similarity>, - Output = Similarity>; + D; + self: Rotation, right: Similarity, D>, + Output = Similarity, D>; [val val] => &self * &right; [ref val] => self * &right; [val ref] => &self * right; @@ -474,9 +475,9 @@ similarity_from_composition_impl_all!( // Similarity ÷ Rotation similarity_from_composition_impl_all!( Div, div; - (D, D), (D, U1) for D: DimName; - self: Similarity>, rhs: Rotation, - Output = Similarity>; + D; + self: Similarity, D>, rhs: Rotation, + Output = Similarity, D>; [val val] => { let scaling = self.scaling(); Similarity::from_isometry(self.isometry / rhs, scaling) @@ -492,9 +493,9 @@ similarity_from_composition_impl_all!( // Rotation ÷ Similarity similarity_from_composition_impl_all!( Div, div; - (D, D), (D, U1) for D: DimName; - self: Rotation, right: Similarity>, - Output = Similarity>; + D; + self: Rotation, right: Similarity, D>, + Output = Similarity, D>; // TODO: don't call inverse explicitly? [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; @@ -505,7 +506,7 @@ similarity_from_composition_impl_all!( // Similarity × UnitQuaternion similarity_from_composition_impl_all!( Mul, mul; - (U4, U1), (U3, U1); + ; self: Similarity, 3>, rhs: UnitQuaternion, Output = Similarity, 3>; [val val] => { @@ -523,7 +524,7 @@ similarity_from_composition_impl_all!( // UnitQuaternion × Similarity similarity_from_composition_impl_all!( Mul, mul; - (U4, U1), (U3, U1); + ; self: UnitQuaternion, right: Similarity, 3>, Output = Similarity, 3>; [val val] => &self * &right; @@ -535,7 +536,7 @@ similarity_from_composition_impl_all!( // Similarity ÷ UnitQuaternion similarity_from_composition_impl_all!( Div, div; - (U4, U1), (U3, U1); + ; self: Similarity, 3>, rhs: UnitQuaternion, Output = Similarity, 3>; [val val] => { @@ -553,7 +554,7 @@ similarity_from_composition_impl_all!( // UnitQuaternion ÷ Similarity similarity_from_composition_impl_all!( Div, div; - (U4, U1), (U3, U1); + ; self: UnitQuaternion, right: Similarity, 3>, Output = Similarity, 3>; // TODO: don't call inverse explicitly? @@ -566,9 +567,9 @@ similarity_from_composition_impl_all!( // Similarity × UnitComplex similarity_from_composition_impl_all!( Mul, mul; - (U2, U1), (U2, U1); - self: Similarity>, rhs: UnitComplex, - Output = Similarity>; + ; + self: Similarity, 2>, rhs: UnitComplex, + Output = Similarity, 2>; [val val] => { let scaling = self.scaling(); Similarity::from_isometry(self.isometry * rhs, scaling) @@ -584,9 +585,9 @@ similarity_from_composition_impl_all!( // Similarity ÷ UnitComplex similarity_from_composition_impl_all!( Div, div; - (U2, U1), (U2, U1); - self: Similarity>, rhs: UnitComplex, - Output = Similarity>; + ; + self: Similarity, 2>, rhs: UnitComplex, + Output = Similarity, 2>; [val val] => { let scaling = self.scaling(); Similarity::from_isometry(self.isometry / rhs, scaling) diff --git a/src/geometry/similarity_simba.rs b/src/geometry/similarity_simba.rs index 0436130a..91a9e733 100755 --- a/src/geometry/similarity_simba.rs +++ b/src/geometry/similarity_simba.rs @@ -7,7 +7,6 @@ where N::Element: SimdRealField, R: SimdValue + AbstractRotation, R::Element: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { type Element = Similarity; type SimdBool = N::SimdBool; diff --git a/src/geometry/swizzle.rs b/src/geometry/swizzle.rs index e0c42eaa..d76464e6 100644 --- a/src/geometry/swizzle.rs +++ b/src/geometry/swizzle.rs @@ -21,7 +21,6 @@ macro_rules! impl_swizzle { impl Point where Const: ToTypenum, - // DefaultAllocator: Allocator, { impl_swizzle!( where U0: xx() -> Point2[0, 0], diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 15b2c939..fceae681 100755 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -11,7 +11,7 @@ use simba::scalar::RealField; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; use crate::base::storage::Owned; -use crate::base::{CMatrixN, CVectorN, Const, DefaultAllocator, MatrixN}; +use crate::base::{CVectorN, Const, DefaultAllocator, DimName, MatrixN}; use crate::geometry::Point; @@ -28,10 +28,10 @@ pub trait TCategory: Any + Debug + Copy + PartialEq + Send { /// Checks that the given matrix is a valid homogeneous representation of an element of the /// category `Self`. - fn check_homogeneous_invariants(mat: &CMatrixN) -> bool + fn check_homogeneous_invariants(mat: &MatrixN) -> bool where - N::Epsilon: Copy; - // DefaultAllocator: Allocator; + N::Epsilon: Copy, + DefaultAllocator: Allocator; } /// Traits that gives the `Transform` category that is compatible with the result of the @@ -71,10 +71,10 @@ pub enum TAffine {} impl TCategory for TGeneral { #[inline] - fn check_homogeneous_invariants(_: &CMatrixN) -> bool + fn check_homogeneous_invariants(_: &MatrixN) -> bool where N::Epsilon: Copy, - // DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { true } @@ -82,10 +82,10 @@ impl TCategory for TGeneral { impl TCategory for TProjective { #[inline] - fn check_homogeneous_invariants(mat: &CMatrixN) -> bool + fn check_homogeneous_invariants(mat: &MatrixN) -> bool where N::Epsilon: Copy, - // DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { mat.is_invertible() } @@ -98,12 +98,12 @@ impl TCategory for TAffine { } #[inline] - fn check_homogeneous_invariants(mat: &CMatrixN) -> bool + fn check_homogeneous_invariants(mat: &MatrixN) -> bool where N::Epsilon: Copy, - // DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { - let last = D - 1; + let last = D::dim() - 1; mat.is_invertible() && mat[(last, last)] == N::one() && (0..last).all(|i| mat[(last, i)].is_zero()) diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 9a51bbb4..7a70c546 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -4,8 +4,8 @@ use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign}; use simba::scalar::{ClosedAdd, ClosedMul, RealField, SubsetOf}; use crate::base::allocator::Allocator; -use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1, U3, U4}; -use crate::base::{DefaultAllocator, MatrixN, Scalar, VectorN}; +use crate::base::dimension::{DimNameAdd, DimNameSum, U1, U4}; +use crate::base::{CVectorN, Const, DefaultAllocator, MatrixN, Scalar}; use crate::geometry::{ Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory, @@ -107,16 +107,19 @@ where // Transform × Vector md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory; - self: Transform, rhs: VectorN, Output = VectorN; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C; + where Const: DimNameAdd, C: TCategory; + self: Transform, rhs: CVectorN, Output = CVectorN; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; [ref ref] => { - let transform = self.matrix().fixed_slice::(0, 0); + let transform = self.matrix().fixed_slice::, Const>(0, 0); if C::has_normalizer() { - let normalizer = self.matrix().fixed_slice::(D::dim(), 0); + let normalizer = self.matrix().fixed_slice::>(D, 0); let n = normalizer.tr_dot(&rhs); if !n.is_zero() { @@ -131,20 +134,22 @@ md_impl_all!( // Transform × Point md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory - where DefaultAllocator: Allocator; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C; + where Const: DimNameAdd, C: TCategory; self: Transform, rhs: Point, Output = Point; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; [ref ref] => { - let transform = self.matrix().fixed_slice::(0, 0); - let translation = self.matrix().fixed_slice::(0, D::dim()); + let transform = self.matrix().fixed_slice::, Const>(0, 0); + let translation = self.matrix().fixed_slice::, U1>(0, D); if C::has_normalizer() { - let normalizer = self.matrix().fixed_slice::(D::dim(), 0); + let normalizer = self.matrix().fixed_slice::>(D, 0); #[allow(clippy::suspicious_arithmetic_impl)] - let n = normalizer.tr_dot(&rhs.coords) + unsafe { *self.matrix().get_unchecked((D::dim(), D::dim())) }; + let n = normalizer.tr_dot(&rhs.coords) + unsafe { *self.matrix().get_unchecked((D, D)) }; if !n.is_zero() { return (transform * rhs + translation) / n; @@ -158,8 +163,11 @@ md_impl_all!( // Transform × Transform md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategoryMul, CB: TCategory; - self: Transform, rhs: Transform, Output = Transform; + (DimNameSum, U1>, DimNameSum, U1>), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for CA, CB; + where Const: DimNameAdd, CA: TCategoryMul, CB: TCategory; + self: Transform, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.into_inner()); [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.matrix()); @@ -169,7 +177,10 @@ md_impl_all!( // Transform × Rotation md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (D, D) for D: DimNameAdd, C: TCategoryMul; + (DimNameSum, U1>, DimNameSum, U1>), (Const, Const) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Rotation, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -180,7 +191,10 @@ md_impl_all!( // Rotation × Transform md_impl_all!( Mul, mul where N: RealField; - (D, D), (DimNameSum, DimNameSum) for D: DimNameAdd, C: TCategoryMul; + (Const, Const), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Rotation, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -191,7 +205,10 @@ md_impl_all!( // Transform × UnitQuaternion md_impl_all!( Mul, mul where N: RealField; - (U4, U4), (U4, U1) for C: TCategoryMul; + (U4, U4), (U4, U1) + const; + for C; + where C: TCategoryMul; self: Transform, rhs: UnitQuaternion, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -202,7 +219,10 @@ md_impl_all!( // UnitQuaternion × Transform md_impl_all!( Mul, mul where N: RealField; - (U4, U1), (U4, U4) for C: TCategoryMul; + (U4, U1), (U4, U4) + const; + for C; + where C: TCategoryMul; self: UnitQuaternion, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -213,8 +233,10 @@ md_impl_all!( // Transform × Isometry md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (D, U1) - for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C, R; + where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> >; self: Transform, rhs: Isometry, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -225,8 +247,10 @@ md_impl_all!( // Isometry × Transform md_impl_all!( Mul, mul where N: RealField; - (D, U1), (DimNameSum, DimNameSum) - for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; + (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for C, R; + where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> >; self: Isometry, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -237,8 +261,10 @@ md_impl_all!( // Transform × Similarity md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (D, U1) - for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C, R; + where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> >; self: Transform, rhs: Similarity, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -249,8 +275,10 @@ md_impl_all!( // Similarity × Transform md_impl_all!( Mul, mul where N: RealField; - (D, U1), (DimNameSum, DimNameSum) - for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; + (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for C, R; + where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> >; self: Similarity, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -269,7 +297,10 @@ md_impl_all!( // Transform × Translation md_impl_all!( Mul, mul where N: RealField; - (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Translation, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -280,8 +311,10 @@ md_impl_all!( // Translation × Transform md_impl_all!( Mul, mul where N: RealField; - (D, U1), (DimNameSum, DimNameSum) - for D: DimNameAdd, C: TCategoryMul; + (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Translation, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -292,8 +325,11 @@ md_impl_all!( // Transform ÷ Transform md_impl_all!( Div, div where N: RealField; - (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategoryMul, CB: SubTCategoryOf; - self: Transform, rhs: Transform, Output = Transform; + (DimNameSum, U1>, DimNameSum, U1>), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for CA, CB; + where Const: DimNameAdd, CA: TCategoryMul, CB: SubTCategoryOf; + self: Transform, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.clone().inverse() }; @@ -303,7 +339,10 @@ md_impl_all!( // Transform ÷ Rotation md_impl_all!( Div, div where N: RealField; - (DimNameSum, DimNameSum), (D, D) for D: DimNameAdd, C: TCategoryMul; + (DimNameSum, U1>, DimNameSum, U1>), (Const, Const) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Rotation, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -314,7 +353,10 @@ md_impl_all!( // Rotation ÷ Transform md_impl_all!( Div, div where N: RealField; - (D, D), (DimNameSum, DimNameSum) for D: DimNameAdd, C: TCategoryMul; + (Const, Const), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Rotation, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; @@ -325,7 +367,10 @@ md_impl_all!( // Transform ÷ UnitQuaternion md_impl_all!( Div, div where N: RealField; - (U4, U4), (U4, U1) for C: TCategoryMul; + (U4, U4), (U4, U1) + const; + for C; + where C: TCategoryMul; self: Transform, rhs: UnitQuaternion, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -336,7 +381,10 @@ md_impl_all!( // UnitQuaternion ÷ Transform md_impl_all!( Div, div where N: RealField; - (U4, U1), (U4, U4) for C: TCategoryMul; + (U4, U1), (U4, U4) + const; + for C; + where C: TCategoryMul; self: UnitQuaternion, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; @@ -347,9 +395,9 @@ md_impl_all!( // // Transform ÷ Isometry // md_impl_all!( // Div, div where N: RealField; -// (DimNameSum, DimNameSum), (D, U1) -// for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > -// where SB::Alloc: Allocator, DimNameSum >; +// (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) +// for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> > +// where SB::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Transform, rhs: Isometry, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.inverse().to_homogeneous()); // [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.inverse().to_homogeneous()); @@ -360,9 +408,9 @@ md_impl_all!( // // Isometry ÷ Transform // md_impl_all!( // Div, div where N: RealField; -// (D, U1), (DimNameSum, DimNameSum) -// for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > -// where SA::Alloc: Allocator, DimNameSum >; +// (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) +// for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> > +// where SA::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Isometry, rhs: Transform, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); // [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -373,10 +421,10 @@ md_impl_all!( // // Transform ÷ Similarity // md_impl_all!( // Div, div where N: RealField; -// (DimNameSum, DimNameSum), (D, U1) -// for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > +// (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) +// for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> > // where SB::Alloc: Allocator -// where SB::Alloc: Allocator, DimNameSum >; +// where SB::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Transform, rhs: Similarity, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); // [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -387,10 +435,10 @@ md_impl_all!( // // Similarity ÷ Transform // md_impl_all!( // Div, div where N: RealField; -// (D, U1), (DimNameSum, DimNameSum) -// for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > +// (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) +// for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>> > // where SA::Alloc: Allocator -// where SA::Alloc: Allocator, DimNameSum >; +// where SA::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Similarity, rhs: Transform, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); // [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -401,7 +449,10 @@ md_impl_all!( // Transform ÷ Translation md_impl_all!( Div, div where N: RealField; - (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Translation, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -412,8 +463,10 @@ md_impl_all!( // Translation ÷ Transform md_impl_all!( Div, div where N: RealField; - (D, U1), (DimNameSum, DimNameSum) - for D: DimNameAdd, C: TCategoryMul; + (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for C; + where Const: DimNameAdd, C: TCategoryMul; self: Translation, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; @@ -424,8 +477,11 @@ md_impl_all!( // Transform ×= Transform md_assign_impl_all!( MulAssign, mul_assign where N: RealField; - (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategory, CB: SubTCategoryOf; - self: Transform, rhs: Transform; + (DimNameSum, U1>, DimNameSum, U1>), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for CA, CB; + where Const: DimNameAdd, CA: TCategory, CB: SubTCategoryOf; + self: Transform, rhs: Transform; [val] => *self.matrix_mut_unchecked() *= rhs.into_inner(); [ref] => *self.matrix_mut_unchecked() *= rhs.matrix(); ); @@ -433,8 +489,10 @@ md_assign_impl_all!( // Transform ×= Similarity md_assign_impl_all!( MulAssign, mul_assign where N: RealField; - (DimNameSum, DimNameSum), (D, U1) - for D: DimNameAdd, C: TCategory, R: SubsetOf> >; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C, R; + where Const: DimNameAdd, C: TCategory, R: SubsetOf, U1>> >; self: Transform, rhs: Similarity; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -443,8 +501,10 @@ md_assign_impl_all!( // Transform ×= Isometry md_assign_impl_all!( MulAssign, mul_assign where N: RealField; - (DimNameSum, DimNameSum), (D, U1) - for D: DimNameAdd, C: TCategory, R: SubsetOf> >; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C, R; + where Const: DimNameAdd, C: TCategory, R: SubsetOf, U1>> >; self: Transform, rhs: Isometry; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -461,7 +521,10 @@ md_assign_impl_all!( // Transform ×= Translation md_assign_impl_all!( MulAssign, mul_assign where N: RealField; - (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C; + where Const: DimNameAdd, C: TCategory; self: Transform, rhs: Translation; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -470,7 +533,10 @@ md_assign_impl_all!( // Transform ×= Rotation md_assign_impl_all!( MulAssign, mul_assign where N: RealField; - (DimNameSum, DimNameSum), (D, D) for D: DimNameAdd, C: TCategory; + (DimNameSum, U1>, DimNameSum, U1>), (Const, Const) + const D; + for C; + where Const: DimNameAdd, C: TCategory; self: Transform, rhs: Rotation; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -479,7 +545,10 @@ md_assign_impl_all!( // Transform ×= UnitQuaternion md_assign_impl_all!( MulAssign, mul_assign where N: RealField; - (U4, U4), (U4, U1) for C: TCategory; + (U4, U4), (U4, U1) + const; + for C; + where C: TCategory; self: Transform, rhs: UnitQuaternion; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -488,9 +557,11 @@ md_assign_impl_all!( // Transform ÷= Transform md_assign_impl_all!( DivAssign, div_assign where N: RealField; - (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) - for D: DimNameAdd, CA: SuperTCategoryOf, CB: SubTCategoryOf; - self: Transform, rhs: Transform; + (DimNameSum, U1>, DimNameSum, U1>), (DimNameSum, U1>, DimNameSum, U1>) + const D; + for CA, CB; + where Const: DimNameAdd, CA: SuperTCategoryOf, CB: SubTCategoryOf; + self: Transform, rhs: Transform; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.clone().inverse() }; ); @@ -498,8 +569,8 @@ md_assign_impl_all!( // // Transform ÷= Similarity // md_assign_impl_all!( // DivAssign, div_assign; -// (DimNameSum, DimNameSum), (D, U1) -// for D: DimNameAdd, C: TCategory, R: SubsetOf> >; +// (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) +// for Const: DimNameAdd, C: TCategory, R: SubsetOf, U1>> >; // self: Transform, rhs: Similarity; // [val] => *self *= rhs.inverse(); // [ref] => *self *= rhs.inverse(); @@ -509,8 +580,8 @@ md_assign_impl_all!( // // Transform ÷= Isometry // md_assign_impl_all!( // DivAssign, div_assign; -// (DimNameSum, DimNameSum), (D, U1) -// for D: DimNameAdd, C: TCategory, R: SubsetOf> >; +// (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) +// for Const: DimNameAdd, C: TCategory, R: SubsetOf, U1>> >; // self: Transform, rhs: Isometry; // [val] => *self *= rhs.inverse(); // [ref] => *self *= rhs.inverse(); @@ -519,7 +590,10 @@ md_assign_impl_all!( // Transform ÷= Translation md_assign_impl_all!( DivAssign, div_assign where N: RealField; - (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory; + (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) + const D; + for C; + where Const: DimNameAdd, C: TCategory; self: Transform, rhs: Translation; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -528,7 +602,10 @@ md_assign_impl_all!( // Transform ÷= Rotation md_assign_impl_all!( DivAssign, div_assign where N: RealField; - (DimNameSum, DimNameSum), (D, D) for D: DimNameAdd, C: TCategory; + (DimNameSum, U1>, DimNameSum, U1>), (Const, Const) + const D; + for C; + where Const: DimNameAdd, C: TCategory; self: Transform, rhs: Rotation; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -537,7 +614,10 @@ md_assign_impl_all!( // Transform ÷= UnitQuaternion md_assign_impl_all!( DivAssign, div_assign where N: RealField; - (U4, U4), (U4, U1) for C: TCategory; + (U4, U4), (U4, U1) + const; + for C; + where C: TCategory; self: Transform, rhs: UnitQuaternion; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 1ae452bb..0fc450cc 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -34,7 +34,6 @@ pub struct Translation impl hash::Hash for Translation where - // DefaultAllocator: Allocator, Owned>: hash::Hash, { fn hash(&self, state: &mut H) { @@ -42,15 +41,10 @@ where } } -impl Copy for Translation where - // DefaultAllocator: Allocator, - Owned>: Copy -{ -} +impl Copy for Translation where Owned>: Copy {} impl Clone for Translation where - // DefaultAllocator: Allocator, Owned>: Clone, { #[inline] @@ -60,12 +54,10 @@ where } #[cfg(feature = "abomonation-serialize")] -impl Abomonation for Translation +impl Abomonation for Translation where N: Scalar, - D: DimName, CVectorN: Abomonation, - // DefaultAllocator: Allocator, { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { self.vector.entomb(writer) @@ -83,8 +75,7 @@ where #[cfg(feature = "serde-serialize")] impl Serialize for Translation where - // DefaultAllocator: Allocator, - Owned: Serialize, + Owned>: Serialize, { fn serialize(&self, serializer: S) -> Result where @@ -97,8 +88,7 @@ where #[cfg(feature = "serde-serialize")] impl<'a, N: Scalar, const D: usize> Deserialize<'a> for Translation where - // DefaultAllocator: Allocator, - Owned: Deserialize<'a>, + Owned>: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result where @@ -169,8 +159,9 @@ impl Translation Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { - let mut res = MatrixN::>::identity(); - res.fixed_slice_mut::(0, D).copy_from(&self.vector); + let mut res = MatrixN::, U1>>::identity(); + res.fixed_slice_mut::, U1>(0, D) + .copy_from(&self.vector); res } @@ -257,7 +248,6 @@ impl PartialEq for Translation impl AbsDiffEq for Translation where - // DefaultAllocator: Allocator, N::Epsilon: Copy, { type Epsilon = N::Epsilon; @@ -275,7 +265,6 @@ where impl RelativeEq for Translation where - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] @@ -297,7 +286,6 @@ where impl UlpsEq for Translation where - // DefaultAllocator: Allocator, N::Epsilon: Copy, { #[inline] diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index cfd441d5..7ee2359c 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -12,7 +12,7 @@ use rand::{ use simba::scalar::{ClosedAdd, SupersetOf}; -use crate::base::{CVectorN, Scalar}; +use crate::base::{CVectorN, Const, Scalar}; use crate::geometry::Translation; @@ -54,7 +54,6 @@ impl Translation pub fn cast(self) -> Translation where Translation: SupersetOf, - // DefaultAllocator: Allocator, { crate::convert(self) } @@ -73,7 +72,6 @@ impl One for Translation #[cfg(feature = "rand-no-std")] impl Distribution> for Standard where - // DefaultAllocator: Allocator, Standard: Distribution, { /// Generate an arbitrary random variate for testing purposes. @@ -86,8 +84,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for Translation where - // DefaultAllocator: Allocator, - Owned: Send, + Owned>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index c49e2735..ca5daa25 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -5,7 +5,7 @@ use simba::simd::PrimitiveSimdValue; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::{Const, DefaultAllocator, MatrixN, Scalar, VectorN}; +use crate::base::{CVectorN, Const, DefaultAllocator, MatrixN, Scalar, VectorN}; use crate::geometry::{ AbstractRotation, Isometry, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, @@ -28,7 +28,6 @@ impl SubsetOf> for Translation where N1: Scalar, N2: Scalar + SupersetOf, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Translation { @@ -37,7 +36,7 @@ where #[inline] fn is_in_subset(rot: &Translation) -> bool { - crate::is_convertible::<_, VectorN>(&rot.vector) + crate::is_convertible::<_, CVectorN>(&rot.vector) } #[inline] @@ -53,7 +52,6 @@ where N1: RealField, N2: RealField + SupersetOf, R: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Isometry { @@ -84,7 +82,7 @@ where #[inline] fn is_in_subset(dq: &UnitDualQuaternion) -> bool { - crate::is_convertible::<_, Translation>(&dq.translation()) + crate::is_convertible::<_, Translation>(&dq.translation()) && dq.rotation() == UnitQuaternion::identity() } @@ -100,7 +98,6 @@ where N1: RealField, N2: RealField + SupersetOf, R: AbstractRotation, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn to_superset(&self) -> Similarity { @@ -160,7 +157,7 @@ where #[inline] fn is_in_subset(m: &MatrixN, U1>>) -> bool { - let id = m.fixed_slice::, U1>, D>(0, 0); + let id = m.fixed_slice::, U1>, Const>(0, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && @@ -172,7 +169,7 @@ where #[inline] fn from_superset_unchecked(m: &MatrixN, U1>>) -> Self { - let t = m.fixed_slice::(0, D); + let t = m.fixed_slice::, U1>(0, D); Self { vector: crate::convert_unchecked(t.into_owned()), } @@ -207,7 +204,6 @@ impl From<[Translation::Element; 2]>, N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Translation; 2]) -> Self { @@ -223,7 +219,6 @@ impl From<[Translation::Element; 4]>, N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Translation; 4]) -> Self { @@ -241,7 +236,6 @@ impl From<[Translation::Element; 8]>, N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Translation; 8]) -> Self { @@ -263,7 +257,6 @@ impl From<[Translation::Element; 16]>, N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { #[inline] fn from(arr: [Translation; 16]) -> Self { diff --git a/src/geometry/translation_ops.rs b/src/geometry/translation_ops.rs index fc53b1e6..11d18469 100644 --- a/src/geometry/translation_ops.rs +++ b/src/geometry/translation_ops.rs @@ -4,57 +4,65 @@ use simba::scalar::{ClosedAdd, ClosedSub}; use crate::base::allocator::{Allocator, SameShapeAllocator}; use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use crate::base::dimension::{DimName, U1}; -use crate::base::{DefaultAllocator, Scalar}; +use crate::base::dimension::U1; +use crate::base::{Const, DefaultAllocator, Scalar}; use crate::geometry::{Point, Translation}; // Translation × Translation add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: &'a Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector + &right.vector) }; 'a, 'b); add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: &'a Translation, right: Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector + right.vector) }; 'a); add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector + &right.vector) }; 'b); add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: Translation, right: Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector + right.vector) }; ); // Translation ÷ Translation // TODO: instead of calling inverse explicitly, could we just add a `mul_tr` or `mul_inv` method? add_sub_impl!(Div, div, ClosedSub; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: &'a Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector - &right.vector) }; 'a, 'b); add_sub_impl!(Div, div, ClosedSub; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: &'a Translation, right: Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector - right.vector) }; 'a); add_sub_impl!(Div, div, ClosedSub; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector - &right.vector) }; 'b); add_sub_impl!(Div, div, ClosedSub; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: Translation, right: Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector - right.vector) }; ); @@ -62,47 +70,51 @@ add_sub_impl!(Div, div, ClosedSub; // TODO: we don't handle properly non-zero origins here. Do we want this to be the intended // behavior? add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: &'a Translation, right: &'b Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + &self.vector }; 'a, 'b); add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: &'a Translation, right: Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + &self.vector }; 'a); add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: Translation, right: &'b Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + self.vector }; 'b); add_sub_impl!(Mul, mul, ClosedAdd; - (D, U1), (D, U1) -> (D) for D: DimName; + (Const, U1), (Const, U1) -> (Const) + const D; for; where; self: Translation, right: Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + self.vector }; ); // Translation *= Translation add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; - (D, U1), (D, U1) for D: DimName; + const D; self: Translation, right: &'b Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector += &right.vector }; 'b); add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; - (D, U1), (D, U1) for D: DimName; + const D; self: Translation, right: Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector += right.vector }; ); add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; - (D, U1), (D, U1) for D: DimName; + const D; self: Translation, right: &'b Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector -= &right.vector }; 'b); add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; - (D, U1), (D, U1) for D: DimName; + const D; self: Translation, right: Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector -= right.vector }; ); diff --git a/src/geometry/translation_simba.rs b/src/geometry/translation_simba.rs index 6d96618f..60d6e53f 100755 --- a/src/geometry/translation_simba.rs +++ b/src/geometry/translation_simba.rs @@ -8,7 +8,6 @@ use crate::geometry::Translation; impl SimdValue for Translation where N::Element: Scalar, - // DefaultAllocator: Allocator + Allocator, { type Element = Translation; type SimdBool = N::SimdBool; diff --git a/src/geometry/unit_complex_ops.rs b/src/geometry/unit_complex_ops.rs index ef227023..621dd46a 100644 --- a/src/geometry/unit_complex_ops.rs +++ b/src/geometry/unit_complex_ops.rs @@ -1,9 +1,7 @@ use std::ops::{Div, DivAssign, Mul, MulAssign}; -use crate::base::allocator::Allocator; -use crate::base::dimension::{U1, U2}; use crate::base::storage::Storage; -use crate::base::{DefaultAllocator, Unit, Vector, Vector2}; +use crate::base::{Const, Unit, Vector, Vector2}; use crate::geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex}; use simba::simd::SimdRealField; @@ -142,12 +140,11 @@ where macro_rules! complex_op_impl( ($Op: ident, $op: ident; - ($RDim: ident, $CDim: ident) $(for $Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*; + $($Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; $action: expr; $($lives: tt),*) => { impl<$($lives ,)* N: SimdRealField $(, $Storage: $StoragesBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs - where N::Element: SimdRealField, - DefaultAllocator: Allocator { + where N::Element: SimdRealField { type Output = $Result; #[inline] @@ -160,7 +157,7 @@ macro_rules! complex_op_impl( macro_rules! complex_op_impl_all( ($Op: ident, $op: ident; - ($RDim: ident, $CDim: ident) $(for $Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*; + $($Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*; $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; [val val] => $action_val_val: expr; [ref val] => $action_ref_val: expr; @@ -168,22 +165,22 @@ macro_rules! complex_op_impl_all( [ref ref] => $action_ref_ref: expr;) => { complex_op_impl!($Op, $op; - ($RDim, $CDim) $(for $Storage: $StoragesBound $(<$($BoundParam),*>)*),*; + $($Storage: $StoragesBound $(<$($BoundParam),*>)*),*; $lhs: $Lhs, $rhs: $Rhs, Output = $Result; $action_val_val; ); complex_op_impl!($Op, $op; - ($RDim, $CDim) $(for $Storage: $StoragesBound $(<$($BoundParam),*>)*),*; + $($Storage: $StoragesBound $(<$($BoundParam),*>)*),*; $lhs: &'a $Lhs, $rhs: $Rhs, Output = $Result; $action_ref_val; 'a); complex_op_impl!($Op, $op; - ($RDim, $CDim) $(for $Storage: $StoragesBound $(<$($BoundParam),*>)*),*; + $($Storage: $StoragesBound $(<$($BoundParam),*>)*),*; $lhs: $Lhs, $rhs: &'b $Rhs, Output = $Result; $action_val_ref; 'b); complex_op_impl!($Op, $op; - ($RDim, $CDim) $(for $Storage: $StoragesBound $(<$($BoundParam),*>)*),*; + $($Storage: $StoragesBound $(<$($BoundParam),*>)*),*; $lhs: &'a $Lhs, $rhs: &'b $Rhs, Output = $Result; $action_ref_ref; 'a, 'b); @@ -194,8 +191,8 @@ macro_rules! complex_op_impl_all( // UnitComplex × Rotation complex_op_impl_all!( Mul, mul; - (U2, U2); - self: UnitComplex, rhs: Rotation, Output = UnitComplex; + ; + self: UnitComplex, rhs: Rotation, Output = UnitComplex; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -205,8 +202,8 @@ complex_op_impl_all!( // UnitComplex ÷ Rotation complex_op_impl_all!( Div, div; - (U2, U2); - self: UnitComplex, rhs: Rotation, Output = UnitComplex; + ; + self: UnitComplex, rhs: Rotation, Output = UnitComplex; [val val] => &self / &rhs; [ref val] => self / &rhs; [val ref] => &self / rhs; @@ -216,8 +213,8 @@ complex_op_impl_all!( // Rotation × UnitComplex complex_op_impl_all!( Mul, mul; - (U2, U2); - self: Rotation, rhs: UnitComplex, Output = UnitComplex; + ; + self: Rotation, rhs: UnitComplex, Output = UnitComplex; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -227,8 +224,8 @@ complex_op_impl_all!( // Rotation ÷ UnitComplex complex_op_impl_all!( Div, div; - (U2, U2); - self: Rotation, rhs: UnitComplex, Output = UnitComplex; + ; + self: Rotation, rhs: UnitComplex, Output = UnitComplex; [val val] => &self / &rhs; [ref val] => self / &rhs; [val ref] => &self / rhs; @@ -238,7 +235,7 @@ complex_op_impl_all!( // UnitComplex × Point complex_op_impl_all!( Mul, mul; - (U2, U1); + ; self: UnitComplex, rhs: Point2, Output = Point2; [val val] => &self * &rhs; [ref val] => self * &rhs; @@ -249,8 +246,8 @@ complex_op_impl_all!( // UnitComplex × Vector complex_op_impl_all!( Mul, mul; - (U2, U1) for S: Storage; - self: UnitComplex, rhs: Vector, Output = Vector2; + S: Storage>; + self: UnitComplex, rhs: Vector, S>, Output = Vector2; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -264,8 +261,8 @@ complex_op_impl_all!( // UnitComplex × Unit complex_op_impl_all!( Mul, mul; - (U2, U1) for S: Storage; - self: UnitComplex, rhs: Unit>, Output = Unit>; + S: Storage>; + self: UnitComplex, rhs: Unit, S>>, Output = Unit>; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -275,9 +272,9 @@ complex_op_impl_all!( // UnitComplex × Isometry complex_op_impl_all!( Mul, mul; - (U2, U1); - self: UnitComplex, rhs: Isometry>, - Output = Isometry>; + ; + self: UnitComplex, rhs: Isometry, 2>, + Output = Isometry, 2>; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -290,9 +287,9 @@ complex_op_impl_all!( // UnitComplex × Similarity complex_op_impl_all!( Mul, mul; - (U2, U1); - self: UnitComplex, rhs: Similarity>, - Output = Similarity>; + ; + self: UnitComplex, rhs: Similarity, 2>, + Output = Similarity, 2>; [val val] => &self * &rhs; [ref val] => self * &rhs; [val ref] => &self * rhs; @@ -302,9 +299,9 @@ complex_op_impl_all!( // UnitComplex × Translation complex_op_impl_all!( Mul, mul; - (U2, U1); - self: UnitComplex, rhs: Translation, - Output = Isometry>; + ; + self: UnitComplex, rhs: Translation, + Output = Isometry, 2>; [val val] => Isometry::from_parts(Translation::from(&self * rhs.vector), self); [ref val] => Isometry::from_parts(Translation::from( self * rhs.vector), *self); [val ref] => Isometry::from_parts(Translation::from(&self * &rhs.vector), self); @@ -314,9 +311,9 @@ complex_op_impl_all!( // Translation × UnitComplex complex_op_impl_all!( Mul, mul; - (U2, U1); - self: Translation, right: UnitComplex, - Output = Isometry>; + ; + self: Translation, right: UnitComplex, + Output = Isometry, 2>; [val val] => Isometry::from_parts(self, right); [ref val] => Isometry::from_parts(self.clone(), right); [val ref] => Isometry::from_parts(self, *right); @@ -366,56 +363,51 @@ where } // UnitComplex ×= Rotation -impl MulAssign> for UnitComplex +impl MulAssign> for UnitComplex where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] - fn mul_assign(&mut self, rhs: Rotation) { + fn mul_assign(&mut self, rhs: Rotation) { *self = &*self * rhs } } -impl<'b, N: SimdRealField> MulAssign<&'b Rotation> for UnitComplex +impl<'b, N: SimdRealField> MulAssign<&'b Rotation> for UnitComplex where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] - fn mul_assign(&mut self, rhs: &'b Rotation) { + fn mul_assign(&mut self, rhs: &'b Rotation) { *self = &*self * rhs } } // UnitComplex ÷= Rotation -impl DivAssign> for UnitComplex +impl DivAssign> for UnitComplex where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] - fn div_assign(&mut self, rhs: Rotation) { + fn div_assign(&mut self, rhs: Rotation) { *self = &*self / rhs } } -impl<'b, N: SimdRealField> DivAssign<&'b Rotation> for UnitComplex +impl<'b, N: SimdRealField> DivAssign<&'b Rotation> for UnitComplex where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] - fn div_assign(&mut self, rhs: &'b Rotation) { + fn div_assign(&mut self, rhs: &'b Rotation) { *self = &*self / rhs } } // Rotation ×= UnitComplex -impl MulAssign> for Rotation +impl MulAssign> for Rotation where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] fn mul_assign(&mut self, rhs: UnitComplex) { @@ -423,10 +415,9 @@ where } } -impl<'b, N: SimdRealField> MulAssign<&'b UnitComplex> for Rotation +impl<'b, N: SimdRealField> MulAssign<&'b UnitComplex> for Rotation where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] fn mul_assign(&mut self, rhs: &'b UnitComplex) { @@ -435,10 +426,9 @@ where } // Rotation ÷= UnitComplex -impl DivAssign> for Rotation +impl DivAssign> for Rotation where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] fn div_assign(&mut self, rhs: UnitComplex) { @@ -446,10 +436,9 @@ where } } -impl<'b, N: SimdRealField> DivAssign<&'b UnitComplex> for Rotation +impl<'b, N: SimdRealField> DivAssign<&'b UnitComplex> for Rotation where N::Element: SimdRealField, - DefaultAllocator: Allocator, { #[inline] fn div_assign(&mut self, rhs: &'b UnitComplex) { diff --git a/src/proptest/mod.rs b/src/proptest/mod.rs index ae263956..2551aa3d 100644 --- a/src/proptest/mod.rs +++ b/src/proptest/mod.rs @@ -53,20 +53,20 @@ //! with [matrix](fn.matrix.html) as follows: //! //! ```rust -//! use nalgebra::{Dynamic, MatrixMN, U3}; +//! use nalgebra::{Dynamic, MatrixMN, Const}; //! use nalgebra::proptest::matrix; //! use proptest::prelude::*; //! -//! type MyMatrix = MatrixMN; +//! type MyMatrix = MatrixMN, Dynamic>; //! //! /// Returns a strategy for pairs of matrices with `U3` rows and the same number of //! /// columns. //! fn matrix_pairs() -> impl Strategy { -//! matrix(-5 ..= 5, U3, 0 ..= 10) +//! matrix(-5 ..= 5, Const::<3>, 0 ..= 10) //! // We first generate the initial matrix `a`, and then depending on the concrete //! // instances of `a`, we pick a second matrix with the same number of columns //! .prop_flat_map(|a| { -//! let b = matrix(-5 .. 5, U3, a.ncols()); +//! let b = matrix(-5 .. 5, Const::<3>, a.ncols()); //! // This returns a new tuple strategy where we keep `a` fixed while //! // the second item is a strategy that generates instances with the same //! // dimensions as `a` @@ -141,7 +141,7 @@ //! PROPTEST_MAX_SHRINK_ITERS=100000 cargo test my_failing_test //! ``` use crate::allocator::Allocator; -use crate::{DefaultAllocator, Dim, DimName, Dynamic, MatrixMN, Scalar, U1}; +use crate::{Const, DefaultAllocator, Dim, DimName, Dynamic, MatrixMN, Scalar, U1}; use proptest::arbitrary::Arbitrary; use proptest::collection::vec; use proptest::strategy::{BoxedStrategy, Just, NewTree, Strategy, ValueTree}; @@ -225,16 +225,16 @@ fn dynamic_dim_range() -> DimRange { /// ## Examples /// ``` /// use nalgebra::proptest::matrix; -/// use nalgebra::{MatrixMN, U3, Dynamic}; +/// use nalgebra::{MatrixMN, Const, Dynamic}; /// use proptest::prelude::*; /// /// proptest! { /// # /* /// #[test] /// # */ -/// fn my_test(a in matrix(0 .. 5i32, U3, 0 ..= 5)) { +/// fn my_test(a in matrix(0 .. 5i32, Const::<3>, 0 ..= 5)) { /// // Let's make sure we've got the correct type first -/// let a: MatrixMN<_, U3, Dynamic> = a; +/// let a: MatrixMN<_, Const::<3>, Dynamic> = a; /// prop_assert!(a.nrows() == 3); /// prop_assert!(a.ncols() <= 5); /// prop_assert!(a.iter().all(|x_ij| *x_ij >= 0 && *x_ij < 5)); @@ -329,7 +329,7 @@ where D: Dim, DefaultAllocator: Allocator, { - matrix_(value_strategy, length.into(), U1.into()) + matrix_(value_strategy, length.into(), Const::<1>.into()) } impl Default for MatrixParameters diff --git a/src/third_party/alga/alga_isometry.rs b/src/third_party/alga/alga_isometry.rs index 3cb965a8..68788494 100755 --- a/src/third_party/alga/alga_isometry.rs +++ b/src/third_party/alga/alga_isometry.rs @@ -8,9 +8,7 @@ use alga::linear::{ Transformation, }; -use crate::base::allocator::Allocator; -use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, VectorN}; +use crate::base::CVectorN; use crate::geometry::{AbstractRotation, Isometry, Point, Translation}; @@ -19,11 +17,10 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation}; * Algebraic structures. * */ -impl Identity - for Isometry +impl Identity + for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { @@ -31,11 +28,10 @@ where } } -impl TwoSidedInverse - for Isometry +impl TwoSidedInverse + for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -49,11 +45,10 @@ where } } -impl AbstractMagma - for Isometry +impl AbstractMagma + for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn operate(&self, rhs: &Self) -> Self { @@ -63,9 +58,8 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Isometry - where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator { } + impl $marker<$operator> for Isometry + where R: Rotation> + AbstractRotation { } )*} ); @@ -82,11 +76,10 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> - for Isometry +impl Transformation> + for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn transform_point(&self, pt: &Point) -> Point { @@ -94,16 +87,15 @@ where } #[inline] - fn transform_vector(&self, v: &VectorN) -> VectorN { + fn transform_vector(&self, v: &CVectorN) -> CVectorN { self.transform_vector(v) } } -impl ProjectiveTransformation> - for Isometry +impl + ProjectiveTransformation> for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn inverse_transform_point(&self, pt: &Point) -> Point { @@ -111,16 +103,15 @@ where } #[inline] - fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { + fn inverse_transform_vector(&self, v: &CVectorN) -> CVectorN { self.inverse_transform_vector(v) } } -impl AffineTransformation> - for Isometry +impl AffineTransformation> + for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { type Rotation = R; type NonUniformScaling = Id; @@ -175,11 +166,10 @@ where } } -impl Similarity> - for Isometry +impl Similarity> + for Isometry where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { type Scaling = Id; @@ -201,9 +191,8 @@ where macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for Isometry - where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator { } + impl $Trait> for Isometry + where R: Rotation> + AbstractRotation { } )*} ); diff --git a/src/third_party/alga/alga_point.rs b/src/third_party/alga/alga_point.rs index 5a7cace5..2e8064f9 100644 --- a/src/third_party/alga/alga_point.rs +++ b/src/third_party/alga/alga_point.rs @@ -1,25 +1,19 @@ use alga::general::{Field, JoinSemilattice, Lattice, MeetSemilattice, RealField}; use alga::linear::{AffineSpace, EuclideanSpace}; -use crate::base::allocator::Allocator; -use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, Scalar, VectorN}; +use crate::base::{CVectorN, Scalar}; use crate::geometry::Point; -impl AffineSpace for Point +impl AffineSpace for Point where N: Scalar + Field, - DefaultAllocator: Allocator, { - type Translation = VectorN; + type Translation = CVectorN; } -impl EuclideanSpace for Point -where - DefaultAllocator: Allocator, -{ - type Coordinates = VectorN; +impl EuclideanSpace for Point { + type Coordinates = CVectorN; type RealField = N; #[inline] @@ -48,10 +42,9 @@ where * Ordering * */ -impl MeetSemilattice for Point +impl MeetSemilattice for Point where N: Scalar + MeetSemilattice, - DefaultAllocator: Allocator, { #[inline] fn meet(&self, other: &Self) -> Self { @@ -59,10 +52,9 @@ where } } -impl JoinSemilattice for Point +impl JoinSemilattice for Point where N: Scalar + JoinSemilattice, - DefaultAllocator: Allocator, { #[inline] fn join(&self, other: &Self) -> Self { @@ -70,10 +62,9 @@ where } } -impl Lattice for Point +impl Lattice for Point where N: Scalar + Lattice, - DefaultAllocator: Allocator, { #[inline] fn meet_join(&self, other: &Self) -> (Self, Self) { diff --git a/src/third_party/alga/alga_rotation.rs b/src/third_party/alga/alga_rotation.rs index f37ebbd1..100d3b30 100755 --- a/src/third_party/alga/alga_rotation.rs +++ b/src/third_party/alga/alga_rotation.rs @@ -7,10 +7,7 @@ use alga::linear::{ ProjectiveTransformation, Similarity, Transformation, }; -use crate::base::allocator::Allocator; -use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, VectorN}; - +use crate::base::CVectorN; use crate::geometry::{Point, Rotation}; /* @@ -18,10 +15,8 @@ use crate::geometry::{Point, Rotation}; * Algebraic structures. * */ -impl Identity +impl Identity for Rotation -where - DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { @@ -29,10 +24,8 @@ where } } -impl TwoSidedInverse +impl TwoSidedInverse for Rotation -where - DefaultAllocator: Allocator, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -46,10 +39,8 @@ where } } -impl AbstractMagma +impl AbstractMagma for Rotation -where - DefaultAllocator: Allocator, { #[inline] fn operate(&self, rhs: &Self) -> Self { @@ -59,8 +50,8 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Rotation - where DefaultAllocator: Allocator { } + impl $marker<$operator> for Rotation + { } )*} ); @@ -77,10 +68,8 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> +impl Transformation> for Rotation -where - DefaultAllocator: Allocator + Allocator, { #[inline] fn transform_point(&self, pt: &Point) -> Point { @@ -88,15 +77,13 @@ where } #[inline] - fn transform_vector(&self, v: &VectorN) -> VectorN { + fn transform_vector(&self, v: &CVectorN) -> CVectorN { self.transform_vector(v) } } -impl ProjectiveTransformation> +impl ProjectiveTransformation> for Rotation -where - DefaultAllocator: Allocator + Allocator, { #[inline] fn inverse_transform_point(&self, pt: &Point) -> Point { @@ -104,15 +91,13 @@ where } #[inline] - fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { + fn inverse_transform_vector(&self, v: &CVectorN) -> CVectorN { self.inverse_transform_vector(v) } } -impl AffineTransformation> +impl AffineTransformation> for Rotation -where - DefaultAllocator: Allocator + Allocator, { type Rotation = Self; type NonUniformScaling = Id; @@ -154,9 +139,8 @@ where } } -impl Similarity> for Rotation -where - DefaultAllocator: Allocator + Allocator, +impl Similarity> + for Rotation { type Scaling = Id; @@ -178,19 +162,16 @@ where macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for Rotation - where DefaultAllocator: Allocator + - Allocator { } + impl $Trait> for Rotation + { } )*} ); marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation); /// Subgroups of the n-dimensional rotation group `SO(n)`. -impl linear::Rotation> +impl linear::Rotation> for Rotation -where - DefaultAllocator: Allocator + Allocator, { #[inline] fn powf(&self, _: N) -> Option { @@ -200,14 +181,14 @@ where } #[inline] - fn rotation_between(_: &VectorN, _: &VectorN) -> Option { + fn rotation_between(_: &CVectorN, _: &CVectorN) -> Option { // XXX: Add the general case. // XXX: Use specialization for 2D and 3D. unimplemented!() } #[inline] - fn scaled_rotation_between(_: &VectorN, _: &VectorN, _: N) -> Option { + fn scaled_rotation_between(_: &CVectorN, _: &CVectorN, _: N) -> Option { // XXX: Add the general case. // XXX: Use specialization for 2D and 3D. unimplemented!() diff --git a/src/third_party/alga/alga_similarity.rs b/src/third_party/alga/alga_similarity.rs index 58dd4563..8f3bb126 100755 --- a/src/third_party/alga/alga_similarity.rs +++ b/src/third_party/alga/alga_similarity.rs @@ -5,10 +5,7 @@ use alga::general::{ use alga::linear::Similarity as AlgaSimilarity; use alga::linear::{AffineTransformation, ProjectiveTransformation, Rotation, Transformation}; -use crate::base::allocator::Allocator; -use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, VectorN}; - +use crate::base::CVectorN; use crate::geometry::{AbstractRotation, Point, Similarity, Translation}; /* @@ -16,11 +13,10 @@ use crate::geometry::{AbstractRotation, Point, Similarity, Translation}; * Algebraic structures. * */ -impl Identity - for Similarity +impl Identity + for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { @@ -28,11 +24,10 @@ where } } -impl TwoSidedInverse - for Similarity +impl TwoSidedInverse + for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -46,11 +41,10 @@ where } } -impl AbstractMagma - for Similarity +impl AbstractMagma + for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn operate(&self, rhs: &Self) -> Self { @@ -60,9 +54,9 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Similarity + impl $marker<$operator> for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator { } + { } )*} ); @@ -79,11 +73,10 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> - for Similarity +impl Transformation> + for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn transform_point(&self, pt: &Point) -> Point { @@ -91,16 +84,15 @@ where } #[inline] - fn transform_vector(&self, v: &VectorN) -> VectorN { + fn transform_vector(&self, v: &CVectorN) -> CVectorN { self.transform_vector(v) } } -impl ProjectiveTransformation> - for Similarity +impl + ProjectiveTransformation> for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { #[inline] fn inverse_transform_point(&self, pt: &Point) -> Point { @@ -108,16 +100,15 @@ where } #[inline] - fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { + fn inverse_transform_vector(&self, v: &CVectorN) -> CVectorN { self.inverse_transform_vector(v) } } -impl AffineTransformation> - for Similarity +impl AffineTransformation> + for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { type NonUniformScaling = N; type Rotation = R; @@ -171,11 +162,10 @@ where } } -impl AlgaSimilarity> - for Similarity +impl AlgaSimilarity> + for Similarity where R: Rotation> + AbstractRotation, - DefaultAllocator: Allocator, { type Scaling = N; diff --git a/src/third_party/alga/alga_transform.rs b/src/third_party/alga/alga_transform.rs index f83a0f8c..a4c23e4f 100755 --- a/src/third_party/alga/alga_transform.rs +++ b/src/third_party/alga/alga_transform.rs @@ -6,7 +6,7 @@ use alga::linear::{ProjectiveTransformation, Transformation}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::{DefaultAllocator, VectorN}; +use crate::base::{CVectorN, Const, DefaultAllocator}; use crate::geometry::{Point, SubTCategoryOf, TCategory, TProjective, Transform}; @@ -15,11 +15,12 @@ use crate::geometry::{Point, SubTCategoryOf, TCategory, TProjective, Transform}; * Algebraic structures. * */ -impl, C> Identity - for Transform +impl Identity + for Transform where + Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, DimNameSum>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn identity() -> Self { @@ -27,11 +28,12 @@ where } } -impl, C> TwoSidedInverse - for Transform +impl TwoSidedInverse + for Transform where + Const: DimNameAdd, C: SubTCategoryOf, - DefaultAllocator: Allocator, DimNameSum>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -45,11 +47,12 @@ where } } -impl, C> AbstractMagma - for Transform +impl AbstractMagma + for Transform where + Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, DimNameSum>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn operate(&self, rhs: &Self) -> Self { @@ -59,17 +62,21 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl, C> $marker<$operator> for Transform - where C: TCategory, - DefaultAllocator: Allocator, DimNameSum> { } + impl $marker<$operator> for Transform + where + Const: DimNameAdd, + C: TCategory, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { } )*} ); macro_rules! impl_inversible_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl, C> $marker<$operator> for Transform - where C: SubTCategoryOf, - DefaultAllocator: Allocator, DimNameSum> { } + impl $marker<$operator> for Transform + where + Const: DimNameAdd, + C: SubTCategoryOf, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { } )*} ); @@ -89,14 +96,13 @@ impl_inversible_multiplicative_structures!( * Transformation groups. * */ -impl, C> Transformation> for Transform +impl Transformation> for Transform where + Const: DimNameAdd, N: RealField + simba::scalar::RealField, C: TCategory, - DefaultAllocator: Allocator, DimNameSum> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>>, { #[inline] fn transform_point(&self, pt: &Point) -> Point { @@ -104,19 +110,18 @@ where } #[inline] - fn transform_vector(&self, v: &VectorN) -> VectorN { + fn transform_vector(&self, v: &CVectorN) -> CVectorN { self.transform_vector(v) } } -impl, C> ProjectiveTransformation> for Transform +impl ProjectiveTransformation> for Transform where + Const: DimNameAdd, N: RealField + simba::scalar::RealField, C: SubTCategoryOf, - DefaultAllocator: Allocator, DimNameSum> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>>, { #[inline] fn inverse_transform_point(&self, pt: &Point) -> Point { @@ -124,17 +129,17 @@ where } #[inline] - fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { + fn inverse_transform_vector(&self, v: &CVectorN) -> CVectorN { self.inverse_transform_vector(v) } } // TODO: we need to implement an SVD for this. // -// impl, C> AffineTransformation> for Transform +// impl AffineTransformation> for Transform // where N: RealField, // C: SubTCategoryOf, -// DefaultAllocator: Allocator, DimNameSum> + +// DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + // Allocator + // Allocator { // type PreRotation = Rotation; diff --git a/src/third_party/alga/alga_translation.rs b/src/third_party/alga/alga_translation.rs index aba6f1f4..542fde0b 100755 --- a/src/third_party/alga/alga_translation.rs +++ b/src/third_party/alga/alga_translation.rs @@ -8,10 +8,7 @@ use alga::linear::{ Transformation, }; -use crate::base::allocator::Allocator; -use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, VectorN}; - +use crate::base::CVectorN; use crate::geometry::{Point, Translation}; /* @@ -19,10 +16,8 @@ use crate::geometry::{Point, Translation}; * Algebraic structures. * */ -impl Identity +impl Identity for Translation -where - DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { @@ -30,10 +25,8 @@ where } } -impl TwoSidedInverse +impl TwoSidedInverse for Translation -where - DefaultAllocator: Allocator, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -47,10 +40,8 @@ where } } -impl AbstractMagma +impl AbstractMagma for Translation -where - DefaultAllocator: Allocator, { #[inline] fn operate(&self, rhs: &Self) -> Self { @@ -60,8 +51,8 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Translation - where DefaultAllocator: Allocator { } + impl $marker<$operator> for Translation + { } )*} ); @@ -78,10 +69,8 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> +impl Transformation> for Translation -where - DefaultAllocator: Allocator, { #[inline] fn transform_point(&self, pt: &Point) -> Point { @@ -89,15 +78,13 @@ where } #[inline] - fn transform_vector(&self, v: &VectorN) -> VectorN { + fn transform_vector(&self, v: &CVectorN) -> CVectorN { v.clone() } } -impl ProjectiveTransformation> +impl ProjectiveTransformation> for Translation -where - DefaultAllocator: Allocator, { #[inline] fn inverse_transform_point(&self, pt: &Point) -> Point { @@ -105,15 +92,13 @@ where } #[inline] - fn inverse_transform_vector(&self, v: &VectorN) -> VectorN { + fn inverse_transform_vector(&self, v: &CVectorN) -> CVectorN { v.clone() } } -impl AffineTransformation> +impl AffineTransformation> for Translation -where - DefaultAllocator: Allocator, { type Rotation = Id; type NonUniformScaling = Id; @@ -155,10 +140,8 @@ where } } -impl Similarity> +impl Similarity> for Translation -where - DefaultAllocator: Allocator, { type Scaling = Id; @@ -180,26 +163,24 @@ where macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for Translation - where DefaultAllocator: Allocator { } + impl $Trait> for Translation + { } )*} ); marker_impl!(Isometry, DirectIsometry); /// Subgroups of the n-dimensional translation group `T(n)`. -impl AlgaTranslation> +impl AlgaTranslation> for Translation -where - DefaultAllocator: Allocator, { #[inline] - fn to_vector(&self) -> VectorN { + fn to_vector(&self) -> CVectorN { self.vector.clone() } #[inline] - fn from_vector(v: VectorN) -> Option { + fn from_vector(v: CVectorN) -> Option { Some(Self::from(v)) } diff --git a/tests/core/conversion.rs b/tests/core/conversion.rs index 93545004..58ac179a 100644 --- a/tests/core/conversion.rs +++ b/tests/core/conversion.rs @@ -287,12 +287,12 @@ fn matrix_slice_from_matrix_ref() { ($mref:expr) => { MatrixSlice::<_, U3, U4, U1, U3>::from($mref) }; - }; + } macro_rules! fixed_slice_mut { ($mref:expr) => { MatrixSliceMut::<_, U3, U4, U1, U3>::from($mref) }; - }; + } // TODO: The `into_owned()` is a result of `PartialEq` not being implemented for different // Self and RHS. See issue #674. Once this is implemented, we can remove `into_owned` diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 1430aedf..a88f2c1f 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -838,17 +838,16 @@ fn swizzle() { mod transposition_tests { use super::*; use crate::proptest::{dmatrix, matrix, vector4, PROPTEST_F64}; - use na::{U2, U3, U4, U6}; use proptest::{prop_assert, prop_assert_eq, proptest}; proptest! { #[test] - fn transpose_transpose_is_self(m in matrix(PROPTEST_F64, U2, U3)) { + fn transpose_transpose_is_self(m in matrix(PROPTEST_F64, Const::<2>, Const::<3>)) { prop_assert_eq!(m.transpose().transpose(), m) } #[test] - fn transpose_mut_transpose_mut_is_self(m in matrix(PROPTEST_F64, U3, U3)) { + fn transpose_mut_transpose_mut_is_self(m in matrix(PROPTEST_F64, Const::<3>, Const::<3>)) { let mut mm = m; mm.transpose_mut(); mm.transpose_mut(); @@ -875,7 +874,7 @@ mod transposition_tests { } #[test] - fn tr_mul_is_transpose_then_mul(m in matrix(PROPTEST_F64, U4, U6), v in vector4()) { + fn tr_mul_is_transpose_then_mul(m in matrix(PROPTEST_F64, Const::<4>, Const::<6>), v in vector4()) { prop_assert!(relative_eq!(m.transpose() * v, m.tr_mul(&v), epsilon = 1.0e-7)) } } diff --git a/tests/linalg/cholesky.rs b/tests/linalg/cholesky.rs index 0e4a3817..bb578d49 100644 --- a/tests/linalg/cholesky.rs +++ b/tests/linalg/cholesky.rs @@ -4,7 +4,7 @@ macro_rules! gen_tests( ($module: ident, $scalar: ty) => { mod $module { use na::debug::RandomSDP; - use na::dimension::{U4, Const, Dynamic}; + use na::dimension::{Const, Dynamic}; use na::{DMatrix, DVector, Matrix4x3, Vector4}; use rand::random; use simba::scalar::ComplexField; diff --git a/tests/proptest/mod.rs b/tests/proptest/mod.rs index 174c0fdd..be77f501 100644 --- a/tests/proptest/mod.rs +++ b/tests/proptest/mod.rs @@ -8,7 +8,7 @@ use nalgebra::proptest::{DimRange, MatrixStrategy}; use nalgebra::{ DMatrix, DVector, DefaultAllocator, Dim, DualQuaternion, Isometry2, Isometry3, Matrix3, MatrixMN, Point2, Point3, Quaternion, Rotation2, Rotation3, Scalar, Similarity3, Translation2, - Translation3, UnitComplex, UnitDualQuaternion, UnitQuaternion, Vector3, U2, U3, U4, U7, U8, + Translation3, UnitComplex, UnitDualQuaternion, UnitQuaternion, Vector3, U3, U4, }; use num_complex::Complex; use proptest::prelude::*; @@ -62,7 +62,7 @@ pub fn isometry3() -> impl Strategy> { // } pub fn similarity3() -> impl Strategy> { - vector(PROPTEST_F64, U7) + vector(PROPTEST_F64, Const::<7>) .prop_map(|v| Similarity3::new(v.xyz(), Vector3::new(v[3], v[4], v[5]), v[6])) } @@ -71,7 +71,7 @@ pub fn unit_dual_quaternion() -> impl Strategy> } pub fn dual_quaternion() -> impl Strategy> { - vector(PROPTEST_F64, U8).prop_map(|v| { + vector(PROPTEST_F64, Const::<8>).prop_map(|v| { DualQuaternion::from_real_and_dual( Quaternion::new(v[0], v[1], v[2], v[3]), Quaternion::new(v[4], v[5], v[6], v[7]), @@ -88,7 +88,7 @@ pub fn unit_quaternion() -> impl Strategy> { } pub fn complex_f64() -> impl Strategy> + Clone { - vector(PROPTEST_F64, U2).prop_map(|v| Complex::new(v.x, v.y)) + vector(PROPTEST_F64, Const::<2>).prop_map(|v| Complex::new(v.x, v.y)) } pub fn dmatrix() -> impl Strategy> { @@ -120,42 +120,41 @@ where // } macro_rules! define_strategies( - ($($strategy_: ident $strategy: ident<$nrows: ident, $ncols: ident>),*) => {$( - pub fn $strategy() -> impl Strategy> { - matrix(PROPTEST_F64, $nrows, $ncols) + ($($strategy_: ident $strategy: ident<$nrows: literal, $ncols: literal>),*) => {$( + pub fn $strategy() -> impl Strategy, Const<$ncols>>> { + matrix(PROPTEST_F64, Const::<$nrows>, Const::<$ncols>) } - pub fn $strategy_(scalar_strategy: ScalarStrategy) -> impl Strategy> + pub fn $strategy_(scalar_strategy: ScalarStrategy) -> impl Strategy, Const<$ncols>>> where ScalarStrategy: Strategy + Clone + 'static, - ScalarStrategy::Value: Scalar, - DefaultAllocator: Allocator { - matrix(scalar_strategy, $nrows, $ncols) + ScalarStrategy::Value: Scalar, { + matrix(scalar_strategy, Const::<$nrows>, Const::<$ncols>) } )*} ); define_strategies!( - matrix1_ matrix1, - matrix2_ matrix2, - matrix3_ matrix3, - matrix4_ matrix4, - matrix5_ matrix5, - matrix6_ matrix6, + matrix1_ matrix1<1, 1>, + matrix2_ matrix2<2, 2>, + matrix3_ matrix3<3, 3>, + matrix4_ matrix4<4, 4>, + matrix5_ matrix5<5, 5>, + matrix6_ matrix6<6, 6>, - matrix5x2_ matrix5x2, - matrix2x5_ matrix2x5, - matrix5x3_ matrix5x3, - matrix3x5_ matrix3x5, - matrix5x4_ matrix5x4, - matrix4x5_ matrix4x5, + matrix5x2_ matrix5x2<5, 2>, + matrix2x5_ matrix2x5<2, 5>, + matrix5x3_ matrix5x3<5, 3>, + matrix3x5_ matrix3x5<3, 5>, + matrix5x4_ matrix5x4<5, 4>, + matrix4x5_ matrix4x5<4, 5>, - vector1_ vector1, - vector2_ vector2, - vector3_ vector3, - vector4_ vector4, - vector5_ vector5, - vector6_ vector6 + vector1_ vector1<1, 1>, + vector2_ vector2<2, 1>, + vector3_ vector3<3, 1>, + vector4_ vector4<4, 1>, + vector5_ vector5<5, 1>, + vector6_ vector6<6, 1> ); /// Generate a proptest that tests that all matrices generated with the @@ -180,16 +179,16 @@ macro_rules! generate_matrix_sanity_test { } // Test all fixed-size matrices with row/col dimensions up to 3 -generate_matrix_sanity_test!(test_matrix_u0_u0, U0, U0); -generate_matrix_sanity_test!(test_matrix_u1_u0, U1, U0); -generate_matrix_sanity_test!(test_matrix_u0_u1, U0, U1); -generate_matrix_sanity_test!(test_matrix_u1_u1, U1, U1); -generate_matrix_sanity_test!(test_matrix_u2_u1, U2, U1); -generate_matrix_sanity_test!(test_matrix_u1_u2, U1, U2); -generate_matrix_sanity_test!(test_matrix_u2_u2, U2, U2); -generate_matrix_sanity_test!(test_matrix_u3_u2, U3, U2); -generate_matrix_sanity_test!(test_matrix_u2_u3, U2, U3); -generate_matrix_sanity_test!(test_matrix_u3_u3, U3, U3); +generate_matrix_sanity_test!(test_matrix_u0_u0, Const::<0>, Const::<0>); +generate_matrix_sanity_test!(test_matrix_u1_u0, Const::<1>, Const::<0>); +generate_matrix_sanity_test!(test_matrix_u0_u1, Const::<0>, Const::<1>); +generate_matrix_sanity_test!(test_matrix_u1_u1, Const::<1>, Const::<1>); +generate_matrix_sanity_test!(test_matrix_u2_u1, Const::<2>, Const::<1>); +generate_matrix_sanity_test!(test_matrix_u1_u2, Const::<1>, Const::<2>); +generate_matrix_sanity_test!(test_matrix_u2_u2, Const::<2>, Const::<2>); +generate_matrix_sanity_test!(test_matrix_u3_u2, Const::<3>, Const::<2>); +generate_matrix_sanity_test!(test_matrix_u2_u3, Const::<2>, Const::<3>); +generate_matrix_sanity_test!(test_matrix_u3_u3, Const::<3>, Const::<3>); // Similarly test all heap-allocated but fixed dim ranges generate_matrix_sanity_test!(test_matrix_0_0, 0, 0); @@ -204,18 +203,18 @@ generate_matrix_sanity_test!(test_matrix_2_3, 2, 3); generate_matrix_sanity_test!(test_matrix_3_3, 3, 3); // Test arbitrary inputs -generate_matrix_sanity_test!(test_matrix_input_1, U5, 1..=5); +generate_matrix_sanity_test!(test_matrix_input_1, Const::<5>, 1..=5); generate_matrix_sanity_test!(test_matrix_input_2, 3..=4, 1..=5); -generate_matrix_sanity_test!(test_matrix_input_3, 1..=2, U3); -generate_matrix_sanity_test!(test_matrix_input_4, 3, U4); +generate_matrix_sanity_test!(test_matrix_input_3, 1..=2, Const::<3>); +generate_matrix_sanity_test!(test_matrix_input_4, 3, Const::<4>); #[test] fn test_matrix_output_types() { // Test that the dimension types are correct for the given inputs - let _: MatrixStrategy<_, U3, U4> = matrix(-5..5, U3, U4); - let _: MatrixStrategy<_, U3, U3> = matrix(-5..5, U3, U3); - let _: MatrixStrategy<_, U3, Dynamic> = matrix(-5..5, U3, 1..=5); - let _: MatrixStrategy<_, Dynamic, U3> = matrix(-5..5, 1..=5, U3); + let _: MatrixStrategy<_, U3, U4> = matrix(-5..5, Const::<3>, Const::<4>); + let _: MatrixStrategy<_, U3, U3> = matrix(-5..5, Const::<3>, Const::<3>); + let _: MatrixStrategy<_, U3, Dynamic> = matrix(-5..5, Const::<3>, 1..=5); + let _: MatrixStrategy<_, Dynamic, U3> = matrix(-5..5, 1..=5, Const::<3>); let _: MatrixStrategy<_, Dynamic, Dynamic> = matrix(-5..5, 1..=5, 1..=5); }