Replace explicit types with Self where possible.

This commit is contained in:
adamnemecek 2019-02-16 13:29:41 -08:00 committed by Sébastien Crozet
parent fac709b0c0
commit 975d72f070
42 changed files with 163 additions and 163 deletions

View File

@ -62,7 +62,7 @@ where DefaultAllocator: Allocator<N, D, D>
N::xpotrf(uplo, dim, m.as_mut_slice(), dim, &mut info); N::xpotrf(uplo, dim, m.as_mut_slice(), dim, &mut info);
lapack_check!(info); lapack_check!(info);
Some(Cholesky { l: m }) Some(Self { l: m })
} }
/// Retrieves the lower-triangular factor of the cholesky decomposition. /// Retrieves the lower-triangular factor of the cholesky decomposition.

View File

@ -127,7 +127,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
lapack_check!(info); lapack_check!(info);
if wi.iter().all(|e| e.is_zero()) { if wi.iter().all(|e| e.is_zero()) {
return Some(Eigen { return Some(Self {
eigenvalues: wr, eigenvalues: wr,
left_eigenvectors: Some(vl), left_eigenvectors: Some(vl),
eigenvectors: Some(vr), eigenvectors: Some(vr),
@ -156,7 +156,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
lapack_check!(info); lapack_check!(info);
if wi.iter().all(|e| e.is_zero()) { if wi.iter().all(|e| e.is_zero()) {
return Some(Eigen { return Some(Self {
eigenvalues: wr, eigenvalues: wr,
left_eigenvectors: Some(vl), left_eigenvectors: Some(vl),
eigenvectors: None, eigenvectors: None,
@ -185,7 +185,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
lapack_check!(info); lapack_check!(info);
if wi.iter().all(|e| e.is_zero()) { if wi.iter().all(|e| e.is_zero()) {
return Some(Eigen { return Some(Self {
eigenvalues: wr, eigenvalues: wr,
left_eigenvectors: None, left_eigenvectors: None,
eigenvectors: Some(vr), eigenvectors: Some(vr),
@ -212,7 +212,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
lapack_check!(info); lapack_check!(info);
if wi.iter().all(|e| e.is_zero()) { if wi.iter().all(|e| e.is_zero()) {
return Some(Eigen { return Some(Self {
eigenvalues: wr, eigenvalues: wr,
left_eigenvectors: None, left_eigenvectors: None,
eigenvectors: None, eigenvectors: None,

View File

@ -48,7 +48,7 @@ impl<N: HessenbergScalar + Zero, D: DimSub<U1>> Hessenberg<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>> where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>>
{ {
/// Computes the hessenberg decomposition of the matrix `m`. /// Computes the hessenberg decomposition of the matrix `m`.
pub fn new(mut m: MatrixN<N, D>) -> Hessenberg<N, D> { pub fn new(mut m: MatrixN<N, D>) -> Self {
let nrows = m.data.shape().0; let nrows = m.data.shape().0;
let n = nrows.value() as i32; let n = nrows.value() as i32;
@ -83,7 +83,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>>
); );
lapack_panic!(info); lapack_panic!(info);
Hessenberg { h: m, tau: tau } Self { h: m, tau: tau }
} }
/// Computes the hessenberg matrix of this decomposition. /// Computes the hessenberg matrix of this decomposition.

View File

@ -82,7 +82,7 @@ where
); );
lapack_panic!(info); lapack_panic!(info);
LU { lu: m, p: ipiv } Self { lu: m, p: ipiv }
} }
/// Gets the lower-triangular matrix part of the decomposition. /// Gets the lower-triangular matrix part of the decomposition.

View File

@ -54,14 +54,14 @@ where DefaultAllocator: Allocator<N, R, C>
+ Allocator<N, DimMinimum<R, C>> + Allocator<N, DimMinimum<R, C>>
{ {
/// Computes the QR decomposition of the matrix `m`. /// Computes the QR decomposition of the matrix `m`.
pub fn new(mut m: MatrixMN<N, R, C>) -> QR<N, R, C> { pub fn new(mut m: MatrixMN<N, R, C>) -> Self {
let (nrows, ncols) = m.data.shape(); let (nrows, ncols) = m.data.shape();
let mut info = 0; let mut info = 0;
let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1) }; let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1) };
if nrows.value() == 0 || ncols.value() == 0 { if nrows.value() == 0 || ncols.value() == 0 {
return QR { qr: m, tau: tau }; return Self { qr: m, tau: tau };
} }
let lwork = N::xgeqrf_work_size( let lwork = N::xgeqrf_work_size(
@ -86,7 +86,7 @@ where DefaultAllocator: Allocator<N, R, C>
&mut info, &mut info,
); );
QR { qr: m, tau: tau } Self { qr: m, tau: tau }
} }
/// Retrieves the upper trapezoidal submatrix `R` of this decomposition. /// Retrieves the upper trapezoidal submatrix `R` of this decomposition.

View File

@ -62,7 +62,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
pub fn new(m: MatrixN<N, D>) -> Self { pub fn new(m: MatrixN<N, D>) -> Self {
let (vals, vecs) = let (vals, vecs) =
Self::do_decompose(m, true).expect("SymmetricEigen: convergence failure."); Self::do_decompose(m, true).expect("SymmetricEigen: convergence failure.");
SymmetricEigen { Self {
eigenvalues: vals, eigenvalues: vals,
eigenvectors: vecs.unwrap(), eigenvectors: vecs.unwrap(),
} }

View File

@ -22,8 +22,8 @@ pub struct Dynamic {
impl Dynamic { impl Dynamic {
/// A dynamic size equal to `value`. /// A dynamic size equal to `value`.
#[inline] #[inline]
pub fn new(value: usize) -> Dynamic { pub fn new(value: usize) -> Self {
Dynamic { value: value } Self { value: value }
} }
} }
@ -80,7 +80,7 @@ impl Dim for Dynamic {
#[inline] #[inline]
fn from_usize(dim: usize) -> Self { fn from_usize(dim: usize) -> Self {
Dynamic::new(dim) Self::new(dim)
} }
#[inline] #[inline]
@ -93,8 +93,8 @@ impl Add<usize> for Dynamic {
type Output = Dynamic; type Output = Dynamic;
#[inline] #[inline]
fn add(self, rhs: usize) -> Dynamic { fn add(self, rhs: usize) -> Self {
Dynamic::new(self.value + rhs) Self::new(self.value + rhs)
} }
} }
@ -102,8 +102,8 @@ impl Sub<usize> for Dynamic {
type Output = Dynamic; type Output = Dynamic;
#[inline] #[inline]
fn sub(self, rhs: usize) -> Dynamic { fn sub(self, rhs: usize) -> Self {
Dynamic::new(self.value - rhs) Self::new(self.value - rhs)
} }
} }

View File

@ -152,7 +152,7 @@ impl<N: Scalar, R: Dim, C: Dim, S> Matrix<N, R, C, S> {
impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> { impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Creates a new matrix with the given data. /// Creates a new matrix with the given data.
#[inline] #[inline]
pub fn from_data(data: S) -> Matrix<N, R, C, S> { pub fn from_data(data: S) -> Self {
unsafe { Self::from_data_statically_unchecked(data) } unsafe { Self::from_data_statically_unchecked(data) }
} }

View File

@ -51,7 +51,7 @@ where
DefaultAllocator: Allocator<N, R, C>, DefaultAllocator: Allocator<N, R, C>,
{ {
#[inline] #[inline]
fn two_sided_inverse(&self) -> MatrixMN<N, R, C> { fn two_sided_inverse(&self) -> Self {
-self -self
} }
@ -203,7 +203,7 @@ impl<N: Real, R: DimName, C: DimName> FiniteDimInnerSpace for MatrixMN<N, R, C>
where DefaultAllocator: Allocator<N, R, C> where DefaultAllocator: Allocator<N, R, C>
{ {
#[inline] #[inline]
fn orthonormalize(vs: &mut [MatrixMN<N, R, C>]) -> usize { fn orthonormalize(vs: &mut [Self]) -> usize {
let mut nbasis_elements = 0; let mut nbasis_elements = 0;
for i in 0..vs.len() { for i in 0..vs.len() {

View File

@ -99,7 +99,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
{ {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
SliceStorage { Self {
ptr: self.ptr, ptr: self.ptr,
shape: self.shape, shape: self.shape,
strides: self.strides, strides: self.strides,

View File

@ -24,7 +24,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Index<usize> for Matrix<N,
type Output = N; type Output = N;
#[inline] #[inline]
fn index(&self, i: usize) -> &N { fn index(&self, i: usize) -> &Self::Output {
let ij = self.vector_to_matrix_index(i); let ij = self.vector_to_matrix_index(i);
&self[ij] &self[ij]
} }
@ -38,7 +38,7 @@ where
type Output = N; type Output = N;
#[inline] #[inline]
fn index(&self, ij: (usize, usize)) -> &N { fn index(&self, ij: (usize, usize)) -> &Self::Output {
let shape = self.shape(); let shape = self.shape();
assert!( assert!(
ij.0 < shape.0 && ij.1 < shape.1, ij.0 < shape.0 && ij.1 < shape.1,

View File

@ -36,12 +36,12 @@ pub type MatrixVec<N, R, C> = VecStorage<N, R, C>;
impl<N, R: Dim, C: Dim> VecStorage<N, R, C> { impl<N, R: Dim, C: Dim> VecStorage<N, R, C> {
/// Creates a new dynamic matrix data storage from the given vector and shape. /// Creates a new dynamic matrix data storage from the given vector and shape.
#[inline] #[inline]
pub fn new(nrows: R, ncols: C, data: Vec<N>) -> VecStorage<N, R, C> { pub fn new(nrows: R, ncols: C, data: Vec<N>) -> Self {
assert!( assert!(
nrows.value() * ncols.value() == data.len(), nrows.value() * ncols.value() == data.len(),
"Data storage buffer dimension mismatch." "Data storage buffer dimension mismatch."
); );
VecStorage { Self {
data: data, data: data,
nrows: nrows, nrows: nrows,
ncols: ncols, ncols: ncols,

View File

@ -100,7 +100,7 @@ where DefaultAllocator: Allocator<N, D>
{ {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Isometry::from_parts(self.translation.clone(), self.rotation.clone()) Self::from_parts(self.translation.clone(), self.rotation.clone())
} }
} }
@ -122,8 +122,8 @@ where DefaultAllocator: Allocator<N, D>
/// assert_relative_eq!(iso * Point3::new(1.0, 2.0, 3.0), Point3::new(-1.0, 2.0, 0.0), epsilon = 1.0e-6); /// assert_relative_eq!(iso * Point3::new(1.0, 2.0, 3.0), Point3::new(-1.0, 2.0, 0.0), epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn from_parts(translation: Translation<N, D>, rotation: R) -> Isometry<N, D, R> { pub fn from_parts(translation: Translation<N, D>, rotation: R) -> Self {
Isometry { Self {
rotation: rotation, rotation: rotation,
translation: translation, translation: translation,
_noconstruct: PhantomData, _noconstruct: PhantomData,
@ -144,7 +144,7 @@ where DefaultAllocator: Allocator<N, D>
/// assert_eq!(inv * (iso * pt), pt); /// assert_eq!(inv * (iso * pt), pt);
/// ``` /// ```
#[inline] #[inline]
pub fn inverse(&self) -> Isometry<N, D, R> { pub fn inverse(&self) -> Self {
let mut res = self.clone(); let mut res = self.clone();
res.inverse_mut(); res.inverse_mut();
res res
@ -306,7 +306,7 @@ where
DefaultAllocator: Allocator<N, D>, DefaultAllocator: Allocator<N, D>,
{ {
#[inline] #[inline]
fn eq(&self, right: &Isometry<N, D, R>) -> bool { fn eq(&self, right: &Self) -> bool {
self.translation == right.translation && self.rotation == right.rotation self.translation == right.translation && self.rotation == right.rotation
} }
} }

View File

@ -121,7 +121,7 @@ where
type Translation = Translation<N, D>; type Translation = Translation<N, D>;
#[inline] #[inline]
fn decompose(&self) -> (Translation<N, D>, R, Id, R) { fn decompose(&self) -> (Self::Translation, R, Id, R) {
( (
self.translation.clone(), self.translation.clone(),
self.rotation.clone(), self.rotation.clone(),

View File

@ -26,7 +26,7 @@ impl<N: Real> Copy for Orthographic3<N> {}
impl<N: Real> Clone for Orthographic3<N> { impl<N: Real> Clone for Orthographic3<N> {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Orthographic3::from_matrix_unchecked(self.matrix.clone()) Self::from_matrix_unchecked(self.matrix.clone())
} }
} }
@ -57,7 +57,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Orthographic3<N> {
where Des: Deserializer<'a> { where Des: Deserializer<'a> {
let matrix = Matrix4::<N>::deserialize(deserializer)?; let matrix = Matrix4::<N>::deserialize(deserializer)?;
Ok(Orthographic3::from_matrix_unchecked(matrix)) Ok(Self::from_matrix_unchecked(matrix))
} }
} }
@ -135,7 +135,7 @@ impl<N: Real> Orthographic3<N> {
/// ``` /// ```
#[inline] #[inline]
pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self { pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self {
Orthographic3 { matrix: matrix } Self { matrix: matrix }
} }
/// Creates a new orthographic projection matrix from an aspect ratio and the vertical field of view. /// Creates a new orthographic projection matrix from an aspect ratio and the vertical field of view.

View File

@ -27,7 +27,7 @@ impl<N: Real> Copy for Perspective3<N> {}
impl<N: Real> Clone for Perspective3<N> { impl<N: Real> Clone for Perspective3<N> {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Perspective3::from_matrix_unchecked(self.matrix.clone()) Self::from_matrix_unchecked(self.matrix.clone())
} }
} }
@ -58,7 +58,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Perspective3<N> {
where Des: Deserializer<'a> { where Des: Deserializer<'a> {
let matrix = Matrix4::<N>::deserialize(deserializer)?; let matrix = Matrix4::<N>::deserialize(deserializer)?;
Ok(Perspective3::from_matrix_unchecked(matrix)) Ok(Self::from_matrix_unchecked(matrix))
} }
} }
@ -75,7 +75,7 @@ impl<N: Real> Perspective3<N> {
); );
let matrix = Matrix4::identity(); let matrix = Matrix4::identity();
let mut res = Perspective3::from_matrix_unchecked(matrix); let mut res = Self::from_matrix_unchecked(matrix);
res.set_fovy(fovy); res.set_fovy(fovy);
res.set_aspect(aspect); res.set_aspect(aspect);
@ -93,7 +93,7 @@ impl<N: Real> Perspective3<N> {
/// projection. /// projection.
#[inline] #[inline]
pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self { pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self {
Perspective3 { matrix: matrix } Self { matrix: matrix }
} }
/// Retrieves the inverse of the underlying homogeneous matrix. /// Retrieves the inverse of the underlying homogeneous matrix.

View File

@ -66,7 +66,7 @@ where
where Des: Deserializer<'a> { where Des: Deserializer<'a> {
let coords = VectorN::<N, D>::deserialize(deserializer)?; let coords = VectorN::<N, D>::deserialize(deserializer)?;
Ok(Point::from(coords)) Ok(Self::from(coords))
} }
} }
@ -126,8 +126,8 @@ where DefaultAllocator: Allocator<N, D>
/// Creates a new point with the given coordinates. /// Creates a new point with the given coordinates.
#[deprecated(note = "Use Point::from(vector) instead.")] #[deprecated(note = "Use Point::from(vector) instead.")]
#[inline] #[inline]
pub fn from_coordinates(coords: VectorN<N, D>) -> Point<N, D> { pub fn from_coordinates(coords: VectorN<N, D>) -> Self {
Point { coords: coords } Self { coords: coords }
} }
/// The dimension of this point. /// The dimension of this point.

View File

@ -54,7 +54,7 @@ where
{ {
#[inline] #[inline]
fn meet(&self, other: &Self) -> Self { fn meet(&self, other: &Self) -> Self {
Point::from(self.coords.meet(&other.coords)) Self::from(self.coords.meet(&other.coords))
} }
} }
@ -65,7 +65,7 @@ where
{ {
#[inline] #[inline]
fn join(&self, other: &Self) -> Self { fn join(&self, other: &Self) -> Self {
Point::from(self.coords.join(&other.coords)) Self::from(self.coords.join(&other.coords))
} }
} }
@ -78,6 +78,6 @@ where
fn meet_join(&self, other: &Self) -> (Self, Self) { fn meet_join(&self, other: &Self) -> (Self, Self) {
let (meet, join) = self.coords.meet_join(&other.coords); let (meet, join) = self.coords.meet_join(&other.coords);
(Point::from(meet), Point::from(join)) (Self::from(meet), Self::from(join))
} }
} }

View File

@ -145,7 +145,7 @@ where
{ {
#[inline] #[inline]
fn arbitrary<G: Gen>(g: &mut G) -> Self { fn arbitrary<G: Gen>(g: &mut G) -> Self {
Point::from(VectorN::arbitrary(g)) Self::from(VectorN::arbitrary(g))
} }
} }
@ -163,7 +163,7 @@ macro_rules! componentwise_constructors_impl(
#[doc = $doc] #[doc = $doc]
#[doc = "```"] #[doc = "```"]
#[inline] #[inline]
pub fn new($($args: N),*) -> Point<N, $D> { pub fn new($($args: N),*) -> Self {
unsafe { unsafe {
let mut res = Self::new_uninitialized(); let mut res = Self::new_uninitialized();
$( *res.get_unchecked_mut($irow) = $args; )* $( *res.get_unchecked_mut($irow) = $args; )*
@ -194,7 +194,7 @@ macro_rules! from_array_impl(
($($D: ty, $len: expr);*) => {$( ($($D: ty, $len: expr);*) => {$(
impl <N: Scalar> From<[N; $len]> for Point<N, $D> { impl <N: Scalar> From<[N; $len]> for Point<N, $D> {
fn from (coords: [N; $len]) -> Self { fn from (coords: [N; $len]) -> Self {
Point { Self {
coords: coords.into() coords: coords.into()
} }
} }

View File

@ -45,7 +45,7 @@ where
#[inline] #[inline]
unsafe fn from_superset_unchecked(m: &Point<N2, D>) -> Self { unsafe fn from_superset_unchecked(m: &Point<N2, D>) -> Self {
Point::from(Matrix::from_superset_unchecked(&m.coords)) Self::from(Matrix::from_superset_unchecked(&m.coords))
} }
} }

View File

@ -46,11 +46,11 @@ where DefaultAllocator: Allocator<N, D>
impl<N: Scalar + ClosedNeg, D: DimName> Neg for Point<N, D> impl<N: Scalar + ClosedNeg, D: DimName> Neg for Point<N, D>
where DefaultAllocator: Allocator<N, D> where DefaultAllocator: Allocator<N, D>
{ {
type Output = Point<N, D>; type Output = Self;
#[inline] #[inline]
fn neg(self) -> Self::Output { fn neg(self) -> Self::Output {
Point::from(-self.coords) Self::Output::from(-self.coords)
} }
} }
@ -61,7 +61,7 @@ where DefaultAllocator: Allocator<N, D>
#[inline] #[inline]
fn neg(self) -> Self::Output { fn neg(self) -> Self::Output {
Point::from(-&self.coords) Self::Output::from(-&self.coords)
} }
} }

View File

@ -68,7 +68,7 @@ impl<N: Real> Copy for Quaternion<N> {}
impl<N: Real> Clone for Quaternion<N> { impl<N: Real> Clone for Quaternion<N> {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Quaternion::from(self.coords.clone()) Self::from(self.coords.clone())
} }
} }
@ -90,7 +90,7 @@ where Owned<N, U4>: Deserialize<'a>
where Des: Deserializer<'a> { where Des: Deserializer<'a> {
let coords = Vector4::<N>::deserialize(deserializer)?; let coords = Vector4::<N>::deserialize(deserializer)?;
Ok(Quaternion::from(coords)) Ok(Self::from(coords))
} }
} }
@ -98,15 +98,15 @@ impl<N: Real> Quaternion<N> {
/// Moves this unit quaternion into one that owns its data. /// Moves this unit quaternion into one that owns its data.
#[inline] #[inline]
#[deprecated(note = "This method is a no-op and will be removed in a future release.")] #[deprecated(note = "This method is a no-op and will be removed in a future release.")]
pub fn into_owned(self) -> Quaternion<N> { pub fn into_owned(self) -> Self {
self self
} }
/// Clones this unit quaternion into one that owns its data. /// Clones this unit quaternion into one that owns its data.
#[inline] #[inline]
#[deprecated(note = "This method is a no-op and will be removed in a future release.")] #[deprecated(note = "This method is a no-op and will be removed in a future release.")]
pub fn clone_owned(&self) -> Quaternion<N> { pub fn clone_owned(&self) -> Self {
Quaternion::from(self.coords.clone_owned()) Self::from(self.coords.clone_owned())
} }
/// Normalizes this quaternion. /// Normalizes this quaternion.
@ -120,8 +120,8 @@ impl<N: Real> Quaternion<N> {
/// relative_eq!(q_normalized.norm(), 1.0); /// relative_eq!(q_normalized.norm(), 1.0);
/// ``` /// ```
#[inline] #[inline]
pub fn normalize(&self) -> Quaternion<N> { pub fn normalize(&self) -> Self {
Quaternion::from(self.coords.normalize()) Self::from(self.coords.normalize())
} }
/// The conjugate of this quaternion. /// The conjugate of this quaternion.
@ -134,14 +134,14 @@ impl<N: Real> Quaternion<N> {
/// assert!(conj.i == -2.0 && conj.j == -3.0 && conj.k == -4.0 && conj.w == 1.0); /// assert!(conj.i == -2.0 && conj.j == -3.0 && conj.k == -4.0 && conj.w == 1.0);
/// ``` /// ```
#[inline] #[inline]
pub fn conjugate(&self) -> Quaternion<N> { pub fn conjugate(&self) -> Self {
let v = Vector4::new( let v = Vector4::new(
-self.coords[0], -self.coords[0],
-self.coords[1], -self.coords[1],
-self.coords[2], -self.coords[2],
self.coords[3], self.coords[3],
); );
Quaternion::from(v) Self::from(v)
} }
/// Inverts this quaternion if it is not zero. /// Inverts this quaternion if it is not zero.
@ -163,8 +163,8 @@ impl<N: Real> Quaternion<N> {
/// assert!(inv_q.is_none()); /// assert!(inv_q.is_none());
/// ``` /// ```
#[inline] #[inline]
pub fn try_inverse(&self) -> Option<Quaternion<N>> { pub fn try_inverse(&self) -> Option<Self> {
let mut res = Quaternion::from(self.coords.clone_owned()); let mut res = Self::from(self.coords.clone_owned());
if res.try_inverse_mut() { if res.try_inverse_mut() {
Some(res) Some(res)
@ -186,7 +186,7 @@ impl<N: Real> Quaternion<N> {
/// assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(1.9, 3.8, 5.7, 7.6)); /// assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(1.9, 3.8, 5.7, 7.6));
/// ``` /// ```
#[inline] #[inline]
pub fn lerp(&self, other: &Quaternion<N>, t: N) -> Quaternion<N> { pub fn lerp(&self, other: &Self, t: N) -> Self {
self * (N::one() - t) + other * t self * (N::one() - t) + other * t
} }
@ -346,12 +346,12 @@ impl<N: Real> Quaternion<N> {
/// assert_relative_eq!(q.ln(), Quaternion::new(1.683647, 1.190289, 0.0, 0.0), epsilon = 1.0e-6) /// assert_relative_eq!(q.ln(), Quaternion::new(1.683647, 1.190289, 0.0, 0.0), epsilon = 1.0e-6)
/// ``` /// ```
#[inline] #[inline]
pub fn ln(&self) -> Quaternion<N> { pub fn ln(&self) -> Self {
let n = self.norm(); let n = self.norm();
let v = self.vector(); let v = self.vector();
let s = self.scalar(); let s = self.scalar();
Quaternion::from_parts(n.ln(), v.normalize() * (s / n).acos()) Self::from_parts(n.ln(), v.normalize() * (s / n).acos())
} }
/// Compute the exponential of a quaternion. /// Compute the exponential of a quaternion.
@ -364,7 +364,7 @@ impl<N: Real> Quaternion<N> {
/// assert_relative_eq!(q.exp(), Quaternion::new(2.0, 5.0, 0.0, 0.0), epsilon = 1.0e-5) /// assert_relative_eq!(q.exp(), Quaternion::new(2.0, 5.0, 0.0, 0.0), epsilon = 1.0e-5)
/// ``` /// ```
#[inline] #[inline]
pub fn exp(&self) -> Quaternion<N> { pub fn exp(&self) -> Self {
self.exp_eps(N::default_epsilon()) self.exp_eps(N::default_epsilon())
} }
@ -383,18 +383,18 @@ impl<N: Real> Quaternion<N> {
/// assert_eq!(q.exp_eps(1.0e-6), Quaternion::identity()); /// assert_eq!(q.exp_eps(1.0e-6), Quaternion::identity());
/// ``` /// ```
#[inline] #[inline]
pub fn exp_eps(&self, eps: N) -> Quaternion<N> { pub fn exp_eps(&self, eps: N) -> Self {
let v = self.vector(); let v = self.vector();
let nn = v.norm_squared(); let nn = v.norm_squared();
if nn <= eps * eps { if nn <= eps * eps {
Quaternion::identity() Self::identity()
} else { } else {
let w_exp = self.scalar().exp(); let w_exp = self.scalar().exp();
let n = nn.sqrt(); let n = nn.sqrt();
let nv = v * (w_exp * n.sin() / n); let nv = v * (w_exp * n.sin() / n);
Quaternion::from_parts(w_exp * n.cos(), nv) Self::from_parts(w_exp * n.cos(), nv)
} }
} }
@ -408,7 +408,7 @@ impl<N: Real> Quaternion<N> {
/// assert_relative_eq!(q.powf(1.5), Quaternion::new( -6.2576659, 4.1549037, 6.2323556, 8.3098075), epsilon = 1.0e-6); /// assert_relative_eq!(q.powf(1.5), Quaternion::new( -6.2576659, 4.1549037, 6.2323556, 8.3098075), epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn powf(&self, n: N) -> Quaternion<N> { pub fn powf(&self, n: N) -> Self {
(self.ln() * n).exp() (self.ln() * n).exp()
} }
@ -520,7 +520,7 @@ impl<N: Real + AbsDiffEq<Epsilon = N>> AbsDiffEq for Quaternion<N> {
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool { fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.as_vector().abs_diff_eq(other.as_vector(), epsilon) || self.as_vector().abs_diff_eq(other.as_vector(), epsilon) ||
// Account for the double-covering of S², i.e. q = -q // Account for the double-covering of S², i.e. q = -q
self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.abs_diff_eq(&-*b, epsilon)) self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.abs_diff_eq(&-*b, epsilon))
} }
} }
@ -540,7 +540,7 @@ impl<N: Real + RelativeEq<Epsilon = N>> RelativeEq for Quaternion<N> {
{ {
self.as_vector().relative_eq(other.as_vector(), epsilon, max_relative) || self.as_vector().relative_eq(other.as_vector(), epsilon, max_relative) ||
// Account for the double-covering of S², i.e. q = -q // Account for the double-covering of S², i.e. q = -q
self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.relative_eq(&-*b, epsilon, max_relative)) self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.relative_eq(&-*b, epsilon, max_relative))
} }
} }
@ -554,7 +554,7 @@ impl<N: Real + UlpsEq<Epsilon = N>> UlpsEq for Quaternion<N> {
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool { fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool {
self.as_vector().ulps_eq(other.as_vector(), epsilon, max_ulps) || self.as_vector().ulps_eq(other.as_vector(), epsilon, max_ulps) ||
// Account for the double-covering of S², i.e. q = -q. // Account for the double-covering of S², i.e. q = -q.
self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.ulps_eq(&-*b, epsilon, max_ulps)) self.as_vector().iter().zip(other.as_vector().iter()).all(|(a, b)| a.ulps_eq(&-*b, epsilon, max_ulps))
} }
} }
@ -577,7 +577,7 @@ impl<N: Real> UnitQuaternion<N> {
#[deprecated( #[deprecated(
note = "This method is unnecessary and will be removed in a future release. Use `.clone()` instead." note = "This method is unnecessary and will be removed in a future release. Use `.clone()` instead."
)] )]
pub fn into_owned(self) -> UnitQuaternion<N> { pub fn into_owned(self) -> Self {
self self
} }
@ -586,7 +586,7 @@ impl<N: Real> UnitQuaternion<N> {
#[deprecated( #[deprecated(
note = "This method is unnecessary and will be removed in a future release. Use `.clone()` instead." note = "This method is unnecessary and will be removed in a future release. Use `.clone()` instead."
)] )]
pub fn clone_owned(&self) -> UnitQuaternion<N> { pub fn clone_owned(&self) -> Self {
*self *self
} }
@ -637,8 +637,8 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_eq!(conj, UnitQuaternion::from_axis_angle(&-axis, 1.78)); /// assert_eq!(conj, UnitQuaternion::from_axis_angle(&-axis, 1.78));
/// ``` /// ```
#[inline] #[inline]
pub fn conjugate(&self) -> UnitQuaternion<N> { pub fn conjugate(&self) -> Self {
UnitQuaternion::new_unchecked(self.as_ref().conjugate()) Self::new_unchecked(self.as_ref().conjugate())
} }
/// Inverts this quaternion if it is not zero. /// Inverts this quaternion if it is not zero.
@ -653,7 +653,7 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_eq!(inv * rot, UnitQuaternion::identity()); /// assert_eq!(inv * rot, UnitQuaternion::identity());
/// ``` /// ```
#[inline] #[inline]
pub fn inverse(&self) -> UnitQuaternion<N> { pub fn inverse(&self) -> Self {
self.conjugate() self.conjugate()
} }
@ -668,7 +668,7 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_relative_eq!(rot1.angle_to(&rot2), 1.0045657, epsilon = 1.0e-6); /// assert_relative_eq!(rot1.angle_to(&rot2), 1.0045657, epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn angle_to(&self, other: &UnitQuaternion<N>) -> N { pub fn angle_to(&self, other: &Self) -> N {
let delta = self.rotation_to(other); let delta = self.rotation_to(other);
delta.angle() delta.angle()
} }
@ -687,7 +687,7 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_relative_eq!(rot_to * rot1, rot2, epsilon = 1.0e-6); /// assert_relative_eq!(rot_to * rot1, rot2, epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn rotation_to(&self, other: &UnitQuaternion<N>) -> UnitQuaternion<N> { pub fn rotation_to(&self, other: &Self) -> Self{
other / self other / self
} }
@ -703,7 +703,7 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(0.9, 0.1, 0.0, 0.0)); /// assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(0.9, 0.1, 0.0, 0.0));
/// ``` /// ```
#[inline] #[inline]
pub fn lerp(&self, other: &UnitQuaternion<N>, t: N) -> Quaternion<N> { pub fn lerp(&self, other: &Self, t: N) -> Quaternion<N> {
self.as_ref().lerp(other.as_ref(), t) self.as_ref().lerp(other.as_ref(), t)
} }
@ -719,11 +719,11 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_eq!(q1.nlerp(&q2, 0.1), UnitQuaternion::new_normalize(Quaternion::new(0.9, 0.1, 0.0, 0.0))); /// assert_eq!(q1.nlerp(&q2, 0.1), UnitQuaternion::new_normalize(Quaternion::new(0.9, 0.1, 0.0, 0.0)));
/// ``` /// ```
#[inline] #[inline]
pub fn nlerp(&self, other: &UnitQuaternion<N>, t: N) -> UnitQuaternion<N> { pub fn nlerp(&self, other: &Self, t: N) -> Self {
let mut res = self.lerp(other, t); let mut res = self.lerp(other, t);
let _ = res.normalize_mut(); let _ = res.normalize_mut();
UnitQuaternion::new_unchecked(res) Self::new_unchecked(res)
} }
/// Spherical linear interpolation between two unit quaternions. /// Spherical linear interpolation between two unit quaternions.
@ -731,7 +731,7 @@ impl<N: Real> UnitQuaternion<N> {
/// Panics if the angle between both quaternion is 180 degrees (in which case the interpolation /// Panics if the angle between both quaternion is 180 degrees (in which case the interpolation
/// is not well-defined). Use `.try_slerp` instead to avoid the panic. /// is not well-defined). Use `.try_slerp` instead to avoid the panic.
#[inline] #[inline]
pub fn slerp(&self, other: &UnitQuaternion<N>, t: N) -> UnitQuaternion<N> { pub fn slerp(&self, other: &Self, t: N) -> Self {
Unit::new_unchecked(Quaternion::from( Unit::new_unchecked(Quaternion::from(
Unit::new_unchecked(self.coords) Unit::new_unchecked(self.coords)
.slerp(&Unit::new_unchecked(other.coords), t) .slerp(&Unit::new_unchecked(other.coords), t)
@ -752,10 +752,10 @@ impl<N: Real> UnitQuaternion<N> {
#[inline] #[inline]
pub fn try_slerp( pub fn try_slerp(
&self, &self,
other: &UnitQuaternion<N>, other: &Self,
t: N, t: N,
epsilon: N, epsilon: N,
) -> Option<UnitQuaternion<N>> ) -> Option<Self>
{ {
Unit::new_unchecked(self.coords) Unit::new_unchecked(self.coords)
.try_slerp(&Unit::new_unchecked(other.coords), t, epsilon) .try_slerp(&Unit::new_unchecked(other.coords), t, epsilon)
@ -902,11 +902,11 @@ impl<N: Real> UnitQuaternion<N> {
/// assert_eq!(pow.angle(), 2.4); /// assert_eq!(pow.angle(), 2.4);
/// ``` /// ```
#[inline] #[inline]
pub fn powf(&self, n: N) -> UnitQuaternion<N> { pub fn powf(&self, n: N) -> Self {
if let Some(v) = self.axis() { if let Some(v) = self.axis() {
UnitQuaternion::from_axis_angle(&v, self.angle() * n) Self::from_axis_angle(&v, self.angle() * n)
} else { } else {
UnitQuaternion::identity() Self::identity()
} }
} }

View File

@ -25,7 +25,7 @@ impl<N: Real> Quaternion<N> {
#[inline] #[inline]
#[deprecated(note = "Use `::from` instead.")] #[deprecated(note = "Use `::from` instead.")]
pub fn from_vector(vector: Vector4<N>) -> Self { pub fn from_vector(vector: Vector4<N>) -> Self {
Quaternion { coords: vector } Self { coords: vector }
} }
/// Creates a new quaternion from its individual components. Note that the arguments order does /// Creates a new quaternion from its individual components. Note that the arguments order does
@ -130,7 +130,7 @@ where Owned<N, U4>: Send
{ {
#[inline] #[inline]
fn arbitrary<G: Gen>(g: &mut G) -> Self { fn arbitrary<G: Gen>(g: &mut G) -> Self {
Quaternion::new( Self::new(
N::arbitrary(g), N::arbitrary(g),
N::arbitrary(g), N::arbitrary(g),
N::arbitrary(g), N::arbitrary(g),
@ -683,7 +683,7 @@ where
#[inline] #[inline]
fn arbitrary<G: Gen>(g: &mut G) -> Self { fn arbitrary<G: Gen>(g: &mut G) -> Self {
let axisangle = Vector3::arbitrary(g); let axisangle = Vector3::arbitrary(g);
UnitQuaternion::from_scaled_axis(axisangle) Self::from_scaled_axis(axisangle)
} }
} }

View File

@ -103,7 +103,7 @@ impl<N1, N2, R> SubsetOf<Isometry<N2, U3, R>> for UnitQuaternion<N1>
where where
N1: Real, N1: Real,
N2: Real + SupersetOf<N1>, N2: Real + SupersetOf<N1>,
R: AlgaRotation<Point3<N2>> + SupersetOf<UnitQuaternion<N1>>, R: AlgaRotation<Point3<N2>> + SupersetOf<Self>,
{ {
#[inline] #[inline]
fn to_superset(&self) -> Isometry<N2, U3, R> { fn to_superset(&self) -> Isometry<N2, U3, R> {
@ -125,7 +125,7 @@ impl<N1, N2, R> SubsetOf<Similarity<N2, U3, R>> for UnitQuaternion<N1>
where where
N1: Real, N1: Real,
N2: Real + SupersetOf<N1>, N2: Real + SupersetOf<N1>,
R: AlgaRotation<Point3<N2>> + SupersetOf<UnitQuaternion<N1>>, R: AlgaRotation<Point3<N2>> + SupersetOf<Self>,
{ {
#[inline] #[inline]
fn to_superset(&self) -> Similarity<N2, U3, R> { fn to_superset(&self) -> Similarity<N2, U3, R> {
@ -186,7 +186,7 @@ impl<N1: Real, N2: Real + SupersetOf<N1>> SubsetOf<Matrix4<N2>> for UnitQuaterni
#[cfg(feature = "mint")] #[cfg(feature = "mint")]
impl<N: Real> From<mint::Quaternion<N>> for Quaternion<N> { impl<N: Real> From<mint::Quaternion<N>> for Quaternion<N> {
fn from(q: mint::Quaternion<N>) -> Self { fn from(q: mint::Quaternion<N>) -> Self {
Quaternion::new(q.s, q.v.x, q.v.y, q.v.z) Self::new(q.s, q.v.x, q.v.y, q.v.z)
} }
} }
@ -220,14 +220,14 @@ impl<N: Real> Into<mint::Quaternion<N>> for UnitQuaternion<N> {
impl<N: Real> From<UnitQuaternion<N>> for Matrix4<N> { impl<N: Real> From<UnitQuaternion<N>> for Matrix4<N> {
#[inline] #[inline]
fn from(q: UnitQuaternion<N>) -> Matrix4<N> { fn from(q: UnitQuaternion<N>) -> Self {
q.to_homogeneous() q.to_homogeneous()
} }
} }
impl<N: Real> From<UnitQuaternion<N>> for Matrix3<N> { impl<N: Real> From<UnitQuaternion<N>> for Matrix3<N> {
#[inline] #[inline]
fn from(q: UnitQuaternion<N>) -> Matrix3<N> { fn from(q: UnitQuaternion<N>) -> Self {
q.to_rotation_matrix().into_inner() q.to_rotation_matrix().into_inner()
} }
} }
@ -235,6 +235,6 @@ impl<N: Real> From<UnitQuaternion<N>> for Matrix3<N> {
impl<N: Real> From<Vector4<N>> for Quaternion<N> { impl<N: Real> From<Vector4<N>> for Quaternion<N> {
#[inline] #[inline]
fn from(coords: Vector4<N>) -> Self { fn from(coords: Vector4<N>) -> Self {
Quaternion { coords } Self { coords }
} }
} }

View File

@ -67,7 +67,7 @@ impl<N: Real> Index<usize> for Quaternion<N> {
type Output = N; type Output = N;
#[inline] #[inline]
fn index(&self, i: usize) -> &N { fn index(&self, i: usize) -> &Self::Output {
&self.coords[i] &self.coords[i]
} }
} }

View File

@ -18,8 +18,8 @@ impl<N: Real, D: Dim, S: Storage<N, D>> Reflection<N, D, S> {
/// ///
/// The bias is the position of the plane on the axis. In particular, a bias equal to zero /// The bias is the position of the plane on the axis. In particular, a bias equal to zero
/// represents a plane that passes through the origin. /// represents a plane that passes through the origin.
pub fn new(axis: Unit<Vector<N, D, S>>, bias: N) -> Reflection<N, D, S> { pub fn new(axis: Unit<Vector<N, D, S>>, bias: N) -> Self {
Reflection { Self {
axis: axis.into_inner(), axis: axis.into_inner(),
bias: bias, bias: bias,
} }
@ -30,7 +30,7 @@ impl<N: Real, D: Dim, S: Storage<N, D>> Reflection<N, D, S> {
pub fn new_containing_point( pub fn new_containing_point(
axis: Unit<Vector<N, D, S>>, axis: Unit<Vector<N, D, S>>,
pt: &Point<N, D>, pt: &Point<N, D>,
) -> Reflection<N, D, S> ) -> Self
where where
D: DimName, D: DimName,
DefaultAllocator: Allocator<N, D>, DefaultAllocator: Allocator<N, D>,

View File

@ -53,7 +53,7 @@ where
{ {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Rotation::from_matrix_unchecked(self.matrix.clone()) Self::from_matrix_unchecked(self.matrix.clone())
} }
} }
@ -100,7 +100,7 @@ where
where Des: Deserializer<'a> { where Des: Deserializer<'a> {
let matrix = MatrixN::<N, D>::deserialize(deserializer)?; let matrix = MatrixN::<N, D>::deserialize(deserializer)?;
Ok(Rotation::from_matrix_unchecked(matrix)) Ok(Self::from_matrix_unchecked(matrix))
} }
} }
@ -241,13 +241,13 @@ where DefaultAllocator: Allocator<N, D, D>
/// assert_eq!(*rot.matrix(), mat); /// assert_eq!(*rot.matrix(), mat);
/// ``` /// ```
#[inline] #[inline]
pub fn from_matrix_unchecked(matrix: MatrixN<N, D>) -> Rotation<N, D> { pub fn from_matrix_unchecked(matrix: MatrixN<N, D>) -> Self {
assert!( assert!(
matrix.is_square(), matrix.is_square(),
"Unable to create a rotation from a non-square matrix." "Unable to create a rotation from a non-square matrix."
); );
Rotation { matrix: matrix } Self { matrix: matrix }
} }
/// Transposes `self`. /// Transposes `self`.
@ -269,8 +269,8 @@ where DefaultAllocator: Allocator<N, D, D>
/// assert_relative_eq!(tr_rot * rot, Rotation2::identity(), epsilon = 1.0e-6); /// assert_relative_eq!(tr_rot * rot, Rotation2::identity(), epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn transpose(&self) -> Rotation<N, D> { pub fn transpose(&self) -> Self {
Rotation::from_matrix_unchecked(self.matrix.transpose()) Self::from_matrix_unchecked(self.matrix.transpose())
} }
/// Inverts `self`. /// Inverts `self`.
@ -292,7 +292,7 @@ where DefaultAllocator: Allocator<N, D, D>
/// assert_relative_eq!(inv * rot, Rotation2::identity(), epsilon = 1.0e-6); /// assert_relative_eq!(inv * rot, Rotation2::identity(), epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn inverse(&self) -> Rotation<N, D> { pub fn inverse(&self) -> Self {
self.transpose() self.transpose()
} }
@ -357,7 +357,7 @@ impl<N: Scalar + PartialEq, D: DimName> PartialEq for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> where DefaultAllocator: Allocator<N, D, D>
{ {
#[inline] #[inline]
fn eq(&self, right: &Rotation<N, D>) -> bool { fn eq(&self, right: &Self) -> bool {
self.matrix == right.matrix self.matrix == right.matrix
} }
} }

View File

@ -102,7 +102,7 @@ impl<N1, N2, D: DimName, R> SubsetOf<Isometry<N2, D, R>> for Rotation<N1, D>
where where
N1: Real, N1: Real,
N2: Real + SupersetOf<N1>, N2: Real + SupersetOf<N1>,
R: AlgaRotation<Point<N2, D>> + SupersetOf<Rotation<N1, D>>, R: AlgaRotation<Point<N2, D>> + SupersetOf<Self>,
DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D>, DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D>,
{ {
#[inline] #[inline]
@ -125,7 +125,7 @@ impl<N1, N2, D: DimName, R> SubsetOf<Similarity<N2, D, R>> for Rotation<N1, D>
where where
N1: Real, N1: Real,
N2: Real + SupersetOf<N1>, N2: Real + SupersetOf<N1>,
R: AlgaRotation<Point<N2, D>> + SupersetOf<Rotation<N1, D>>, R: AlgaRotation<Point<N2, D>> + SupersetOf<Self>,
DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D>, DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D>,
{ {
#[inline] #[inline]
@ -219,28 +219,28 @@ impl<N: Real> From<mint::EulerAngles<N, mint::IntraXYZ>> for Rotation3<N> {
impl<N: Real> From<Rotation2<N>> for Matrix3<N> { impl<N: Real> From<Rotation2<N>> for Matrix3<N> {
#[inline] #[inline]
fn from(q: Rotation2<N>) -> Matrix3<N> { fn from(q: Rotation2<N>) ->Self {
q.to_homogeneous() q.to_homogeneous()
} }
} }
impl<N: Real> From<Rotation2<N>> for Matrix2<N> { impl<N: Real> From<Rotation2<N>> for Matrix2<N> {
#[inline] #[inline]
fn from(q: Rotation2<N>) -> Matrix2<N> { fn from(q: Rotation2<N>) -> Self {
q.into_inner() q.into_inner()
} }
} }
impl<N: Real> From<Rotation3<N>> for Matrix4<N> { impl<N: Real> From<Rotation3<N>> for Matrix4<N> {
#[inline] #[inline]
fn from(q: Rotation3<N>) -> Matrix4<N> { fn from(q: Rotation3<N>) -> Self {
q.to_homogeneous() q.to_homogeneous()
} }
} }
impl<N: Real> From<Rotation3<N>> for Matrix3<N> { impl<N: Real> From<Rotation3<N>> for Matrix3<N> {
#[inline] #[inline]
fn from(q: Rotation3<N>) -> Matrix3<N> { fn from(q: Rotation3<N>) -> Self {
q.into_inner() q.into_inner()
} }
} }

View File

@ -125,7 +125,7 @@ impl<N: Real> Rotation2<N> {
/// assert_relative_eq!(rot1.angle_to(&rot2), 1.6); /// assert_relative_eq!(rot1.angle_to(&rot2), 1.6);
/// ``` /// ```
#[inline] #[inline]
pub fn angle_to(&self, other: &Rotation2<N>) -> N { pub fn angle_to(&self, other: &Self) -> N {
self.rotation_to(other).angle() self.rotation_to(other).angle()
} }
@ -145,7 +145,7 @@ impl<N: Real> Rotation2<N> {
/// assert_relative_eq!(rot_to.inverse() * rot2, rot1); /// assert_relative_eq!(rot_to.inverse() * rot2, rot1);
/// ``` /// ```
#[inline] #[inline]
pub fn rotation_to(&self, other: &Rotation2<N>) -> Rotation2<N> { pub fn rotation_to(&self, other: &Self) -> Self {
other * self.inverse() other * self.inverse()
} }
@ -161,7 +161,7 @@ impl<N: Real> Rotation2<N> {
/// assert_relative_eq!(pow.angle(), 2.0 * 0.78); /// assert_relative_eq!(pow.angle(), 2.0 * 0.78);
/// ``` /// ```
#[inline] #[inline]
pub fn powf(&self, n: N) -> Rotation2<N> { pub fn powf(&self, n: N) -> Self {
Self::new(self.angle() * n) Self::new(self.angle() * n)
} }
@ -655,7 +655,7 @@ impl<N: Real> Rotation3<N> {
/// assert_relative_eq!(rot1.angle_to(&rot2), 1.0045657, epsilon = 1.0e-6); /// assert_relative_eq!(rot1.angle_to(&rot2), 1.0045657, epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn angle_to(&self, other: &Rotation3<N>) -> N { pub fn angle_to(&self, other: &Self) -> N {
self.rotation_to(other).angle() self.rotation_to(other).angle()
} }
@ -673,7 +673,7 @@ impl<N: Real> Rotation3<N> {
/// assert_relative_eq!(rot_to * rot1, rot2, epsilon = 1.0e-6); /// assert_relative_eq!(rot_to * rot1, rot2, epsilon = 1.0e-6);
/// ``` /// ```
#[inline] #[inline]
pub fn rotation_to(&self, other: &Rotation3<N>) -> Rotation3<N> { pub fn rotation_to(&self, other: &Self) -> Self {
other * self.inverse() other * self.inverse()
} }
@ -692,7 +692,7 @@ impl<N: Real> Rotation3<N> {
/// assert_eq!(pow.angle(), 2.4); /// assert_eq!(pow.angle(), 2.4);
/// ``` /// ```
#[inline] #[inline]
pub fn powf(&self, n: N) -> Rotation3<N> { pub fn powf(&self, n: N) -> Self {
if let Some(axis) = self.axis() { if let Some(axis) = self.axis() {
Self::from_axis_angle(&axis, self.angle() * n) Self::from_axis_angle(&axis, self.angle() * n)
} else if self.matrix()[(0, 0)] < N::zero() { } else if self.matrix()[(0, 0)] < N::zero() {

View File

@ -106,20 +106,20 @@ where
translation: Translation<N, D>, translation: Translation<N, D>,
rotation: R, rotation: R,
scaling: N, scaling: N,
) -> Similarity<N, D, R> ) -> Self
{ {
Similarity::from_isometry(Isometry::from_parts(translation, rotation), scaling) Self::from_isometry(Isometry::from_parts(translation, rotation), scaling)
} }
/// Creates a new similarity from its rotational and translational parts. /// Creates a new similarity from its rotational and translational parts.
#[inline] #[inline]
pub fn from_isometry(isometry: Isometry<N, D, R>, scaling: N) -> Similarity<N, D, R> { pub fn from_isometry(isometry: Isometry<N, D, R>, scaling: N) -> Self {
assert!( assert!(
!relative_eq!(scaling, N::zero()), !relative_eq!(scaling, N::zero()),
"The scaling factor must not be zero." "The scaling factor must not be zero."
); );
Similarity { Self {
isometry: isometry, isometry: isometry,
scaling: scaling, scaling: scaling,
} }
@ -127,13 +127,13 @@ where
/// Creates a new similarity that applies only a scaling factor. /// Creates a new similarity that applies only a scaling factor.
#[inline] #[inline]
pub fn from_scaling(scaling: N) -> Similarity<N, D, R> { pub fn from_scaling(scaling: N) -> Self {
Self::from_isometry(Isometry::identity(), scaling) Self::from_isometry(Isometry::identity(), scaling)
} }
/// Inverts `self`. /// Inverts `self`.
#[inline] #[inline]
pub fn inverse(&self) -> Similarity<N, D, R> { pub fn inverse(&self) -> Self {
let mut res = self.clone(); let mut res = self.clone();
res.inverse_mut(); res.inverse_mut();
res res
@ -277,7 +277,7 @@ where
DefaultAllocator: Allocator<N, D>, DefaultAllocator: Allocator<N, D>,
{ {
#[inline] #[inline]
fn eq(&self, right: &Similarity<N, D, R>) -> bool { fn eq(&self, right: &Self) -> bool {
self.isometry == right.isometry && self.scaling == right.scaling self.isometry == right.isometry && self.scaling == right.scaling
} }
} }

View File

@ -57,7 +57,7 @@ where
#[inline] #[inline]
unsafe fn from_superset_unchecked(m: &MatrixN<N2, DimNameSum<D, U1>>) -> Self { unsafe fn from_superset_unchecked(m: &MatrixN<N2, DimNameSum<D, U1>>) -> Self {
Transform::from_matrix_unchecked(::convert_ref_unchecked(m)) Self::from_matrix_unchecked(::convert_ref_unchecked(m))
} }
} }

View File

@ -108,7 +108,7 @@ impl<N: Real> UnitComplex<N> {
/// ``` /// ```
#[inline] #[inline]
pub fn conjugate(&self) -> Self { pub fn conjugate(&self) -> Self {
UnitComplex::new_unchecked(self.conj()) Self::new_unchecked(self.conj())
} }
/// Inverts this complex number if it is not zero. /// Inverts this complex number if it is not zero.
@ -314,7 +314,7 @@ impl<N: Real> From<UnitComplex<N>> for Matrix3<N> {
impl<N: Real> From<UnitComplex<N>> for Matrix2<N> { impl<N: Real> From<UnitComplex<N>> for Matrix2<N> {
#[inline] #[inline]
fn from(q: UnitComplex<N>) -> Matrix2<N> { fn from(q: UnitComplex<N>) -> Self {
q.to_rotation_matrix().into_inner() q.to_rotation_matrix().into_inner()
} }
} }

View File

@ -85,7 +85,7 @@ impl<N: Real> UnitComplex<N> {
/// ``` /// ```
#[inline] #[inline]
pub fn from_cos_sin_unchecked(cos: N, sin: N) -> Self { pub fn from_cos_sin_unchecked(cos: N, sin: N) -> Self {
UnitComplex::new_unchecked(Complex::new(cos, sin)) Self::new_unchecked(Complex::new(cos, sin))
} }
/// Builds a unit complex rotation from an angle in radian wrapped in a 1-dimensional vector. /// Builds a unit complex rotation from an angle in radian wrapped in a 1-dimensional vector.

View File

@ -74,7 +74,7 @@ impl<N1, N2, R> SubsetOf<Isometry<N2, U2, R>> for UnitComplex<N1>
where where
N1: Real, N1: Real,
N2: Real + SupersetOf<N1>, N2: Real + SupersetOf<N1>,
R: AlgaRotation<Point2<N2>> + SupersetOf<UnitComplex<N1>>, R: AlgaRotation<Point2<N2>> + SupersetOf<Self>,
{ {
#[inline] #[inline]
fn to_superset(&self) -> Isometry<N2, U2, R> { fn to_superset(&self) -> Isometry<N2, U2, R> {
@ -96,7 +96,7 @@ impl<N1, N2, R> SubsetOf<Similarity<N2, U2, R>> for UnitComplex<N1>
where where
N1: Real, N1: Real,
N2: Real + SupersetOf<N1>, N2: Real + SupersetOf<N1>,
R: AlgaRotation<Point2<N2>> + SupersetOf<UnitComplex<N1>>, R: AlgaRotation<Point2<N2>> + SupersetOf<Self>,
{ {
#[inline] #[inline]
fn to_superset(&self) -> Similarity<N2, U2, R> { fn to_superset(&self) -> Similarity<N2, U2, R> {

View File

@ -45,11 +45,11 @@ use geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex}
*/ */
// UnitComplex × UnitComplex // UnitComplex × UnitComplex
impl<N: Real> Mul<UnitComplex<N>> for UnitComplex<N> { impl<N: Real> Mul<Self> for UnitComplex<N> {
type Output = UnitComplex<N>; type Output = Self;
#[inline] #[inline]
fn mul(self, rhs: UnitComplex<N>) -> UnitComplex<N> { fn mul(self, rhs: Self) -> Self {
Unit::new_unchecked(self.into_inner() * rhs.into_inner()) Unit::new_unchecked(self.into_inner() * rhs.into_inner())
} }
} }
@ -58,16 +58,16 @@ impl<'a, N: Real> Mul<UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>; type Output = UnitComplex<N>;
#[inline] #[inline]
fn mul(self, rhs: UnitComplex<N>) -> UnitComplex<N> { fn mul(self, rhs: UnitComplex<N>) -> Self::Output {
Unit::new_unchecked(self.complex() * rhs.into_inner()) Unit::new_unchecked(self.complex() * rhs.into_inner())
} }
} }
impl<'b, N: Real> Mul<&'b UnitComplex<N>> for UnitComplex<N> { impl<'b, N: Real> Mul<&'b UnitComplex<N>> for UnitComplex<N> {
type Output = UnitComplex<N>; type Output = Self;
#[inline] #[inline]
fn mul(self, rhs: &'b UnitComplex<N>) -> UnitComplex<N> { fn mul(self, rhs: &'b UnitComplex<N>) -> Self::Output {
Unit::new_unchecked(self.into_inner() * rhs.complex()) Unit::new_unchecked(self.into_inner() * rhs.complex())
} }
} }
@ -76,17 +76,17 @@ impl<'a, 'b, N: Real> Mul<&'b UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>; type Output = UnitComplex<N>;
#[inline] #[inline]
fn mul(self, rhs: &'b UnitComplex<N>) -> UnitComplex<N> { fn mul(self, rhs: &'b UnitComplex<N>) -> Self::Output {
Unit::new_unchecked(self.complex() * rhs.complex()) Unit::new_unchecked(self.complex() * rhs.complex())
} }
} }
// UnitComplex ÷ UnitComplex // UnitComplex ÷ UnitComplex
impl<N: Real> Div<UnitComplex<N>> for UnitComplex<N> { impl<N: Real> Div<Self> for UnitComplex<N> {
type Output = UnitComplex<N>; type Output = Self;
#[inline] #[inline]
fn div(self, rhs: UnitComplex<N>) -> UnitComplex<N> { fn div(self, rhs: Self) -> Self::Output {
Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner())
} }
} }
@ -95,16 +95,16 @@ impl<'a, N: Real> Div<UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>; type Output = UnitComplex<N>;
#[inline] #[inline]
fn div(self, rhs: UnitComplex<N>) -> UnitComplex<N> { fn div(self, rhs: UnitComplex<N>) -> Self::Output {
Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner())
} }
} }
impl<'b, N: Real> Div<&'b UnitComplex<N>> for UnitComplex<N> { impl<'b, N: Real> Div<&'b UnitComplex<N>> for UnitComplex<N> {
type Output = UnitComplex<N>; type Output = Self;
#[inline] #[inline]
fn div(self, rhs: &'b UnitComplex<N>) -> UnitComplex<N> { fn div(self, rhs: &'b UnitComplex<N>) -> Self::Output {
Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.into_inner() * rhs.conjugate().into_inner())
} }
} }
@ -113,7 +113,7 @@ impl<'a, 'b, N: Real> Div<&'b UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>; type Output = UnitComplex<N>;
#[inline] #[inline]
fn div(self, rhs: &'b UnitComplex<N>) -> UnitComplex<N> { fn div(self, rhs: &'b UnitComplex<N>) -> Self::Output {
Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner()) Unit::new_unchecked(self.complex() * rhs.conjugate().into_inner())
} }
} }

View File

@ -61,7 +61,7 @@ where DefaultAllocator: Allocator<N, R, C> + Allocator<(usize, usize), DimMinimu
let mut q = PermutationSequence::identity_generic(min_nrows_ncols); let mut q = PermutationSequence::identity_generic(min_nrows_ncols);
if min_nrows_ncols.value() == 0 { if min_nrows_ncols.value() == 0 {
return FullPivLU { return Self {
lu: matrix, lu: matrix,
p: p, p: p,
q: q, q: q,
@ -91,7 +91,7 @@ where DefaultAllocator: Allocator<N, R, C> + Allocator<(usize, usize), DimMinimu
} }
} }
FullPivLU { Self {
lu: matrix, lu: matrix,
p: p, p: p,
q: q, q: q,

View File

@ -69,7 +69,7 @@ where DefaultAllocator: Allocator<(usize, usize), D>
#[inline] #[inline]
pub fn identity_generic(dim: D) -> Self { pub fn identity_generic(dim: D) -> Self {
unsafe { unsafe {
PermutationSequence { Self {
len: 0, len: 0,
ipiv: VectorN::new_uninitialized_generic(dim, U1), ipiv: VectorN::new_uninitialized_generic(dim, U1),
} }

View File

@ -55,7 +55,7 @@ where
+ Allocator<N, D>, + Allocator<N, D>,
{ {
/// Computes the Schur decomposition of a square matrix. /// Computes the Schur decomposition of a square matrix.
pub fn new(m: MatrixN<N, D>) -> RealSchur<N, D> { pub fn new(m: MatrixN<N, D>) -> Self {
Self::try_new(m, N::default_epsilon(), 0).unwrap() Self::try_new(m, N::default_epsilon(), 0).unwrap()
} }
@ -70,7 +70,7 @@ where
/// * `max_niter` maximum total number of iterations performed by the algorithm. If this /// * `max_niter` maximum total number of iterations performed by the algorithm. If this
/// number of iteration is exceeded, `None` is returned. If `niter == 0`, then the algorithm /// number of iteration is exceeded, `None` is returned. If `niter == 0`, then the algorithm
/// continues indefinitely until convergence. /// continues indefinitely until convergence.
pub fn try_new(m: MatrixN<N, D>, eps: N, max_niter: usize) -> Option<RealSchur<N, D>> { pub fn try_new(m: MatrixN<N, D>, eps: N, max_niter: usize) -> Option<Self> {
let mut work = unsafe { VectorN::new_uninitialized_generic(m.data.shape().0, U1) }; let mut work = unsafe { VectorN::new_uninitialized_generic(m.data.shape().0, U1) };
Self::do_decompose(m, &mut work, eps, max_niter, true).map(|(q, t)| RealSchur { Self::do_decompose(m, &mut work, eps, max_niter, true).map(|(q, t)| RealSchur {

View File

@ -271,7 +271,7 @@ where
} }
} }
Some(SVD { Some(Self {
u: u, u: u,
v_t: v_t, v_t: v_t,
singular_values: b.diagonal, singular_values: b.diagonal,

View File

@ -83,7 +83,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>>
} }
} }
SymmetricTridiagonal { Self {
tri: m, tri: m,
off_diagonal: off_diagonal, off_diagonal: off_diagonal,
} }

View File

@ -21,7 +21,7 @@ impl<'a, N> ColumnEntries<'a, N> {
#[inline] #[inline]
pub fn new(i: &'a [usize], v: &'a [N]) -> Self { pub fn new(i: &'a [usize], v: &'a [N]) -> Self {
assert_eq!(i.len(), v.len()); assert_eq!(i.len(), v.len());
ColumnEntries { curr: 0, i, v } Self { curr: 0, i, v }
} }
} }
@ -29,7 +29,7 @@ impl<'a, N: Copy> Iterator for ColumnEntries<'a, N> {
type Item = (usize, N); type Item = (usize, N);
#[inline] #[inline]
fn next(&mut self) -> Option<(usize, N)> { fn next(&mut self) -> Option<Self::Item> {
if self.curr >= self.i.len() { if self.curr >= self.i.len() {
None None
} else { } else {

View File

@ -138,7 +138,7 @@ where
{ {
type Output = CsMatrix<N, R1, C2>; type Output = CsMatrix<N, R1, C2>;
fn mul(self, rhs: &'b CsMatrix<N, R2, C2, S2>) -> CsMatrix<N, R1, C2> { fn mul(self, rhs: &'b CsMatrix<N, R2, C2, S2>) -> Self::Output {
let (nrows1, ncols1) = self.data.shape(); let (nrows1, ncols1) = self.data.shape();
let (nrows2, ncols2) = rhs.data.shape(); let (nrows2, ncols2) = rhs.data.shape();
assert_eq!( assert_eq!(
@ -231,7 +231,7 @@ where
{ {
type Output = CsMatrix<N, R1, C2>; type Output = CsMatrix<N, R1, C2>;
fn add(self, rhs: &'b CsMatrix<N, R2, C2, S2>) -> CsMatrix<N, R1, C2> { fn add(self, rhs: &'b CsMatrix<N, R2, C2, S2>) -> Self::Output {
let (nrows1, ncols1) = self.data.shape(); let (nrows1, ncols1) = self.data.shape();
let (nrows2, ncols2) = rhs.data.shape(); let (nrows2, ncols2) = rhs.data.shape();
assert_eq!( assert_eq!(
@ -294,7 +294,7 @@ where
{ {
type Output = Self; type Output = Self;
fn mul(mut self, rhs: N) -> Self { fn mul(mut self, rhs: N) -> Self::Output {
for e in self.values_mut() { for e in self.values_mut() {
*e *= rhs *e *= rhs
} }