forked from M-Labs/nalgebra
Typo fixes.
This commit is contained in:
parent
c6bc62c95f
commit
175c41ed3a
@ -130,7 +130,7 @@ This adds support for serialization using the
|
||||
|
||||
Pure Rust implementation of some Blas operations:
|
||||
|
||||
* `.iamax()` retuns the index of the maximum value of a vector.
|
||||
* `.iamax()` returns the index of the maximum value of a vector.
|
||||
* `.axpy(...)` computes `self = a * x + b * self`.
|
||||
* `.gemv(...)` computes `self = alpha * a * x + beta * self` with a matrix and vector `a` and `x`.
|
||||
* `.ger(...)` computes `self = alpha * x^t * y + beta * self` where `x` and `y` are vectors.
|
||||
@ -367,7 +367,7 @@ crate for vectors, rotations and points. To enable them, activate the
|
||||
|
||||
## [0.7.0]
|
||||
### Added
|
||||
* Added implementation of assignement operators (+=, -=, etc.) for
|
||||
* Added implementation of assignment operators (+=, -=, etc.) for
|
||||
everything.
|
||||
### Modified
|
||||
* Points and vectors are now linked to each other with associated types
|
||||
|
@ -90,7 +90,7 @@ pub fn ortho<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -
|
||||
// unimplemented!()
|
||||
//}
|
||||
|
||||
/// Creates a matrix for a symetric perspective-view frustum based on the right handedness and OpenGL near and far clip planes definition.
|
||||
/// Creates a matrix for a symmetric perspective-view frustum based on the right handedness and OpenGL near and far clip planes definition.
|
||||
pub fn perspective<N: Real>(fovy: N, aspect: N, near: N, far: N) -> TMat4<N> {
|
||||
Perspective3::new(fovy, aspect, near, far).unwrap()
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ pub fn project_zo<N: Real>(obj: &TVec3<N>, model: &TMat4<N>, proj: &TMat4<N>, vi
|
||||
)
|
||||
}
|
||||
|
||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using OpengGL near and far clip planes definition.
|
||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using OpenGL near and far clip planes definition.
|
||||
///
|
||||
/// # Parameters
|
||||
/// * `obj`: Specify the window coordinates to be mapped.
|
||||
@ -119,4 +119,4 @@ pub fn unproject_zo<N: Real>(win: &TVec3<N>, model: &TMat4<N>, proj: &TMat4<N>,
|
||||
|
||||
let result = transform * pt;
|
||||
result.fixed_rows::<U3>(0) / result.w
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ pub fn rotate_z_vec4<N: Real>(v: &TVec4<N>, angle: N) -> TVec4<N> {
|
||||
Rotation3::from_axis_angle(&TVec3::z_axis(), angle).to_homogeneous() * v
|
||||
}
|
||||
|
||||
/// Computes a spehical linear interpolation between the vectors `x` and `y` assumed to be normalized.
|
||||
/// Computes a spherical linear interpolation between the vectors `x` and `y` assumed to be normalized.
|
||||
pub fn slerp<N: Real>(x: &TVec3<N>, y: &TVec3<N>, a: N) -> TVec3<N> {
|
||||
Unit::new_unchecked(*x).slerp(&Unit::new_unchecked(*y), a).unwrap()
|
||||
}
|
||||
|
@ -50,13 +50,13 @@
|
||||
* Functions operating in 2d will usually end with the `2d` suffix, e.g., `glm::rotade2d` is for 2D while `glm::rotate` is for 3D.
|
||||
* Functions operating on vector will often end with the `_vec` suffix, possibly followed by the dimension of vector, e.g., `glm::rotate_vec2`.
|
||||
* Every function related to quaternions start with the `quat_` prefix, e.g., `glm::quat_dot(q1, q2)`.
|
||||
* All the conversion functions have unique names as described [bellow](#conversions).
|
||||
* All the conversion functions have unique names as described [below](#conversions).
|
||||
### Vector and matrix construction
|
||||
Vectors, matrices, and quaternions can be constructed using several approaches:
|
||||
* Using functions with the same name as their type in lower-case. For example `glm::vec3(x, y, z)` will create a 3D vector.
|
||||
* Using the `::new` constructor. For example `Vec3::new(x, y, z)` will create a 3D vector.
|
||||
* Using the functions prefixed by `make_` to build a vector a matrix from a slice. For example `glm::make_vec3(&[x, y, z])` will create a 3D vector.
|
||||
Keep in mind that constructing a matrix using this type of funcitons require its components to be arrange in column-major order on the slice.
|
||||
Keep in mind that constructing a matrix using this type of functions require its components to be arrange in column-major order on the slice.
|
||||
* Using a geometric construction function. For example `glm::rotation(angle, axis)` will build a 4x4 homogeneous rotation matrix from an angle (in radians) and an axis.
|
||||
* Using swizzling and conversions as described in the next sections.
|
||||
### Swizzling
|
||||
@ -184,4 +184,4 @@ mod exponential;
|
||||
|
||||
mod ext;
|
||||
mod gtc;
|
||||
mod gtx;
|
||||
mod gtx;
|
||||
|
@ -11,7 +11,7 @@ use na::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Scalar};
|
||||
|
||||
use lapack;
|
||||
|
||||
/// The cholesky decomposion of a symmetric-definite-positive matrix.
|
||||
/// The cholesky decomposition of a symmetric-definite-positive matrix.
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(
|
||||
feature = "serde-serialize",
|
||||
@ -50,7 +50,7 @@ impl<N: CholeskyScalar + Zero, D: Dim> Cholesky<N, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<N, D, D>,
|
||||
{
|
||||
/// Complutes the cholesky decomposition of the given symmetric-definite-positive square
|
||||
/// Computes the cholesky decomposition of the given symmetric-definite-positive square
|
||||
/// matrix.
|
||||
///
|
||||
/// Only the lower-triangular part of the input matrix is considered.
|
||||
@ -183,7 +183,7 @@ where
|
||||
*
|
||||
*/
|
||||
/// Trait implemented by floats (`f32`, `f64`) and complex floats (`Complex<f32>`, `Complex<f64>`)
|
||||
/// supported by the cholesky decompotition.
|
||||
/// supported by the cholesky decomposition.
|
||||
pub trait CholeskyScalar: Scalar {
|
||||
#[allow(missing_docs)]
|
||||
fn xpotrf(uplo: u8, n: i32, a: &mut [Self], lda: i32, info: &mut i32);
|
||||
|
@ -317,7 +317,7 @@ where
|
||||
* Lapack functions dispatch.
|
||||
*
|
||||
*/
|
||||
/// Trait implemented by scalar type for which Lapack funtion exist to compute the
|
||||
/// Trait implemented by scalar type for which Lapack function exist to compute the
|
||||
/// eigendecomposition.
|
||||
pub trait EigenScalar: Scalar {
|
||||
#[allow(missing_docs)]
|
||||
|
@ -244,7 +244,7 @@ where
|
||||
|
||||
/// Solves in-place the linear system `self * x = b`, where `x` is the unknown to be determined.
|
||||
///
|
||||
/// Retuns `false` if no solution was found (the decomposed matrix is singular).
|
||||
/// Returns `false` if no solution was found (the decomposed matrix is singular).
|
||||
pub fn solve_mut<R2: Dim, C2: Dim>(&self, b: &mut MatrixMN<N, R2, C2>) -> bool
|
||||
where
|
||||
DefaultAllocator: Allocator<N, R2, C2> + Allocator<i32, R2>,
|
||||
@ -255,7 +255,7 @@ where
|
||||
/// Solves in-place the linear system `self.transpose() * x = b`, where `x` is the unknown to be
|
||||
/// determined.
|
||||
///
|
||||
/// Retuns `false` if no solution was found (the decomposed matrix is singular).
|
||||
/// Returns `false` if no solution was found (the decomposed matrix is singular).
|
||||
pub fn solve_transpose_mut<R2: Dim, C2: Dim>(&self, b: &mut MatrixMN<N, R2, C2>) -> bool
|
||||
where
|
||||
DefaultAllocator: Allocator<N, R2, C2> + Allocator<i32, R2>,
|
||||
@ -266,7 +266,7 @@ where
|
||||
/// Solves in-place the linear system `self.conjugate_transpose() * x = b`, where `x` is the unknown to
|
||||
/// be determined.
|
||||
///
|
||||
/// Retuns `false` if no solution was found (the decomposed matrix is singular).
|
||||
/// Returns `false` if no solution was found (the decomposed matrix is singular).
|
||||
pub fn solve_conjugate_transpose_mut<R2: Dim, C2: Dim>(
|
||||
&self,
|
||||
b: &mut MatrixMN<N, R2, C2>,
|
||||
|
@ -171,7 +171,7 @@ where
|
||||
* Lapack functions dispatch.
|
||||
*
|
||||
*/
|
||||
/// Trait implemented by scalar types for which Lapack funtion exist to compute the
|
||||
/// Trait implemented by scalar types for which Lapack function exist to compute the
|
||||
/// QR decomposition.
|
||||
pub trait QRScalar: Scalar {
|
||||
fn xgeqrf(
|
||||
@ -195,7 +195,7 @@ pub trait QRScalar: Scalar {
|
||||
) -> i32;
|
||||
}
|
||||
|
||||
/// Trait implemented by reals for which Lapack funtion exist to compute the
|
||||
/// Trait implemented by reals for which Lapack function exist to compute the
|
||||
/// QR decomposition.
|
||||
pub trait QRReal: QRScalar {
|
||||
#[allow(missing_docs)]
|
||||
|
@ -59,14 +59,14 @@ impl<N: RealSchurScalar + Real, D: Dim> RealSchur<N, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>,
|
||||
{
|
||||
/// Computes the eigenvalues and real Schur foorm of the matrix `m`.
|
||||
/// Computes the eigenvalues and real Schur form of the matrix `m`.
|
||||
///
|
||||
/// Panics if the method did not converge.
|
||||
pub fn new(m: MatrixN<N, D>) -> Self {
|
||||
Self::try_new(m).expect("RealSchur decomposition: convergence failed.")
|
||||
}
|
||||
|
||||
/// Computes the eigenvalues and real Schur foorm of the matrix `m`.
|
||||
/// Computes the eigenvalues and real Schur form of the matrix `m`.
|
||||
///
|
||||
/// Returns `None` if the method did not converge.
|
||||
pub fn try_new(mut m: MatrixN<N, D>) -> Option<Self> {
|
||||
|
@ -180,7 +180,7 @@ where
|
||||
let mut res = N::zero();
|
||||
|
||||
// We have to define them outside of the loop (and not inside at first assignment)
|
||||
// otherwize vectorization won't kick in for some reason.
|
||||
// otherwise vectorization won't kick in for some reason.
|
||||
let mut acc0;
|
||||
let mut acc1;
|
||||
let mut acc2;
|
||||
@ -527,7 +527,7 @@ where
|
||||
let is_dynamic = R1::is::<Dynamic>() || C1::is::<Dynamic>() || R2::is::<Dynamic>()
|
||||
|| C2::is::<Dynamic>() || R3::is::<Dynamic>()
|
||||
|| C3::is::<Dynamic>();
|
||||
// Thershold determined ampirically.
|
||||
// Threshold determined empirically.
|
||||
const SMALL_DIM: usize = 5;
|
||||
|
||||
if is_dynamic && nrows1 > SMALL_DIM && ncols1 > SMALL_DIM && nrows2 > SMALL_DIM
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Non-convensional componentwise operators.
|
||||
// Non-conventional componentwise operators.
|
||||
|
||||
use num::{Signed, Zero};
|
||||
use std::ops::{Add, Mul};
|
||||
|
@ -58,7 +58,7 @@ pub type MatrixCross<N, R1, C1, R2, C2> =
|
||||
/// components.
|
||||
///
|
||||
/// The matrix dimensions parameters `R` and `C` can either be:
|
||||
/// - type-level unsigned integer contants (e.g. `U1`, `U124`) from the `nalgebra::` root module.
|
||||
/// - type-level unsigned integer constants (e.g. `U1`, `U124`) from the `nalgebra::` root module.
|
||||
/// All numbers from 0 to 127 are defined that way.
|
||||
/// - type-level unsigned integer constants (e.g. `U1024`, `U10000`) from the `typenum::` crate.
|
||||
/// Using those, you will not get error messages as nice as for numbers smaller than 128 defined on
|
||||
@ -1298,7 +1298,7 @@ impl<N: Real, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
|
||||
|
||||
/// Normalizes this matrix in-place or does nothing if its norm is smaller or equal to `eps`.
|
||||
///
|
||||
/// If the normalization succeded, returns the old normal of this matrix.
|
||||
/// If the normalization succeeded, returns the old normal of this matrix.
|
||||
#[inline]
|
||||
pub fn try_normalize_mut(&mut self, min_norm: N) -> Option<N> {
|
||||
let n = self.norm();
|
||||
|
@ -676,8 +676,8 @@ pub trait SliceRange<D: Dim> {
|
||||
|
||||
/// The start index of the range.
|
||||
fn begin(&self, shape: D) -> usize;
|
||||
// NOTE: this is the index immediatly after the last index.
|
||||
/// The index immediatly after the last index inside of the range.
|
||||
// NOTE: this is the index immediately after the last index.
|
||||
/// The index immediately after the last index inside of the range.
|
||||
fn end(&self, shape: D) -> usize;
|
||||
/// The number of elements of the range, i.e., `self.end - self.begin`.
|
||||
fn size(&self, shape: D) -> Self::Size;
|
||||
|
@ -58,10 +58,10 @@ impl<N, R: Dim, C: Dim> MatrixVec<N, R, C> {
|
||||
&mut self.data
|
||||
}
|
||||
|
||||
/// Resizes the undelying mutable data storage and unrwaps it.
|
||||
/// Resizes the underlying mutable data storage and unwraps it.
|
||||
///
|
||||
/// If `sz` is larger than the current size, additional elements are uninitialized.
|
||||
/// If `sz` is smaller than the current size, additional elements are trucated.
|
||||
/// If `sz` is smaller than the current size, additional elements are truncated.
|
||||
#[inline]
|
||||
pub unsafe fn resize(mut self, sz: usize) -> Vec<N> {
|
||||
let len = self.len();
|
||||
|
@ -124,7 +124,7 @@ where
|
||||
|
||||
/*
|
||||
*
|
||||
* Addition & Substraction
|
||||
* Addition & Subtraction
|
||||
*
|
||||
*/
|
||||
|
||||
@ -415,7 +415,7 @@ macro_rules! componentwise_scalarop_impl(
|
||||
|
||||
// XXX: optimize our iterator!
|
||||
//
|
||||
// Using our own iterator prevents loop unrolling, wich breaks some optimization
|
||||
// Using our own iterator prevents loop unrolling, which breaks some optimization
|
||||
// (like SIMD). On the other hand, using the slice iterator is 4x faster.
|
||||
|
||||
// for left in res.iter_mut() {
|
||||
@ -469,7 +469,7 @@ macro_rules! left_scalar_mul_impl(
|
||||
|
||||
// XXX: optimize our iterator!
|
||||
//
|
||||
// Using our own iterator prevents loop unrolling, wich breaks some optimization
|
||||
// Using our own iterator prevents loop unrolling, which breaks some optimization
|
||||
// (like SIMD). On the other hand, using the slice iterator is 4x faster.
|
||||
|
||||
// for rhs in res.iter_mut() {
|
||||
|
@ -7,7 +7,7 @@ use std::any::Any;
|
||||
/// This does not make any assumption on the algebraic properties of `Self`.
|
||||
pub trait Scalar: Copy + PartialEq + Debug + Any {
|
||||
#[inline]
|
||||
/// Tests if `Self` the the same as the type `T`
|
||||
/// Tests if `Self` the same as the type `T`
|
||||
///
|
||||
/// Typically used to test of `Self` is a f32 or a f64 with `N::is::<f32>()`.
|
||||
fn is<T: Scalar>() -> bool {
|
||||
|
@ -50,7 +50,7 @@ pub unsafe trait Storage<N: Scalar, R: Dim, C: Dim = U1>: Debug + Sized {
|
||||
/// element of any dimension. Must be equal to `Self::dimension()` if it is not `None`.
|
||||
fn shape(&self) -> (R, C);
|
||||
|
||||
/// The spacing between concecutive row elements and consecutive column elements.
|
||||
/// The spacing between consecutive row elements and consecutive column elements.
|
||||
///
|
||||
/// For example this returns `(1, 5)` for a row-major matrix with 5 columns.
|
||||
fn strides(&self) -> (Self::RStride, Self::CStride);
|
||||
|
@ -13,9 +13,9 @@ use abomonation::Abomonation;
|
||||
use alga::general::SubsetOf;
|
||||
use alga::linear::NormedSpace;
|
||||
|
||||
/// A wrapper that ensures the undelying algebraic entity has a unit norm.
|
||||
/// A wrapper that ensures the underlying algebraic entity has a unit norm.
|
||||
///
|
||||
/// Use `.as_ref()` or `.unwrap()` to obtain the undelying value by-reference or by-move.
|
||||
/// Use `.as_ref()` or `.unwrap()` to obtain the underlying value by-reference or by-move.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)]
|
||||
pub struct Unit<T> {
|
||||
@ -187,7 +187,7 @@ where
|
||||
// }
|
||||
// }
|
||||
|
||||
// FIXME:re-enable this impl when spacialization is possible.
|
||||
// FIXME:re-enable this impl when specialization is possible.
|
||||
// Currently, it is disabled so that we can have a nice output for the `UnitQuaternion` display.
|
||||
/*
|
||||
impl<T: fmt::Display> fmt::Display for Unit<T> {
|
||||
|
@ -378,7 +378,7 @@ isometry_from_composition_impl_all!(
|
||||
(D, D), (D, U1) for D: DimName;
|
||||
self: Rotation<N, D>, right: Isometry<N, D, Rotation<N, D>>,
|
||||
Output = Isometry<N, D, Rotation<N, D>>;
|
||||
// FIXME: don't call iverse explicitly?
|
||||
// FIXME: don't call inverse explicitly?
|
||||
[val val] => self * right.inverse();
|
||||
[ref val] => self * right.inverse();
|
||||
[val ref] => self * right.inverse();
|
||||
|
@ -5,7 +5,7 @@
|
||||
/// Macro for the implementation of multiplication and division.
|
||||
macro_rules! md_impl(
|
||||
(
|
||||
// Operator, operator method, and calar bounds.
|
||||
// Operator, operator method, and scalar bounds.
|
||||
$Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)*;
|
||||
// Storage dimensions, and dimension bounds.
|
||||
($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),+
|
||||
@ -13,7 +13,7 @@ macro_rules! md_impl(
|
||||
$(where $ConstraintType: ty: $ConstraintBound: ident<$($ConstraintBoundParams: ty $( = $EqBound: ty )*),*> )*;
|
||||
// Argument identifiers and types + output.
|
||||
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty;
|
||||
// Operator actual mplementation.
|
||||
// Operator actual implementation.
|
||||
$action: expr;
|
||||
// Lifetime.
|
||||
$($lives: tt),*) => {
|
||||
@ -38,7 +38,7 @@ macro_rules! md_impl(
|
||||
/// Implements all the argument reference combinations.
|
||||
macro_rules! md_impl_all(
|
||||
(
|
||||
// Operator, operator method, and calar bounds.
|
||||
// Operator, operator method, and scalar bounds.
|
||||
$Op: ident, $op: ident $(where N: $($ScalarBounds: ident),*)*;
|
||||
// Storage dimensions, and dimension bounds.
|
||||
($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident $(<$($BoundParam: ty),*>)*),+
|
||||
@ -82,7 +82,7 @@ macro_rules! md_impl_all(
|
||||
}
|
||||
);
|
||||
|
||||
/// Macro for the implementation of assignement-multiplication and assignement-division.
|
||||
/// Macro for the implementation of assignment-multiplication and assignment-division.
|
||||
macro_rules! md_assign_impl(
|
||||
(
|
||||
// Operator, operator method, and scalar bounds.
|
||||
@ -109,7 +109,7 @@ macro_rules! md_assign_impl(
|
||||
}
|
||||
);
|
||||
|
||||
/// Macro for the implementation of assignement-multiplication and assignement-division with and
|
||||
/// Macro for the implementation of assignment-multiplication and assignment-division with and
|
||||
/// without reference to the right-hand-side.
|
||||
macro_rules! md_assign_impl_all(
|
||||
(
|
||||
@ -165,7 +165,7 @@ macro_rules! add_sub_impl(
|
||||
);
|
||||
|
||||
// FIXME: merge with `md_assign_impl`.
|
||||
/// Macro for the implementation of assignement-addition and assignement-subtraction.
|
||||
/// Macro for the implementation of assignment-addition and assignment-subtraction.
|
||||
macro_rules! add_sub_assign_impl(
|
||||
($Op: ident, $op: ident, $bound: ident;
|
||||
($R1: ty, $C1: ty),($R2: ty, $C2: ty) for $($Dims: ident: $DimsBound: ident),+;
|
||||
|
@ -149,19 +149,19 @@ impl<N: Real> Perspective3<N> {
|
||||
self.matrix
|
||||
}
|
||||
|
||||
/// Gets the `width / height` aspect ratio of the view frustrum.
|
||||
/// Gets the `width / height` aspect ratio of the view frustum.
|
||||
#[inline]
|
||||
pub fn aspect(&self) -> N {
|
||||
self.matrix[(1, 1)] / self.matrix[(0, 0)]
|
||||
}
|
||||
|
||||
/// Gets the y field of view of the view frustrum.
|
||||
/// Gets the y field of view of the view frustum.
|
||||
#[inline]
|
||||
pub fn fovy(&self) -> N {
|
||||
(N::one() / self.matrix[(1, 1)]).atan() * ::convert(2.0)
|
||||
}
|
||||
|
||||
/// Gets the near plane offset of the view frustrum.
|
||||
/// Gets the near plane offset of the view frustum.
|
||||
#[inline]
|
||||
pub fn znear(&self) -> N {
|
||||
let ratio = (-self.matrix[(2, 2)] + N::one()) / (-self.matrix[(2, 2)] - N::one());
|
||||
@ -169,7 +169,7 @@ impl<N: Real> Perspective3<N> {
|
||||
self.matrix[(2, 3)] / (ratio * ::convert(2.0)) - self.matrix[(2, 3)] / ::convert(2.0)
|
||||
}
|
||||
|
||||
/// Gets the far plane offset of the view frustrum.
|
||||
/// Gets the far plane offset of the view frustum.
|
||||
#[inline]
|
||||
pub fn zfar(&self) -> N {
|
||||
let ratio = (-self.matrix[(2, 2)] + N::one()) / (-self.matrix[(2, 2)] - N::one());
|
||||
@ -219,7 +219,7 @@ impl<N: Real> Perspective3<N> {
|
||||
}
|
||||
|
||||
/// Updates this perspective matrix with a new `width / height` aspect ratio of the view
|
||||
/// frustrum.
|
||||
/// frustum.
|
||||
#[inline]
|
||||
pub fn set_aspect(&mut self, aspect: N) {
|
||||
assert!(
|
||||
@ -229,7 +229,7 @@ impl<N: Real> Perspective3<N> {
|
||||
self.matrix[(0, 0)] = self.matrix[(1, 1)] / aspect;
|
||||
}
|
||||
|
||||
/// Updates this perspective with a new y field of view of the view frustrum.
|
||||
/// Updates this perspective with a new y field of view of the view frustum.
|
||||
#[inline]
|
||||
pub fn set_fovy(&mut self, fovy: N) {
|
||||
let old_m22 = self.matrix[(1, 1)];
|
||||
@ -237,21 +237,21 @@ impl<N: Real> Perspective3<N> {
|
||||
self.matrix[(0, 0)] = self.matrix[(0, 0)] * (self.matrix[(1, 1)] / old_m22);
|
||||
}
|
||||
|
||||
/// Updates this perspective matrix with a new near plane offset of the view frustrum.
|
||||
/// Updates this perspective matrix with a new near plane offset of the view frustum.
|
||||
#[inline]
|
||||
pub fn set_znear(&mut self, znear: N) {
|
||||
let zfar = self.zfar();
|
||||
self.set_znear_and_zfar(znear, zfar);
|
||||
}
|
||||
|
||||
/// Updates this perspective matrix with a new far plane offset of the view frustrum.
|
||||
/// Updates this perspective matrix with a new far plane offset of the view frustum.
|
||||
#[inline]
|
||||
pub fn set_zfar(&mut self, zfar: N) {
|
||||
let znear = self.znear();
|
||||
self.set_znear_and_zfar(znear, zfar);
|
||||
}
|
||||
|
||||
/// Updates this perspective matrix with new near and far plane offsets of the view frustrum.
|
||||
/// Updates this perspective matrix with new near and far plane offsets of the view frustum.
|
||||
#[inline]
|
||||
pub fn set_znear_and_zfar(&mut self, znear: N, zfar: N) {
|
||||
self.matrix[(2, 2)] = (zfar + znear) / (znear - zfar);
|
||||
|
@ -53,7 +53,7 @@ where
|
||||
|
||||
/*
|
||||
*
|
||||
* Traits that buid points.
|
||||
* Traits that build points.
|
||||
*
|
||||
*/
|
||||
impl<N: Scalar + Bounded, D: DimName> Bounded for Point<N, D>
|
||||
|
@ -391,7 +391,7 @@ impl<N: Real> UnitQuaternion<N> {
|
||||
pub fn angle(&self) -> N {
|
||||
let w = self.quaternion().scalar().abs();
|
||||
|
||||
// Handle innacuracies that make break `.acos`.
|
||||
// Handle inaccuracies that make break `.acos`.
|
||||
if w >= N::one() {
|
||||
N::zero()
|
||||
} else {
|
||||
@ -507,7 +507,7 @@ impl<N: Real> UnitQuaternion<N> {
|
||||
Unit::try_new(v, N::zero())
|
||||
}
|
||||
|
||||
/// The rotation axis of this unit quaternion multiplied by the rotation agle.
|
||||
/// The rotation axis of this unit quaternion multiplied by the rotation angle.
|
||||
#[inline]
|
||||
pub fn scaled_axis(&self) -> Vector3<N> {
|
||||
if let Some(axis) = self.axis() {
|
||||
|
@ -278,7 +278,7 @@ impl<N: Real> UnitQuaternion<N> {
|
||||
if let Some(axis) = Unit::try_new(c, N::default_epsilon()) {
|
||||
let cos = na.dot(&nb);
|
||||
|
||||
// The cosinus may be out of [-1, 1] because of innacuracies.
|
||||
// The cosinus may be out of [-1, 1] because of inaccuracies.
|
||||
if cos <= -N::one() {
|
||||
return None;
|
||||
} else if cos >= N::one() {
|
||||
|
@ -44,7 +44,7 @@ impl<N: Real, D: Dim, S: Storage<N, D>> Reflection<N, D, S> {
|
||||
&self.axis
|
||||
}
|
||||
|
||||
// FIXME: naming convension: reflect_to, reflect_assign ?
|
||||
// FIXME: naming convention: reflect_to, reflect_assign ?
|
||||
/// Applies the reflection to the columns of `rhs`.
|
||||
pub fn reflect<R2: Dim, C2: Dim, S2>(&self, rhs: &mut Matrix<N, R2, C2, S2>)
|
||||
where
|
||||
|
@ -53,7 +53,7 @@ md_impl_all!(
|
||||
);
|
||||
|
||||
// Rotation ÷ Rotation
|
||||
// FIXME: instead of calling inverse explicitely, 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?
|
||||
md_impl_all!(
|
||||
Div, div;
|
||||
(D, D), (D, D) for D: DimName;
|
||||
|
@ -35,7 +35,7 @@ impl<N: Real> Rotation2<N> {
|
||||
Self::new(axisangle[0])
|
||||
}
|
||||
|
||||
/// The rotation matrix required to align `a` and `b` but with its angl.
|
||||
/// The rotation matrix required to align `a` and `b` but with its angle.
|
||||
///
|
||||
/// This is the rotation `R` such that `(R * a).angle(b) == 0 && (R * a).dot(b).is_positive()`.
|
||||
#[inline]
|
||||
@ -279,7 +279,7 @@ impl<N: Real> Rotation3<N> {
|
||||
Self::new_observer_frame(dir, up).inverse()
|
||||
}
|
||||
|
||||
/// The rotation matrix required to align `a` and `b` but with its angl.
|
||||
/// The rotation matrix required to align `a` and `b` but with its angle.
|
||||
///
|
||||
/// This is the rotation `R` such that `(R * a).angle(b) == 0 && (R * a).dot(b).is_positive()`.
|
||||
#[inline]
|
||||
|
@ -246,8 +246,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: we don't require `R: Rotation<...>` here becaus this is not useful for the implementation
|
||||
// and makes it harde to use it, e.g., for Transform × Isometry implementation.
|
||||
// NOTE: we don't require `R: Rotation<...>` here because this is not useful for the implementation
|
||||
// and makes it harder to use it, e.g., for Transform × Isometry implementation.
|
||||
// This is OK since all constructors of the isometry enforce the Rotation bound already (and
|
||||
// explicit struct construction is prevented by the private scaling factor).
|
||||
impl<N: Real, D: DimName, R> Similarity<N, D, R>
|
||||
|
@ -65,7 +65,7 @@ where
|
||||
R: AlgaRotation<Point<N, D>>,
|
||||
DefaultAllocator: Allocator<N, D>,
|
||||
{
|
||||
/// The similarity that applies tha scaling factor `scaling`, followed by the rotation `r` with
|
||||
/// The similarity that applies the scaling factor `scaling`, followed by the rotation `r` with
|
||||
/// its axis passing through the point `p`.
|
||||
#[inline]
|
||||
pub fn rotation_wrt_point(r: R, p: Point<N, D>, scaling: N) -> Self {
|
||||
@ -135,7 +135,7 @@ macro_rules! similarity_construction_impl(
|
||||
Self::from_isometry(Isometry::<_, U3, $Rot>::new(translation, axisangle), scaling)
|
||||
}
|
||||
|
||||
/// Creates an similarity that corresponds to the a scaling factor and a local frame of
|
||||
/// Creates an similarity that corresponds to a scaling factor and a local frame of
|
||||
/// an observer standing at the point `eye` and looking toward `target`.
|
||||
///
|
||||
/// It maps the view direction `target - eye` to the positive `z` axis and the origin to the
|
||||
|
@ -445,7 +445,7 @@ similarity_from_composition_impl_all!(
|
||||
(D, D), (D, U1) for D: DimName;
|
||||
self: Rotation<N, D>, right: Similarity<N, D, Rotation<N, D>>,
|
||||
Output = Similarity<N, D, Rotation<N, D>>;
|
||||
// FIXME: don't call iverse explicitly?
|
||||
// FIXME: don't call inverse explicitly?
|
||||
[val val] => self * right.inverse();
|
||||
[ref val] => self * right.inverse();
|
||||
[val ref] => self * right.inverse();
|
||||
|
@ -256,7 +256,7 @@ where
|
||||
self.matrix
|
||||
}
|
||||
|
||||
/// A reference to the underlynig matrix.
|
||||
/// A reference to the underlying matrix.
|
||||
#[inline]
|
||||
pub fn matrix(&self) -> &MatrixN<N, DimNameSum<D, U1>> {
|
||||
&self.matrix
|
||||
|
@ -31,7 +31,7 @@ add_sub_impl!(Mul, mul, ClosedAdd;
|
||||
Translation::from_vector(self.vector + right.vector); );
|
||||
|
||||
// Translation ÷ Translation
|
||||
// FIXME: instead of calling inverse explicitely, 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;
|
||||
(D, U1), (D, U1) -> (D) for D: DimName;
|
||||
self: &'a Translation<N, D>, right: &'b Translation<N, D>, Output = Translation<N, D>;
|
||||
|
@ -35,7 +35,7 @@ impl<N: Real> UnitComplex<N> {
|
||||
Self::new(angle)
|
||||
}
|
||||
|
||||
/// Builds the unit complex number frow the sinus and cosinus of the rotation angle.
|
||||
/// Builds the unit complex number from the sinus and cosinus of the rotation angle.
|
||||
///
|
||||
/// The input values are not checked.
|
||||
#[inline]
|
||||
|
@ -233,8 +233,8 @@ where
|
||||
///
|
||||
/// In particular:
|
||||
/// * If `min < val < max`, this returns `val`.
|
||||
/// * If `val <= min`, this retuns `min`.
|
||||
/// * If `val >= max`, this retuns `max`.
|
||||
/// * If `val <= min`, this returns `min`.
|
||||
/// * If `val >= max`, this returns `max`.
|
||||
#[inline]
|
||||
pub fn clamp<T: PartialOrd>(val: T, min: T, max: T) -> T {
|
||||
if val > min {
|
||||
|
@ -9,7 +9,7 @@ use constraint::{SameNumberOfRows, ShapeConstraint};
|
||||
use dimension::{Dim, DimSub, Dynamic};
|
||||
use storage::{Storage, StorageMut};
|
||||
|
||||
/// The Cholesky decomposion of a symmetric-definite-positive matrix.
|
||||
/// The Cholesky decomposition of a symmetric-definite-positive matrix.
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(
|
||||
feature = "serde-serialize",
|
||||
@ -50,7 +50,7 @@ where
|
||||
{
|
||||
/// Attempts to compute the Cholesky decomposition of `matrix`.
|
||||
///
|
||||
/// Returns `None` if the input matrix is not definite-positive. The intput matrix is assumed
|
||||
/// Returns `None` if the input matrix is not definite-positive. The input matrix is assumed
|
||||
/// to be symmetric and only the lower-triangular part is read.
|
||||
pub fn new(mut matrix: MatrixN<N, D>) -> Option<Self> {
|
||||
assert!(matrix.is_square(), "The input matrix must be square.");
|
||||
@ -157,7 +157,7 @@ where
|
||||
{
|
||||
/// Attempts to compute the Cholesky decomposition of this matrix.
|
||||
///
|
||||
/// Returns `None` if the input matrix is not definite-positive. The intput matrix is assumed
|
||||
/// Returns `None` if the input matrix is not definite-positive. The input matrix is assumed
|
||||
/// to be symmetric and only the lower-triangular part is read.
|
||||
pub fn cholesky(self) -> Option<Cholesky<N, D>> {
|
||||
Cholesky::new(self.into_owned())
|
||||
|
@ -174,7 +174,7 @@ where
|
||||
{
|
||||
/// Solves the linear system `self * x = b`, where `x` is the unknown to be determined.
|
||||
///
|
||||
/// Retuns `None` if the decomposed matrix is not invertible.
|
||||
/// Returns `None` if the decomposed matrix is not invertible.
|
||||
pub fn solve<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
b: &Matrix<N, R2, C2, S2>,
|
||||
|
@ -112,7 +112,7 @@ where
|
||||
let dim = m.data.shape().0;
|
||||
|
||||
// NOTE: we could build the identity matrix and call p_mult on it.
|
||||
// Instead we don't so that we take in accout the matrix sparcity.
|
||||
// Instead we don't so that we take in account the matrix sparseness.
|
||||
let mut res = MatrixN::identity_generic(dim, dim);
|
||||
|
||||
for i in (0..dim.value() - 1).rev() {
|
||||
|
@ -118,7 +118,7 @@ impl<N: Real, D: Dim, S: StorageMut<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: this is an extremely efficient, loop-unrolled matrix inverse from MESA (MIT licenced).
|
||||
// NOTE: this is an extremely efficient, loop-unrolled matrix inverse from MESA (MIT licensed).
|
||||
fn do_inverse4<N: Real, D: Dim, S: StorageMut<N, D, D>>(
|
||||
m: &MatrixN<N, D>,
|
||||
out: &mut SquareMatrix<N, D, S>,
|
||||
|
@ -107,7 +107,7 @@ where
|
||||
let (nrows, ncols) = self.qr.data.shape();
|
||||
|
||||
// NOTE: we could build the identity matrix and call q_mul on it.
|
||||
// Instead we don't so that we take in accout the matrix sparcity.
|
||||
// Instead we don't so that we take in account the matrix sparseness.
|
||||
let mut res = Matrix::identity_generic(nrows, nrows.min(ncols));
|
||||
let dim = self.diag.len();
|
||||
|
||||
|
@ -72,7 +72,7 @@ where
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `eps` − tolerence used to determine when a value converged to 0.
|
||||
/// * `eps` − tolerance used to determine when a value converged to 0.
|
||||
/// * `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
|
||||
/// continues indefinitely until convergence.
|
||||
@ -519,7 +519,7 @@ where
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `eps` − tolerence used to determine when a value converged to 0.
|
||||
/// * `eps` − tolerance used to determine when a value converged to 0.
|
||||
/// * `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
|
||||
/// continues indefinitely until convergence.
|
||||
@ -536,7 +536,7 @@ where
|
||||
|
||||
let mut work = unsafe { VectorN::new_uninitialized_generic(self.data.shape().0, U1) };
|
||||
|
||||
// Special case for 2x2 natrices.
|
||||
// Special case for 2x2 matrices.
|
||||
if self.nrows() == 2 {
|
||||
// FIXME: can we avoid this slicing
|
||||
// (which is needed here just to transform D to U2)?
|
||||
|
@ -8,7 +8,7 @@ use base::{DefaultAllocator, Matrix, MatrixMN, SquareMatrix, Vector};
|
||||
|
||||
impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
/// Computes the solution of the linear system `self . x = b` where `x` is the unknown and only
|
||||
/// the lower-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// the lower-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
#[inline]
|
||||
pub fn solve_lower_triangular<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
@ -28,7 +28,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
|
||||
/// Computes the solution of the linear system `self . x = b` where `x` is the unknown and only
|
||||
/// the upper-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// the upper-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
#[inline]
|
||||
pub fn solve_upper_triangular<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
@ -48,7 +48,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
|
||||
/// Solves the linear system `self . x = b` where `x` is the unknown and only the
|
||||
/// lower-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// lower-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
pub fn solve_lower_triangular_mut<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
b: &mut Matrix<N, R2, C2, S2>,
|
||||
@ -98,7 +98,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
|
||||
// FIXME: add the same but for solving upper-triangular.
|
||||
/// Solves the linear system `self . x = b` where `x` is the unknown and only the
|
||||
/// lower-triangular part of `self` is concidered not-zero. The diagonal is never read as it is
|
||||
/// lower-triangular part of `self` is considered not-zero. The diagonal is never read as it is
|
||||
/// assumed to be equal to `diag`. Returns `false` and does not modify its inputs if `diag` is zero.
|
||||
pub fn solve_lower_triangular_with_diag_mut<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
@ -130,7 +130,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
|
||||
/// Solves the linear system `self . x = b` where `x` is the unknown and only the
|
||||
/// upper-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// upper-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
pub fn solve_upper_triangular_mut<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
b: &mut Matrix<N, R2, C2, S2>,
|
||||
@ -185,7 +185,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
*/
|
||||
|
||||
/// Computes the solution of the linear system `self.transpose() . x = b` where `x` is the unknown and only
|
||||
/// the lower-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// the lower-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
#[inline]
|
||||
pub fn tr_solve_lower_triangular<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
@ -205,7 +205,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
|
||||
/// Computes the solution of the linear system `self.transpose() . x = b` where `x` is the unknown and only
|
||||
/// the upper-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// the upper-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
#[inline]
|
||||
pub fn tr_solve_upper_triangular<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
@ -225,7 +225,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
|
||||
/// Solves the linear system `self.transpose() . x = b` where `x` is the unknown and only the
|
||||
/// lower-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// lower-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
pub fn tr_solve_lower_triangular_mut<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
b: &mut Matrix<N, R2, C2, S2>,
|
||||
@ -272,7 +272,7 @@ impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S> {
|
||||
}
|
||||
|
||||
/// Solves the linear system `self.transpose() . x = b` where `x` is the unknown and only the
|
||||
/// upper-triangular part of `self` (including the diagonal) is concidered not-zero.
|
||||
/// upper-triangular part of `self` (including the diagonal) is considered not-zero.
|
||||
pub fn tr_solve_upper_triangular_mut<R2: Dim, C2: Dim, S2>(
|
||||
&self,
|
||||
b: &mut Matrix<N, R2, C2, S2>,
|
||||
|
@ -94,7 +94,7 @@ where
|
||||
///
|
||||
/// * `compute_u` − set this to `true` to enable the computation of left-singular vectors.
|
||||
/// * `compute_v` − set this to `true` to enable the computation of left-singular vectors.
|
||||
/// * `eps` − tolerence used to determine when a value converged to 0.
|
||||
/// * `eps` − tolerance used to determine when a value converged to 0.
|
||||
/// * `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
|
||||
/// continues indefinitely until convergence.
|
||||
@ -251,7 +251,7 @@ where
|
||||
end -= 1;
|
||||
}
|
||||
|
||||
// Re-delimit the suproblem in case some decoupling occured.
|
||||
// Re-delimit the subproblem in case some decoupling occurred.
|
||||
let sub = Self::delimit_subproblem(&mut b, &mut u, &mut v_t, end, eps);
|
||||
start = sub.0;
|
||||
end = sub.1;
|
||||
@ -593,7 +593,7 @@ where
|
||||
///
|
||||
/// * `compute_u` − set this to `true` to enable the computation of left-singular vectors.
|
||||
/// * `compute_v` − set this to `true` to enable the computation of left-singular vectors.
|
||||
/// * `eps` − tolerence used to determine when a value converged to 0.
|
||||
/// * `eps` − tolerance used to determine when a value converged to 0.
|
||||
/// * `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
|
||||
/// continues indefinitely until convergence.
|
||||
|
@ -214,7 +214,7 @@ where
|
||||
end -= 1;
|
||||
}
|
||||
|
||||
// Re-delimit the suproblem in case some decoupling occured.
|
||||
// Re-delimit the subproblem in case some decoupling occurred.
|
||||
let sub = Self::delimit_subproblem(&diag, &mut off_diag, end, eps);
|
||||
|
||||
start = sub.0;
|
||||
@ -297,7 +297,7 @@ where
|
||||
pub fn wilkinson_shift<N: Real>(tmm: N, tnn: N, tmn: N) -> N {
|
||||
let sq_tmn = tmn * tmn;
|
||||
if !sq_tmn.is_zero() {
|
||||
// We have the guarantee thet the denominator won't be zero.
|
||||
// We have the guarantee that the denominator won't be zero.
|
||||
let d = (tmm - tnn) * ::convert(0.5);
|
||||
tnn - sq_tmn / (d + d.signum() * (d * d + sq_tmn).sqrt())
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user