diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index a02cbd08..2e4b7cd5 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -3,7 +3,6 @@ use std::fmt; use std::hash; #[cfg(feature = "abomonation-serialize")] use std::io::{Result as IOResult, Write}; -use std::marker::PhantomData; #[cfg(feature = "serde-serialize")] use serde::{Deserialize, Serialize}; @@ -37,7 +36,8 @@ use crate::geometry::{AbstractRotation, Point, Translation}; Owned: Deserialize<'de>")) )] pub struct Isometry -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// The pure rotational part of this isometry. pub rotation: R, @@ -91,7 +91,8 @@ where } impl + Clone> Clone for Isometry -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { #[inline] fn clone(&self) -> Self { @@ -100,7 +101,8 @@ where DefaultAllocator: Allocator } impl> Isometry -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// Creates a new isometry from its rotational and translational parts. /// @@ -353,7 +355,8 @@ where // This is OK since all constructors of the isometry enforce the Rotation bound already (and // explicit struct construction is prevented by the dummy ZST field). impl Isometry -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// Converts this isometry into its equivalent homogeneous transformation matrix. /// @@ -440,8 +443,7 @@ where other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, - ) -> bool - { + ) -> bool { self.translation .relative_eq(&other.translation, epsilon, max_relative) && self diff --git a/src/geometry/isometry_simba.rs b/src/geometry/isometry_simba.rs index a3515305..e5d2c839 100755 --- a/src/geometry/isometry_simba.rs +++ b/src/geometry/isometry_simba.rs @@ -2,7 +2,7 @@ use simba::simd::SimdValue; use crate::base::allocator::Allocator; use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, Scalar}; +use crate::base::DefaultAllocator; use crate::SimdRealField; use crate::geometry::{AbstractRotation, Isometry, Translation}; diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index 2fc0c507..83b4521d 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -1,6 +1,6 @@ use num::{One, Zero}; use simba::scalar::{ClosedDiv, SubsetOf, SupersetOf}; -use simba::simd::{PrimitiveSimdValue, SimdValue}; +use simba::simd::PrimitiveSimdValue; use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; @@ -143,7 +143,8 @@ where } impl From> for Point -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { #[inline] fn from(coords: VectorN) -> Self { diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index 70d4c220..175275d4 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -71,7 +71,9 @@ impl Quaternion { #[inline] // FIXME: take a reference to `vector`? pub fn from_parts(scalar: N, vector: Vector) -> Self - where SB: Storage { + where + SB: Storage, + { Self::new(scalar, vector[0], vector[1], vector[2]) } @@ -100,14 +102,17 @@ impl Quaternion { // FIXME: merge with the previous block. impl Quaternion -where N::Element: SimdRealField +where + N::Element: SimdRealField, { /// Creates a new quaternion from its polar decomposition. /// /// Note that `axis` is assumed to be a unit vector. // FIXME: take a reference to `axis`? pub fn from_polar_decomposition(scale: N, theta: N, axis: Unit>) -> Self - where SB: Storage { + where + SB: Storage, + { let rot = UnitQuaternion::::from_axis_angle(&axis, theta * crate::convert(2.0f64)); rot.into_inner() * scale @@ -115,7 +120,8 @@ where N::Element: SimdRealField } impl One for Quaternion -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn one() -> Self { @@ -124,7 +130,8 @@ where N::Element: SimdRealField } impl Zero for Quaternion -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn zero() -> Self { @@ -138,7 +145,8 @@ where N::Element: SimdRealField } impl Distribution> for Standard -where Standard: Distribution +where + Standard: Distribution, { #[inline] fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion { @@ -148,7 +156,8 @@ where Standard: Distribution #[cfg(feature = "arbitrary")] impl Arbitrary for Quaternion -where Owned: Send +where + Owned: Send, { #[inline] fn arbitrary(g: &mut G) -> Self { @@ -162,7 +171,8 @@ where Owned: Send } impl UnitQuaternion -where N::Element: SimdRealField +where + N::Element: SimdRealField, { /// The rotation identity. /// @@ -209,7 +219,9 @@ where N::Element: SimdRealField /// ``` #[inline] pub fn from_axis_angle(axis: &Unit>, angle: N) -> Self - where SB: Storage { + where + SB: Storage, + { let (sang, cang) = (angle / crate::convert(2.0f64)).simd_sin_cos(); let q = Quaternion::from_parts(cang, axis.as_ref() * sang); @@ -335,7 +347,9 @@ where N::Element: SimdRealField /// convergence parameters and starting solution. /// This implements "A Robust Method to Extract the Rotational Part of Deformations" by Müller et al. pub fn from_matrix(m: &Matrix3) -> Self - where N: RealField { + where + N: RealField, + { Rotation3::from_matrix(m).into() } @@ -352,7 +366,9 @@ where N::Element: SimdRealField /// to the actual solution is provided. Can be set to `UnitQuaternion::identity()` if no other /// guesses come to mind. pub fn from_matrix_eps(m: &Matrix3, eps: N, max_iter: usize, guess: Self) -> Self - where N: RealField { + where + N: RealField, + { let guess = Rotation3::from(guess); Rotation3::from_matrix_eps(m, eps, max_iter, guess).into() } @@ -619,7 +635,9 @@ where N::Element: SimdRealField /// ``` #[inline] pub fn new(axisangle: Vector) -> Self - where SB: Storage { + where + SB: Storage, + { let two: N = crate::convert(2.0f64); let q = Quaternion::::from_imag(axisangle / two).exp(); Self::new_unchecked(q) @@ -648,7 +666,9 @@ where N::Element: SimdRealField /// ``` #[inline] pub fn new_eps(axisangle: Vector, eps: N) -> Self - where SB: Storage { + where + SB: Storage, + { let two: N = crate::convert(2.0f64); let q = Quaternion::::from_imag(axisangle / two).exp_eps(eps); Self::new_unchecked(q) @@ -678,7 +698,9 @@ where N::Element: SimdRealField /// ``` #[inline] pub fn from_scaled_axis(axisangle: Vector) -> Self - where SB: Storage { + where + SB: Storage, + { Self::new(axisangle) } @@ -706,7 +728,9 @@ where N::Element: SimdRealField /// ``` #[inline] pub fn from_scaled_axis_eps(axisangle: Vector, eps: N) -> Self - where SB: Storage { + where + SB: Storage, + { Self::new_eps(axisangle, eps) } @@ -736,7 +760,9 @@ where N::Element: SimdRealField /// ``` #[inline] pub fn mean_of(unit_quaternions: impl IntoIterator) -> Self - where N: RealField { + where + N: RealField, + { let quaternions_matrix: Matrix4 = unit_quaternions .into_iter() .map(|q| q.as_vector() * q.as_vector().transpose()) @@ -765,7 +791,8 @@ where N::Element: SimdRealField } impl One for UnitQuaternion -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn one() -> Self { @@ -800,7 +827,7 @@ where } #[cfg(feature = "arbitrary")] -impl Arbitrary for UnitQuaternion +impl Arbitrary for UnitQuaternion where Owned: Send, Owned: Send, diff --git a/src/geometry/quaternion_simba.rs b/src/geometry/quaternion_simba.rs index 0120defe..b43db8d9 100755 --- a/src/geometry/quaternion_simba.rs +++ b/src/geometry/quaternion_simba.rs @@ -2,10 +2,11 @@ use simba::simd::SimdValue; use crate::base::Vector4; use crate::geometry::{Quaternion, UnitQuaternion}; -use crate::{RealField, Scalar}; +use crate::Scalar; impl SimdValue for Quaternion -where N::Element: Scalar +where + N::Element: Scalar, { type Element = Quaternion; type SimdBool = N::SimdBool; @@ -47,7 +48,8 @@ where N::Element: Scalar } impl SimdValue for UnitQuaternion -where N::Element: Scalar +where + N::Element: Scalar, { type Element = UnitQuaternion; type SimdBool = N::SimdBool; diff --git a/src/geometry/similarity_construction.rs b/src/geometry/similarity_construction.rs index 60e6d0f0..510758cf 100644 --- a/src/geometry/similarity_construction.rs +++ b/src/geometry/similarity_construction.rs @@ -107,15 +107,15 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for Similarity where - N: SimdRealField + Arbitrary + Send, - N::Element: SimdRealField, + N: RealField + Arbitrary + Send, + N::Element: RealField, R: AbstractRotation + Arbitrary + Send, DefaultAllocator: Allocator, Owned: Send, { #[inline] fn arbitrary(rng: &mut G) -> Self { - let mut s = Arbitrary::arbitrary(rng); + let mut s: N = Arbitrary::arbitrary(rng); while s.is_zero() { s = Arbitrary::arbitrary(rng) } @@ -132,7 +132,8 @@ where // 2D similarity. impl Similarity> -where N::Element: SimdRealField +where + N::Element: SimdRealField, { /// Creates a new similarity from a translation, a rotation, and an uniform scaling factor. /// @@ -157,7 +158,8 @@ where N::Element: SimdRealField } impl Similarity> -where N::Element: SimdRealField +where + N::Element: SimdRealField, { /// Creates a new similarity from a translation and a rotation angle. /// diff --git a/src/geometry/similarity_simba.rs b/src/geometry/similarity_simba.rs index 3db56b74..bf3858f7 100755 --- a/src/geometry/similarity_simba.rs +++ b/src/geometry/similarity_simba.rs @@ -2,7 +2,7 @@ use simba::simd::{SimdRealField, SimdValue}; use crate::base::allocator::Allocator; use crate::base::dimension::DimName; -use crate::base::{DefaultAllocator, Scalar}; +use crate::base::DefaultAllocator; use crate::geometry::{AbstractRotation, Isometry, Similarity}; diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index e82ecaaa..88d52ce4 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "abomonation-serialize")] use abomonation::Abomonation; -use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub, RealField}; +use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; @@ -24,7 +24,8 @@ use crate::geometry::Point; #[repr(C)] #[derive(Debug)] pub struct Translation -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// The translation coordinates, i.e., how much is added to a point's coordinates when it is /// translated. @@ -87,7 +88,9 @@ where Owned: Serialize, { fn serialize(&self, serializer: S) -> Result - where S: Serializer { + where + S: Serializer, + { self.vector.serialize(serializer) } } @@ -99,7 +102,9 @@ where Owned: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result - where Des: Deserializer<'a> { + where + Des: Deserializer<'a>, + { let matrix = VectorN::::deserialize(deserializer)?; Ok(Translation::from(matrix)) @@ -107,7 +112,8 @@ where } impl Translation -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// Creates a new translation from the given vector. #[inline] @@ -133,7 +139,9 @@ where DefaultAllocator: Allocator #[inline] #[must_use = "Did you mean to use inverse_mut()?"] pub fn inverse(&self) -> Translation - where N: ClosedNeg { + where + N: ClosedNeg, + { Translation::from(-&self.vector) } @@ -189,13 +197,16 @@ where DefaultAllocator: Allocator /// ``` #[inline] pub fn inverse_mut(&mut self) - where N: ClosedNeg { + where + N: ClosedNeg, + { self.vector.neg_mut() } } impl Translation -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// Translate the given point. /// @@ -214,7 +225,8 @@ where DefaultAllocator: Allocator } impl Translation -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { /// Translate the given point by the inverse of this translation. /// @@ -233,7 +245,8 @@ where DefaultAllocator: Allocator impl Eq for Translation where DefaultAllocator: Allocator {} impl PartialEq for Translation -where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { #[inline] fn eq(&self, right: &Translation) -> bool { @@ -275,8 +288,7 @@ where other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, - ) -> bool - { + ) -> bool { self.vector .relative_eq(&other.vector, epsilon, max_relative) } @@ -304,7 +316,8 @@ where * */ impl fmt::Display for Translation -where DefaultAllocator: Allocator + Allocator +where + DefaultAllocator: Allocator + Allocator, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let precision = f.precision().unwrap_or(3); diff --git a/src/geometry/unit_complex_conversion.rs b/src/geometry/unit_complex_conversion.rs index 250da3a9..91736764 100644 --- a/src/geometry/unit_complex_conversion.rs +++ b/src/geometry/unit_complex_conversion.rs @@ -2,7 +2,7 @@ use num::Zero; use num_complex::Complex; use simba::scalar::{RealField, SubsetOf, SupersetOf}; -use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue}; +use simba::simd::{PrimitiveSimdValue, SimdRealField}; use crate::base::dimension::U2; use crate::base::{Matrix2, Matrix3, Scalar}; @@ -155,7 +155,8 @@ impl> SubsetOf> for Un } impl From> for Rotation2 -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn from(q: UnitComplex) -> Self { @@ -164,7 +165,8 @@ where N::Element: SimdRealField } impl From> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn from(q: Rotation2) -> Self { @@ -173,7 +175,8 @@ where N::Element: SimdRealField } impl From> for Matrix3 -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn from(q: UnitComplex) -> Matrix3 { @@ -182,7 +185,8 @@ where N::Element: SimdRealField } impl From> for Matrix2 -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn from(q: UnitComplex) -> Self { diff --git a/src/geometry/unit_complex_ops.rs b/src/geometry/unit_complex_ops.rs index 32281020..f7af7088 100644 --- a/src/geometry/unit_complex_ops.rs +++ b/src/geometry/unit_complex_ops.rs @@ -5,7 +5,6 @@ use crate::base::dimension::{U1, U2}; use crate::base::storage::Storage; use crate::base::{DefaultAllocator, Unit, Vector, Vector2}; use crate::geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex}; -use simba::scalar::RealField; use simba::simd::SimdRealField; /* @@ -53,7 +52,8 @@ impl Mul for UnitComplex { } impl<'a, N: SimdRealField> Mul> for &'a UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = UnitComplex; @@ -64,7 +64,8 @@ where N::Element: SimdRealField } impl<'b, N: SimdRealField> Mul<&'b UnitComplex> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = Self; @@ -75,7 +76,8 @@ where N::Element: SimdRealField } impl<'a, 'b, N: SimdRealField> Mul<&'b UnitComplex> for &'a UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = UnitComplex; @@ -87,7 +89,8 @@ where N::Element: SimdRealField // UnitComplex ÷ UnitComplex impl Div for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = Self; @@ -98,7 +101,8 @@ where N::Element: SimdRealField } impl<'a, N: SimdRealField> Div> for &'a UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = UnitComplex; @@ -109,7 +113,8 @@ where N::Element: SimdRealField } impl<'b, N: SimdRealField> Div<&'b UnitComplex> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = Self; @@ -120,7 +125,8 @@ where N::Element: SimdRealField } impl<'a, 'b, N: SimdRealField> Div<&'b UnitComplex> for &'a UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Output = UnitComplex; @@ -315,7 +321,8 @@ complex_op_impl_all!( // UnitComplex ×= UnitComplex impl MulAssign> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn mul_assign(&mut self, rhs: UnitComplex) { @@ -324,7 +331,8 @@ where N::Element: SimdRealField } impl<'b, N: SimdRealField> MulAssign<&'b UnitComplex> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn mul_assign(&mut self, rhs: &'b UnitComplex) { @@ -334,7 +342,8 @@ where N::Element: SimdRealField // UnitComplex /= UnitComplex impl DivAssign> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn div_assign(&mut self, rhs: UnitComplex) { @@ -343,7 +352,8 @@ where N::Element: SimdRealField } impl<'b, N: SimdRealField> DivAssign<&'b UnitComplex> for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { #[inline] fn div_assign(&mut self, rhs: &'b UnitComplex) { diff --git a/src/geometry/unit_complex_simba.rs b/src/geometry/unit_complex_simba.rs index e1c9de34..5e8bfa78 100755 --- a/src/geometry/unit_complex_simba.rs +++ b/src/geometry/unit_complex_simba.rs @@ -2,12 +2,13 @@ use num_complex::Complex; use simba::simd::SimdValue; use std::ops::Deref; -use crate::base::{Scalar, Unit}; +use crate::base::Unit; use crate::geometry::UnitComplex; use crate::SimdRealField; impl SimdValue for UnitComplex -where N::Element: SimdRealField +where + N::Element: SimdRealField, { type Element = UnitComplex; type SimdBool = N::SimdBool;