Merge pull request #781 from filnet/clippy_fixes

Clippy fixes
This commit is contained in:
Sébastien Crozet 2020-10-26 09:36:29 +01:00 committed by GitHub
commit 224b5629e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 163 additions and 222 deletions

View File

@ -149,6 +149,7 @@ isometry_binop_impl_all!(
[ref ref] => { [ref ref] => {
let shift = self.rotation.transform_vector(&rhs.translation.vector); let shift = self.rotation.transform_vector(&rhs.translation.vector);
#[allow(clippy::suspicious_arithmetic_impl)]
Isometry::from_parts(Translation::from(&self.translation.vector + shift), Isometry::from_parts(Translation::from(&self.translation.vector + shift),
self.rotation.clone() * rhs.rotation.clone()) // FIXME: too bad we have to clone. self.rotation.clone() * rhs.rotation.clone()) // FIXME: too bad we have to clone.
}; };
@ -157,10 +158,10 @@ isometry_binop_impl_all!(
isometry_binop_impl_all!( isometry_binop_impl_all!(
Div, div; Div, div;
self: Isometry<N, D, R>, rhs: Isometry<N, D, R>, Output = Isometry<N, D, R>; self: Isometry<N, D, R>, rhs: Isometry<N, D, R>, Output = Isometry<N, D, R>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// Isometry ×= Translation // Isometry ×= Translation
@ -289,6 +290,7 @@ isometry_binop_impl_all!(
[ref val] => self * &right; [ref val] => self * &right;
[val ref] => &self * right; [val ref] => &self * right;
[ref ref] => { [ref ref] => {
#[allow(clippy::suspicious_arithmetic_impl)]
let new_tr = &self.translation.vector + self.rotation.transform_vector(&right.vector); let new_tr = &self.translation.vector + self.rotation.transform_vector(&right.vector);
Isometry::from_parts(Translation::from(new_tr), self.rotation.clone()) Isometry::from_parts(Translation::from(new_tr), self.rotation.clone())
}; };
@ -427,10 +429,10 @@ isometry_from_composition_impl_all!(
self: Rotation<N, D>, right: Isometry<N, D, Rotation<N, D>>, self: Rotation<N, D>, right: Isometry<N, D, Rotation<N, D>>,
Output = Isometry<N, D, Rotation<N, D>>; Output = Isometry<N, D, Rotation<N, D>>;
// FIXME: don't call inverse explicitly? // FIXME: don't call inverse explicitly?
[val val] => self * right.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => self * right.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => self * right.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => self * right.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
); );
// Isometry × UnitQuaternion // Isometry × UnitQuaternion
@ -479,10 +481,10 @@ isometry_from_composition_impl_all!(
self: UnitQuaternion<N>, right: Isometry<N, U3, UnitQuaternion<N>>, self: UnitQuaternion<N>, right: Isometry<N, U3, UnitQuaternion<N>>,
Output = Isometry<N, U3, UnitQuaternion<N>>; Output = Isometry<N, U3, UnitQuaternion<N>>;
// FIXME: don't call inverse explicitly? // FIXME: don't call inverse explicitly?
[val val] => self * right.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => self * right.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => self * right.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => self * right.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
); );
// Translation × Rotation // Translation × Rotation

View File

@ -389,6 +389,7 @@ where
/// ``` /// ```
#[inline] #[inline]
pub fn outer(&self, other: &Self) -> Self { pub fn outer(&self, other: &Self) -> Self {
#[allow(clippy::eq_op)]
(self * other - other * self).half() (self * other - other * self).half()
} }

View File

@ -121,11 +121,10 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Add, add; Add, add;
(U4, U1), (U4, U1); (U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>; self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
Quaternion::from(self.coords + rhs.coords); Quaternion::from(self.coords + rhs.coords); );
);
// Quaternion - Quaternion // Quaternion - Quaternion
quaternion_op_impl!( quaternion_op_impl!(
@ -150,11 +149,10 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Sub, sub; Sub, sub;
(U4, U1), (U4, U1); (U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>; self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
Quaternion::from(self.coords - rhs.coords); Quaternion::from(self.coords - rhs.coords); );
);
// Quaternion × Quaternion // Quaternion × Quaternion
quaternion_op_impl!( quaternion_op_impl!(
@ -183,11 +181,10 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U4, U1), (U4, U1); (U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>; self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
&self * &rhs; &self * &rhs; );
);
// UnitQuaternion × UnitQuaternion // UnitQuaternion × UnitQuaternion
quaternion_op_impl!( quaternion_op_impl!(
@ -212,18 +209,17 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U4, U1), (U4, U1); (U4, U1), (U4, U1);
self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>; self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>;
&self * &rhs; &self * &rhs; );
);
// UnitQuaternion ÷ UnitQuaternion // UnitQuaternion ÷ UnitQuaternion
quaternion_op_impl!( quaternion_op_impl!(
Div, div; Div, div;
(U4, U1), (U4, U1); (U4, U1), (U4, U1);
self: &'a UnitQuaternion<N>, rhs: &'b UnitQuaternion<N>, Output = UnitQuaternion<N>; self: &'a UnitQuaternion<N>, rhs: &'b UnitQuaternion<N>, Output = UnitQuaternion<N>;
self * rhs.inverse(); #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
'a, 'b); 'a, 'b);
quaternion_op_impl!( quaternion_op_impl!(
@ -241,11 +237,10 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Div, div; Div, div;
(U4, U1), (U4, U1); (U4, U1), (U4, U1);
self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>; self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>;
&self / &rhs; &self / &rhs; );
);
// UnitQuaternion × Rotation // UnitQuaternion × Rotation
quaternion_op_impl!( quaternion_op_impl!(
@ -274,12 +269,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U4, U1), (U3, U3); (U4, U1), (U3, U3);
self: UnitQuaternion<N>, rhs: Rotation<N, U3>, self: UnitQuaternion<N>, rhs: Rotation<N, U3>,
Output = UnitQuaternion<N> => U3, U3; Output = UnitQuaternion<N> => U3, U3;
self * UnitQuaternion::<N>::from_rotation_matrix(&rhs); self * UnitQuaternion::<N>::from_rotation_matrix(&rhs); );
);
// UnitQuaternion ÷ Rotation // UnitQuaternion ÷ Rotation
quaternion_op_impl!( quaternion_op_impl!(
@ -308,12 +302,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Div, div; Div, div;
(U4, U1), (U3, U3); (U4, U1), (U3, U3);
self: UnitQuaternion<N>, rhs: Rotation<N, U3>, self: UnitQuaternion<N>, rhs: Rotation<N, U3>,
Output = UnitQuaternion<N> => U3, U3; Output = UnitQuaternion<N> => U3, U3;
self / UnitQuaternion::<N>::from_rotation_matrix(&rhs); self / UnitQuaternion::<N>::from_rotation_matrix(&rhs); );
);
// Rotation × UnitQuaternion // Rotation × UnitQuaternion
quaternion_op_impl!( quaternion_op_impl!(
@ -342,12 +335,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U3, U3), (U4, U1); (U3, U3), (U4, U1);
self: Rotation<N, U3>, rhs: UnitQuaternion<N>, self: Rotation<N, U3>, rhs: UnitQuaternion<N>,
Output = UnitQuaternion<N> => U3, U3; Output = UnitQuaternion<N> => U3, U3;
UnitQuaternion::<N>::from_rotation_matrix(&self) * rhs; UnitQuaternion::<N>::from_rotation_matrix(&self) * rhs; );
);
// Rotation ÷ UnitQuaternion // Rotation ÷ UnitQuaternion
quaternion_op_impl!( quaternion_op_impl!(
@ -376,12 +368,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Div, div; Div, div;
(U3, U3), (U4, U1); (U3, U3), (U4, U1);
self: Rotation<N, U3>, rhs: UnitQuaternion<N>, self: Rotation<N, U3>, rhs: UnitQuaternion<N>,
Output = UnitQuaternion<N> => U3, U3; Output = UnitQuaternion<N> => U3, U3;
UnitQuaternion::<N>::from_rotation_matrix(&self) / rhs; UnitQuaternion::<N>::from_rotation_matrix(&self) / rhs; );
);
// UnitQuaternion × Vector // UnitQuaternion × Vector
quaternion_op_impl!( quaternion_op_impl!(
@ -415,12 +406,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U4, U1), (U3, U1) for SB: Storage<N, U3> ; (U4, U1), (U3, U1) for SB: Storage<N, U3> ;
self: UnitQuaternion<N>, rhs: Vector<N, U3, SB>, self: UnitQuaternion<N>, rhs: Vector<N, U3, SB>,
Output = Vector3<N> => U3, U4; Output = Vector3<N> => U3, U4;
&self * &rhs; &self * &rhs; );
);
// UnitQuaternion × Point // UnitQuaternion × Point
quaternion_op_impl!( quaternion_op_impl!(
@ -448,12 +438,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U4, U1), (U3, U1); (U4, U1), (U3, U1);
self: UnitQuaternion<N>, rhs: Point3<N>, self: UnitQuaternion<N>, rhs: Point3<N>,
Output = Point3<N> => U3, U4; Output = Point3<N> => U3, U4;
Point3::from(self * rhs.coords); Point3::from(self * rhs.coords); );
);
// UnitQuaternion × Unit<Vector> // UnitQuaternion × Unit<Vector>
quaternion_op_impl!( quaternion_op_impl!(
@ -481,12 +470,11 @@ quaternion_op_impl!(
'b); 'b);
quaternion_op_impl!( quaternion_op_impl!(
Mul, mul; Mul, mul;
(U4, U1), (U3, U1) for SB: Storage<N, U3> ; (U4, U1), (U3, U1) for SB: Storage<N, U3> ;
self: UnitQuaternion<N>, rhs: Unit<Vector<N, U3, SB>>, self: UnitQuaternion<N>, rhs: Unit<Vector<N, U3, SB>>,
Output = Unit<Vector3<N>> => U3, U4; Output = Unit<Vector3<N>> => U3, U4;
Unit::new_unchecked(self * rhs.into_inner()); Unit::new_unchecked(self * rhs.into_inner()); );
);
macro_rules! scalar_op_impl( macro_rules! scalar_op_impl(
($($Op: ident, $op: ident, $OpAssign: ident, $op_assign: ident);* $(;)*) => {$( ($($Op: ident, $op: ident, $OpAssign: ident, $op_assign: ident);* $(;)*) => {$(

View File

@ -59,10 +59,10 @@ md_impl_all!(
Div, div; Div, div;
(D, D), (D, D) for D: DimName; (D, D), (D, D) for D: DimName;
self: Rotation<N, D>, right: Rotation<N, D>, Output = Rotation<N, D>; self: Rotation<N, D>, right: Rotation<N, D>, Output = Rotation<N, D>;
[val val] => self * right.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => self * right.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => self * right.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => self * right.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
); );
// Rotation × Matrix // Rotation × Matrix
@ -98,10 +98,10 @@ md_impl_all!(
where DefaultAllocator: Allocator<N, R1, D2> where DefaultAllocator: Allocator<N, R1, D2>
where ShapeConstraint: AreMultipliable<R1, C1, D2, D2>; where ShapeConstraint: AreMultipliable<R1, C1, D2, D2>;
self: Matrix<N, R1, C1, SA>, right: Rotation<N, D2>, Output = MatrixMN<N, R1, D2>; self: Matrix<N, R1, C1, SA>, right: Rotation<N, D2>, Output = MatrixMN<N, R1, D2>;
[val val] => self * right.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => self * right.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => self * right.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => self * right.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
); );
// Rotation × Point // Rotation × Point

View File

@ -158,15 +158,14 @@ similarity_binop_impl_all!(
similarity_binop_impl_all!( similarity_binop_impl_all!(
Div, div; Div, div;
self: Similarity<N, D, R>, rhs: Similarity<N, D, R>, Output = Similarity<N, D, R>; self: Similarity<N, D, R>, rhs: Similarity<N, D, R>, Output = Similarity<N, D, R>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// Similarity ×= Translation // Similarity ×= Translation
similarity_binop_assign_impl_all!( similarity_binop_assign_impl_all!(
MulAssign, mul_assign; MulAssign, mul_assign;
self: Similarity<N, D, R>, rhs: Translation<N, D>; self: Similarity<N, D, R>, rhs: Translation<N, D>;
[val] => *self *= &rhs; [val] => *self *= &rhs;
@ -281,6 +280,7 @@ similarity_binop_impl_all!(
[ref ref] => { [ref ref] => {
let shift = self.isometry.rotation.transform_vector(&rhs.translation.vector) * self.scaling(); let shift = self.isometry.rotation.transform_vector(&rhs.translation.vector) * self.scaling();
Similarity::from_parts( Similarity::from_parts(
#[allow(clippy::suspicious_arithmetic_impl)]
Translation::from(&self.isometry.translation.vector + shift), Translation::from(&self.isometry.translation.vector + shift),
self.isometry.rotation.clone() * rhs.rotation.clone(), self.isometry.rotation.clone() * rhs.rotation.clone(),
self.scaling()) self.scaling())
@ -290,10 +290,10 @@ similarity_binop_impl_all!(
similarity_binop_impl_all!( similarity_binop_impl_all!(
Div, div; Div, div;
self: Similarity<N, D, R>, rhs: Isometry<N, D, R>, Output = Similarity<N, D, R>; self: Similarity<N, D, R>, rhs: Isometry<N, D, R>, Output = Similarity<N, D, R>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// Isometry × Similarity // Isometry × Similarity
@ -322,10 +322,10 @@ similarity_binop_impl_all!(
similarity_binop_impl_all!( similarity_binop_impl_all!(
Div, div; Div, div;
self: Isometry<N, D, R>, rhs: Similarity<N, D, R>, Output = Similarity<N, D, R>; self: Isometry<N, D, R>, rhs: Similarity<N, D, R>, Output = Similarity<N, D, R>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// Similarity × Point // Similarity × Point
@ -364,6 +364,7 @@ similarity_binop_impl_all!(
[ref ref] => { [ref ref] => {
let shift = self.isometry.rotation.transform_vector(&right.vector) * self.scaling(); let shift = self.isometry.rotation.transform_vector(&right.vector) * self.scaling();
Similarity::from_parts( Similarity::from_parts(
#[allow(clippy::suspicious_arithmetic_impl)]
Translation::from(&self.isometry.translation.vector + shift), Translation::from(&self.isometry.translation.vector + shift),
self.isometry.rotation.clone(), self.isometry.rotation.clone(),
self.scaling()) self.scaling())
@ -495,10 +496,10 @@ similarity_from_composition_impl_all!(
self: Rotation<N, D>, right: Similarity<N, D, Rotation<N, D>>, self: Rotation<N, D>, right: Similarity<N, D, Rotation<N, D>>,
Output = Similarity<N, D, Rotation<N, D>>; Output = Similarity<N, D, Rotation<N, D>>;
// FIXME: don't call inverse explicitly? // FIXME: don't call inverse explicitly?
[val val] => self * right.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => self * right.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => self * right.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => self * right.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
); );
// Similarity × UnitQuaternion // Similarity × UnitQuaternion
@ -556,10 +557,10 @@ similarity_from_composition_impl_all!(
self: UnitQuaternion<N>, right: Similarity<N, U3, UnitQuaternion<N>>, self: UnitQuaternion<N>, right: Similarity<N, U3, UnitQuaternion<N>>,
Output = Similarity<N, U3, UnitQuaternion<N>>; Output = Similarity<N, U3, UnitQuaternion<N>>;
// FIXME: don't call inverse explicitly? // FIXME: don't call inverse explicitly?
[val val] => self * right.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => self * right.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => self * right.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => self * right.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
); );
// Similarity × UnitComplex // Similarity × UnitComplex

View File

@ -143,6 +143,7 @@ md_impl_all!(
if C::has_normalizer() { if C::has_normalizer() {
let normalizer = self.matrix().fixed_slice::<U1, D>(D::dim(), 0); let normalizer = self.matrix().fixed_slice::<U1, D>(D::dim(), 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::dim(), D::dim())) };
if !n.is_zero() { if !n.is_zero() {
@ -293,10 +294,10 @@ md_impl_all!(
Div, div where N: RealField; Div, div where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, CA: TCategoryMul<CB>, CB: SubTCategoryOf<TProjective>; (DimNameSum<D, U1>, DimNameSum<D, U1>), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, CA: TCategoryMul<CB>, CB: SubTCategoryOf<TProjective>;
self: Transform<N, D, CA>, rhs: Transform<N, D, CB>, Output = Transform<N, D, CA::Representative>; self: Transform<N, D, CA>, rhs: Transform<N, D, CB>, Output = Transform<N, D, CA::Representative>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.clone().inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.clone().inverse() };
[ref ref] => self * rhs.clone().inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.clone().inverse() };
); );
// Transform ÷ Rotation // Transform ÷ Rotation
@ -304,10 +305,10 @@ md_impl_all!(
Div, div where N: RealField; Div, div where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, D) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>; (DimNameSum<D, U1>, DimNameSum<D, U1>), (D, D) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Transform<N, D, C>, rhs: Rotation<N, D>, Output = Transform<N, D, C::Representative>; self: Transform<N, D, C>, rhs: Rotation<N, D>, Output = Transform<N, D, C::Representative>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// Rotation ÷ Transform // Rotation ÷ Transform
@ -315,10 +316,10 @@ md_impl_all!(
Div, div where N: RealField; Div, div where N: RealField;
(D, D), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>; (D, D), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Rotation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>; self: Rotation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
[val val] => self.inverse() * rhs; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[ref val] => self.inverse() * rhs; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[val ref] => self.inverse() * rhs; [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[ref ref] => self.inverse() * rhs; [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
); );
// Transform ÷ UnitQuaternion // Transform ÷ UnitQuaternion
@ -326,10 +327,10 @@ md_impl_all!(
Div, div where N: RealField; Div, div where N: RealField;
(U4, U4), (U4, U1) for C: TCategoryMul<TAffine>; (U4, U4), (U4, U1) for C: TCategoryMul<TAffine>;
self: Transform<N, U3, C>, rhs: UnitQuaternion<N>, Output = Transform<N, U3, C::Representative>; self: Transform<N, U3, C>, rhs: UnitQuaternion<N>, Output = Transform<N, U3, C::Representative>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// UnitQuaternion ÷ Transform // UnitQuaternion ÷ Transform
@ -337,10 +338,10 @@ md_impl_all!(
Div, div where N: RealField; Div, div where N: RealField;
(U4, U1), (U4, U4) for C: TCategoryMul<TAffine>; (U4, U1), (U4, U4) for C: TCategoryMul<TAffine>;
self: UnitQuaternion<N>, rhs: Transform<N, U3, C>, Output = Transform<N, U3, C::Representative>; self: UnitQuaternion<N>, rhs: Transform<N, U3, C>, Output = Transform<N, U3, C::Representative>;
[val val] => self.inverse() * rhs; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[ref val] => self.inverse() * rhs; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[val ref] => self.inverse() * rhs; [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[ref ref] => self.inverse() * rhs; [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
); );
// // Transform ÷ Isometry // // Transform ÷ Isometry
@ -402,10 +403,10 @@ md_impl_all!(
Div, div where N: RealField; Div, div where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>; (DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Transform<N, D, C>, rhs: Translation<N, D>, Output = Transform<N, D, C::Representative>; self: Transform<N, D, C>, rhs: Translation<N, D>, Output = Transform<N, D, C::Representative>;
[val val] => self * rhs.inverse(); [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => self * rhs.inverse(); [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => self * rhs.inverse(); [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => self * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
); );
// Translation ÷ Transform // Translation ÷ Transform
@ -414,10 +415,10 @@ md_impl_all!(
(D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>) (D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>; for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Translation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>; self: Translation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
[val val] => self.inverse() * rhs; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[ref val] => self.inverse() * rhs; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[val ref] => self.inverse() * rhs; [val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
[ref ref] => self.inverse() * rhs; [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
); );
// Transform ×= Transform // Transform ×= Transform

View File

@ -13,44 +13,50 @@ use crate::geometry::{Point, Translation};
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: &'a Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>; self: &'a Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>;
Translation::from(&self.vector + &right.vector); 'a, 'b); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector + &right.vector) };
'a, 'b);
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: &'a Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>; self: &'a Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>;
Translation::from(&self.vector + right.vector); 'a); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector + right.vector) };
'a);
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>; self: Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>;
Translation::from(self.vector + &right.vector); 'b); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector + &right.vector) };
'b);
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>; self: Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>;
Translation::from(self.vector + right.vector); ); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector + right.vector) }; );
// Translation ÷ Translation // Translation ÷ Translation
// FIXME: instead of calling inverse explicitly, could we just add a `mul_tr` or `mul_inv` method? // FIXME: instead of calling inverse explicitly, could we just add a `mul_tr` or `mul_inv` method?
add_sub_impl!(Div, div, ClosedSub; add_sub_impl!(Div, div, ClosedSub;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: &'a Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>; self: &'a Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>;
Translation::from(&self.vector - &right.vector); 'a, 'b); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector - &right.vector) };
'a, 'b);
add_sub_impl!(Div, div, ClosedSub; add_sub_impl!(Div, div, ClosedSub;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: &'a Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>; self: &'a Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>;
Translation::from(&self.vector - right.vector); 'a); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector - right.vector) };
'a);
add_sub_impl!(Div, div, ClosedSub; add_sub_impl!(Div, div, ClosedSub;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>; self: Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>;
Translation::from(self.vector - &right.vector); 'b); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector - &right.vector) };
'b);
add_sub_impl!(Div, div, ClosedSub; add_sub_impl!(Div, div, ClosedSub;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>; self: Translation<N, D>, right: Translation<N, D>, Output = Translation<N, D>;
Translation::from(self.vector - right.vector); ); #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector - right.vector) }; );
// Translation × Point // Translation × Point
// FIXME: we don't handle properly non-zero origins here. Do we want this to be the intended // FIXME: we don't handle properly non-zero origins here. Do we want this to be the intended
@ -58,107 +64,45 @@ add_sub_impl!(Div, div, ClosedSub;
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: &'a Translation<N, D>, right: &'b Point<N, D>, Output = Point<N, D>; self: &'a Translation<N, D>, right: &'b Point<N, D>, Output = Point<N, D>;
right + &self.vector; 'a, 'b); #[allow(clippy::suspicious_arithmetic_impl)] { right + &self.vector };
'a, 'b);
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: &'a Translation<N, D>, right: Point<N, D>, Output = Point<N, D>; self: &'a Translation<N, D>, right: Point<N, D>, Output = Point<N, D>;
right + &self.vector; 'a); #[allow(clippy::suspicious_arithmetic_impl)] { right + &self.vector };
'a);
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: Translation<N, D>, right: &'b Point<N, D>, Output = Point<N, D>; self: Translation<N, D>, right: &'b Point<N, D>, Output = Point<N, D>;
right + self.vector; 'b); #[allow(clippy::suspicious_arithmetic_impl)] { right + self.vector };
'b);
add_sub_impl!(Mul, mul, ClosedAdd; add_sub_impl!(Mul, mul, ClosedAdd;
(D, U1), (D, U1) -> (D) for D: DimName; (D, U1), (D, U1) -> (D) for D: DimName;
self: Translation<N, D>, right: Point<N, D>, Output = Point<N, D>; self: Translation<N, D>, right: Point<N, D>, Output = Point<N, D>;
right + self.vector; ); #[allow(clippy::suspicious_arithmetic_impl)] { right + self.vector }; );
// Translation *= Translation // Translation *= Translation
add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd;
(D, U1), (D, U1) for D: DimName; (D, U1), (D, U1) for D: DimName;
self: Translation<N, D>, right: &'b Translation<N, D>; self: Translation<N, D>, right: &'b Translation<N, D>;
self.vector += &right.vector; 'b); #[allow(clippy::suspicious_arithmetic_impl)] { self.vector += &right.vector };
'b);
add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd;
(D, U1), (D, U1) for D: DimName; (D, U1), (D, U1) for D: DimName;
self: Translation<N, D>, right: Translation<N, D>; self: Translation<N, D>, right: Translation<N, D>;
self.vector += right.vector; ); #[allow(clippy::suspicious_arithmetic_impl)] { self.vector += right.vector }; );
add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; add_sub_assign_impl!(DivAssign, div_assign, ClosedSub;
(D, U1), (D, U1) for D: DimName; (D, U1), (D, U1) for D: DimName;
self: Translation<N, D>, right: &'b Translation<N, D>; self: Translation<N, D>, right: &'b Translation<N, D>;
self.vector -= &right.vector; 'b); #[allow(clippy::suspicious_arithmetic_impl)] { self.vector -= &right.vector };
'b);
add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; add_sub_assign_impl!(DivAssign, div_assign, ClosedSub;
(D, U1), (D, U1) for D: DimName; (D, U1), (D, U1) for D: DimName;
self: Translation<N, D>, right: Translation<N, D>; self: Translation<N, D>, right: Translation<N, D>;
self.vector -= right.vector; ); #[allow(clippy::suspicious_arithmetic_impl)] { self.vector -= right.vector }; );
/*
// Translation × Matrix
add_sub_impl!(Mul, mul;
(D1, D1), (R2, C2) for D1, R2, C2;
self: &'a Translation<N, D1>, right: &'b Matrix<N, R2, C2>, Output = MatrixMN<N, D1, C2>;
self.vector() * right; 'a, 'b);
add_sub_impl!(Mul, mul;
(D1, D1), (R2, C2) for D1, R2, C2;
self: &'a Translation<N, D1>, right: Matrix<N, R2, C2>, Output = MatrixMN<N, D1, C2>;
self.vector() * right; 'a);
add_sub_impl!(Mul, mul;
(D1, D1), (R2, C2) for D1, R2, C2;
self: Translation<N, D1>, right: &'b Matrix<N, R2, C2>, Output = MatrixMN<N, D1, C2>;
self.unwrap() * right; 'b);
add_sub_impl!(Mul, mul;
(D1, D1), (R2, C2) for D1, R2, C2;
self: Translation<N, D1>, right: Matrix<N, R2, C2>, Output = MatrixMN<N, D1, C2>;
self.unwrap() * right; );
// Matrix × Translation
add_sub_impl!(Mul, mul;
(R1, C1), (D2, D2) for R1, C1, D2;
self: &'a Matrix<N, R1, C1>, right: &'b Translation<N, D2>, Output = MatrixMN<N, R1, D2>;
self * right.vector(); 'a, 'b);
add_sub_impl!(Mul, mul;
(R1, C1), (D2, D2) for R1, C1, D2;
self: &'a Matrix<N, R1, C1>, right: Translation<N, D2>, Output = MatrixMN<N, R1, D2>;
self * right.unwrap(); 'a);
add_sub_impl!(Mul, mul;
(R1, C1), (D2, D2) for R1, C1, D2;
self: Matrix<N, R1, C1>, right: &'b Translation<N, D2>, Output = MatrixMN<N, R1, D2>;
self * right.vector(); 'b);
add_sub_impl!(Mul, mul;
(R1, C1), (D2, D2) for R1, C1, D2;
self: Matrix<N, R1, C1>, right: Translation<N, D2>, Output = MatrixMN<N, R1, D2>;
self * right.unwrap(); );
// Matrix *= Translation
md_assign_impl!(MulAssign, mul_assign;
(R1, C1), (C1, C1) for R1, C1;
self: Matrix<N, R1, C1>, right: &'b Translation<N, C1>;
self.mul_assign(right.vector()); 'b);
md_assign_impl!(MulAssign, mul_assign;
(R1, C1), (C1, C1) for R1, C1;
self: Matrix<N, R1, C1>, right: Translation<N, C1>;
self.mul_assign(right.unwrap()); );
md_assign_impl!(DivAssign, div_assign;
(R1, C1), (C1, C1) for R1, C1;
self: Matrix<N, R1, C1>, right: &'b Translation<N, C1>;
self.mul_assign(right.inverse().vector()); 'b);
md_assign_impl!(DivAssign, div_assign;
(R1, C1), (C1, C1) for R1, C1;
self: Matrix<N, R1, C1>, right: Translation<N, C1>;
self.mul_assign(right.inverse().unwrap()); );
*/

View File

@ -96,6 +96,7 @@ where
#[inline] #[inline]
fn div(self, rhs: Self) -> Self::Output { fn div(self, rhs: Self) -> Self::Output {
#[allow(clippy::suspicious_arithmetic_impl)]
Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner())
} }
} }
@ -108,6 +109,7 @@ where
#[inline] #[inline]
fn div(self, rhs: UnitComplex<N>) -> Self::Output { fn div(self, rhs: UnitComplex<N>) -> Self::Output {
#[allow(clippy::suspicious_arithmetic_impl)]
Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner())
} }
} }
@ -120,6 +122,7 @@ where
#[inline] #[inline]
fn div(self, rhs: &'b UnitComplex<N>) -> Self::Output { fn div(self, rhs: &'b UnitComplex<N>) -> Self::Output {
#[allow(clippy::suspicious_arithmetic_impl)]
Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner())
} }
} }
@ -132,6 +135,7 @@ where
#[inline] #[inline]
fn div(self, rhs: &'b UnitComplex<N>) -> Self::Output { fn div(self, rhs: &'b UnitComplex<N>) -> Self::Output {
#[allow(clippy::suspicious_arithmetic_impl)]
Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner())
} }
} }
@ -206,7 +210,7 @@ complex_op_impl_all!(
[val val] => &self / &rhs; [val val] => &self / &rhs;
[ref val] => self / &rhs; [ref val] => self / &rhs;
[val ref] => &self / rhs; [val ref] => &self / rhs;
[ref ref] => self * UnitComplex::from_rotation_matrix(rhs).inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * UnitComplex::from_rotation_matrix(rhs).inverse() };
); );
// Rotation × UnitComplex // Rotation × UnitComplex
@ -228,7 +232,7 @@ complex_op_impl_all!(
[val val] => &self / &rhs; [val val] => &self / &rhs;
[ref val] => self / &rhs; [ref val] => self / &rhs;
[val ref] => &self / rhs; [val ref] => &self / rhs;
[ref ref] => UnitComplex::from_rotation_matrix(self) * rhs.inverse(); [ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { UnitComplex::from_rotation_matrix(self) * rhs.inverse() };
); );
// UnitComplex × Point // UnitComplex × Point