commit
81d2cbf96c
@ -530,7 +530,7 @@ pub fn perspective_lh_no<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> T
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!relative_eq!(aspect, N::zero()),
|
!relative_eq!(aspect, N::zero()),
|
||||||
"The apsect ratio must not be zero."
|
"The aspect ratio must not be zero."
|
||||||
);
|
);
|
||||||
|
|
||||||
let one = N::one();
|
let one = N::one();
|
||||||
@ -566,7 +566,7 @@ pub fn perspective_lh_zo<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> T
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!relative_eq!(aspect, N::zero()),
|
!relative_eq!(aspect, N::zero()),
|
||||||
"The apsect ratio must not be zero."
|
"The aspect ratio must not be zero."
|
||||||
);
|
);
|
||||||
|
|
||||||
let one = N::one();
|
let one = N::one();
|
||||||
@ -632,7 +632,7 @@ pub fn perspective_rh_no<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> T
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!relative_eq!(aspect, N::zero()),
|
!relative_eq!(aspect, N::zero()),
|
||||||
"The apsect ratio must not be zero."
|
"The aspect ratio must not be zero."
|
||||||
);
|
);
|
||||||
|
|
||||||
let negone = -N::one();
|
let negone = -N::one();
|
||||||
@ -669,7 +669,7 @@ pub fn perspective_rh_zo<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> T
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!relative_eq!(aspect, N::zero()),
|
!relative_eq!(aspect, N::zero()),
|
||||||
"The apsect ratio must not be zero."
|
"The aspect ratio must not be zero."
|
||||||
);
|
);
|
||||||
|
|
||||||
let negone = -N::one();
|
let negone = -N::one();
|
||||||
|
@ -363,8 +363,8 @@ where
|
|||||||
|
|
||||||
while self.nrows() - i >= 8 {
|
while self.nrows() - i >= 8 {
|
||||||
acc0 += unsafe {
|
acc0 += unsafe {
|
||||||
conjugate(self.get_unchecked((i + 0, j)).inlined_clone())
|
conjugate(self.get_unchecked((i, j)).inlined_clone())
|
||||||
* rhs.get_unchecked((i + 0, j)).inlined_clone()
|
* rhs.get_unchecked((i, j)).inlined_clone()
|
||||||
};
|
};
|
||||||
acc1 += unsafe {
|
acc1 += unsafe {
|
||||||
conjugate(self.get_unchecked((i + 1, j)).inlined_clone())
|
conjugate(self.get_unchecked((i + 1, j)).inlined_clone())
|
||||||
|
@ -23,7 +23,7 @@ impl Dynamic {
|
|||||||
/// A dynamic size equal to `value`.
|
/// A dynamic size equal to `value`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(value: usize) -> Self {
|
pub fn new(value: usize) -> Self {
|
||||||
Self { value: value }
|
Self { value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ impl<N: Scalar, R: Dim, C: Dim, S> Matrix<N, R, C, S> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_data_statically_unchecked(data: S) -> Matrix<N, R, C, S> {
|
pub unsafe fn from_data_statically_unchecked(data: S) -> Matrix<N, R, C, S> {
|
||||||
Matrix {
|
Matrix {
|
||||||
data: data,
|
data,
|
||||||
_phantoms: PhantomData,
|
_phantoms: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,7 @@ impl<N, R: Dim, C: Dim> VecStorage<N, R, C> {
|
|||||||
nrows.value() * ncols.value() == data.len(),
|
nrows.value() * ncols.value() == data.len(),
|
||||||
"Data storage buffer dimension mismatch."
|
"Data storage buffer dimension mismatch."
|
||||||
);
|
);
|
||||||
Self {
|
Self { data, nrows, ncols }
|
||||||
data: data,
|
|
||||||
nrows: nrows,
|
|
||||||
ncols: ncols,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The underlying data storage.
|
/// The underlying data storage.
|
||||||
|
@ -139,7 +139,7 @@ impl<N: RealField> Orthographic3<N> {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self {
|
pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self {
|
||||||
Self { matrix: matrix }
|
Self { 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.
|
||||||
@ -151,7 +151,7 @@ impl<N: RealField> Orthographic3<N> {
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!relative_eq!(aspect, N::zero()),
|
!relative_eq!(aspect, N::zero()),
|
||||||
"The apsect ratio must not be zero."
|
"The aspect ratio must not be zero."
|
||||||
);
|
);
|
||||||
|
|
||||||
let half: N = crate::convert(0.5);
|
let half: N = crate::convert(0.5);
|
||||||
|
@ -75,7 +75,7 @@ impl<N: RealField> Perspective3<N> {
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!relative_eq!(aspect, N::zero()),
|
!relative_eq!(aspect, N::zero()),
|
||||||
"The apsect ratio must not be zero."
|
"The aspect ratio must not be zero."
|
||||||
);
|
);
|
||||||
|
|
||||||
let matrix = Matrix4::identity();
|
let matrix = Matrix4::identity();
|
||||||
@ -97,7 +97,7 @@ impl<N: RealField> Perspective3<N> {
|
|||||||
/// projection.
|
/// projection.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self {
|
pub fn from_matrix_unchecked(matrix: Matrix4<N>) -> Self {
|
||||||
Self { matrix: matrix }
|
Self { matrix }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the inverse of the underlying homogeneous matrix.
|
/// Retrieves the inverse of the underlying homogeneous matrix.
|
||||||
@ -294,7 +294,7 @@ impl<N: RealField + Arbitrary> Arbitrary for Perspective3<N> {
|
|||||||
|
|
||||||
impl<N: RealField> From<Perspective3<N>> for Matrix4<N> {
|
impl<N: RealField> From<Perspective3<N>> for Matrix4<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(orth: Perspective3<N>) -> Self {
|
fn from(pers: Perspective3<N>) -> Self {
|
||||||
orth.into_inner()
|
pers.into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ where
|
|||||||
#[deprecated(note = "Use Point::from(vector) instead.")]
|
#[deprecated(note = "Use Point::from(vector) instead.")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_coordinates(coords: VectorN<N, D>) -> Self {
|
pub fn from_coordinates(coords: VectorN<N, D>) -> Self {
|
||||||
Self { coords: coords }
|
Self { coords }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The dimension of this point.
|
/// The dimension of this point.
|
||||||
|
@ -492,18 +492,18 @@ where
|
|||||||
|
|
||||||
// The cosinus may be out of [-1, 1] because of inaccuracies.
|
// The cosinus may be out of [-1, 1] because of inaccuracies.
|
||||||
if cos <= -N::one() {
|
if cos <= -N::one() {
|
||||||
return None;
|
None
|
||||||
} else if cos >= N::one() {
|
} else if cos >= N::one() {
|
||||||
return Some(Self::identity());
|
Some(Self::identity())
|
||||||
} else {
|
} else {
|
||||||
return Some(Self::from_axis_angle(&axis, cos.acos() * s));
|
Some(Self::from_axis_angle(&axis, cos.acos() * s))
|
||||||
}
|
}
|
||||||
} else if na.dot(&nb) < N::zero() {
|
} else if na.dot(&nb) < N::zero() {
|
||||||
// PI
|
// PI
|
||||||
//
|
//
|
||||||
// The rotation axis is undefined but the angle not zero. This is not a
|
// The rotation axis is undefined but the angle not zero. This is not a
|
||||||
// simple rotation.
|
// simple rotation.
|
||||||
return None;
|
None
|
||||||
} else {
|
} else {
|
||||||
// Zero
|
// Zero
|
||||||
Some(Self::identity())
|
Some(Self::identity())
|
||||||
|
@ -255,7 +255,7 @@ where
|
|||||||
"Unable to create a rotation from a non-square matrix."
|
"Unable to create a rotation from a non-square matrix."
|
||||||
);
|
);
|
||||||
|
|
||||||
Self { matrix: matrix }
|
Self { matrix }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transposes `self`.
|
/// Transposes `self`.
|
||||||
|
@ -245,7 +245,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_matrix_unchecked(matrix: MatrixN<N, DimNameSum<D, U1>>) -> Self {
|
pub fn from_matrix_unchecked(matrix: MatrixN<N, DimNameSum<D, U1>>) -> Self {
|
||||||
Transform {
|
Transform {
|
||||||
matrix: matrix,
|
matrix,
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[deprecated(note = "Use `::from` instead.")]
|
#[deprecated(note = "Use `::from` instead.")]
|
||||||
pub fn from_vector(vector: VectorN<N, D>) -> Translation<N, D> {
|
pub fn from_vector(vector: VectorN<N, D>) -> Translation<N, D> {
|
||||||
Translation { vector: vector }
|
Translation { vector }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inverts `self`.
|
/// Inverts `self`.
|
||||||
|
@ -60,11 +60,7 @@ where
|
|||||||
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 Self {
|
return Self { lu: matrix, p, q };
|
||||||
lu: matrix,
|
|
||||||
p: p,
|
|
||||||
q: q,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..min_nrows_ncols.value() {
|
for i in 0..min_nrows_ncols.value() {
|
||||||
@ -90,11 +86,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self { lu: matrix, p, q }
|
||||||
lu: matrix,
|
|
||||||
p: p,
|
|
||||||
q: q,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -96,7 +96,7 @@ where
|
|||||||
let mut p = PermutationSequence::identity_generic(min_nrows_ncols);
|
let mut p = PermutationSequence::identity_generic(min_nrows_ncols);
|
||||||
|
|
||||||
if min_nrows_ncols.value() == 0 {
|
if min_nrows_ncols.value() == 0 {
|
||||||
return LU { lu: matrix, p: p };
|
return LU { lu: matrix, p };
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..min_nrows_ncols.value() {
|
for i in 0..min_nrows_ncols.value() {
|
||||||
@ -117,7 +117,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LU { lu: matrix, p: p }
|
LU { lu: matrix, p }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -57,20 +57,14 @@ where
|
|||||||
let mut diag = unsafe { MatrixMN::new_uninitialized_generic(min_nrows_ncols, U1) };
|
let mut diag = unsafe { MatrixMN::new_uninitialized_generic(min_nrows_ncols, U1) };
|
||||||
|
|
||||||
if min_nrows_ncols.value() == 0 {
|
if min_nrows_ncols.value() == 0 {
|
||||||
return QR {
|
return QR { qr: matrix, diag };
|
||||||
qr: matrix,
|
|
||||||
diag: diag,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ite in 0..min_nrows_ncols.value() {
|
for ite in 0..min_nrows_ncols.value() {
|
||||||
householder::clear_column_unchecked(&mut matrix, &mut diag[ite], ite, 0, None);
|
householder::clear_column_unchecked(&mut matrix, &mut diag[ite], ite, 0, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
QR {
|
QR { qr: matrix, diag }
|
||||||
qr: matrix,
|
|
||||||
diag: diag,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the upper trapezoidal submatrix `R` of this decomposition.
|
/// Retrieves the upper trapezoidal submatrix `R` of this decomposition.
|
||||||
|
@ -73,10 +73,8 @@ where
|
|||||||
pub fn try_new(m: MatrixN<N, D>, eps: N::RealField, max_niter: usize) -> Option<Self> {
|
pub fn try_new(m: MatrixN<N, D>, eps: N::RealField, 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)| Schur {
|
Self::do_decompose(m, &mut work, eps, max_niter, true)
|
||||||
q: q.unwrap(),
|
.map(|(q, t)| Schur { q: q.unwrap(), t })
|
||||||
t: t,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_decompose(
|
fn do_decompose(
|
||||||
@ -138,9 +136,9 @@ where
|
|||||||
let m = end - 1;
|
let m = end - 1;
|
||||||
let n = end;
|
let n = end;
|
||||||
|
|
||||||
let h11 = t[(start + 0, start + 0)];
|
let h11 = t[(start, start)];
|
||||||
let h12 = t[(start + 0, start + 1)];
|
let h12 = t[(start, start + 1)];
|
||||||
let h21 = t[(start + 1, start + 0)];
|
let h21 = t[(start + 1, start)];
|
||||||
let h22 = t[(start + 1, start + 1)];
|
let h22 = t[(start + 1, start + 1)];
|
||||||
let h32 = t[(start + 2, start + 1)];
|
let h32 = t[(start + 2, start + 1)];
|
||||||
|
|
||||||
@ -163,7 +161,7 @@ where
|
|||||||
|
|
||||||
if not_zero {
|
if not_zero {
|
||||||
if k > start {
|
if k > start {
|
||||||
t[(k + 0, k - 1)] = norm;
|
t[(k, k - 1)] = norm;
|
||||||
t[(k + 1, k - 1)] = N::zero();
|
t[(k + 1, k - 1)] = N::zero();
|
||||||
t[(k + 2, k - 1)] = N::zero();
|
t[(k + 2, k - 1)] = N::zero();
|
||||||
}
|
}
|
||||||
|
@ -218,9 +218,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diagonal[k + 0] = subm[(0, 0)];
|
diagonal[k] = subm[(0, 0)];
|
||||||
diagonal[k + 1] = subm[(1, 1)];
|
diagonal[k + 1] = subm[(1, 1)];
|
||||||
off_diagonal[k + 0] = subm[(0, 1)];
|
off_diagonal[k] = subm[(0, 1)];
|
||||||
|
|
||||||
if k != n - 1 {
|
if k != n - 1 {
|
||||||
off_diagonal[k + 1] = subm[(1, 2)];
|
off_diagonal[k + 1] = subm[(1, 2)];
|
||||||
@ -244,7 +244,7 @@ where
|
|||||||
let u2 = u2.map(|u2| GivensRotation::new_unchecked(u2.c(), N::from_real(u2.s())));
|
let u2 = u2.map(|u2| GivensRotation::new_unchecked(u2.c(), N::from_real(u2.s())));
|
||||||
let v2 = v2.map(|v2| GivensRotation::new_unchecked(v2.c(), N::from_real(v2.s())));
|
let v2 = v2.map(|v2| GivensRotation::new_unchecked(v2.c(), N::from_real(v2.s())));
|
||||||
|
|
||||||
diagonal[start + 0] = s[0];
|
diagonal[start] = s[0];
|
||||||
diagonal[start + 1] = s[1];
|
diagonal[start + 1] = s[1];
|
||||||
off_diagonal[start] = N::RealField::zero();
|
off_diagonal[start] = N::RealField::zero();
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ where
|
|||||||
let eigvals = m.eigenvalues().unwrap();
|
let eigvals = m.eigenvalues().unwrap();
|
||||||
let basis = Vector2::new(eigvals.x - diag[start + 1], off_diag[start]);
|
let basis = Vector2::new(eigvals.x - diag[start + 1], off_diag[start]);
|
||||||
|
|
||||||
diag[start + 0] = eigvals[0];
|
diag[start] = eigvals[0];
|
||||||
diag[start + 1] = eigvals[1];
|
diag[start + 1] = eigvals[1];
|
||||||
|
|
||||||
if let Some(ref mut q) = q {
|
if let Some(ref mut q) = q {
|
||||||
|
Loading…
Reference in New Issue
Block a user