Rename Real to RealField.

This commit is contained in:
sebcrozet 2019-03-25 11:21:41 +01:00
parent 5b28c39fa7
commit 4ef4001836
98 changed files with 915 additions and 915 deletions

View File

@ -4,7 +4,7 @@ extern crate nalgebra as na;
use alga::linear::FiniteDimInnerSpace;
use na::allocator::Allocator;
use na::dimension::Dim;
use na::{DefaultAllocator, Real, Unit, Vector2, Vector3, VectorN};
use na::{DefaultAllocator, RealField, Unit, Vector2, Vector3, VectorN};
/// Reflects a vector wrt. the hyperplane with normal `plane_normal`.
fn reflect_wrt_hyperplane_with_algebraic_genericity<V>(plane_normal: &Unit<V>, vector: &V) -> V
@ -14,12 +14,12 @@ where V: FiniteDimInnerSpace + Copy {
}
/// Reflects a vector wrt. the hyperplane with normal `plane_normal`.
fn reflect_wrt_hyperplane_with_dimensional_genericity<N: Real, D: Dim>(
fn reflect_wrt_hyperplane_with_dimensional_genericity<N: RealField, D: Dim>(
plane_normal: &Unit<VectorN<N, D>>,
vector: &VectorN<N, D>,
) -> VectorN<N, D>
where
N: Real,
N: RealField,
D: Dim,
DefaultAllocator: Allocator<N, D>,
{
@ -29,7 +29,7 @@ where
/// Reflects a 2D vector wrt. the 2D line with normal `plane_normal`.
fn reflect_wrt_hyperplane2<N>(plane_normal: &Unit<Vector2<N>>, vector: &Vector2<N>) -> Vector2<N>
where N: Real {
where N: RealField {
let n = plane_normal.as_ref(); // Get the underlying Vector2
vector - n * (n.dot(vector) * na::convert(2.0))
}
@ -37,7 +37,7 @@ where N: Real {
/// Reflects a 3D vector wrt. the 3D plane with normal `plane_normal`.
/// /!\ This is an exact replicate of `reflect_wrt_hyperplane2, but for 3D.
fn reflect_wrt_hyperplane3<N>(plane_normal: &Unit<Vector3<N>>, vector: &Vector3<N>) -> Vector3<N>
where N: Real {
where N: RealField {
let n = plane_normal.as_ref(); // Get the underlying Vector3
vector - n * (n.dot(vector) * na::convert(2.0))
}

View File

@ -1,7 +1,7 @@
extern crate alga;
extern crate nalgebra as na;
use alga::general::{Real, RingCommutative};
use alga::general::{RealField, RingCommutative};
use na::{Scalar, Vector3};
fn print_vector<N: Scalar>(m: &Vector3<N>) {
@ -14,11 +14,11 @@ fn print_squared_norm<N: Scalar + RingCommutative>(v: &Vector3<N>) {
println!("{:?}", sqnorm);
}
fn print_norm<N: Real>(v: &Vector3<N>) {
fn print_norm<N: RealField>(v: &Vector3<N>) {
// NOTE: alternatively, nalgebra already defines `v.norm()`.
let norm = v.dot(v).sqrt();
// The Real bound implies that N is Display so we can
// The RealField bound implies that N is Display so we can
// use "{}" instead of "{:?}" for the format string.
println!("{}", norm)
}

View File

@ -1,4 +1,4 @@
use na::{self, DefaultAllocator, Real};
use na::{self, DefaultAllocator, RealField};
use num::FromPrimitive;
use std::mem;
@ -43,7 +43,7 @@ where DefaultAllocator: Alloc<N, R, C> {
/// * [`fract`](fn.fract.html)
/// * [`round`](fn.round.html)
/// * [`trunc`](fn.trunc.html)
pub fn ceil<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn ceil<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|x| x.ceil())
}
@ -222,7 +222,7 @@ where DefaultAllocator: Alloc<f32, D> {
/// * [`fract`](fn.fract.html)
/// * [`round`](fn.round.html)
/// * [`trunc`](fn.trunc.html)
pub fn floor<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn floor<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|x| x.floor())
}
@ -249,14 +249,14 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`floor`](fn.floor.html)
/// * [`round`](fn.round.html)
/// * [`trunc`](fn.trunc.html)
pub fn fract<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn fract<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|x| x.fract())
}
//// FIXME: should be implemented for TVec/TMat?
///// Returns the (significant, exponent) of this float number.
//pub fn frexp<N: Real>(x: N, exp: N) -> (N, N) {
//pub fn frexp<N: RealField>(x: N, exp: N) -> (N, N) {
// // FIXME: is there a better approach?
// let e = x.log2().ceil();
// (x * (-e).exp2(), e)
@ -310,7 +310,7 @@ where DefaultAllocator: Alloc<f32, D> {
//}
///// Returns the (significant, exponent) of this float number.
//pub fn ldexp<N: Real>(x: N, exp: N) -> N {
//pub fn ldexp<N: RealField>(x: N, exp: N) -> N {
// // FIXME: is there a better approach?
// x * (exp).exp2()
//}
@ -499,7 +499,7 @@ pub fn modf<N: Number>(x: N, i: N) -> N {
/// * [`floor`](fn.floor.html)
/// * [`fract`](fn.fract.html)
/// * [`trunc`](fn.trunc.html)
pub fn round<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn round<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|x| x.round())
}
@ -576,7 +576,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`floor`](fn.floor.html)
/// * [`fract`](fn.fract.html)
/// * [`round`](fn.round.html)
pub fn trunc<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn trunc<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|x| x.trunc())
}

View File

@ -1,6 +1,6 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
use na::{Scalar, Real, U2, U3, U4};
use na::{Scalar, RealField, U2, U3, U4};
use crate::aliases::{TMat, Qua, TVec1, TVec2, TVec3, TVec4, TMat2, TMat2x3, TMat2x4, TMat3, TMat3x2, TMat3x4,
TMat4, TMat4x2, TMat4x3};
@ -168,6 +168,6 @@ pub fn mat4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
}
/// Creates a new quaternion.
pub fn quat<N: Real>(x: N, y: N, z: N, w: N) -> Qua<N> {
pub fn quat<N: RealField>(x: N, y: N, z: N, w: N) -> Qua<N> {
Qua::new(w, x, y, z)
}

View File

@ -1,5 +1,5 @@
use crate::aliases::TVec;
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::traits::{Alloc, Dimension};
/// Component-wise exponential.
@ -7,7 +7,7 @@ use crate::traits::{Alloc, Dimension};
/// # See also:
///
/// * [`exp2`](fn.exp2.html)
pub fn exp<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn exp<N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
v.map(|x| x.exp())
}
@ -17,7 +17,7 @@ where DefaultAllocator: Alloc<N, D> {
/// # See also:
///
/// * [`exp`](fn.exp.html)
pub fn exp2<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn exp2<N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
v.map(|x| x.exp2())
}
@ -27,7 +27,7 @@ where DefaultAllocator: Alloc<N, D> {
/// # See also:
///
/// * [`sqrt`](fn.sqrt.html)
pub fn inversesqrt<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn inversesqrt<N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
v.map(|x| N::one() / x.sqrt())
}
@ -37,7 +37,7 @@ where DefaultAllocator: Alloc<N, D> {
/// # See also:
///
/// * [`log2`](fn.log2.html)
pub fn log<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn log<N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
v.map(|x| x.ln())
}
@ -47,13 +47,13 @@ where DefaultAllocator: Alloc<N, D> {
/// # See also:
///
/// * [`log`](fn.log.html)
pub fn log2<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn log2<N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
v.map(|x| x.log2())
}
/// Component-wise power.
pub fn pow<N: Real, D: Dimension>(base: &TVec<N, D>, exponent: &TVec<N, D>) -> TVec<N, D>
pub fn pow<N: RealField, D: Dimension>(base: &TVec<N, D>, exponent: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
base.zip_map(exponent, |b, e| b.powf(e))
}
@ -66,7 +66,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`exp2`](fn.exp2.html)
/// * [`inversesqrt`](fn.inversesqrt.html)
/// * [`pow`](fn.pow.html)
pub fn sqrt<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn sqrt<N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
v.map(|x| x.sqrt())
}

View File

@ -1,55 +1,55 @@
use crate::aliases::TMat4;
use na::{Real};
use na::{RealField};
//pub fn frustum<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//pub fn frustum_lh<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_lh<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_lr_no<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_lr_no<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_lh_zo<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_lh_zo<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_no<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_no<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_rh<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_rh<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_rh_no<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_rh_no<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_rh_zo<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_rh_zo<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn frustum_zo<N: Real>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
//pub fn frustum_zo<N: RealField>(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4<N> {
// unimplemented!()
//}
//pub fn infinite_perspective<N: Real>(fovy: N, aspect: N, near: N) -> TMat4<N> {
//pub fn infinite_perspective<N: RealField>(fovy: N, aspect: N, near: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn infinite_perspective_lh<N: Real>(fovy: N, aspect: N, near: N) -> TMat4<N> {
//pub fn infinite_perspective_lh<N: RealField>(fovy: N, aspect: N, near: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn infinite_perspective_rh<N: Real>(fovy: N, aspect: N, near: N) -> TMat4<N> {
//pub fn infinite_perspective_rh<N: RealField>(fovy: N, aspect: N, near: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn infinite_ortho<N: Real>(left: N, right: N, bottom: N, top: N) -> TMat4<N> {
//pub fn infinite_ortho<N: RealField>(left: N, right: N, bottom: N, top: N) -> TMat4<N> {
// unimplemented!()
//}
@ -64,7 +64,7 @@ use na::{Real};
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
ortho_rh_no(left, right, bottom, top, znear, zfar)
}
@ -79,7 +79,7 @@ pub fn ortho<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_lh<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_lh<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
ortho_lh_no(left, right, bottom, top, znear, zfar)
}
@ -94,7 +94,7 @@ pub fn ortho_lh<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_lh_no<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_lh_no<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
let two : N = crate::convert(2.0);
let mut mat : TMat4<N> = TMat4::<N>::identity();
@ -119,7 +119,7 @@ pub fn ortho_lh_no<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_lh_zo<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_lh_zo<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
let one : N = N::one();
let two : N = crate::convert(2.0);
let mut mat : TMat4<N> = TMat4::<N>::identity();
@ -145,7 +145,7 @@ pub fn ortho_lh_zo<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_no<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_no<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
ortho_rh_no(left, right, bottom, top, znear, zfar)
}
@ -160,7 +160,7 @@ pub fn ortho_no<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_rh<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_rh<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
ortho_rh_no(left, right, bottom, top, znear, zfar)
}
@ -175,7 +175,7 @@ pub fn ortho_rh<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_rh_no<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_rh_no<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
let two : N = crate::convert(2.0);
let mut mat : TMat4<N> = TMat4::<N>::identity();
@ -200,7 +200,7 @@ pub fn ortho_rh_no<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_rh_zo<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_rh_zo<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
let one : N = N::one();
let two : N = crate::convert(2.0);
let mut mat : TMat4<N> = TMat4::<N>::identity();
@ -226,7 +226,7 @@ pub fn ortho_rh_zo<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar
/// * `znear` - Distance from the viewer to the near clipping plane
/// * `zfar` - Distance from the viewer to the far clipping plane
///
pub fn ortho_zo<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
pub fn ortho_zo<N: RealField>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4<N> {
ortho_rh_zo(left, right, bottom, top, znear, zfar)
}
@ -240,7 +240,7 @@ pub fn ortho_zo<N: Real>(left: N, right: N, bottom: N, top: N, znear: N, zfar: N
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
perspective_fov_rh_no(fov, width, height, near, far)
}
@ -254,7 +254,7 @@ pub fn perspective_fov<N: Real>(fov: N, width: N, height: N, near: N, far: N) ->
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_lh<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_lh<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
perspective_fov_lh_no(fov, width, height, near, far)
}
@ -268,7 +268,7 @@ pub fn perspective_fov_lh<N: Real>(fov: N, width: N, height: N, near: N, far: N)
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_lh_no<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_lh_no<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
assert!(
width > N::zero(),
"The width must be greater than zero"
@ -307,7 +307,7 @@ pub fn perspective_fov_lh_no<N: Real>(fov: N, width: N, height: N, near: N, far:
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_lh_zo<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_lh_zo<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
assert!(
width > N::zero(),
"The width must be greater than zero"
@ -346,7 +346,7 @@ pub fn perspective_fov_lh_zo<N: Real>(fov: N, width: N, height: N, near: N, far:
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_no<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_no<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
perspective_fov_rh_no(fov, width, height, near, far)
}
@ -360,7 +360,7 @@ pub fn perspective_fov_no<N: Real>(fov: N, width: N, height: N, near: N, far: N)
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_rh<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_rh<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
perspective_fov_rh_no(fov, width, height, near, far)
}
@ -374,7 +374,7 @@ pub fn perspective_fov_rh<N: Real>(fov: N, width: N, height: N, near: N, far: N)
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_rh_no<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_rh_no<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
assert!(
width > N::zero(),
"The width must be greater than zero"
@ -413,7 +413,7 @@ pub fn perspective_fov_rh_no<N: Real>(fov: N, width: N, height: N, near: N, far:
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_rh_zo<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_rh_zo<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
assert!(
width > N::zero(),
"The width must be greater than zero"
@ -452,7 +452,7 @@ pub fn perspective_fov_rh_zo<N: Real>(fov: N, width: N, height: N, near: N, far:
/// * `near` - Distance from the viewer to the near clipping plane
/// * `far` - Distance from the viewer to the far clipping plane
///
pub fn perspective_fov_zo<N: Real>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_fov_zo<N: RealField>(fov: N, width: N, height: N, near: N, far: N) -> TMat4<N> {
perspective_fov_rh_zo(fov, width, height, near, far)
}
@ -467,7 +467,7 @@ pub fn perspective_fov_zo<N: Real>(fov: N, width: N, height: N, near: N, far: N)
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
// TODO: Breaking change - revert back to proper glm conventions?
//
// Prior to changes to support configuring the behaviour of this function it was simply
@ -496,7 +496,7 @@ pub fn perspective<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_lh<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_lh<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
perspective_lh_no(aspect, fovy, near, far)
}
@ -511,7 +511,7 @@ pub fn perspective_lh<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N>
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_lh_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_lh_no<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
assert!(
!relative_eq!(far - near, N::zero()),
"The near-plane and far-plane must not be superimposed."
@ -547,7 +547,7 @@ pub fn perspective_lh_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_lh_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_lh_zo<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
assert!(
!relative_eq!(far - near, N::zero()),
"The near-plane and far-plane must not be superimposed."
@ -583,7 +583,7 @@ pub fn perspective_lh_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_no<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
perspective_rh_no(aspect, fovy, near, far)
}
@ -598,7 +598,7 @@ pub fn perspective_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N>
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_rh<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_rh<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
perspective_rh_no(aspect, fovy, near, far)
}
@ -613,7 +613,7 @@ pub fn perspective_rh<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N>
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_rh_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_rh_no<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
assert!(
!relative_eq!(far - near, N::zero()),
"The near-plane and far-plane must not be superimposed."
@ -650,7 +650,7 @@ pub fn perspective_rh_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_rh_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_rh_zo<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
assert!(
!relative_eq!(far - near, N::zero()),
"The near-plane and far-plane must not be superimposed."
@ -687,14 +687,14 @@ pub fn perspective_rh_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
///
/// # Important note
/// The `aspect` and `fovy` argument are interchanged compared to the original GLM API.
pub fn perspective_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
pub fn perspective_zo<N: RealField>(aspect: N, fovy: N, near: N, far: N) -> TMat4<N> {
perspective_rh_zo(aspect, fovy, near, far)
}
//pub fn tweaked_infinite_perspective<N: Real>(fovy: N, aspect: N, near: N) -> TMat4<N> {
//pub fn tweaked_infinite_perspective<N: RealField>(fovy: N, aspect: N, near: N) -> TMat4<N> {
// unimplemented!()
//}
//
//pub fn tweaked_infinite_perspective_ep<N: Real>(fovy: N, aspect: N, near: N, ep: N) -> TMat4<N> {
//pub fn tweaked_infinite_perspective_ep<N: RealField>(fovy: N, aspect: N, near: N, ep: N) -> TMat4<N> {
// unimplemented!()
//}

View File

@ -1,4 +1,4 @@
use na::{self, Real, U3};
use na::{self, RealField, U3};
use crate::aliases::{TMat4, TVec2, TVec3, TVec4};
@ -9,7 +9,7 @@ use crate::aliases::{TMat4, TVec2, TVec3, TVec4};
/// * `center` - Specify the center of a picking region in window coordinates.
/// * `delta` - Specify the width and height, respectively, of the picking region in window coordinates.
/// * `viewport` - Rendering viewport.
pub fn pick_matrix<N: Real>(center: &TVec2<N>, delta: &TVec2<N>, viewport: &TVec4<N>) -> TMat4<N> {
pub fn pick_matrix<N: RealField>(center: &TVec2<N>, delta: &TVec2<N>, viewport: &TVec4<N>) -> TMat4<N> {
let shift = TVec3::new(
(viewport.z - (center.x - viewport.x) * na::convert(2.0)) / delta.x,
(viewport.w - (center.y - viewport.y) * na::convert(2.0)) / delta.y,
@ -41,7 +41,7 @@ pub fn pick_matrix<N: Real>(center: &TVec2<N>, delta: &TVec2<N>, viewport: &TVec
/// * [`unproject`](fn.unproject.html)
/// * [`unproject_no`](fn.unproject_no.html)
/// * [`unproject_zo`](fn.unproject_zo.html)
pub fn project<N: Real>(
pub fn project<N: RealField>(
obj: &TVec3<N>,
model: &TMat4<N>,
proj: &TMat4<N>,
@ -69,7 +69,7 @@ pub fn project<N: Real>(
/// * [`unproject`](fn.unproject.html)
/// * [`unproject_no`](fn.unproject_no.html)
/// * [`unproject_zo`](fn.unproject_zo.html)
pub fn project_no<N: Real>(
pub fn project_no<N: RealField>(
obj: &TVec3<N>,
model: &TMat4<N>,
proj: &TMat4<N>,
@ -98,7 +98,7 @@ pub fn project_no<N: Real>(
/// * [`unproject`](fn.unproject.html)
/// * [`unproject_no`](fn.unproject_no.html)
/// * [`unproject_zo`](fn.unproject_zo.html)
pub fn project_zo<N: Real>(
pub fn project_zo<N: RealField>(
obj: &TVec3<N>,
model: &TMat4<N>,
proj: &TMat4<N>,
@ -132,7 +132,7 @@ pub fn project_zo<N: Real>(
/// * [`project_zo`](fn.project_zo.html)
/// * [`unproject_no`](fn.unproject_no.html)
/// * [`unproject_zo`](fn.unproject_zo.html)
pub fn unproject<N: Real>(
pub fn unproject<N: RealField>(
win: &TVec3<N>,
model: &TMat4<N>,
proj: &TMat4<N>,
@ -160,7 +160,7 @@ pub fn unproject<N: Real>(
/// * [`project_zo`](fn.project_zo.html)
/// * [`unproject`](fn.unproject.html)
/// * [`unproject_zo`](fn.unproject_zo.html)
pub fn unproject_no<N: Real>(
pub fn unproject_no<N: RealField>(
win: &TVec3<N>,
model: &TMat4<N>,
proj: &TMat4<N>,
@ -198,7 +198,7 @@ pub fn unproject_no<N: Real>(
/// * [`project_zo`](fn.project_zo.html)
/// * [`unproject`](fn.unproject.html)
/// * [`unproject_no`](fn.unproject_no.html)
pub fn unproject_zo<N: Real>(
pub fn unproject_zo<N: RealField>(
win: &TVec3<N>,
model: &TMat4<N>,
proj: &TMat4<N>,

View File

@ -1,4 +1,4 @@
use na::{DefaultAllocator, Point3, Real, Rotation3, Unit};
use na::{DefaultAllocator, Point3, RealField, Rotation3, Unit};
use crate::aliases::{TMat, TMat4, TVec, TVec3};
use crate::traits::{Alloc, Dimension, Number};
@ -21,7 +21,7 @@ where DefaultAllocator: Alloc<N, D, D> {
///
/// * [`look_at_lh`](fn.look_at_lh.html)
/// * [`look_at_rh`](fn.look_at_rh.html)
pub fn look_at<N: Real>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
pub fn look_at<N: RealField>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
look_at_rh(eye, center, up)
}
@ -37,7 +37,7 @@ pub fn look_at<N: Real>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMa
///
/// * [`look_at`](fn.look_at.html)
/// * [`look_at_rh`](fn.look_at_rh.html)
pub fn look_at_lh<N: Real>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
pub fn look_at_lh<N: RealField>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
TMat::look_at_lh(&Point3::from(*eye), &Point3::from(*center), up)
}
@ -53,7 +53,7 @@ pub fn look_at_lh<N: Real>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) ->
///
/// * [`look_at`](fn.look_at.html)
/// * [`look_at_lh`](fn.look_at_lh.html)
pub fn look_at_rh<N: Real>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
pub fn look_at_rh<N: RealField>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
TMat::look_at_rh(&Point3::from(*eye), &Point3::from(*center), up)
}
@ -72,7 +72,7 @@ pub fn look_at_rh<N: Real>(eye: &TVec3<N>, center: &TVec3<N>, up: &TVec3<N>) ->
/// * [`rotate_z`](fn.rotate_z.html)
/// * [`scale`](fn.scale.html)
/// * [`translate`](fn.translate.html)
pub fn rotate<N: Real>(m: &TMat4<N>, angle: N, axis: &TVec3<N>) -> TMat4<N> {
pub fn rotate<N: RealField>(m: &TMat4<N>, angle: N, axis: &TVec3<N>) -> TMat4<N> {
m * Rotation3::from_axis_angle(&Unit::new_normalize(*axis), angle).to_homogeneous()
}
@ -90,7 +90,7 @@ pub fn rotate<N: Real>(m: &TMat4<N>, angle: N, axis: &TVec3<N>) -> TMat4<N> {
/// * [`rotate_z`](fn.rotate_z.html)
/// * [`scale`](fn.scale.html)
/// * [`translate`](fn.translate.html)
pub fn rotate_x<N: Real>(m: &TMat4<N>, angle: N) -> TMat4<N> {
pub fn rotate_x<N: RealField>(m: &TMat4<N>, angle: N) -> TMat4<N> {
rotate(m, angle, &TVec::x())
}
@ -108,7 +108,7 @@ pub fn rotate_x<N: Real>(m: &TMat4<N>, angle: N) -> TMat4<N> {
/// * [`rotate_z`](fn.rotate_z.html)
/// * [`scale`](fn.scale.html)
/// * [`translate`](fn.translate.html)
pub fn rotate_y<N: Real>(m: &TMat4<N>, angle: N) -> TMat4<N> {
pub fn rotate_y<N: RealField>(m: &TMat4<N>, angle: N) -> TMat4<N> {
rotate(m, angle, &TVec::y())
}
@ -126,7 +126,7 @@ pub fn rotate_y<N: Real>(m: &TMat4<N>, angle: N) -> TMat4<N> {
/// * [`rotate_y`](fn.rotate_y.html)
/// * [`scale`](fn.scale.html)
/// * [`translate`](fn.translate.html)
pub fn rotate_z<N: Real>(m: &TMat4<N>, angle: N) -> TMat4<N> {
pub fn rotate_z<N: RealField>(m: &TMat4<N>, angle: N) -> TMat4<N> {
rotate(m, angle, &TVec::z())
}

View File

@ -1,36 +1,36 @@
use na::{self, Real, Unit};
use na::{self, RealField, Unit};
use crate::aliases::Qua;
/// The conjugate of `q`.
pub fn quat_conjugate<N: Real>(q: &Qua<N>) -> Qua<N> {
pub fn quat_conjugate<N: RealField>(q: &Qua<N>) -> Qua<N> {
q.conjugate()
}
/// The inverse of `q`.
pub fn quat_inverse<N: Real>(q: &Qua<N>) -> Qua<N> {
pub fn quat_inverse<N: RealField>(q: &Qua<N>) -> Qua<N> {
q.try_inverse().unwrap_or_else(na::zero)
}
//pub fn quat_isinf<N: Real>(x: &Qua<N>) -> TVec<bool, U4> {
//pub fn quat_isinf<N: RealField>(x: &Qua<N>) -> TVec<bool, U4> {
// x.coords.map(|e| e.is_inf())
//}
//pub fn quat_isnan<N: Real>(x: &Qua<N>) -> TVec<bool, U4> {
//pub fn quat_isnan<N: RealField>(x: &Qua<N>) -> TVec<bool, U4> {
// x.coords.map(|e| e.is_nan())
//}
/// Interpolate linearly between `x` and `y`.
pub fn quat_lerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
pub fn quat_lerp<N: RealField>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
x.lerp(y, a)
}
//pub fn quat_mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
//pub fn quat_mix<N: RealField>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
// x * (N::one() - a) + y * a
//}
/// Interpolate spherically between `x` and `y`.
pub fn quat_slerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
pub fn quat_slerp<N: RealField>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
Unit::new_normalize(*x)
.slerp(&Unit::new_normalize(*y), a)
.into_inner()

View File

@ -1,28 +1,28 @@
use na::Real;
use na::RealField;
use crate::aliases::Qua;
/// Multiplies two quaternions.
pub fn quat_cross<N: Real>(q1: &Qua<N>, q2: &Qua<N>) -> Qua<N> {
pub fn quat_cross<N: RealField>(q1: &Qua<N>, q2: &Qua<N>) -> Qua<N> {
q1 * q2
}
/// The scalar product of two quaternions.
pub fn quat_dot<N: Real>(x: &Qua<N>, y: &Qua<N>) -> N {
pub fn quat_dot<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> N {
x.dot(y)
}
/// The magnitude of the quaternion `q`.
pub fn quat_length<N: Real>(q: &Qua<N>) -> N {
pub fn quat_length<N: RealField>(q: &Qua<N>) -> N {
q.norm()
}
/// The magnitude of the quaternion `q`.
pub fn quat_magnitude<N: Real>(q: &Qua<N>) -> N {
pub fn quat_magnitude<N: RealField>(q: &Qua<N>) -> N {
q.norm()
}
/// Normalizes the quaternion `q`.
pub fn quat_normalize<N: Real>(q: &Qua<N>) -> Qua<N> {
pub fn quat_normalize<N: RealField>(q: &Qua<N>) -> Qua<N> {
q.normalize()
}

View File

@ -1,23 +1,23 @@
use na::{Real, U4};
use na::{RealField, U4};
use crate::aliases::{Qua, TVec};
/// Component-wise equality comparison between two quaternions.
pub fn quat_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_equal<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
crate::equal(&x.coords, &y.coords)
}
/// Component-wise approximate equality comparison between two quaternions.
pub fn quat_equal_eps<N: Real>(x: &Qua<N>, y: &Qua<N>, epsilon: N) -> TVec<bool, U4> {
pub fn quat_equal_eps<N: RealField>(x: &Qua<N>, y: &Qua<N>, epsilon: N) -> TVec<bool, U4> {
crate::equal_eps(&x.coords, &y.coords, epsilon)
}
/// Component-wise non-equality comparison between two quaternions.
pub fn quat_not_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_not_equal<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
crate::not_equal(&x.coords, &y.coords)
}
/// Component-wise approximate non-equality comparison between two quaternions.
pub fn quat_not_equal_eps<N: Real>(x: &Qua<N>, y: &Qua<N>, epsilon: N) -> TVec<bool, U4> {
pub fn quat_not_equal_eps<N: RealField>(x: &Qua<N>, y: &Qua<N>, epsilon: N) -> TVec<bool, U4> {
crate::not_equal_eps(&x.coords, &y.coords, epsilon)
}

View File

@ -1,27 +1,27 @@
use na::{Real, Unit, UnitQuaternion};
use na::{RealField, Unit, UnitQuaternion};
use crate::aliases::{Qua, TVec3};
/// Computes the quaternion exponential.
pub fn quat_exp<N: Real>(q: &Qua<N>) -> Qua<N> {
pub fn quat_exp<N: RealField>(q: &Qua<N>) -> Qua<N> {
q.exp()
}
/// Computes the quaternion logarithm.
pub fn quat_log<N: Real>(q: &Qua<N>) -> Qua<N> {
pub fn quat_log<N: RealField>(q: &Qua<N>) -> Qua<N> {
q.ln()
}
/// Raises the quaternion `q` to the power `y`.
pub fn quat_pow<N: Real>(q: &Qua<N>, y: N) -> Qua<N> {
pub fn quat_pow<N: RealField>(q: &Qua<N>, y: N) -> Qua<N> {
q.powf(y)
}
/// Builds a quaternion from an axis and an angle, and right-multiply it to the quaternion `q`.
pub fn quat_rotate<N: Real>(q: &Qua<N>, angle: N, axis: &TVec3<N>) -> Qua<N> {
pub fn quat_rotate<N: RealField>(q: &Qua<N>, angle: N, axis: &TVec3<N>) -> Qua<N> {
q * UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).into_inner()
}
//pub fn quat_sqrt<N: Real>(q: &Qua<N>) -> Qua<N> {
//pub fn quat_sqrt<N: RealField>(q: &Qua<N>) -> Qua<N> {
// unimplemented!()
//}

View File

@ -1,19 +1,19 @@
use na::{Real, Unit, UnitQuaternion};
use na::{RealField, Unit, UnitQuaternion};
use crate::aliases::{Qua, TVec3};
/// The rotation angle of this quaternion assumed to be normalized.
pub fn quat_angle<N: Real>(x: &Qua<N>) -> N {
pub fn quat_angle<N: RealField>(x: &Qua<N>) -> N {
UnitQuaternion::from_quaternion(*x).angle()
}
/// Creates a quaternion from an axis and an angle.
pub fn quat_angle_axis<N: Real>(angle: N, axis: &TVec3<N>) -> Qua<N> {
pub fn quat_angle_axis<N: RealField>(angle: N, axis: &TVec3<N>) -> Qua<N> {
UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).into_inner()
}
/// The rotation axis of a quaternion assumed to be normalized.
pub fn quat_axis<N: Real>(x: &Qua<N>) -> TVec3<N> {
pub fn quat_axis<N: RealField>(x: &Qua<N>) -> TVec3<N> {
if let Some(a) = UnitQuaternion::from_quaternion(*x).axis() {
a.into_inner()
} else {

View File

@ -1,5 +1,5 @@
use approx::AbsDiffEq;
use na::Real;
use na::RealField;
/// Default epsilon value used for approximate comparison.
pub fn epsilon<N: AbsDiffEq<Epsilon = N>>() -> N {
@ -22,6 +22,6 @@ pub fn epsilon<N: AbsDiffEq<Epsilon = N>>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn pi<N: Real>() -> N {
pub fn pi<N: RealField>() -> N {
N::pi()
}

View File

@ -1,4 +1,4 @@
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::aliases::{TVec, TVec3};
use crate::traits::{Alloc, Dimension, Number};
@ -13,7 +13,7 @@ pub fn cross<N: Number, D: Dimension>(x: &TVec3<N>, y: &TVec3<N>) -> TVec3<N> {
/// # See also:
///
/// * [`distance2`](fn.distance2.html)
pub fn distance<N: Real, D: Dimension>(p0: &TVec<N, D>, p1: &TVec<N, D>) -> N
pub fn distance<N: RealField, D: Dimension>(p0: &TVec<N, D>, p1: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
(p1 - p0).norm()
}
@ -49,7 +49,7 @@ where
/// * [`length2`](fn.length2.html)
/// * [`magnitude`](fn.magnitude.html)
/// * [`magnitude2`](fn.magnitude2.html)
pub fn length<N: Real, D: Dimension>(x: &TVec<N, D>) -> N
pub fn length<N: RealField, D: Dimension>(x: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
x.norm()
}
@ -63,13 +63,13 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`length`](fn.length.html)
/// * [`magnitude2`](fn.magnitude2.html)
/// * [`nalgebra::norm`](../nalgebra/fn.norm.html)
pub fn magnitude<N: Real, D: Dimension>(x: &TVec<N, D>) -> N
pub fn magnitude<N: RealField, D: Dimension>(x: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
x.norm()
}
/// Normalizes a vector.
pub fn normalize<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn normalize<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.normalize()
}
@ -82,7 +82,7 @@ where DefaultAllocator: Alloc<N, D> {
}
/// For the incident vector `i` and surface normal `n`, and the ratio of indices of refraction `eta`, return the refraction vector.
pub fn refract_vec<N: Real, D: Dimension>(i: &TVec<N, D>, n: &TVec<N, D>, eta: N) -> TVec<N, D>
pub fn refract_vec<N: RealField, D: Dimension>(i: &TVec<N, D>, n: &TVec<N, D>, eta: N) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
let ni = n.dot(i);
let k = N::one() - eta * eta * (N::one() - ni * ni);

View File

@ -1,14 +1,14 @@
use na::{self, Real};
use na::{self, RealField};
/// The Euler constant.
///
/// This is a shorthand alias for [`euler`](fn.euler.html).
pub fn e<N: Real>() -> N {
pub fn e<N: RealField>() -> N {
N::e()
}
/// The Euler constant.
pub fn euler<N: Real>() -> N {
pub fn euler<N: RealField>() -> N {
N::e()
}
@ -28,12 +28,12 @@ pub fn euler<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn four_over_pi<N: Real>() -> N {
pub fn four_over_pi<N: RealField>() -> N {
na::convert::<_, N>(4.0) / N::pi()
}
/// Returns the golden ratio.
pub fn golden_ratio<N: Real>() -> N {
pub fn golden_ratio<N: RealField>() -> N {
(N::one() + root_five()) / na::convert(2.0)
}
@ -53,7 +53,7 @@ pub fn golden_ratio<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn half_pi<N: Real>() -> N {
pub fn half_pi<N: RealField>() -> N {
N::frac_pi_2()
}
@ -63,7 +63,7 @@ pub fn half_pi<N: Real>() -> N {
///
/// * [`ln_ten`](fn.ln_ten.html)
/// * [`ln_two`](fn.ln_two.html)
pub fn ln_ln_two<N: Real>() -> N {
pub fn ln_ln_two<N: RealField>() -> N {
N::ln_2().ln()
}
@ -73,7 +73,7 @@ pub fn ln_ln_two<N: Real>() -> N {
///
/// * [`ln_ln_two`](fn.ln_ln_two.html)
/// * [`ln_two`](fn.ln_two.html)
pub fn ln_ten<N: Real>() -> N {
pub fn ln_ten<N: RealField>() -> N {
N::ln_10()
}
@ -83,7 +83,7 @@ pub fn ln_ten<N: Real>() -> N {
///
/// * [`ln_ln_two`](fn.ln_ln_two.html)
/// * [`ln_ten`](fn.ln_ten.html)
pub fn ln_two<N: Real>() -> N {
pub fn ln_two<N: RealField>() -> N {
N::ln_2()
}
@ -106,12 +106,12 @@ pub use na::one;
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn one_over_pi<N: Real>() -> N {
pub fn one_over_pi<N: RealField>() -> N {
N::frac_1_pi()
}
/// Returns `1 / sqrt(2)`.
pub fn one_over_root_two<N: Real>() -> N {
pub fn one_over_root_two<N: RealField>() -> N {
N::one() / root_two()
}
@ -131,7 +131,7 @@ pub fn one_over_root_two<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn one_over_two_pi<N: Real>() -> N {
pub fn one_over_two_pi<N: RealField>() -> N {
N::frac_1_pi() * na::convert(0.5)
}
@ -151,7 +151,7 @@ pub fn one_over_two_pi<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn quarter_pi<N: Real>() -> N {
pub fn quarter_pi<N: RealField>() -> N {
N::frac_pi_4()
}
@ -161,7 +161,7 @@ pub fn quarter_pi<N: Real>() -> N {
///
/// * [`root_three`](fn.root_three.html)
/// * [`root_two`](fn.root_two.html)
pub fn root_five<N: Real>() -> N {
pub fn root_five<N: RealField>() -> N {
na::convert::<_, N>(5.0).sqrt()
}
@ -181,12 +181,12 @@ pub fn root_five<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn root_half_pi<N: Real>() -> N {
pub fn root_half_pi<N: RealField>() -> N {
(N::pi() / na::convert(2.0)).sqrt()
}
/// Returns `sqrt(ln(4))`.
pub fn root_ln_four<N: Real>() -> N {
pub fn root_ln_four<N: RealField>() -> N {
na::convert::<_, N>(4.0).ln().sqrt()
}
@ -206,7 +206,7 @@ pub fn root_ln_four<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn root_pi<N: Real>() -> N {
pub fn root_pi<N: RealField>() -> N {
N::pi().sqrt()
}
@ -216,7 +216,7 @@ pub fn root_pi<N: Real>() -> N {
///
/// * [`root_five`](fn.root_five.html)
/// * [`root_two`](fn.root_two.html)
pub fn root_three<N: Real>() -> N {
pub fn root_three<N: RealField>() -> N {
na::convert::<_, N>(3.0).sqrt()
}
@ -226,8 +226,8 @@ pub fn root_three<N: Real>() -> N {
///
/// * [`root_five`](fn.root_five.html)
/// * [`root_three`](fn.root_three.html)
pub fn root_two<N: Real>() -> N {
// FIXME: there should be a crate::sqrt_2() on the Real trait.
pub fn root_two<N: RealField>() -> N {
// FIXME: there should be a crate::sqrt_2() on the RealField trait.
na::convert::<_, N>(2.0).sqrt()
}
@ -247,7 +247,7 @@ pub fn root_two<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn root_two_pi<N: Real>() -> N {
pub fn root_two_pi<N: RealField>() -> N {
N::two_pi().sqrt()
}
@ -256,7 +256,7 @@ pub fn root_two_pi<N: Real>() -> N {
/// # See also:
///
/// * [`two_thirds`](fn.two_thirds.html)
pub fn third<N: Real>() -> N {
pub fn third<N: RealField>() -> N {
na::convert(1.0 / 3.0)
}
@ -276,7 +276,7 @@ pub fn third<N: Real>() -> N {
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn three_over_two_pi<N: Real>() -> N {
pub fn three_over_two_pi<N: RealField>() -> N {
na::convert::<_, N>(3.0) / N::two_pi()
}
@ -295,7 +295,7 @@ pub fn three_over_two_pi<N: Real>() -> N {
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn two_over_pi<N: Real>() -> N {
pub fn two_over_pi<N: RealField>() -> N {
N::frac_2_pi()
}
@ -315,7 +315,7 @@ pub fn two_over_pi<N: Real>() -> N {
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_pi`](fn.two_pi.html)
pub fn two_over_root_pi<N: Real>() -> N {
pub fn two_over_root_pi<N: RealField>() -> N {
N::frac_2_sqrt_pi()
}
@ -335,7 +335,7 @@ pub fn two_over_root_pi<N: Real>() -> N {
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
/// * [`two_over_pi`](fn.two_over_pi.html)
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
pub fn two_pi<N: Real>() -> N {
pub fn two_pi<N: RealField>() -> N {
N::two_pi()
}
@ -344,7 +344,7 @@ pub fn two_pi<N: Real>() -> N {
/// # See also:
///
/// * [`third`](fn.third.html)
pub fn two_thirds<N: Real>() -> N {
pub fn two_thirds<N: RealField>() -> N {
na::convert(2.0 / 3.0)
}

View File

@ -1,17 +1,17 @@
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::aliases::TMat;
use crate::traits::{Alloc, Dimension};
/// Fast matrix inverse for affine matrix.
pub fn affine_inverse<N: Real, D: Dimension>(m: TMat<N, D, D>) -> TMat<N, D, D>
pub fn affine_inverse<N: RealField, D: Dimension>(m: TMat<N, D, D>) -> TMat<N, D, D>
where DefaultAllocator: Alloc<N, D, D> {
// FIXME: this should be optimized.
m.try_inverse().unwrap_or_else(TMat::<_, D, D>::zeros)
}
/// Compute the transpose of the inverse of a matrix.
pub fn inverse_transpose<N: Real, D: Dimension>(m: TMat<N, D, D>) -> TMat<N, D, D>
pub fn inverse_transpose<N: RealField, D: Dimension>(m: TMat<N, D, D>) -> TMat<N, D, D>
where DefaultAllocator: Alloc<N, D, D> {
m.try_inverse()
.unwrap_or_else(TMat::<_, D, D>::zeros)

View File

@ -1,4 +1,4 @@
use na::{Scalar, Real, DefaultAllocator, U3, U4};
use na::{Scalar, RealField, DefaultAllocator, U3, U4};
use crate::traits::{Alloc, Dimension};
use crate::aliases::*;
@ -53,7 +53,7 @@ pub fn packRGBM<N: Scalar>(rgb: &TVec3<N>) -> TVec4<N> {
unimplemented!()
}
pub fn packSnorm<I: Scalar, N: Real, D: Dimension>(v: TVec<N, D>) -> TVec<I, D>
pub fn packSnorm<I: Scalar, N: RealField, D: Dimension>(v: TVec<N, D>) -> TVec<I, D>
where DefaultAllocator: Alloc<N, D> + Alloc<I, D> {
unimplemented!()
}
@ -102,7 +102,7 @@ pub fn packUint4x8(v: &U8Vec4) -> i32 {
unimplemented!()
}
pub fn packUnorm<UI: Scalar, N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<UI, D>
pub fn packUnorm<UI: Scalar, N: RealField, D: Dimension>(v: &TVec<N, D>) -> TVec<UI, D>
where DefaultAllocator: Alloc<N, D> + Alloc<UI, D> {
unimplemented!()
}
@ -196,7 +196,7 @@ pub fn unpackRGBM<N: Scalar>(rgbm: &TVec4<N>) -> TVec3<N> {
unimplemented!()
}
pub fn unpackSnorm<I: Scalar, N: Real, D: Dimension>(v: &TVec<I, D>) -> TVec<N, D>
pub fn unpackSnorm<I: Scalar, N: RealField, D: Dimension>(v: &TVec<I, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> + Alloc<I, D> {
unimplemented!()
}
@ -245,7 +245,7 @@ pub fn unpackUint4x8(p: i32) -> U8Vec4 {
unimplemented!()
}
pub fn unpackUnorm<UI: Scalar, N: Real, D: Dimension>(v: &TVec<UI, D>) -> TVec<N, D>
pub fn unpackUnorm<UI: Scalar, N: RealField, D: Dimension>(v: &TVec<UI, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> + Alloc<UI, D> {
unimplemented!()
}

View File

@ -1,36 +1,36 @@
use na::{Real, UnitQuaternion, U4};
use na::{RealField, UnitQuaternion, U4};
use crate::aliases::{Qua, TMat4, TVec, TVec3};
/// Euler angles of the quaternion `q` as (pitch, yaw, roll).
pub fn quat_euler_angles<N: Real>(x: &Qua<N>) -> TVec3<N> {
pub fn quat_euler_angles<N: RealField>(x: &Qua<N>) -> TVec3<N> {
let q = UnitQuaternion::new_unchecked(*x);
let a = q.euler_angles();
TVec3::new(a.2, a.1, a.0)
}
/// Component-wise `>` comparison between two quaternions.
pub fn quat_greater_than<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_greater_than<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
crate::greater_than(&x.coords, &y.coords)
}
/// Component-wise `>=` comparison between two quaternions.
pub fn quat_greater_than_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_greater_than_equal<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
crate::greater_than_equal(&x.coords, &y.coords)
}
/// Component-wise `<` comparison between two quaternions.
pub fn quat_less_than<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_less_than<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
crate::less_than(&x.coords, &y.coords)
}
/// Component-wise `<=` comparison between two quaternions.
pub fn quat_less_than_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_less_than_equal<N: RealField>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
crate::less_than_equal(&x.coords, &y.coords)
}
/// Convert a quaternion to a rotation matrix in homogeneous coordinates.
pub fn quat_cast<N: Real>(x: &Qua<N>) -> TMat4<N> {
pub fn quat_cast<N: RealField>(x: &Qua<N>) -> TMat4<N> {
crate::quat_to_mat4(x)
}
@ -41,34 +41,34 @@ pub fn quat_cast<N: Real>(x: &Qua<N>) -> TMat4<N> {
/// * `direction` - Direction vector point at where to look
/// * `up` - Object up vector
///
pub fn quat_look_at<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
pub fn quat_look_at<N: RealField>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
quat_look_at_rh(direction, up)
}
/// Computes a left-handed look-at quaternion (equivalent to a left-handed look-at matrix).
pub fn quat_look_at_lh<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
pub fn quat_look_at_lh<N: RealField>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
UnitQuaternion::look_at_lh(direction, up).into_inner()
}
/// Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix).
pub fn quat_look_at_rh<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
pub fn quat_look_at_rh<N: RealField>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
UnitQuaternion::look_at_rh(direction, up).into_inner()
}
/// The "roll" Euler angle of the quaternion `x` assumed to be normalized.
pub fn quat_roll<N: Real>(x: &Qua<N>) -> N {
pub fn quat_roll<N: RealField>(x: &Qua<N>) -> N {
// FIXME: optimize this.
quat_euler_angles(x).z
}
/// The "yaw" Euler angle of the quaternion `x` assumed to be normalized.
pub fn quat_yaw<N: Real>(x: &Qua<N>) -> N {
pub fn quat_yaw<N: RealField>(x: &Qua<N>) -> N {
// FIXME: optimize this.
quat_euler_angles(x).y
}
/// The "pitch" Euler angle of the quaternion `x` assumed to be normalized.
pub fn quat_pitch<N: Real>(x: &Qua<N>) -> N {
pub fn quat_pitch<N: RealField>(x: &Qua<N>) -> N {
// FIXME: optimize this.
quat_euler_angles(x).x
}

View File

@ -1,4 +1,4 @@
use na::{Scalar, Real, U3, DefaultAllocator};
use na::{Scalar, RealField, U3, DefaultAllocator};
use crate::traits::{Number, Alloc, Dimension};
use crate::aliases::TVec;

View File

@ -1,4 +1,4 @@
use na::{DefaultAllocator, Quaternion, Real, Scalar};
use na::{DefaultAllocator, Quaternion, RealField, Scalar};
use crate::aliases::{
Qua, TMat, TMat2, TMat2x3, TMat2x4, TMat3, TMat3x2, TMat3x4, TMat4, TMat4x2, TMat4x3, TVec1,
@ -112,7 +112,7 @@ pub fn mat4_to_mat2<N: Scalar>(m: &TMat4<N>) -> TMat2<N> {
}
/// Creates a quaternion from a slice arranged as `[x, y, z, w]`.
pub fn make_quat<N: Real>(ptr: &[N]) -> Qua<N> {
pub fn make_quat<N: RealField>(ptr: &[N]) -> Qua<N> {
Quaternion::from(TVec4::from_column_slice(ptr))
}

View File

@ -1,163 +1,163 @@
use na::{Real, U3, U4};
use na::{RealField, U3, U4};
use crate::aliases::{TVec, TMat};
pub fn derivedEulerAngleX<N: Real>(angleX: N, angularVelocityX: N) -> TMat4<N> {
pub fn derivedEulerAngleX<N: RealField>(angleX: N, angularVelocityX: N) -> TMat4<N> {
unimplemented!()
}
pub fn derivedEulerAngleY<N: Real>(angleY: N, angularVelocityY: N) -> TMat4<N> {
pub fn derivedEulerAngleY<N: RealField>(angleY: N, angularVelocityY: N) -> TMat4<N> {
unimplemented!()
}
pub fn derivedEulerAngleZ<N: Real>(angleZ: N, angularVelocityZ: N) -> TMat4<N> {
pub fn derivedEulerAngleZ<N: RealField>(angleZ: N, angularVelocityZ: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleX<N: Real>(angleX: N) -> TMat4<N> {
pub fn eulerAngleX<N: RealField>(angleX: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleXY<N: Real>(angleX: N, angleY: N) -> TMat4<N> {
pub fn eulerAngleXY<N: RealField>(angleX: N, angleY: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleXYX<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleXYX<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleXYZ<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleXYZ<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleXZ<N: Real>(angleX: N, angleZ: N) -> TMat4<N> {
pub fn eulerAngleXZ<N: RealField>(angleX: N, angleZ: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleXZX<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleXZX<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleXZY<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleXZY<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleY<N: Real>(angleY: N) -> TMat4<N> {
pub fn eulerAngleY<N: RealField>(angleY: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleYX<N: Real>(angleY: N, angleX: N) -> TMat4<N> {
pub fn eulerAngleYX<N: RealField>(angleY: N, angleX: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleYXY<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleYXY<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleYXZ<N: Real>(yaw: N, pitch: N, roll: N) -> TMat4<N> {
pub fn eulerAngleYXZ<N: RealField>(yaw: N, pitch: N, roll: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleYZ<N: Real>(angleY: N, angleZ: N) -> TMat4<N> {
pub fn eulerAngleYZ<N: RealField>(angleY: N, angleZ: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleYZX<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleYZX<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleYZY<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleYZY<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZ<N: Real>(angleZ: N) -> TMat4<N> {
pub fn eulerAngleZ<N: RealField>(angleZ: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZX<N: Real>(angle: N, angleX: N) -> TMat4<N> {
pub fn eulerAngleZX<N: RealField>(angle: N, angleX: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZXY<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleZXY<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZXZ<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleZXZ<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZY<N: Real>(angleZ: N, angleY: N) -> TMat4<N> {
pub fn eulerAngleZY<N: RealField>(angleZ: N, angleY: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZYX<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleZYX<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn eulerAngleZYZ<N: Real>(t1: N, t2: N, t3: N) -> TMat4<N> {
pub fn eulerAngleZYZ<N: RealField>(t1: N, t2: N, t3: N) -> TMat4<N> {
unimplemented!()
}
pub fn extractEulerAngleXYX<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleXYX<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleXYZ<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleXYZ<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleXZX<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleXZX<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleXZY<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleXZY<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleYXY<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleYXY<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleYXZ<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleYXZ<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleYZX<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleYZX<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleYZY<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleYZY<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleZXY<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleZXY<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleZXZ<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleZXZ<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleZYX<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleZYX<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn extractEulerAngleZYZ<N: Real>(M: &TMat4<N>) -> (N, N, N) {
pub fn extractEulerAngleZYZ<N: RealField>(M: &TMat4<N>) -> (N, N, N) {
unimplemented!()
}
pub fn orientate2<N: Real>(angle: N) -> TMat3x3<N> {
pub fn orientate2<N: RealField>(angle: N) -> TMat3x3<N> {
unimplemented!()
}
pub fn orientate3<N: Real>(angles: TVec3<N>) -> TMat3x3<N> {
pub fn orientate3<N: RealField>(angles: TVec3<N>) -> TMat3x3<N> {
unimplemented!()
}
pub fn orientate4<N: Real>(angles: TVec3<N>) -> TMat4<N> {
pub fn orientate4<N: RealField>(angles: TVec3<N>) -> TMat4<N> {
unimplemented!()
}
pub fn yawPitchRoll<N: Real>(yaw: N, pitch: N, roll: N) -> TMat4<N> {
pub fn yawPitchRoll<N: RealField>(yaw: N, pitch: N, roll: N) -> TMat4<N> {
unimplemented!()
}

View File

@ -1,4 +1,4 @@
use na::Real;
use na::RealField;
use crate::aliases::{TMat3, TMat4, TVec3};
@ -7,7 +7,7 @@ use crate::aliases::{TMat3, TMat4, TVec3};
/// # See also:
///
/// * [`matrix_cross`](fn.matrix_cross.html)
pub fn matrix_cross3<N: Real>(x: &TVec3<N>) -> TMat3<N> {
pub fn matrix_cross3<N: RealField>(x: &TVec3<N>) -> TMat3<N> {
x.cross_matrix()
}
@ -16,6 +16,6 @@ pub fn matrix_cross3<N: Real>(x: &TVec3<N>) -> TMat3<N> {
/// # See also:
///
/// * [`matrix_cross3`](fn.matrix_cross3.html)
pub fn matrix_cross<N: Real>(x: &TVec3<N>) -> TMat4<N> {
pub fn matrix_cross<N: RealField>(x: &TVec3<N>) -> TMat4<N> {
crate::mat3_to_mat4(&x.cross_matrix())
}

View File

@ -1,4 +1,4 @@
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::aliases::TVec;
use crate::traits::{Alloc, Dimension};
@ -8,7 +8,7 @@ use crate::traits::{Alloc, Dimension};
/// # See also:
///
/// * [`distance`](fn.distance.html)
pub fn distance2<N: Real, D: Dimension>(p0: &TVec<N, D>, p1: &TVec<N, D>) -> N
pub fn distance2<N: RealField, D: Dimension>(p0: &TVec<N, D>, p1: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
(p1 - p0).norm_squared()
}
@ -20,7 +20,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`l1_norm`](fn.l1_norm.html)
/// * [`l2_distance`](fn.l2_distance.html)
/// * [`l2_norm`](fn.l2_norm.html)
pub fn l1_distance<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
pub fn l1_distance<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
l1_norm(&(y - x))
}
@ -35,7 +35,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`l1_distance`](fn.l1_distance.html)
/// * [`l2_distance`](fn.l2_distance.html)
/// * [`l2_norm`](fn.l2_norm.html)
pub fn l1_norm<N: Real, D: Dimension>(v: &TVec<N, D>) -> N
pub fn l1_norm<N: RealField, D: Dimension>(v: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
crate::comp_add(&v.abs())
}
@ -54,7 +54,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`length2`](fn.length2.html)
/// * [`magnitude`](fn.magnitude.html)
/// * [`magnitude2`](fn.magnitude2.html)
pub fn l2_distance<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
pub fn l2_distance<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
l2_norm(&(y - x))
}
@ -75,7 +75,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`length2`](fn.length2.html)
/// * [`magnitude`](fn.magnitude.html)
/// * [`magnitude2`](fn.magnitude2.html)
pub fn l2_norm<N: Real, D: Dimension>(x: &TVec<N, D>) -> N
pub fn l2_norm<N: RealField, D: Dimension>(x: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
x.norm()
}
@ -91,7 +91,7 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`length`](fn.length.html)
/// * [`magnitude`](fn.magnitude.html)
/// * [`magnitude2`](fn.magnitude2.html)
pub fn length2<N: Real, D: Dimension>(x: &TVec<N, D>) -> N
pub fn length2<N: RealField, D: Dimension>(x: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
x.norm_squared()
}
@ -107,17 +107,17 @@ where DefaultAllocator: Alloc<N, D> {
/// * [`length2`](fn.length2.html)
/// * [`magnitude`](fn.magnitude.html)
/// * [`nalgebra::norm_squared`](../nalgebra/fn.norm_squared.html)
pub fn magnitude2<N: Real, D: Dimension>(x: &TVec<N, D>) -> N
pub fn magnitude2<N: RealField, D: Dimension>(x: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
x.norm_squared()
}
//pub fn lxNorm<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>, unsigned int Depth) -> N
//pub fn lxNorm<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>, unsigned int Depth) -> N
// where DefaultAllocator: Alloc<N, D> {
// unimplemented!()
//}
//
//pub fn lxNorm<N: Real, D: Dimension>(x: &TVec<N, D>, unsigned int Depth) -> N
//pub fn lxNorm<N: RealField, D: Dimension>(x: &TVec<N, D>, unsigned int Depth) -> N
// where DefaultAllocator: Alloc<N, D> {
// unimplemented!()
//}

View File

@ -1,10 +1,10 @@
use na::Real;
use na::RealField;
use crate::aliases::TVec3;
/// The normal vector of the given triangle.
///
/// The normal is computed as the normalized vector `cross(p2 - p1, p3 - p1)`.
pub fn triangle_normal<N: Real>(p1: &TVec3<N>, p2: &TVec3<N>, p3: &TVec3<N>) -> TVec3<N> {
pub fn triangle_normal<N: RealField>(p1: &TVec3<N>, p2: &TVec3<N>, p3: &TVec3<N>) -> TVec3<N> {
(p2 - p1).cross(&(p3 - p1)).normalize()
}

View File

@ -1,4 +1,4 @@
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::aliases::TVec;
use crate::traits::{Alloc, Dimension};
@ -10,7 +10,7 @@ use crate::traits::{Alloc, Dimension};
/// # See also:
///
/// * [`normalize_dot`](fn.normalize_dot.html`)
pub fn fast_normalize_dot<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
pub fn fast_normalize_dot<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
// XXX: improve those.
x.normalize().dot(&y.normalize())
@ -21,7 +21,7 @@ where DefaultAllocator: Alloc<N, D> {
/// # See also:
///
/// * [`fast_normalize_dot`](fn.fast_normalize_dot.html`)
pub fn normalize_dot<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
pub fn normalize_dot<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
// XXX: improve those.
x.normalize().dot(&y.normalize())

View File

@ -1,97 +1,97 @@
use na::{Real, Rotation3, Unit, UnitQuaternion, U3};
use na::{RealField, Rotation3, Unit, UnitQuaternion, U3};
use crate::aliases::{Qua, TMat3, TMat4, TVec3, TVec4};
/// Rotate the vector `v` by the quaternion `q` assumed to be normalized.
pub fn quat_cross_vec<N: Real>(q: &Qua<N>, v: &TVec3<N>) -> TVec3<N> {
pub fn quat_cross_vec<N: RealField>(q: &Qua<N>, v: &TVec3<N>) -> TVec3<N> {
UnitQuaternion::new_unchecked(*q) * v
}
/// Rotate the vector `v` by the inverse of the quaternion `q` assumed to be normalized.
pub fn quat_inv_cross_vec<N: Real>(v: &TVec3<N>, q: &Qua<N>) -> TVec3<N> {
pub fn quat_inv_cross_vec<N: RealField>(v: &TVec3<N>, q: &Qua<N>) -> TVec3<N> {
UnitQuaternion::new_unchecked(*q).inverse() * v
}
/// The quaternion `w` component.
pub fn quat_extract_real_component<N: Real>(q: &Qua<N>) -> N {
pub fn quat_extract_real_component<N: RealField>(q: &Qua<N>) -> N {
q.w
}
/// Normalized linear interpolation between two quaternions.
pub fn quat_fast_mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
pub fn quat_fast_mix<N: RealField>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
Unit::new_unchecked(*x)
.nlerp(&Unit::new_unchecked(*y), a)
.into_inner()
}
//pub fn quat_intermediate<N: Real>(prev: &Qua<N>, curr: &Qua<N>, next: &Qua<N>) -> Qua<N> {
//pub fn quat_intermediate<N: RealField>(prev: &Qua<N>, curr: &Qua<N>, next: &Qua<N>) -> Qua<N> {
// unimplemented!()
//}
/// The squared magnitude of a quaternion `q`.
pub fn quat_length2<N: Real>(q: &Qua<N>) -> N {
pub fn quat_length2<N: RealField>(q: &Qua<N>) -> N {
q.norm_squared()
}
/// The squared magnitude of a quaternion `q`.
pub fn quat_magnitude2<N: Real>(q: &Qua<N>) -> N {
pub fn quat_magnitude2<N: RealField>(q: &Qua<N>) -> N {
q.norm_squared()
}
/// The quaternion representing the identity rotation.
pub fn quat_identity<N: Real>() -> Qua<N> {
pub fn quat_identity<N: RealField>() -> Qua<N> {
UnitQuaternion::identity().into_inner()
}
/// Rotates a vector by a quaternion assumed to be normalized.
pub fn quat_rotate_vec3<N: Real>(q: &Qua<N>, v: &TVec3<N>) -> TVec3<N> {
pub fn quat_rotate_vec3<N: RealField>(q: &Qua<N>, v: &TVec3<N>) -> TVec3<N> {
UnitQuaternion::new_unchecked(*q) * v
}
/// Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized.
pub fn quat_rotate_vec<N: Real>(q: &Qua<N>, v: &TVec4<N>) -> TVec4<N> {
pub fn quat_rotate_vec<N: RealField>(q: &Qua<N>, v: &TVec4<N>) -> TVec4<N> {
let rotated = Unit::new_unchecked(*q) * v.fixed_rows::<U3>(0);
TVec4::new(rotated.x, rotated.y, rotated.z, v.w)
}
/// The rotation required to align `orig` to `dest`.
pub fn quat_rotation<N: Real>(orig: &TVec3<N>, dest: &TVec3<N>) -> Qua<N> {
pub fn quat_rotation<N: RealField>(orig: &TVec3<N>, dest: &TVec3<N>) -> Qua<N> {
UnitQuaternion::rotation_between(orig, dest)
.unwrap_or_else(UnitQuaternion::identity)
.into_inner()
}
/// The spherical linear interpolation between two quaternions.
pub fn quat_short_mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
pub fn quat_short_mix<N: RealField>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
Unit::new_normalize(*x)
.slerp(&Unit::new_normalize(*y), a)
.into_inner()
}
//pub fn quat_squad<N: Real>(q1: &Qua<N>, q2: &Qua<N>, s1: &Qua<N>, s2: &Qua<N>, h: N) -> Qua<N> {
//pub fn quat_squad<N: RealField>(q1: &Qua<N>, q2: &Qua<N>, s1: &Qua<N>, s2: &Qua<N>, h: N) -> Qua<N> {
// unimplemented!()
//}
/// Converts a quaternion to a rotation matrix.
pub fn quat_to_mat3<N: Real>(x: &Qua<N>) -> TMat3<N> {
pub fn quat_to_mat3<N: RealField>(x: &Qua<N>) -> TMat3<N> {
UnitQuaternion::new_unchecked(*x)
.to_rotation_matrix()
.into_inner()
}
/// Converts a quaternion to a rotation matrix in homogenous coordinates.
pub fn quat_to_mat4<N: Real>(x: &Qua<N>) -> TMat4<N> {
pub fn quat_to_mat4<N: RealField>(x: &Qua<N>) -> TMat4<N> {
UnitQuaternion::new_unchecked(*x).to_homogeneous()
}
/// Converts a rotation matrix to a quaternion.
pub fn mat3_to_quat<N: Real>(x: &TMat3<N>) -> Qua<N> {
pub fn mat3_to_quat<N: RealField>(x: &TMat3<N>) -> Qua<N> {
let r = Rotation3::from_matrix_unchecked(*x);
UnitQuaternion::from_rotation_matrix(&r).into_inner()
}
/// Converts a rotation matrix in homogeneous coordinates to a quaternion.
pub fn to_quat<N: Real>(x: &TMat4<N>) -> Qua<N> {
pub fn to_quat<N: RealField>(x: &TMat4<N>) -> Qua<N> {
let rot = x.fixed_slice::<U3, U3>(0, 0).into_owned();
mat3_to_quat(&rot)
}

View File

@ -1,4 +1,4 @@
use na::{Real, Rotation3, Unit, UnitQuaternion};
use na::{RealField, Rotation3, Unit, UnitQuaternion};
use crate::aliases::{Qua, TMat4, TVec3};
@ -9,7 +9,7 @@ use crate::aliases::{Qua, TMat4, TVec3};
/// * `m` - Input matrix multiplied by this rotation matrix.
/// * `angle` - Rotation angle expressed in radians.
/// * `axis` - Rotation axis, must be normalized.
pub fn rotate_normalized_axis<N: Real>(m: &TMat4<N>, angle: N, axis: &TVec3<N>) -> TMat4<N> {
pub fn rotate_normalized_axis<N: RealField>(m: &TMat4<N>, angle: N, axis: &TVec3<N>) -> TMat4<N> {
m * Rotation3::from_axis_angle(&Unit::new_unchecked(*axis), angle).to_homogeneous()
}
@ -20,6 +20,6 @@ pub fn rotate_normalized_axis<N: Real>(m: &TMat4<N>, angle: N, axis: &TVec3<N>)
/// * `q` - Source orientation.
/// * `angle` - Angle expressed in radians.
/// * `axis` - Normalized axis of the rotation, must be normalized.
pub fn quat_rotate_normalized_axis<N: Real>(q: &Qua<N>, angle: N, axis: &TVec3<N>) -> Qua<N> {
pub fn quat_rotate_normalized_axis<N: RealField>(q: &Qua<N>, angle: N, axis: &TVec3<N>) -> Qua<N> {
q * UnitQuaternion::from_axis_angle(&Unit::new_unchecked(*axis), angle).into_inner()
}

View File

@ -1,9 +1,9 @@
use na::{Real, Rotation3, Unit, UnitComplex};
use na::{RealField, Rotation3, Unit, UnitComplex};
use crate::aliases::{TMat4, TVec2, TVec3, TVec4};
/// Build the rotation matrix needed to align `normal` and `up`.
pub fn orientation<N: Real>(normal: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
pub fn orientation<N: RealField>(normal: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
if let Some(r) = Rotation3::rotation_between(normal, up) {
r.to_homogeneous()
} else {
@ -12,52 +12,52 @@ pub fn orientation<N: Real>(normal: &TVec3<N>, up: &TVec3<N>) -> TMat4<N> {
}
/// Rotate a two dimensional vector.
pub fn rotate_vec2<N: Real>(v: &TVec2<N>, angle: N) -> TVec2<N> {
pub fn rotate_vec2<N: RealField>(v: &TVec2<N>, angle: N) -> TVec2<N> {
UnitComplex::new(angle) * v
}
/// Rotate a three dimensional vector around an axis.
pub fn rotate_vec3<N: Real>(v: &TVec3<N>, angle: N, normal: &TVec3<N>) -> TVec3<N> {
pub fn rotate_vec3<N: RealField>(v: &TVec3<N>, angle: N, normal: &TVec3<N>) -> TVec3<N> {
Rotation3::from_axis_angle(&Unit::new_normalize(*normal), angle) * v
}
/// Rotate a thee dimensional vector in homogeneous coordinates around an axis.
pub fn rotate_vec4<N: Real>(v: &TVec4<N>, angle: N, normal: &TVec3<N>) -> TVec4<N> {
pub fn rotate_vec4<N: RealField>(v: &TVec4<N>, angle: N, normal: &TVec3<N>) -> TVec4<N> {
Rotation3::from_axis_angle(&Unit::new_normalize(*normal), angle).to_homogeneous() * v
}
/// Rotate a three dimensional vector around the `X` axis.
pub fn rotate_x_vec3<N: Real>(v: &TVec3<N>, angle: N) -> TVec3<N> {
pub fn rotate_x_vec3<N: RealField>(v: &TVec3<N>, angle: N) -> TVec3<N> {
Rotation3::from_axis_angle(&TVec3::x_axis(), angle) * v
}
/// Rotate a three dimensional vector in homogeneous coordinates around the `X` axis.
pub fn rotate_x_vec4<N: Real>(v: &TVec4<N>, angle: N) -> TVec4<N> {
pub fn rotate_x_vec4<N: RealField>(v: &TVec4<N>, angle: N) -> TVec4<N> {
Rotation3::from_axis_angle(&TVec3::x_axis(), angle).to_homogeneous() * v
}
/// Rotate a three dimensional vector around the `Y` axis.
pub fn rotate_y_vec3<N: Real>(v: &TVec3<N>, angle: N) -> TVec3<N> {
pub fn rotate_y_vec3<N: RealField>(v: &TVec3<N>, angle: N) -> TVec3<N> {
Rotation3::from_axis_angle(&TVec3::y_axis(), angle) * v
}
/// Rotate a three dimensional vector in homogeneous coordinates around the `Y` axis.
pub fn rotate_y_vec4<N: Real>(v: &TVec4<N>, angle: N) -> TVec4<N> {
pub fn rotate_y_vec4<N: RealField>(v: &TVec4<N>, angle: N) -> TVec4<N> {
Rotation3::from_axis_angle(&TVec3::y_axis(), angle).to_homogeneous() * v
}
/// Rotate a three dimensional vector around the `Z` axis.
pub fn rotate_z_vec3<N: Real>(v: &TVec3<N>, angle: N) -> TVec3<N> {
pub fn rotate_z_vec3<N: RealField>(v: &TVec3<N>, angle: N) -> TVec3<N> {
Rotation3::from_axis_angle(&TVec3::z_axis(), angle) * v
}
/// Rotate a three dimensional vector in homogeneous coordinates around the `Z` axis.
pub fn rotate_z_vec4<N: Real>(v: &TVec4<N>, angle: N) -> TVec4<N> {
pub fn rotate_z_vec4<N: RealField>(v: &TVec4<N>, angle: N) -> TVec4<N> {
Rotation3::from_axis_angle(&TVec3::z_axis(), angle).to_homogeneous() * v
}
/// 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> {
pub fn slerp<N: RealField>(x: &TVec3<N>, y: &TVec3<N>, a: N) -> TVec3<N> {
Unit::new_unchecked(*x)
.slerp(&Unit::new_unchecked(*y), a)
.into_inner()

View File

@ -1,4 +1,4 @@
use na::{Real, Rotation2, Rotation3, Unit};
use na::{RealField, Rotation2, Rotation3, Unit};
use crate::aliases::{TMat3, TMat4, TVec2, TVec3};
use crate::traits::Number;
@ -12,7 +12,7 @@ use crate::traits::Number;
/// * [`rotation2d`](fn.rotation2d.html)
/// * [`scaling2d`](fn.scaling2d.html)
/// * [`translation2d`](fn.translation2d.html)
pub fn rotation<N: Real>(angle: N, v: &TVec3<N>) -> TMat4<N> {
pub fn rotation<N: RealField>(angle: N, v: &TVec3<N>) -> TMat4<N> {
Rotation3::from_axis_angle(&Unit::new_normalize(*v), angle).to_homogeneous()
}
@ -51,7 +51,7 @@ pub fn translation<N: Number>(v: &TVec3<N>) -> TMat4<N> {
/// * [`translation`](fn.translation.html)
/// * [`scaling2d`](fn.scaling2d.html)
/// * [`translation2d`](fn.translation2d.html)
pub fn rotation2d<N: Real>(angle: N) -> TMat3<N> {
pub fn rotation2d<N: RealField>(angle: N) -> TMat3<N> {
Rotation2::new(angle).to_homogeneous()
}

View File

@ -1,4 +1,4 @@
use na::{Real, UnitComplex};
use na::{RealField, UnitComplex};
use crate::aliases::{TMat3, TVec2};
use crate::traits::Number;
@ -12,7 +12,7 @@ use crate::traits::Number;
/// * [`scaling2d`](fn.scaling2d.html)
/// * [`translate2d`](fn.translate2d.html)
/// * [`translation2d`](fn.translation2d.html)
pub fn rotate2d<N: Real>(m: &TMat3<N>, angle: N) -> TMat3<N> {
pub fn rotate2d<N: RealField>(m: &TMat3<N>, angle: N) -> TMat3<N> {
m * UnitComplex::new(angle).to_homogeneous()
}

View File

@ -1,18 +1,18 @@
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::aliases::TVec;
use crate::traits::{Alloc, Dimension};
/// The angle between two vectors.
pub fn angle<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
pub fn angle<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
x.angle(y)
}
//pub fn oriented_angle<N: Real>(x: &TVec2<N>, y: &TVec2<N>) -> N {
//pub fn oriented_angle<N: RealField>(x: &TVec2<N>, y: &TVec2<N>) -> N {
// unimplemented!()
//}
//
//pub fn oriented_angle_ref<N: Real>(x: &TVec3<N>, y: &TVec3<N>, refv: &TVec3<N>) -> N {
//pub fn oriented_angle_ref<N: RealField>(x: &TVec3<N>, y: &TVec3<N>, refv: &TVec3<N>) -> N {
// unimplemented!()
//}

View File

@ -1,4 +1,4 @@
use na::{DefaultAllocator, Real};
use na::{DefaultAllocator, RealField};
use crate::aliases::{TVec, TVec2, TVec3};
use crate::traits::{Alloc, Dimension, Number};
@ -45,7 +45,7 @@ where DefaultAllocator: Alloc<N, D> {
}
/// Returns `true` if `v` has a magnitude of 1 (up to an epsilon).
pub fn is_normalized<N: Real, D: Dimension>(v: &TVec<N, D>, epsilon: N) -> bool
pub fn is_normalized<N: RealField, D: Dimension>(v: &TVec<N, D>, epsilon: N) -> bool
where DefaultAllocator: Alloc<N, D> {
abs_diff_eq!(v.norm_squared(), N::one(), epsilon = epsilon * epsilon)
}

View File

@ -1,4 +1,4 @@
use na::{Scalar, Real, U3, DefaultAllocator};
use na::{Scalar, RealField, U3, DefaultAllocator};
use crate::traits::{Number, Alloc, Dimension};
use crate::aliases::TVec;

View File

@ -191,7 +191,7 @@ pub use gtx::{
pub use na::{
convert, convert_ref, convert_ref_unchecked, convert_unchecked, try_convert, try_convert_ref,
};
pub use na::{DefaultAllocator, Real, Scalar, U1, U2, U3, U4};
pub use na::{DefaultAllocator, RealField, Scalar, U1, U2, U3, U4};
mod aliases;
mod common;

View File

@ -1,16 +1,16 @@
use na::{DefaultAllocator, Real, Scalar};
use na::{DefaultAllocator, RealField, Scalar};
use crate::aliases::{TMat, TVec};
use crate::traits::{Alloc, Dimension, Number};
/// The determinant of the matrix `m`.
pub fn determinant<N: Real, D: Dimension>(m: &TMat<N, D, D>) -> N
pub fn determinant<N: RealField, D: Dimension>(m: &TMat<N, D, D>) -> N
where DefaultAllocator: Alloc<N, D, D> {
m.determinant()
}
/// The inverse of the matrix `m`.
pub fn inverse<N: Real, D: Dimension>(m: &TMat<N, D, D>) -> TMat<N, D, D>
pub fn inverse<N: RealField, D: Dimension>(m: &TMat<N, D, D>) -> TMat<N, D, D>
where DefaultAllocator: Alloc<N, D, D> {
m.clone()
.try_inverse()

View File

@ -1,94 +1,94 @@
use na::{self, DefaultAllocator, Real};
use na::{self, DefaultAllocator, RealField};
use crate::aliases::TVec;
use crate::traits::{Alloc, Dimension};
/// Component-wise arc-cosinus.
pub fn acos<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn acos<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.acos())
}
/// Component-wise hyperbolic arc-cosinus.
pub fn acosh<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn acosh<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.acosh())
}
/// Component-wise arc-sinus.
pub fn asin<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn asin<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.asin())
}
/// Component-wise hyperbolic arc-sinus.
pub fn asinh<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn asinh<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.asinh())
}
/// Component-wise arc-tangent of `y / x`.
pub fn atan2<N: Real, D: Dimension>(y: &TVec<N, D>, x: &TVec<N, D>) -> TVec<N, D>
pub fn atan2<N: RealField, D: Dimension>(y: &TVec<N, D>, x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
y.zip_map(x, |y, x| y.atan2(x))
}
/// Component-wise arc-tangent.
pub fn atan<N: Real, D: Dimension>(y_over_x: &TVec<N, D>) -> TVec<N, D>
pub fn atan<N: RealField, D: Dimension>(y_over_x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
y_over_x.map(|e| e.atan())
}
/// Component-wise hyperbolic arc-tangent.
pub fn atanh<N: Real, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
pub fn atanh<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.atanh())
}
/// Component-wise cosinus.
pub fn cos<N: Real, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
pub fn cos<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.cos())
}
/// Component-wise hyperbolic cosinus.
pub fn cosh<N: Real, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
pub fn cosh<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.cosh())
}
/// Component-wise conversion from radians to degrees.
pub fn degrees<N: Real, D: Dimension>(radians: &TVec<N, D>) -> TVec<N, D>
pub fn degrees<N: RealField, D: Dimension>(radians: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
radians.map(|e| e * na::convert(180.0) / N::pi())
}
/// Component-wise conversion fro degrees to radians.
pub fn radians<N: Real, D: Dimension>(degrees: &TVec<N, D>) -> TVec<N, D>
pub fn radians<N: RealField, D: Dimension>(degrees: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
degrees.map(|e| e * N::pi() / na::convert(180.0))
}
/// Component-wise sinus.
pub fn sin<N: Real, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
pub fn sin<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.sin())
}
/// Component-wise hyperbolic sinus.
pub fn sinh<N: Real, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
pub fn sinh<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.sinh())
}
/// Component-wise tangent.
pub fn tan<N: Real, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
pub fn tan<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.tan())
}
/// Component-wise hyperbolic tangent.
pub fn tanh<N: Real, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
pub fn tanh<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.tanh())
}

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use num::Zero;
use num_complex::Complex;
use alga::general::Real;
use alga::general::RealField;
use na::allocator::Allocator;
use na::dimension::{Dim, U1};
@ -51,7 +51,7 @@ where
MatrixN<N, D>: Copy,
{}
impl<N: EigenScalar + Real, D: Dim> Eigen<N, D>
impl<N: EigenScalar + RealField, D: Dim> Eigen<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
/// Computes the eigenvalues and eigenvectors of the square matrix `m`.

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use num::Zero;
use num_complex::Complex;
use alga::general::Real;
use alga::general::RealField;
use na::allocator::Allocator;
use na::dimension::{Dim, U1};
@ -49,7 +49,7 @@ where
VectorN<N, D>: Copy,
{}
impl<N: SchurScalar + Real, D: Dim> Schur<N, D>
impl<N: SchurScalar + RealField, D: Dim> Schur<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
/// Computes the eigenvalues and real Schur form of the matrix `m`.
@ -161,7 +161,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
* Lapack functions dispatch.
*
*/
/// Trait implemented by scalars for which Lapack implements the Real Schur decomposition.
/// Trait implemented by scalars for which Lapack implements the RealField Schur decomposition.
pub trait SchurScalar: Scalar {
#[allow(missing_docs)]
fn xgees(

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use num::Zero;
use std::ops::MulAssign;
use alga::general::Real;
use alga::general::RealField;
use na::allocator::Allocator;
use na::dimension::{Dim, U1};
@ -52,7 +52,7 @@ where
VectorN<N, D>: Copy,
{}
impl<N: SymmetricEigenScalar + Real, D: Dim> SymmetricEigen<N, D>
impl<N: SymmetricEigenScalar + RealField, D: Dim> SymmetricEigen<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
/// Computes the eigenvalues and eigenvectors of the symmetric matrix `m`.

View File

@ -18,7 +18,7 @@ use crate::geometry::{
Isometry, IsometryMatrix3, Orthographic3, Perspective3, Point, Point3, Rotation2, Rotation3,
};
use alga::general::{Real, Ring};
use alga::general::{RealField, Ring};
use alga::linear::Transformation;
impl<N, D: DimName> MatrixN<N, D>
@ -65,7 +65,7 @@ where
}
}
impl<N: Real> Matrix3<N> {
impl<N: RealField> Matrix3<N> {
/// Builds a 2 dimensional homogeneous rotation matrix from an angle in radian.
#[inline]
pub fn new_rotation(angle: N) -> Self {
@ -73,7 +73,7 @@ impl<N: Real> Matrix3<N> {
}
}
impl<N: Real> Matrix4<N> {
impl<N: RealField> Matrix4<N> {
/// Builds a 3D homogeneous rotation matrix from an axis and an angle (multiplied together).
///
/// Returns the identity matrix if the given argument is zero.
@ -320,7 +320,7 @@ impl<N: Scalar + Ring, D: DimName, S: StorageMut<N, D, D>> SquareMatrix<N, D, S>
}
}
impl<N: Real, D: DimNameSub<U1>, S: Storage<N, D, D>> SquareMatrix<N, D, S>
impl<N: RealField, D: DimNameSub<U1>, S: Storage<N, D, D>> SquareMatrix<N, D, S>
where DefaultAllocator: Allocator<N, D, D>
+ Allocator<N, DimNameDiff<D, U1>>
+ Allocator<N, DimNameDiff<D, U1>, DimNameDiff<D, U1>>
@ -364,7 +364,7 @@ where DefaultAllocator: Allocator<N, D, D>
}
}
impl<N: Real, D: DimNameSub<U1>> Transformation<Point<N, DimNameDiff<D, U1>>> for MatrixN<N, D>
impl<N: RealField, D: DimNameSub<U1>> Transformation<Point<N, DimNameDiff<D, U1>>> for MatrixN<N, D>
where DefaultAllocator: Allocator<N, D, D>
+ Allocator<N, DimNameDiff<D, U1>>
+ Allocator<N, DimNameDiff<D, U1>, DimNameDiff<D, U1>>

View File

@ -12,7 +12,7 @@ use std::iter;
use typenum::{self, Cmp, Greater};
#[cfg(feature = "std")]
use alga::general::Real;
use alga::general::RealField;
use alga::general::{ClosedAdd, ClosedMul};
use crate::base::allocator::Allocator;
@ -795,7 +795,7 @@ where
}
#[cfg(feature = "std")]
impl<N: Real, D: DimName> Distribution<Unit<VectorN<N, D>>> for Standard
impl<N: RealField, D: DimName> Distribution<Unit<VectorN<N, D>>> for Standard
where
DefaultAllocator: Allocator<N, D>,
StandardNormal: Distribution<N>,

View File

@ -16,7 +16,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use alga::general::{ClosedAdd, ClosedMul, ClosedSub, Real, Ring, ComplexField, Field};
use alga::general::{ClosedAdd, ClosedMul, ClosedSub, RealField, Ring, ComplexField, Field};
use crate::base::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR};
use crate::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
@ -983,14 +983,14 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Divides each component of the complex matrix `self` by the given real.
#[inline]
pub fn unscale(&self, real: N::Real) -> MatrixMN<N, R, C>
pub fn unscale(&self, real: N::RealField) -> MatrixMN<N, R, C>
where DefaultAllocator: Allocator<N, R, C> {
self.map(|e| e.unscale(real))
}
/// Multiplies each component of the complex matrix `self` by the given real.
#[inline]
pub fn scale(&self, real: N::Real) -> MatrixMN<N, R, C>
pub fn scale(&self, real: N::RealField) -> MatrixMN<N, R, C>
where DefaultAllocator: Allocator<N, R, C> {
self.map(|e| e.scale(real))
}
@ -1005,13 +1005,13 @@ impl<N: ComplexField, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S>
/// Divides each component of the complex matrix `self` by the given real.
#[inline]
pub fn unscale_mut(&mut self, real: N::Real) {
pub fn unscale_mut(&mut self, real: N::RealField) {
self.apply(|e| e.unscale(real))
}
/// Multiplies each component of the complex matrix `self` by the given real.
#[inline]
pub fn scale_mut(&mut self, real: N::Real) {
pub fn scale_mut(&mut self, real: N::RealField) {
self.apply(|e| e.scale(real))
}
}
@ -1544,7 +1544,7 @@ where DefaultAllocator: Allocator<N, U3>
impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// The smallest angle between two vectors.
#[inline]
pub fn angle<R2: Dim, C2: Dim, SB>(&self, other: &Matrix<N, R2, C2, SB>) -> N::Real
pub fn angle<R2: Dim, C2: Dim, SB>(&self, other: &Matrix<N, R2, C2, SB>) -> N::RealField
where
SB: Storage<N, R2, C2>,
ShapeConstraint: DimEq<R, R2> + DimEq<C, C2>,
@ -1554,14 +1554,14 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
let n2 = other.norm();
if n1.is_zero() || n2.is_zero() {
N::Real::zero()
N::RealField::zero()
} else {
let cang = prod.real() / (n1 * n2);
if cang > N::Real::one() {
N::Real::zero()
} else if cang < -N::Real::one() {
N::Real::pi()
if cang > N::RealField::one() {
N::RealField::zero()
} else if cang < -N::RealField::one() {
N::RealField::pi()
} else {
cang.acos()
}
@ -1597,13 +1597,13 @@ impl<N: ComplexField, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>> {
pub fn slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,
t: N::Real,
t: N::RealField,
) -> Unit<VectorN<N, D>>
where
DefaultAllocator: Allocator<N, D>,
{
// FIXME: the result is wrong when self and rhs are collinear with opposite direction.
self.try_slerp(rhs, t, N::Real::default_epsilon())
self.try_slerp(rhs, t, N::RealField::default_epsilon())
.unwrap_or(Unit::new_unchecked(self.clone_owned()))
}
@ -1614,8 +1614,8 @@ impl<N: ComplexField, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>> {
pub fn try_slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,
t: N::Real,
epsilon: N::Real,
t: N::RealField,
epsilon: N::RealField,
) -> Option<Unit<VectorN<N, D>>>
where
DefaultAllocator: Allocator<N, D>,
@ -1623,18 +1623,18 @@ impl<N: ComplexField, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>> {
let (c_hang, c_hang_sign) = self.dotc(rhs).to_exp();
// self == other
if c_hang >= N::Real::one() {
if c_hang >= N::RealField::one() {
return Some(Unit::new_unchecked(self.clone_owned()));
}
let hang = c_hang.acos();
let s_hang = (N::Real::one() - c_hang * c_hang).sqrt();
let s_hang = (N::RealField::one() - c_hang * c_hang).sqrt();
// FIXME: what if s_hang is 0.0 ? The result is not well-defined.
if relative_eq!(s_hang, N::Real::zero(), epsilon = epsilon) {
if relative_eq!(s_hang, N::RealField::zero(), epsilon = epsilon) {
None
} else {
let ta = ((N::Real::one() - t) * hang).sin() / s_hang;
let ta = ((N::RealField::one() - t) * hang).sin() / s_hang;
let tb = (t * hang).sin() / s_hang;
let mut res = self.scale(ta);
res.axpy(c_hang_sign.scale(tb), &**rhs, N::one());

View File

@ -148,16 +148,16 @@ where
impl<N: ComplexField, R: DimName, C: DimName> NormedSpace for MatrixMN<N, R, C>
where DefaultAllocator: Allocator<N, R, C>
{
type Real = N::Real;
type RealField = N::RealField;
type ComplexField = N;
#[inline]
fn norm_squared(&self) -> N::Real {
fn norm_squared(&self) -> N::RealField {
self.norm_squared()
}
#[inline]
fn norm(&self) -> N::Real {
fn norm(&self) -> N::RealField {
self.norm()
}
@ -167,17 +167,17 @@ where DefaultAllocator: Allocator<N, R, C>
}
#[inline]
fn normalize_mut(&mut self) -> N::Real {
fn normalize_mut(&mut self) -> N::RealField {
self.normalize_mut()
}
#[inline]
fn try_normalize(&self, min_norm: N::Real) -> Option<Self> {
fn try_normalize(&self, min_norm: N::RealField) -> Option<Self> {
self.try_normalize(min_norm)
}
#[inline]
fn try_normalize_mut(&mut self, min_norm: N::Real) -> Option<N::Real> {
fn try_normalize_mut(&mut self, min_norm: N::RealField) -> Option<N::RealField> {
self.try_normalize_mut(min_norm)
}
}
@ -186,7 +186,7 @@ impl<N: ComplexField, R: DimName, C: DimName> InnerSpace for MatrixMN<N, R, C>
where DefaultAllocator: Allocator<N, R, C>
{
#[inline]
fn angle(&self, other: &Self) -> N::Real {
fn angle(&self, other: &Self) -> N::RealField {
self.angle(other)
}
@ -216,7 +216,7 @@ where DefaultAllocator: Allocator<N, R, C>
}
}
if vs[i].try_normalize_mut(N::Real::zero()).is_some() {
if vs[i].try_normalize_mut(N::RealField::zero()).is_some() {
// FIXME: this will be efficient on dynamically-allocated vectors but for
// statically-allocated ones, `.clone_from` would be better.
vs.swap(nbasis_elements, i);
@ -301,7 +301,7 @@ where DefaultAllocator: Allocator<N, R, C>
elt -= v * elt.dot(v)
}
if let Some(subsp_elt) = elt.try_normalize(N::Real::zero()) {
if let Some(subsp_elt) = elt.try_normalize(N::RealField::zero()) {
if !f(&subsp_elt) {
return;
};

View File

@ -1,7 +1,7 @@
use num::Zero;
use crate::allocator::Allocator;
use crate::{Real, ComplexField};
use crate::{RealField, ComplexField};
use crate::storage::{Storage, StorageMut};
use crate::base::{DefaultAllocator, Matrix, Dim, MatrixMN};
use crate::constraint::{SameNumberOfRows, SameNumberOfColumns, ShapeConstraint};
@ -13,10 +13,10 @@ use crate::constraint::{SameNumberOfRows, SameNumberOfColumns, ShapeConstraint};
/// This may be moved to the alga crate in the future.
pub trait Norm<N: ComplexField> {
/// Apply this norm to the given matrix.
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::Real
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::RealField
where R: Dim, C: Dim, S: Storage<N, R, C>;
/// Use the metric induced by this norm to compute the metric distance between the two given matrices.
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::Real
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::RealField
where R1: Dim, C1: Dim, S1: Storage<N, R1, C1>,
R2: Dim, C2: Dim, S2: Storage<N, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>;
@ -31,17 +31,17 @@ pub struct UniformNorm;
impl<N: ComplexField> Norm<N> for EuclideanNorm {
#[inline]
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::Real
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::RealField
where R: Dim, C: Dim, S: Storage<N, R, C> {
m.norm_squared().sqrt()
}
#[inline]
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::Real
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::RealField
where R1: Dim, C1: Dim, S1: Storage<N, R1, C1>,
R2: Dim, C2: Dim, S2: Storage<N, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2> {
m1.zip_fold(m2, N::Real::zero(), |acc, a, b| {
m1.zip_fold(m2, N::RealField::zero(), |acc, a, b| {
let diff = a - b;
acc + diff.modulus_squared()
}).sqrt()
@ -50,19 +50,19 @@ impl<N: ComplexField> Norm<N> for EuclideanNorm {
impl<N: ComplexField> Norm<N> for LpNorm {
#[inline]
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::Real
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::RealField
where R: Dim, C: Dim, S: Storage<N, R, C> {
m.fold(N::Real::zero(), |a, b| {
m.fold(N::RealField::zero(), |a, b| {
a + b.modulus().powi(self.0)
}).powf(crate::convert(1.0 / (self.0 as f64)))
}
#[inline]
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::Real
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::RealField
where R1: Dim, C1: Dim, S1: Storage<N, R1, C1>,
R2: Dim, C2: Dim, S2: Storage<N, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2> {
m1.zip_fold(m2, N::Real::zero(), |acc, a, b| {
m1.zip_fold(m2, N::RealField::zero(), |acc, a, b| {
let diff = a - b;
acc + diff.modulus().powi(self.0)
}).powf(crate::convert(1.0 / (self.0 as f64)))
@ -71,19 +71,19 @@ impl<N: ComplexField> Norm<N> for LpNorm {
impl<N: ComplexField> Norm<N> for UniformNorm {
#[inline]
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::Real
fn norm<R, C, S>(&self, m: &Matrix<N, R, C, S>) -> N::RealField
where R: Dim, C: Dim, S: Storage<N, R, C> {
// NOTE: we don't use `m.amax()` here because for the complex
// numbers this will return the max norm1 instead of the modulus.
m.fold(N::Real::zero(), |acc, a| acc.max(a.modulus()))
m.fold(N::RealField::zero(), |acc, a| acc.max(a.modulus()))
}
#[inline]
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::Real
fn metric_distance<R1, C1, S1, R2, C2, S2>(&self, m1: &Matrix<N, R1, C1, S1>, m2: &Matrix<N, R2, C2, S2>) -> N::RealField
where R1: Dim, C1: Dim, S1: Storage<N, R1, C1>,
R2: Dim, C2: Dim, S2: Storage<N, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2> {
m1.zip_fold(m2, N::Real::zero(), |acc, a, b| {
m1.zip_fold(m2, N::RealField::zero(), |acc, a, b| {
let val = (a - b).modulus();
if val > acc {
val
@ -98,8 +98,8 @@ impl<N: ComplexField> Norm<N> for UniformNorm {
impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// The squared L2 norm of this vector.
#[inline]
pub fn norm_squared(&self) -> N::Real {
let mut res = N::Real::zero();
pub fn norm_squared(&self) -> N::RealField {
let mut res = N::RealField::zero();
for i in 0..self.ncols() {
let col = self.column(i);
@ -113,7 +113,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
///
/// Use `.apply_norm` to apply a custom norm.
#[inline]
pub fn norm(&self) -> N::Real {
pub fn norm(&self) -> N::RealField {
self.norm_squared().sqrt()
}
@ -121,7 +121,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
///
/// Use `.apply_metric_distance` to apply a custom norm.
#[inline]
pub fn metric_distance<R2, C2, S2>(&self, rhs: &Matrix<N, R2, C2, S2>) -> N::Real
pub fn metric_distance<R2, C2, S2>(&self, rhs: &Matrix<N, R2, C2, S2>) -> N::RealField
where R2: Dim, C2: Dim, S2: Storage<N, R2, C2>,
ShapeConstraint: SameNumberOfRows<R, R2> + SameNumberOfColumns<C, C2> {
self.apply_metric_distance(rhs, &EuclideanNorm)
@ -140,7 +140,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// assert_eq!(v.apply_norm(&EuclideanNorm), v.norm());
/// ```
#[inline]
pub fn apply_norm(&self, norm: &impl Norm<N>) -> N::Real {
pub fn apply_norm(&self, norm: &impl Norm<N>) -> N::RealField {
norm.norm(self)
}
@ -159,7 +159,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// assert_eq!(v1.apply_metric_distance(&v2, &EuclideanNorm), (v1 - v2).norm());
/// ```
#[inline]
pub fn apply_metric_distance<R2, C2, S2>(&self, rhs: &Matrix<N, R2, C2, S2>, norm: &impl Norm<N>) -> N::Real
pub fn apply_metric_distance<R2, C2, S2>(&self, rhs: &Matrix<N, R2, C2, S2>, norm: &impl Norm<N>) -> N::RealField
where R2: Dim, C2: Dim, S2: Storage<N, R2, C2>,
ShapeConstraint: SameNumberOfRows<R, R2> + SameNumberOfColumns<C, C2> {
norm.metric_distance(self, rhs)
@ -171,7 +171,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
///
/// This function is simply implemented as a call to `norm()`
#[inline]
pub fn magnitude(&self) -> N::Real {
pub fn magnitude(&self) -> N::RealField {
self.norm()
}
@ -181,7 +181,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
///
/// This function is simply implemented as a call to `norm_squared()`
#[inline]
pub fn magnitude_squared(&self) -> N::Real {
pub fn magnitude_squared(&self) -> N::RealField {
self.norm_squared()
}
@ -194,7 +194,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Returns a normalized version of this matrix unless its norm as smaller or equal to `eps`.
#[inline]
pub fn try_normalize(&self, min_norm: N::Real) -> Option<MatrixMN<N, R, C>>
pub fn try_normalize(&self, min_norm: N::RealField) -> Option<MatrixMN<N, R, C>>
where DefaultAllocator: Allocator<N, R, C> {
let n = self.norm();
@ -207,7 +207,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// The Lp norm of this matrix.
#[inline]
pub fn lp_norm(&self, p: i32) -> N::Real {
pub fn lp_norm(&self, p: i32) -> N::RealField {
self.apply_norm(&LpNorm(p))
}
}
@ -216,7 +216,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
impl<N: ComplexField, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
/// Normalizes this matrix in-place and returns its norm.
#[inline]
pub fn normalize_mut(&mut self) -> N::Real {
pub fn normalize_mut(&mut self) -> N::RealField {
let n = self.norm();
self.unscale_mut(n);
@ -227,7 +227,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S>
///
/// If the normalization succeeded, returns the old normal of this matrix.
#[inline]
pub fn try_normalize_mut(&mut self, min_norm: N::Real) -> Option<N::Real> {
pub fn try_normalize_mut(&mut self, min_norm: N::RealField) -> Option<N::RealField> {
let n = self.norm();
if n <= min_norm {

View File

@ -832,7 +832,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Returns the the 1-norm of the complex component with the largest 1-norm.
#[inline]
pub fn camax(&self) -> N::Real
pub fn camax(&self) -> N::RealField
where N: ComplexField {
self.xcmp(|e| e.norm1(), |a, b| a > b)
}
@ -853,7 +853,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Returns the the 1-norm of the complex component with the smallest 1-norm.
#[inline]
pub fn camin(&self) -> N::Real
pub fn camin(&self) -> N::RealField
where N: ComplexField {
self.xcmp(|e| e.norm1(), |a, b| a < b)
}

View File

@ -2,7 +2,7 @@
use approx::RelativeEq;
use num::{One, Zero};
use alga::general::{ClosedAdd, ClosedMul, Real, ComplexField};
use alga::general::{ClosedAdd, ClosedMul, RealField, ComplexField};
use crate::base::allocator::Allocator;
use crate::base::dimension::{Dim, DimMin};
@ -101,7 +101,7 @@ impl<N: ComplexField, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
}
}
impl<N: Real, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S>
impl<N: RealField, D: Dim, S: Storage<N, D, D>> SquareMatrix<N, D, S>
where DefaultAllocator: Allocator<N, D, D>
{
/// Checks that this matrix is orthogonal and has a determinant equal to 1.

View File

@ -64,13 +64,13 @@ impl<T: NormedSpace> Unit<T> {
///
/// Returns `None` if the norm was smaller or equal to `min_norm`.
#[inline]
pub fn try_new(value: T, min_norm: T::Real) -> Option<Self> {
pub fn try_new(value: T, min_norm: T::RealField) -> Option<Self> {
Self::try_new_and_get(value, min_norm).map(|res| res.0)
}
/// Normalize the given value and return it wrapped on a `Unit` structure and its norm.
#[inline]
pub fn new_and_get(mut value: T) -> (Self, T::Real) {
pub fn new_and_get(mut value: T) -> (Self, T::RealField) {
let n = value.normalize_mut();
(Unit { value: value }, n)
@ -80,7 +80,7 @@ impl<T: NormedSpace> Unit<T> {
///
/// Returns `None` if the norm was smaller or equal to `min_norm`.
#[inline]
pub fn try_new_and_get(mut value: T, min_norm: T::Real) -> Option<(Self, T::Real)> {
pub fn try_new_and_get(mut value: T, min_norm: T::RealField) -> Option<(Self, T::RealField)> {
if let Some(n) = value.try_normalize_mut(min_norm) {
Some((Unit { value: value }, n))
} else {
@ -94,7 +94,7 @@ impl<T: NormedSpace> Unit<T> {
/// Returns the norm before re-normalization. See `.renormalize_fast` for a faster alternative
/// that may be slightly less accurate if `self` drifted significantly from having a unit length.
#[inline]
pub fn renormalize(&mut self) -> T::Real {
pub fn renormalize(&mut self) -> T::RealField {
self.value.normalize_mut()
}
@ -104,8 +104,8 @@ impl<T: NormedSpace> Unit<T> {
#[inline]
pub fn renormalize_fast(&mut self) {
let sq_norm = self.value.norm_squared();
let _3: T::Real = crate::convert(3.0);
let _0_5: T::Real = crate::convert(0.5);
let _3: T::RealField = crate::convert(3.0);
let _0_5: T::RealField = crate::convert(0.5);
self.value *= T::ComplexField::from_real(_0_5 * (_3 - sq_norm));
}
}

View File

@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use alga::general::{Real, SubsetOf};
use alga::general::{RealField, SubsetOf};
use alga::linear::Rotation;
use crate::base::allocator::Allocator;
@ -36,7 +36,7 @@ use crate::geometry::{Point, Translation};
DefaultAllocator: Allocator<N, D>,
Owned<N, D>: Deserialize<'de>"))
)]
pub struct Isometry<N: Real, D: DimName, R>
pub struct Isometry<N: RealField, D: DimName, R>
where DefaultAllocator: Allocator<N, D>
{
/// The pure rotational part of this isometry.
@ -55,7 +55,7 @@ where DefaultAllocator: Allocator<N, D>
#[cfg(feature = "abomonation-serialize")]
impl<N, D, R> Abomonation for Isometry<N, D, R>
where
N: Real,
N: RealField,
D: DimName,
R: Abomonation,
Translation<N, D>: Abomonation,
@ -77,7 +77,7 @@ where
}
}
impl<N: Real + hash::Hash, D: DimName + hash::Hash, R: hash::Hash> hash::Hash for Isometry<N, D, R>
impl<N: RealField + hash::Hash, D: DimName + hash::Hash, R: hash::Hash> hash::Hash for Isometry<N, D, R>
where
DefaultAllocator: Allocator<N, D>,
Owned<N, D>: hash::Hash,
@ -88,14 +88,14 @@ where
}
}
impl<N: Real, D: DimName + Copy, R: Rotation<Point<N, D>> + Copy> Copy for Isometry<N, D, R>
impl<N: RealField, D: DimName + Copy, R: Rotation<Point<N, D>> + Copy> Copy for Isometry<N, D, R>
where
DefaultAllocator: Allocator<N, D>,
Owned<N, D>: Copy,
{
}
impl<N: Real, D: DimName, R: Rotation<Point<N, D>> + Clone> Clone for Isometry<N, D, R>
impl<N: RealField, D: DimName, R: Rotation<Point<N, D>> + Clone> Clone for Isometry<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -104,7 +104,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName, R: Rotation<Point<N, D>>> Isometry<N, D, R>
impl<N: RealField, D: DimName, R: Rotation<Point<N, D>>> Isometry<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
/// Creates a new isometry from its rotational and translational parts.
@ -260,7 +260,7 @@ where DefaultAllocator: Allocator<N, D>
// and makes it hard 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 dummy ZST field).
impl<N: Real, D: DimName, R> Isometry<N, D, R>
impl<N: RealField, D: DimName, R> Isometry<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
/// Converts this isometry into its equivalent homogeneous transformation matrix.
@ -293,14 +293,14 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName, R> Eq for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> Eq for Isometry<N, D, R>
where
R: Rotation<Point<N, D>> + Eq,
DefaultAllocator: Allocator<N, D>,
{
}
impl<N: Real, D: DimName, R> PartialEq for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> PartialEq for Isometry<N, D, R>
where
R: Rotation<Point<N, D>> + PartialEq,
DefaultAllocator: Allocator<N, D>,
@ -311,7 +311,7 @@ where
}
}
impl<N: Real, D: DimName, R> AbsDiffEq for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> AbsDiffEq for Isometry<N, D, R>
where
R: Rotation<Point<N, D>> + AbsDiffEq<Epsilon = N::Epsilon>,
DefaultAllocator: Allocator<N, D>,
@ -331,7 +331,7 @@ where
}
}
impl<N: Real, D: DimName, R> RelativeEq for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> RelativeEq for Isometry<N, D, R>
where
R: Rotation<Point<N, D>> + RelativeEq<Epsilon = N::Epsilon>,
DefaultAllocator: Allocator<N, D>,
@ -358,7 +358,7 @@ where
}
}
impl<N: Real, D: DimName, R> UlpsEq for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> UlpsEq for Isometry<N, D, R>
where
R: Rotation<Point<N, D>> + UlpsEq<Epsilon = N::Epsilon>,
DefaultAllocator: Allocator<N, D>,
@ -382,7 +382,7 @@ where
* Display
*
*/
impl<N: Real + fmt::Display, D: DimName, R> fmt::Display for Isometry<N, D, R>
impl<N: RealField + fmt::Display, D: DimName, R> fmt::Display for Isometry<N, D, R>
where
R: fmt::Display,
DefaultAllocator: Allocator<N, D> + Allocator<usize, D>,

View File

@ -1,6 +1,6 @@
use alga::general::{
AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, Real,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, RealField,
};
use alga::linear::Isometry as AlgaIsometry;
use alga::linear::{
@ -19,7 +19,7 @@ use crate::geometry::{Isometry, Point, Translation};
* Algebraic structures.
*
*/
impl<N: Real, D: DimName, R> Identity<Multiplicative> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> Identity<Multiplicative> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -30,7 +30,7 @@ where
}
}
impl<N: Real, D: DimName, R> TwoSidedInverse<Multiplicative> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> TwoSidedInverse<Multiplicative> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -46,7 +46,7 @@ where
}
}
impl<N: Real, D: DimName, R> AbstractMagma<Multiplicative> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> AbstractMagma<Multiplicative> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -59,7 +59,7 @@ where
macro_rules! impl_multiplicative_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real, D: DimName, R> $marker<$operator> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> $marker<$operator> for Isometry<N, D, R>
where R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> { }
)*}
@ -78,7 +78,7 @@ impl_multiplicative_structures!(
* Transformation groups.
*
*/
impl<N: Real, D: DimName, R> Transformation<Point<N, D>> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> Transformation<Point<N, D>> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -94,7 +94,7 @@ where
}
}
impl<N: Real, D: DimName, R> ProjectiveTransformation<Point<N, D>> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> ProjectiveTransformation<Point<N, D>> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -111,7 +111,7 @@ where
}
}
impl<N: Real, D: DimName, R> AffineTransformation<Point<N, D>> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> AffineTransformation<Point<N, D>> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -169,7 +169,7 @@ where
}
}
impl<N: Real, D: DimName, R> Similarity<Point<N, D>> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> Similarity<Point<N, D>> for Isometry<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -194,7 +194,7 @@ where
macro_rules! marker_impl(
($($Trait: ident),*) => {$(
impl<N: Real, D: DimName, R> $Trait<Point<N, D>> for Isometry<N, D, R>
impl<N: RealField, D: DimName, R> $Trait<Point<N, D>> for Isometry<N, D, R>
where R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> { }
)*}

View File

@ -7,7 +7,7 @@ use num::One;
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use alga::general::Real;
use alga::general::RealField;
use alga::linear::Rotation as AlgaRotation;
use crate::base::allocator::Allocator;
@ -19,7 +19,7 @@ use crate::geometry::{
UnitQuaternion, Translation2, Translation3
};
impl<N: Real, D: DimName, R: AlgaRotation<Point<N, D>>> Isometry<N, D, R>
impl<N: RealField, D: DimName, R: AlgaRotation<Point<N, D>>> Isometry<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
/// Creates a new identity isometry.
@ -65,7 +65,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName, R: AlgaRotation<Point<N, D>>> One for Isometry<N, D, R>
impl<N: RealField, D: DimName, R: AlgaRotation<Point<N, D>>> One for Isometry<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
/// Creates a new identity isometry.
@ -75,7 +75,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName, R> Distribution<Isometry<N, D, R>> for Standard
impl<N: RealField, D: DimName, R> Distribution<Isometry<N, D, R>> for Standard
where
R: AlgaRotation<Point<N, D>>,
Standard: Distribution<N> + Distribution<R>,
@ -90,7 +90,7 @@ where
#[cfg(feature = "arbitrary")]
impl<N, D: DimName, R> Arbitrary for Isometry<N, D, R>
where
N: Real + Arbitrary + Send,
N: RealField + Arbitrary + Send,
R: AlgaRotation<Point<N, D>> + Arbitrary + Send,
Owned<N, D>: Send,
DefaultAllocator: Allocator<N, D>,
@ -108,7 +108,7 @@ where
*/
// 2D rotation.
impl<N: Real> Isometry<N, U2, Rotation2<N>> {
impl<N: RealField> Isometry<N, U2, Rotation2<N>> {
/// Creates a new 2D isometry from a translation and a rotation angle.
///
/// Its rotational part is represented as a 2x2 rotation matrix.
@ -143,7 +143,7 @@ impl<N: Real> Isometry<N, U2, Rotation2<N>> {
}
}
impl<N: Real> Isometry<N, U2, UnitComplex<N>> {
impl<N: RealField> Isometry<N, U2, UnitComplex<N>> {
/// Creates a new 2D isometry from a translation and a rotation angle.
///
/// Its rotational part is represented as an unit complex number.
@ -181,7 +181,7 @@ impl<N: Real> Isometry<N, U2, UnitComplex<N>> {
// 3D rotation.
macro_rules! isometry_construction_impl(
($RotId: ident < $($RotParams: ident),*>, $RRDim: ty, $RCDim: ty) => {
impl<N: Real> Isometry<N, U3, $RotId<$($RotParams),*>> {
impl<N: RealField> Isometry<N, U3, $RotId<$($RotParams),*>> {
/// Creates a new isometry from a translation and a rotation axis-angle.
///
/// # Example

View File

@ -1,4 +1,4 @@
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::general::{RealField, SubsetOf, SupersetOf};
use alga::linear::Rotation;
use crate::base::allocator::Allocator;
@ -19,8 +19,8 @@ use crate::geometry::{Isometry, Point, Similarity, SuperTCategoryOf, TAffine, Tr
impl<N1, N2, D: DimName, R1, R2> SubsetOf<Isometry<N2, D, R2>> for Isometry<N1, D, R1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R1: Rotation<Point<N1, D>> + SubsetOf<R2>,
R2: Rotation<Point<N2, D>>,
DefaultAllocator: Allocator<N1, D> + Allocator<N2, D>,
@ -47,8 +47,8 @@ where
impl<N1, N2, D: DimName, R1, R2> SubsetOf<Similarity<N2, D, R2>> for Isometry<N1, D, R1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R1: Rotation<Point<N1, D>> + SubsetOf<R2>,
R2: Rotation<Point<N2, D>>,
DefaultAllocator: Allocator<N1, D> + Allocator<N2, D>,
@ -71,8 +71,8 @@ where
impl<N1, N2, D, R, C> SubsetOf<Transform<N2, D, C>> for Isometry<N1, D, R>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
C: SuperTCategoryOf<TAffine>,
R: Rotation<Point<N1, D>>
+ SubsetOf<MatrixN<N1, DimNameSum<D, U1>>>
@ -105,8 +105,8 @@ where
impl<N1, N2, D, R> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Isometry<N1, D, R>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: Rotation<Point<N1, D>>
+ SubsetOf<MatrixN<N1, DimNameSum<D, U1>>>
+ SubsetOf<MatrixN<N2, DimNameSum<D, U1>>>,
@ -149,7 +149,7 @@ where
}
}
impl<N: Real, D: DimName, R> From<Isometry<N, D, R>> for MatrixN<N, DimNameSum<D, U1>>
impl<N: RealField, D: DimName, R> From<Isometry<N, D, R>> for MatrixN<N, DimNameSum<D, U1>>
where
D: DimNameAdd<U1>,
R: SubsetOf<MatrixN<N, DimNameSum<D, U1>>>,

View File

@ -1,6 +1,6 @@
use std::ops::{Div, DivAssign, Mul, MulAssign};
use alga::general::Real;
use alga::general::RealField;
use alga::linear::Rotation as AlgaRotation;
use crate::base::allocator::Allocator;
@ -64,7 +64,7 @@ macro_rules! isometry_binop_impl(
($Op: ident, $op: ident;
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real, D: DimName, R> $Op<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField, D: DimName, R> $Op<$Rhs> for $Lhs
where R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> {
type Output = $Output;
@ -111,7 +111,7 @@ macro_rules! isometry_binop_assign_impl_all(
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty;
[val] => $action_val: expr;
[ref] => $action_ref: expr;) => {
impl<N: Real, D: DimName, R> $OpAssign<$Rhs> for $Lhs
impl<N: RealField, D: DimName, R> $OpAssign<$Rhs> for $Lhs
where R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> {
#[inline]
@ -120,7 +120,7 @@ macro_rules! isometry_binop_assign_impl_all(
}
}
impl<'b, N: Real, D: DimName, R> $OpAssign<&'b $Rhs> for $Lhs
impl<'b, N: RealField, D: DimName, R> $OpAssign<&'b $Rhs> for $Lhs
where R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> {
#[inline]
@ -286,7 +286,7 @@ macro_rules! isometry_from_composition_impl(
($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(for $Dims: ident: $DimsBound: ident),*;
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs
where DefaultAllocator: Allocator<N, $R1, $C1> +
Allocator<N, $R2, $C2> {
type Output = $Output;

View File

@ -7,7 +7,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::mem;
use alga::general::Real;
use alga::general::RealField;
use crate::base::dimension::U3;
use crate::base::helper;
@ -17,26 +17,26 @@ use crate::base::{Matrix4, Vector, Vector3};
use crate::geometry::{Point3, Projective3};
/// A 3D orthographic projection stored as an homogeneous 4x4 matrix.
pub struct Orthographic3<N: Real> {
pub struct Orthographic3<N: RealField> {
matrix: Matrix4<N>,
}
impl<N: Real> Copy for Orthographic3<N> {}
impl<N: RealField> Copy for Orthographic3<N> {}
impl<N: Real> Clone for Orthographic3<N> {
impl<N: RealField> Clone for Orthographic3<N> {
#[inline]
fn clone(&self) -> Self {
Self::from_matrix_unchecked(self.matrix.clone())
}
}
impl<N: Real> fmt::Debug for Orthographic3<N> {
impl<N: RealField> fmt::Debug for Orthographic3<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.matrix.fmt(f)
}
}
impl<N: Real> PartialEq for Orthographic3<N> {
impl<N: RealField> PartialEq for Orthographic3<N> {
#[inline]
fn eq(&self, right: &Self) -> bool {
self.matrix == right.matrix
@ -44,7 +44,7 @@ impl<N: Real> PartialEq for Orthographic3<N> {
}
#[cfg(feature = "serde-serialize")]
impl<N: Real + Serialize> Serialize for Orthographic3<N> {
impl<N: RealField + Serialize> Serialize for Orthographic3<N> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
self.matrix.serialize(serializer)
@ -52,7 +52,7 @@ impl<N: Real + Serialize> Serialize for Orthographic3<N> {
}
#[cfg(feature = "serde-serialize")]
impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Orthographic3<N> {
impl<'a, N: RealField + Deserialize<'a>> Deserialize<'a> for Orthographic3<N> {
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
where Des: Deserializer<'a> {
let matrix = Matrix4::<N>::deserialize(deserializer)?;
@ -61,7 +61,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Orthographic3<N> {
}
}
impl<N: Real> Orthographic3<N> {
impl<N: RealField> Orthographic3<N> {
/// Creates a new orthographic projection matrix.
///
/// This follows the OpenGL convention, so this will flip the `z` axis.
@ -678,7 +678,7 @@ impl<N: Real> Orthographic3<N> {
}
}
impl<N: Real> Distribution<Orthographic3<N>> for Standard
impl<N: RealField> Distribution<Orthographic3<N>> for Standard
where Standard: Distribution<N>
{
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> Orthographic3<N> {
@ -694,7 +694,7 @@ where Standard: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for Orthographic3<N>
impl<N: RealField + Arbitrary> Arbitrary for Orthographic3<N>
where Matrix4<N>: Send
{
fn arbitrary<G: Gen>(g: &mut G) -> Self {
@ -709,7 +709,7 @@ where Matrix4<N>: Send
}
}
impl<N: Real> From<Orthographic3<N>> for Matrix4<N> {
impl<N: RealField> From<Orthographic3<N>> for Matrix4<N> {
#[inline]
fn from(orth: Orthographic3<N>) -> Self {
orth.into_inner()

View File

@ -8,7 +8,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::mem;
use alga::general::Real;
use alga::general::RealField;
use crate::base::dimension::U3;
use crate::base::helper;
@ -22,22 +22,22 @@ pub struct Perspective3<N: Scalar> {
matrix: Matrix4<N>,
}
impl<N: Real> Copy for Perspective3<N> {}
impl<N: RealField> Copy for Perspective3<N> {}
impl<N: Real> Clone for Perspective3<N> {
impl<N: RealField> Clone for Perspective3<N> {
#[inline]
fn clone(&self) -> Self {
Self::from_matrix_unchecked(self.matrix.clone())
}
}
impl<N: Real> fmt::Debug for Perspective3<N> {
impl<N: RealField> fmt::Debug for Perspective3<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.matrix.fmt(f)
}
}
impl<N: Real> PartialEq for Perspective3<N> {
impl<N: RealField> PartialEq for Perspective3<N> {
#[inline]
fn eq(&self, right: &Self) -> bool {
self.matrix == right.matrix
@ -45,7 +45,7 @@ impl<N: Real> PartialEq for Perspective3<N> {
}
#[cfg(feature = "serde-serialize")]
impl<N: Real + Serialize> Serialize for Perspective3<N> {
impl<N: RealField + Serialize> Serialize for Perspective3<N> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
self.matrix.serialize(serializer)
@ -53,7 +53,7 @@ impl<N: Real + Serialize> Serialize for Perspective3<N> {
}
#[cfg(feature = "serde-serialize")]
impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Perspective3<N> {
impl<'a, N: RealField + Deserialize<'a>> Deserialize<'a> for Perspective3<N> {
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
where Des: Deserializer<'a> {
let matrix = Matrix4::<N>::deserialize(deserializer)?;
@ -62,7 +62,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Perspective3<N> {
}
}
impl<N: Real> Perspective3<N> {
impl<N: RealField> Perspective3<N> {
/// Creates a new perspective matrix from the aspect ratio, y field of view, and near/far planes.
pub fn new(aspect: N, fovy: N, znear: N, zfar: N) -> Self {
assert!(
@ -261,7 +261,7 @@ impl<N: Real> Perspective3<N> {
}
}
impl<N: Real> Distribution<Perspective3<N>> for Standard
impl<N: RealField> Distribution<Perspective3<N>> for Standard
where Standard: Distribution<N>
{
fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3<N> {
@ -274,7 +274,7 @@ where Standard: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for Perspective3<N> {
impl<N: RealField + Arbitrary> Arbitrary for Perspective3<N> {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let znear = Arbitrary::arbitrary(g);
let zfar = helper::reject(g, |&x: &N| !(x - znear).is_zero());
@ -284,7 +284,7 @@ impl<N: Real + Arbitrary> Arbitrary for Perspective3<N> {
}
}
impl<N: Real> From<Perspective3<N>> for Matrix4<N> {
impl<N: RealField> From<Perspective3<N>> for Matrix4<N> {
#[inline]
fn from(orth: Perspective3<N>) -> Self {
orth.into_inner()

View File

@ -1,4 +1,4 @@
use alga::general::{Field, JoinSemilattice, Lattice, MeetSemilattice, Real};
use alga::general::{Field, JoinSemilattice, Lattice, MeetSemilattice, RealField};
use alga::linear::{AffineSpace, EuclideanSpace};
use crate::base::allocator::Allocator;
@ -15,11 +15,11 @@ where
type Translation = VectorN<N, D>;
}
impl<N: Real, D: DimName> EuclideanSpace for Point<N, D>
impl<N: RealField, D: DimName> EuclideanSpace for Point<N, D>
where DefaultAllocator: Allocator<N, D>
{
type Coordinates = VectorN<N, D>;
type Real = N;
type RealField = N;
#[inline]
fn origin() -> Self {

View File

@ -13,7 +13,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use alga::general::Real;
use alga::general::RealField;
use crate::base::dimension::{U1, U3, U4};
use crate::base::storage::{CStride, RStride};
@ -25,13 +25,13 @@ use crate::geometry::Rotation;
/// that may be used as a rotation.
#[repr(C)]
#[derive(Debug)]
pub struct Quaternion<N: Real> {
pub struct Quaternion<N: RealField> {
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
pub coords: Vector4<N>,
}
#[cfg(feature = "abomonation-serialize")]
impl<N: Real> Abomonation for Quaternion<N>
impl<N: RealField> Abomonation for Quaternion<N>
where Vector4<N>: Abomonation
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
@ -47,9 +47,9 @@ where Vector4<N>: Abomonation
}
}
impl<N: Real + Eq> Eq for Quaternion<N> {}
impl<N: RealField + Eq> Eq for Quaternion<N> {}
impl<N: Real> PartialEq for Quaternion<N> {
impl<N: RealField> PartialEq for Quaternion<N> {
fn eq(&self, rhs: &Self) -> bool {
self.coords == rhs.coords ||
// Account for the double-covering of S², i.e. q = -q
@ -57,15 +57,15 @@ impl<N: Real> PartialEq for Quaternion<N> {
}
}
impl<N: Real + hash::Hash> hash::Hash for Quaternion<N> {
impl<N: RealField + hash::Hash> hash::Hash for Quaternion<N> {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.coords.hash(state)
}
}
impl<N: Real> Copy for Quaternion<N> {}
impl<N: RealField> Copy for Quaternion<N> {}
impl<N: Real> Clone for Quaternion<N> {
impl<N: RealField> Clone for Quaternion<N> {
#[inline]
fn clone(&self) -> Self {
Self::from(self.coords.clone())
@ -73,7 +73,7 @@ impl<N: Real> Clone for Quaternion<N> {
}
#[cfg(feature = "serde-serialize")]
impl<N: Real> Serialize for Quaternion<N>
impl<N: RealField> Serialize for Quaternion<N>
where Owned<N, U4>: Serialize
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@ -83,7 +83,7 @@ where Owned<N, U4>: Serialize
}
#[cfg(feature = "serde-serialize")]
impl<'a, N: Real> Deserialize<'a> for Quaternion<N>
impl<'a, N: RealField> Deserialize<'a> for Quaternion<N>
where Owned<N, U4>: Deserialize<'a>
{
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
@ -94,7 +94,7 @@ where Owned<N, U4>: Deserialize<'a>
}
}
impl<N: Real> Quaternion<N> {
impl<N: RealField> Quaternion<N> {
/// Moves this unit quaternion into one that owns its data.
#[inline]
#[deprecated(note = "This method is a no-op and will be removed in a future release.")]
@ -508,7 +508,7 @@ impl<N: Real> Quaternion<N> {
}
}
impl<N: Real + AbsDiffEq<Epsilon = N>> AbsDiffEq for Quaternion<N> {
impl<N: RealField + AbsDiffEq<Epsilon = N>> AbsDiffEq for Quaternion<N> {
type Epsilon = N;
#[inline]
@ -524,7 +524,7 @@ impl<N: Real + AbsDiffEq<Epsilon = N>> AbsDiffEq for Quaternion<N> {
}
}
impl<N: Real + RelativeEq<Epsilon = N>> RelativeEq for Quaternion<N> {
impl<N: RealField + RelativeEq<Epsilon = N>> RelativeEq for Quaternion<N> {
#[inline]
fn default_max_relative() -> Self::Epsilon {
N::default_max_relative()
@ -544,7 +544,7 @@ impl<N: Real + RelativeEq<Epsilon = N>> RelativeEq for Quaternion<N> {
}
}
impl<N: Real + UlpsEq<Epsilon = N>> UlpsEq for Quaternion<N> {
impl<N: RealField + UlpsEq<Epsilon = N>> UlpsEq for Quaternion<N> {
#[inline]
fn default_max_ulps() -> u32 {
N::default_max_ulps()
@ -558,7 +558,7 @@ impl<N: Real + UlpsEq<Epsilon = N>> UlpsEq for Quaternion<N> {
}
}
impl<N: Real + fmt::Display> fmt::Display for Quaternion<N> {
impl<N: RealField + fmt::Display> fmt::Display for Quaternion<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
@ -571,7 +571,7 @@ impl<N: Real + fmt::Display> fmt::Display for Quaternion<N> {
/// A unit quaternions. May be used to represent a rotation.
pub type UnitQuaternion<N> = Unit<Quaternion<N>>;
impl<N: Real> UnitQuaternion<N> {
impl<N: RealField> UnitQuaternion<N> {
/// Moves this unit quaternion into one that owns its data.
#[inline]
#[deprecated(
@ -1007,7 +1007,7 @@ impl<N: Real> UnitQuaternion<N> {
}
}
impl<N: Real + fmt::Display> fmt::Display for UnitQuaternion<N> {
impl<N: RealField + fmt::Display> fmt::Display for UnitQuaternion<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(axis) = self.axis() {
let axis = axis.into_inner();
@ -1029,7 +1029,7 @@ impl<N: Real + fmt::Display> fmt::Display for UnitQuaternion<N> {
}
}
impl<N: Real + AbsDiffEq<Epsilon = N>> AbsDiffEq for UnitQuaternion<N> {
impl<N: RealField + AbsDiffEq<Epsilon = N>> AbsDiffEq for UnitQuaternion<N> {
type Epsilon = N;
#[inline]
@ -1043,7 +1043,7 @@ impl<N: Real + AbsDiffEq<Epsilon = N>> AbsDiffEq for UnitQuaternion<N> {
}
}
impl<N: Real + RelativeEq<Epsilon = N>> RelativeEq for UnitQuaternion<N> {
impl<N: RealField + RelativeEq<Epsilon = N>> RelativeEq for UnitQuaternion<N> {
#[inline]
fn default_max_relative() -> Self::Epsilon {
N::default_max_relative()
@ -1062,7 +1062,7 @@ impl<N: Real + RelativeEq<Epsilon = N>> RelativeEq for UnitQuaternion<N> {
}
}
impl<N: Real + UlpsEq<Epsilon = N>> UlpsEq for UnitQuaternion<N> {
impl<N: RealField + UlpsEq<Epsilon = N>> UlpsEq for UnitQuaternion<N> {
#[inline]
fn default_max_ulps() -> u32 {
N::default_max_ulps()

View File

@ -3,7 +3,7 @@ use num::Zero;
use alga::general::{
AbstractGroup, AbstractGroupAbelian, AbstractLoop, AbstractMagma, AbstractModule,
AbstractMonoid, AbstractQuasigroup, AbstractSemigroup, Additive, Id, Identity, TwoSidedInverse, Module,
Multiplicative, Real,
Multiplicative, RealField,
};
use alga::linear::{
AffineTransformation, DirectIsometry, FiniteDimVectorSpace, Isometry, NormedSpace,
@ -14,35 +14,35 @@ use alga::linear::{
use crate::base::{Vector3, Vector4};
use crate::geometry::{Point3, Quaternion, UnitQuaternion};
impl<N: Real> Identity<Multiplicative> for Quaternion<N> {
impl<N: RealField> Identity<Multiplicative> for Quaternion<N> {
#[inline]
fn identity() -> Self {
Self::identity()
}
}
impl<N: Real> Identity<Additive> for Quaternion<N> {
impl<N: RealField> Identity<Additive> for Quaternion<N> {
#[inline]
fn identity() -> Self {
Self::zero()
}
}
impl<N: Real> AbstractMagma<Multiplicative> for Quaternion<N> {
impl<N: RealField> AbstractMagma<Multiplicative> for Quaternion<N> {
#[inline]
fn operate(&self, rhs: &Self) -> Self {
self * rhs
}
}
impl<N: Real> AbstractMagma<Additive> for Quaternion<N> {
impl<N: RealField> AbstractMagma<Additive> for Quaternion<N> {
#[inline]
fn operate(&self, rhs: &Self) -> Self {
self + rhs
}
}
impl<N: Real> TwoSidedInverse<Additive> for Quaternion<N> {
impl<N: RealField> TwoSidedInverse<Additive> for Quaternion<N> {
#[inline]
fn two_sided_inverse(&self) -> Self {
-self
@ -51,7 +51,7 @@ impl<N: Real> TwoSidedInverse<Additive> for Quaternion<N> {
macro_rules! impl_structures(
($Quaternion: ident; $($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real> $marker<$operator> for $Quaternion<N> { }
impl<N: RealField> $marker<$operator> for $Quaternion<N> { }
)*}
);
@ -73,7 +73,7 @@ impl_structures!(
* Vector space.
*
*/
impl<N: Real> AbstractModule for Quaternion<N> {
impl<N: RealField> AbstractModule for Quaternion<N> {
type AbstractRing = N;
#[inline]
@ -82,15 +82,15 @@ impl<N: Real> AbstractModule for Quaternion<N> {
}
}
impl<N: Real> Module for Quaternion<N> {
impl<N: RealField> Module for Quaternion<N> {
type Ring = N;
}
impl<N: Real> VectorSpace for Quaternion<N> {
impl<N: RealField> VectorSpace for Quaternion<N> {
type Field = N;
}
impl<N: Real> FiniteDimVectorSpace for Quaternion<N> {
impl<N: RealField> FiniteDimVectorSpace for Quaternion<N> {
#[inline]
fn dimension() -> usize {
4
@ -117,8 +117,8 @@ impl<N: Real> FiniteDimVectorSpace for Quaternion<N> {
}
}
impl<N: Real> NormedSpace for Quaternion<N> {
type Real = N;
impl<N: RealField> NormedSpace for Quaternion<N> {
type RealField = N;
type ComplexField = N;
#[inline]
@ -162,21 +162,21 @@ impl<N: Real> NormedSpace for Quaternion<N> {
* Implementations for UnitQuaternion.
*
*/
impl<N: Real> Identity<Multiplicative> for UnitQuaternion<N> {
impl<N: RealField> Identity<Multiplicative> for UnitQuaternion<N> {
#[inline]
fn identity() -> Self {
Self::identity()
}
}
impl<N: Real> AbstractMagma<Multiplicative> for UnitQuaternion<N> {
impl<N: RealField> AbstractMagma<Multiplicative> for UnitQuaternion<N> {
#[inline]
fn operate(&self, rhs: &Self) -> Self {
self * rhs
}
}
impl<N: Real> TwoSidedInverse<Multiplicative> for UnitQuaternion<N> {
impl<N: RealField> TwoSidedInverse<Multiplicative> for UnitQuaternion<N> {
#[inline]
fn two_sided_inverse(&self) -> Self {
self.inverse()
@ -197,7 +197,7 @@ impl_structures!(
AbstractGroup<Multiplicative>
);
impl<N: Real> Transformation<Point3<N>> for UnitQuaternion<N> {
impl<N: RealField> Transformation<Point3<N>> for UnitQuaternion<N> {
#[inline]
fn transform_point(&self, pt: &Point3<N>) -> Point3<N> {
self * pt
@ -209,7 +209,7 @@ impl<N: Real> Transformation<Point3<N>> for UnitQuaternion<N> {
}
}
impl<N: Real> ProjectiveTransformation<Point3<N>> for UnitQuaternion<N> {
impl<N: RealField> ProjectiveTransformation<Point3<N>> for UnitQuaternion<N> {
#[inline]
fn inverse_transform_point(&self, pt: &Point3<N>) -> Point3<N> {
// FIXME: would it be useful performancewise not to call inverse explicitly (i-e. implement
@ -223,7 +223,7 @@ impl<N: Real> ProjectiveTransformation<Point3<N>> for UnitQuaternion<N> {
}
}
impl<N: Real> AffineTransformation<Point3<N>> for UnitQuaternion<N> {
impl<N: RealField> AffineTransformation<Point3<N>> for UnitQuaternion<N> {
type Rotation = Self;
type NonUniformScaling = Id;
type Translation = Id;
@ -264,7 +264,7 @@ impl<N: Real> AffineTransformation<Point3<N>> for UnitQuaternion<N> {
}
}
impl<N: Real> Similarity<Point3<N>> for UnitQuaternion<N> {
impl<N: RealField> Similarity<Point3<N>> for UnitQuaternion<N> {
type Scaling = Id;
#[inline]
@ -285,13 +285,13 @@ impl<N: Real> Similarity<Point3<N>> for UnitQuaternion<N> {
macro_rules! marker_impl(
($($Trait: ident),*) => {$(
impl<N: Real> $Trait<Point3<N>> for UnitQuaternion<N> { }
impl<N: RealField> $Trait<Point3<N>> for UnitQuaternion<N> { }
)*}
);
marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation);
impl<N: Real> Rotation<Point3<N>> for UnitQuaternion<N> {
impl<N: RealField> Rotation<Point3<N>> for UnitQuaternion<N> {
#[inline]
fn powf(&self, n: N) -> Option<Self> {
Some(self.powf(n))

View File

@ -9,7 +9,7 @@ use num::{One, Zero};
use rand::distributions::{Distribution, OpenClosed01, Standard};
use rand::Rng;
use alga::general::Real;
use alga::general::RealField;
use crate::base::dimension::U3;
use crate::base::storage::Storage;
@ -19,7 +19,7 @@ use crate::base::{Unit, Vector, Vector4, Matrix3};
use crate::geometry::{Quaternion, Rotation3, UnitQuaternion};
impl<N: Real> Quaternion<N> {
impl<N: RealField> Quaternion<N> {
/// Creates a quaternion from a 4D vector. The quaternion scalar part corresponds to the `w`
/// vector component.
#[inline]
@ -96,14 +96,14 @@ impl<N: Real> Quaternion<N> {
}
}
impl<N: Real> One for Quaternion<N> {
impl<N: RealField> One for Quaternion<N> {
#[inline]
fn one() -> Self {
Self::identity()
}
}
impl<N: Real> Zero for Quaternion<N> {
impl<N: RealField> Zero for Quaternion<N> {
#[inline]
fn zero() -> Self {
Self::new(N::zero(), N::zero(), N::zero(), N::zero())
@ -115,7 +115,7 @@ impl<N: Real> Zero for Quaternion<N> {
}
}
impl<N: Real> Distribution<Quaternion<N>> for Standard
impl<N: RealField> Distribution<Quaternion<N>> for Standard
where Standard: Distribution<N>
{
#[inline]
@ -125,7 +125,7 @@ where Standard: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for Quaternion<N>
impl<N: RealField + Arbitrary> Arbitrary for Quaternion<N>
where Owned<N, U4>: Send
{
#[inline]
@ -139,7 +139,7 @@ where Owned<N, U4>: Send
}
}
impl<N: Real> UnitQuaternion<N> {
impl<N: RealField> UnitQuaternion<N> {
/// The rotation identity.
///
/// # Example
@ -669,14 +669,14 @@ impl<N: Real> UnitQuaternion<N> {
}
}
impl<N: Real> One for UnitQuaternion<N> {
impl<N: RealField> One for UnitQuaternion<N> {
#[inline]
fn one() -> Self {
Self::identity()
}
}
impl<N: Real> Distribution<UnitQuaternion<N>> for Standard
impl<N: RealField> Distribution<UnitQuaternion<N>> for Standard
where OpenClosed01: Distribution<N>
{
/// Generate a uniformly distributed random rotation quaternion.
@ -701,7 +701,7 @@ where OpenClosed01: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for UnitQuaternion<N>
impl<N: RealField + Arbitrary> Arbitrary for UnitQuaternion<N>
where
Owned<N, U4>: Send,
Owned<N, U3>: Send,

View File

@ -1,6 +1,6 @@
use num::Zero;
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::general::{RealField, SubsetOf, SupersetOf};
use alga::linear::Rotation as AlgaRotation;
#[cfg(feature = "mint")]
@ -34,8 +34,8 @@ use crate::geometry::{
impl<N1, N2> SubsetOf<Quaternion<N2>> for Quaternion<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> Quaternion<N2> {
@ -57,8 +57,8 @@ where
impl<N1, N2> SubsetOf<UnitQuaternion<N2>> for UnitQuaternion<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> UnitQuaternion<N2> {
@ -78,8 +78,8 @@ where
impl<N1, N2> SubsetOf<Rotation<N2, U3>> for UnitQuaternion<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> Rotation3<N2> {
@ -101,8 +101,8 @@ where
impl<N1, N2, R> SubsetOf<Isometry<N2, U3, R>> for UnitQuaternion<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: AlgaRotation<Point3<N2>> + SupersetOf<Self>,
{
#[inline]
@ -123,8 +123,8 @@ where
impl<N1, N2, R> SubsetOf<Similarity<N2, U3, R>> for UnitQuaternion<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: AlgaRotation<Point3<N2>> + SupersetOf<Self>,
{
#[inline]
@ -145,8 +145,8 @@ where
impl<N1, N2, C> SubsetOf<Transform<N2, U3, C>> for UnitQuaternion<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
C: SuperTCategoryOf<TAffine>,
{
#[inline]
@ -165,7 +165,7 @@ where
}
}
impl<N1: Real, N2: Real + SupersetOf<N1>> SubsetOf<Matrix4<N2>> for UnitQuaternion<N1> {
impl<N1: RealField, N2: RealField + SupersetOf<N1>> SubsetOf<Matrix4<N2>> for UnitQuaternion<N1> {
#[inline]
fn to_superset(&self) -> Matrix4<N2> {
self.to_homogeneous().to_superset()
@ -184,14 +184,14 @@ impl<N1: Real, N2: Real + SupersetOf<N1>> SubsetOf<Matrix4<N2>> for UnitQuaterni
}
#[cfg(feature = "mint")]
impl<N: Real> From<mint::Quaternion<N>> for Quaternion<N> {
impl<N: RealField> From<mint::Quaternion<N>> for Quaternion<N> {
fn from(q: mint::Quaternion<N>) -> Self {
Self::new(q.s, q.v.x, q.v.y, q.v.z)
}
}
#[cfg(feature = "mint")]
impl<N: Real> Into<mint::Quaternion<N>> for Quaternion<N> {
impl<N: RealField> Into<mint::Quaternion<N>> for Quaternion<N> {
fn into(self) -> mint::Quaternion<N> {
mint::Quaternion {
v: mint::Vector3 {
@ -205,7 +205,7 @@ impl<N: Real> Into<mint::Quaternion<N>> for Quaternion<N> {
}
#[cfg(feature = "mint")]
impl<N: Real> Into<mint::Quaternion<N>> for UnitQuaternion<N> {
impl<N: RealField> Into<mint::Quaternion<N>> for UnitQuaternion<N> {
fn into(self) -> mint::Quaternion<N> {
mint::Quaternion {
v: mint::Vector3 {
@ -218,35 +218,35 @@ impl<N: Real> Into<mint::Quaternion<N>> for UnitQuaternion<N> {
}
}
impl<N: Real> From<UnitQuaternion<N>> for Matrix4<N> {
impl<N: RealField> From<UnitQuaternion<N>> for Matrix4<N> {
#[inline]
fn from(q: UnitQuaternion<N>) -> Self {
q.to_homogeneous()
}
}
impl<N: Real> From<UnitQuaternion<N>> for Rotation3<N> {
impl<N: RealField> From<UnitQuaternion<N>> for Rotation3<N> {
#[inline]
fn from(q: UnitQuaternion<N>) -> Self {
q.to_rotation_matrix()
}
}
impl<N: Real> From<Rotation3<N>> for UnitQuaternion<N> {
impl<N: RealField> From<Rotation3<N>> for UnitQuaternion<N> {
#[inline]
fn from(q: Rotation3<N>) -> Self {
Self::from_rotation_matrix(&q)
}
}
impl<N: Real> From<UnitQuaternion<N>> for Matrix3<N> {
impl<N: RealField> From<UnitQuaternion<N>> for Matrix3<N> {
#[inline]
fn from(q: UnitQuaternion<N>) -> Self {
q.to_rotation_matrix().into_inner()
}
}
impl<N: Real> From<Vector4<N>> for Quaternion<N> {
impl<N: RealField> From<Vector4<N>> for Quaternion<N> {
#[inline]
fn from(coords: Vector4<N>) -> Self {
Self { coords }

View File

@ -1,13 +1,13 @@
use std::mem;
use std::ops::{Deref, DerefMut};
use alga::general::Real;
use alga::general::RealField;
use crate::base::coordinates::IJKW;
use crate::geometry::Quaternion;
impl<N: Real> Deref for Quaternion<N> {
impl<N: RealField> Deref for Quaternion<N> {
type Target = IJKW<N>;
#[inline]
@ -16,7 +16,7 @@ impl<N: Real> Deref for Quaternion<N> {
}
}
impl<N: Real> DerefMut for Quaternion<N> {
impl<N: RealField> DerefMut for Quaternion<N> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { mem::transmute(self) }

View File

@ -54,7 +54,7 @@ use std::ops::{
Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign,
};
use alga::general::Real;
use alga::general::RealField;
use crate::base::allocator::Allocator;
use crate::base::dimension::{U1, U3, U4};
@ -63,7 +63,7 @@ use crate::base::{DefaultAllocator, Unit, Vector, Vector3};
use crate::geometry::{Point3, Quaternion, Rotation, UnitQuaternion};
impl<N: Real> Index<usize> for Quaternion<N> {
impl<N: RealField> Index<usize> for Quaternion<N> {
type Output = N;
#[inline]
@ -72,7 +72,7 @@ impl<N: Real> Index<usize> for Quaternion<N> {
}
}
impl<N: Real> IndexMut<usize> for Quaternion<N> {
impl<N: RealField> IndexMut<usize> for Quaternion<N> {
#[inline]
fn index_mut(&mut self, i: usize) -> &mut N {
&mut self.coords[i]
@ -85,7 +85,7 @@ macro_rules! quaternion_op_impl(
$(for $Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*;
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty $(=> $VDimA: ty, $VDimB: ty)*;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real $(, $Storage: $StoragesBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField $(, $Storage: $StoragesBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs
where DefaultAllocator: Allocator<N, $LhsRDim, $LhsCDim> +
Allocator<N, $RhsRDim, $RhsCDim> {
type Output = $Result;
@ -490,7 +490,7 @@ quaternion_op_impl!(
macro_rules! scalar_op_impl(
($($Op: ident, $op: ident, $OpAssign: ident, $op_assign: ident);* $(;)*) => {$(
impl<N: Real> $Op<N> for Quaternion<N> {
impl<N: RealField> $Op<N> for Quaternion<N> {
type Output = Quaternion<N>;
#[inline]
@ -499,7 +499,7 @@ macro_rules! scalar_op_impl(
}
}
impl<'a, N: Real> $Op<N> for &'a Quaternion<N> {
impl<'a, N: RealField> $Op<N> for &'a Quaternion<N> {
type Output = Quaternion<N>;
#[inline]
@ -508,7 +508,7 @@ macro_rules! scalar_op_impl(
}
}
impl<N: Real> $OpAssign<N> for Quaternion<N> {
impl<N: RealField> $OpAssign<N> for Quaternion<N> {
#[inline]
fn $op_assign(&mut self, n: N) {
@ -547,7 +547,7 @@ macro_rules! left_scalar_mul_impl(
left_scalar_mul_impl!(f32, f64);
impl<N: Real> Neg for Quaternion<N> {
impl<N: RealField> Neg for Quaternion<N> {
type Output = Quaternion<N>;
#[inline]
@ -556,7 +556,7 @@ impl<N: Real> Neg for Quaternion<N> {
}
}
impl<'a, N: Real> Neg for &'a Quaternion<N> {
impl<'a, N: RealField> Neg for &'a Quaternion<N> {
type Output = Quaternion<N>;
#[inline]
@ -570,7 +570,7 @@ macro_rules! quaternion_op_impl(
($LhsRDim: ident, $LhsCDim: ident), ($RhsRDim: ident, $RhsCDim: ident);
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty $(=> $VDimA: ty, $VDimB: ty)*;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real> $OpAssign<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField> $OpAssign<$Rhs> for $Lhs
where DefaultAllocator: Allocator<N, $LhsRDim, $LhsCDim> +
Allocator<N, $RhsRDim, $RhsCDim> {

View File

@ -14,7 +14,7 @@ use crate::base::storage::Owned;
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use alga::general::Real;
use alga::general::RealField;
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
@ -429,7 +429,7 @@ where
*/
impl<N, D: DimName> fmt::Display for Rotation<N, D>
where
N: Real + fmt::Display,
N: RealField + fmt::Display,
DefaultAllocator: Allocator<N, D, D> + Allocator<usize, D, D>,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,6 +1,6 @@
use alga::general::{
AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, Real,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, RealField,
};
use alga::linear::{
self, AffineTransformation, DirectIsometry, Isometry, OrthogonalTransformation,
@ -18,7 +18,7 @@ use crate::geometry::{Point, Rotation};
* Algebraic structures.
*
*/
impl<N: Real, D: DimName> Identity<Multiplicative> for Rotation<N, D>
impl<N: RealField, D: DimName> Identity<Multiplicative> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D>
{
#[inline]
@ -27,7 +27,7 @@ where DefaultAllocator: Allocator<N, D, D>
}
}
impl<N: Real, D: DimName> TwoSidedInverse<Multiplicative> for Rotation<N, D>
impl<N: RealField, D: DimName> TwoSidedInverse<Multiplicative> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D>
{
#[inline]
@ -41,7 +41,7 @@ where DefaultAllocator: Allocator<N, D, D>
}
}
impl<N: Real, D: DimName> AbstractMagma<Multiplicative> for Rotation<N, D>
impl<N: RealField, D: DimName> AbstractMagma<Multiplicative> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D>
{
#[inline]
@ -52,7 +52,7 @@ where DefaultAllocator: Allocator<N, D, D>
macro_rules! impl_multiplicative_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real, D: DimName> $marker<$operator> for Rotation<N, D>
impl<N: RealField, D: DimName> $marker<$operator> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> { }
)*}
);
@ -70,7 +70,7 @@ impl_multiplicative_structures!(
* Transformation groups.
*
*/
impl<N: Real, D: DimName> Transformation<Point<N, D>> for Rotation<N, D>
impl<N: RealField, D: DimName> Transformation<Point<N, D>> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
#[inline]
@ -84,7 +84,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
}
}
impl<N: Real, D: DimName> ProjectiveTransformation<Point<N, D>> for Rotation<N, D>
impl<N: RealField, D: DimName> ProjectiveTransformation<Point<N, D>> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
#[inline]
@ -98,7 +98,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
}
}
impl<N: Real, D: DimName> AffineTransformation<Point<N, D>> for Rotation<N, D>
impl<N: RealField, D: DimName> AffineTransformation<Point<N, D>> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
type Rotation = Self;
@ -141,7 +141,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
}
}
impl<N: Real, D: DimName> Similarity<Point<N, D>> for Rotation<N, D>
impl<N: RealField, D: DimName> Similarity<Point<N, D>> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
type Scaling = Id;
@ -164,7 +164,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
macro_rules! marker_impl(
($($Trait: ident),*) => {$(
impl<N: Real, D: DimName> $Trait<Point<N, D>> for Rotation<N, D>
impl<N: RealField, D: DimName> $Trait<Point<N, D>> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> +
Allocator<N, D> { }
)*}
@ -173,7 +173,7 @@ macro_rules! marker_impl(
marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation);
/// Subgroups of the n-dimensional rotation group `SO(n)`.
impl<N: Real, D: DimName> linear::Rotation<Point<N, D>> for Rotation<N, D>
impl<N: RealField, D: DimName> linear::Rotation<Point<N, D>> for Rotation<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
#[inline]
@ -199,7 +199,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
}
/*
impl<N: Real> Matrix for Rotation<N> {
impl<N: RealField> Matrix for Rotation<N> {
type Field = N;
type Row = Matrix<N>;
type Column = Matrix<N>;
@ -241,7 +241,7 @@ impl<N: Real> Matrix for Rotation<N> {
}
}
impl<N: Real> SquareMatrix for Rotation<N> {
impl<N: RealField> SquareMatrix for Rotation<N> {
type Vector = Matrix<N>;
#[inline]
@ -271,5 +271,5 @@ impl<N: Real> SquareMatrix for Rotation<N> {
}
}
impl<N: Real> InversibleSquareMatrix for Rotation<N> { }
impl<N: RealField> InversibleSquareMatrix for Rotation<N> { }
*/

View File

@ -1,6 +1,6 @@
use num::Zero;
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::general::{RealField, SubsetOf, SupersetOf};
use alga::linear::Rotation as AlgaRotation;
#[cfg(feature = "mint")]
@ -32,8 +32,8 @@ use crate::geometry::{
impl<N1, N2, D: DimName> SubsetOf<Rotation<N2, D>> for Rotation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D, D>,
{
#[inline]
@ -54,8 +54,8 @@ where
impl<N1, N2> SubsetOf<UnitQuaternion<N2>> for Rotation3<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> UnitQuaternion<N2> {
@ -77,8 +77,8 @@ where
impl<N1, N2> SubsetOf<UnitComplex<N2>> for Rotation2<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> UnitComplex<N2> {
@ -100,8 +100,8 @@ where
impl<N1, N2, D: DimName, R> SubsetOf<Isometry<N2, D, R>> for Rotation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: AlgaRotation<Point<N2, D>> + SupersetOf<Self>,
DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D>,
{
@ -123,8 +123,8 @@ where
impl<N1, N2, D: DimName, R> SubsetOf<Similarity<N2, D, R>> for Rotation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: AlgaRotation<Point<N2, D>> + SupersetOf<Self>,
DefaultAllocator: Allocator<N1, D, D> + Allocator<N2, D>,
{
@ -146,8 +146,8 @@ where
impl<N1, N2, D, C> SubsetOf<Transform<N2, D, C>> for Rotation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
C: SuperTCategoryOf<TAffine>,
D: DimNameAdd<U1> + DimMin<D, Output = D>, // needed by .is_special_orthogonal()
DefaultAllocator: Allocator<N1, D, D>
@ -175,8 +175,8 @@ where
impl<N1, N2, D> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Rotation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
D: DimNameAdd<U1> + DimMin<D, Output = D>, // needed by .is_special_orthogonal()
DefaultAllocator: Allocator<N1, D, D>
+ Allocator<N2, D, D>
@ -211,34 +211,34 @@ where
}
#[cfg(feature = "mint")]
impl<N: Real> From<mint::EulerAngles<N, mint::IntraXYZ>> for Rotation3<N> {
impl<N: RealField> From<mint::EulerAngles<N, mint::IntraXYZ>> for Rotation3<N> {
fn from(euler: mint::EulerAngles<N, mint::IntraXYZ>) -> Self {
Self::from_euler_angles(euler.a, euler.b, euler.c)
}
}
impl<N: Real> From<Rotation2<N>> for Matrix3<N> {
impl<N: RealField> From<Rotation2<N>> for Matrix3<N> {
#[inline]
fn from(q: Rotation2<N>) ->Self {
q.to_homogeneous()
}
}
impl<N: Real> From<Rotation2<N>> for Matrix2<N> {
impl<N: RealField> From<Rotation2<N>> for Matrix2<N> {
#[inline]
fn from(q: Rotation2<N>) -> Self {
q.into_inner()
}
}
impl<N: Real> From<Rotation3<N>> for Matrix4<N> {
impl<N: RealField> From<Rotation3<N>> for Matrix4<N> {
#[inline]
fn from(q: Rotation3<N>) -> Self {
q.to_homogeneous()
}
}
impl<N: Real> From<Rotation3<N>> for Matrix3<N> {
impl<N: RealField> From<Rotation3<N>> for Matrix3<N> {
#[inline]
fn from(q: Rotation3<N>) -> Self {
q.into_inner()

View File

@ -3,7 +3,7 @@ use crate::base::storage::Owned;
#[cfg(feature = "arbitrary")]
use quickcheck::{Arbitrary, Gen};
use alga::general::Real;
use alga::general::RealField;
use num::Zero;
use rand::distributions::{Distribution, OpenClosed01, Standard};
use rand::Rng;
@ -20,7 +20,7 @@ use crate::geometry::{Rotation2, Rotation3, UnitComplex, UnitQuaternion};
* 2D Rotation matrix.
*
*/
impl<N: Real> Rotation2<N> {
impl<N: RealField> Rotation2<N> {
/// Builds a 2 dimensional rotation matrix from an angle in radian.
///
/// # Example
@ -232,7 +232,7 @@ impl<N: Real> Rotation2<N> {
}
}
impl<N: Real> Distribution<Rotation2<N>> for Standard
impl<N: RealField> Distribution<Rotation2<N>> for Standard
where OpenClosed01: Distribution<N>
{
/// Generate a uniformly distributed random rotation.
@ -243,7 +243,7 @@ where OpenClosed01: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for Rotation2<N>
impl<N: RealField + Arbitrary> Arbitrary for Rotation2<N>
where Owned<N, U2, U2>: Send
{
#[inline]
@ -257,7 +257,7 @@ where Owned<N, U2, U2>: Send
* 3D Rotation matrix.
*
*/
impl<N: Real> Rotation3<N> {
impl<N: RealField> Rotation3<N> {
/// Builds a 3 dimensional rotation matrix from an axis and an angle.
///
/// # Arguments
@ -819,7 +819,7 @@ impl<N: Real> Rotation3<N> {
}
}
impl<N: Real> Distribution<Rotation3<N>> for Standard
impl<N: RealField> Distribution<Rotation3<N>> for Standard
where OpenClosed01: Distribution<N>
{
/// Generate a uniformly distributed random rotation.
@ -859,7 +859,7 @@ where OpenClosed01: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for Rotation3<N>
impl<N: RealField + Arbitrary> Arbitrary for Rotation3<N>
where
Owned<N, U3, U3>: Send,
Owned<N, U3>: Send,

View File

@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use alga::general::{Real, SubsetOf};
use alga::general::{RealField, SubsetOf};
use alga::linear::Rotation;
use crate::base::allocator::Allocator;
@ -41,7 +41,7 @@ use crate::geometry::{Isometry, Point, Translation};
Owned<N, D>: Deserialize<'de>"
))
)]
pub struct Similarity<N: Real, D: DimName, R>
pub struct Similarity<N: RealField, D: DimName, R>
where DefaultAllocator: Allocator<N, D>
{
/// The part of this similarity that does not include the scaling factor.
@ -50,7 +50,7 @@ where DefaultAllocator: Allocator<N, D>
}
#[cfg(feature = "abomonation-serialize")]
impl<N: Real, D: DimName, R> Abomonation for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Abomonation for Similarity<N, D, R>
where
Isometry<N, D, R>: Abomonation,
DefaultAllocator: Allocator<N, D>,
@ -68,7 +68,7 @@ where
}
}
impl<N: Real + hash::Hash, D: DimName + hash::Hash, R: hash::Hash> hash::Hash
impl<N: RealField + hash::Hash, D: DimName + hash::Hash, R: hash::Hash> hash::Hash
for Similarity<N, D, R>
where
DefaultAllocator: Allocator<N, D>,
@ -80,13 +80,13 @@ where
}
}
impl<N: Real, D: DimName + Copy, R: Rotation<Point<N, D>> + Copy> Copy for Similarity<N, D, R>
impl<N: RealField, D: DimName + Copy, R: Rotation<Point<N, D>> + Copy> Copy for Similarity<N, D, R>
where
DefaultAllocator: Allocator<N, D>,
Owned<N, D>: Copy,
{}
impl<N: Real, D: DimName, R: Rotation<Point<N, D>> + Clone> Clone for Similarity<N, D, R>
impl<N: RealField, D: DimName, R: Rotation<Point<N, D>> + Clone> Clone for Similarity<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -95,7 +95,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName, R> Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -244,7 +244,7 @@ where
// 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>
impl<N: RealField, D: DimName, R> Similarity<N, D, R>
where DefaultAllocator: Allocator<N, D>
{
/// Converts this similarity into its equivalent homogeneous transformation matrix.
@ -265,13 +265,13 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName, R> Eq for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Eq for Similarity<N, D, R>
where
R: Rotation<Point<N, D>> + Eq,
DefaultAllocator: Allocator<N, D>,
{}
impl<N: Real, D: DimName, R> PartialEq for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> PartialEq for Similarity<N, D, R>
where
R: Rotation<Point<N, D>> + PartialEq,
DefaultAllocator: Allocator<N, D>,
@ -282,7 +282,7 @@ where
}
}
impl<N: Real, D: DimName, R> AbsDiffEq for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> AbsDiffEq for Similarity<N, D, R>
where
R: Rotation<Point<N, D>> + AbsDiffEq<Epsilon = N::Epsilon>,
DefaultAllocator: Allocator<N, D>,
@ -302,7 +302,7 @@ where
}
}
impl<N: Real, D: DimName, R> RelativeEq for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> RelativeEq for Similarity<N, D, R>
where
R: Rotation<Point<N, D>> + RelativeEq<Epsilon = N::Epsilon>,
DefaultAllocator: Allocator<N, D>,
@ -329,7 +329,7 @@ where
}
}
impl<N: Real, D: DimName, R> UlpsEq for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> UlpsEq for Similarity<N, D, R>
where
R: Rotation<Point<N, D>> + UlpsEq<Epsilon = N::Epsilon>,
DefaultAllocator: Allocator<N, D>,
@ -354,7 +354,7 @@ where
*/
impl<N, D: DimName, R> fmt::Display for Similarity<N, D, R>
where
N: Real + fmt::Display,
N: RealField + fmt::Display,
R: Rotation<Point<N, D>> + fmt::Display,
DefaultAllocator: Allocator<N, D> + Allocator<usize, D>,
{

View File

@ -1,6 +1,6 @@
use alga::general::{
AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup,
AbstractSemigroup, Identity, TwoSidedInverse, Multiplicative, Real,
AbstractSemigroup, Identity, TwoSidedInverse, Multiplicative, RealField,
};
use alga::linear::Similarity as AlgaSimilarity;
use alga::linear::{AffineTransformation, ProjectiveTransformation, Rotation, Transformation};
@ -16,7 +16,7 @@ use crate::geometry::{Point, Similarity, Translation};
* Algebraic structures.
*
*/
impl<N: Real, D: DimName, R> Identity<Multiplicative> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Identity<Multiplicative> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -27,7 +27,7 @@ where
}
}
impl<N: Real, D: DimName, R> TwoSidedInverse<Multiplicative> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> TwoSidedInverse<Multiplicative> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -43,7 +43,7 @@ where
}
}
impl<N: Real, D: DimName, R> AbstractMagma<Multiplicative> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> AbstractMagma<Multiplicative> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -56,7 +56,7 @@ where
macro_rules! impl_multiplicative_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real, D: DimName, R> $marker<$operator> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> $marker<$operator> for Similarity<N, D, R>
where R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> { }
)*}
@ -75,7 +75,7 @@ impl_multiplicative_structures!(
* Transformation groups.
*
*/
impl<N: Real, D: DimName, R> Transformation<Point<N, D>> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Transformation<Point<N, D>> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -91,7 +91,7 @@ where
}
}
impl<N: Real, D: DimName, R> ProjectiveTransformation<Point<N, D>> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> ProjectiveTransformation<Point<N, D>> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -107,7 +107,7 @@ where
}
}
impl<N: Real, D: DimName, R> AffineTransformation<Point<N, D>> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> AffineTransformation<Point<N, D>> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -164,7 +164,7 @@ where
}
}
impl<N: Real, D: DimName, R> AlgaSimilarity<Point<N, D>> for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> AlgaSimilarity<Point<N, D>> for Similarity<N, D, R>
where
R: Rotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,

View File

@ -7,7 +7,7 @@ use num::One;
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use alga::general::Real;
use alga::general::RealField;
use alga::linear::Rotation as AlgaRotation;
use crate::base::allocator::Allocator;
@ -19,7 +19,7 @@ use crate::geometry::{
UnitQuaternion,
};
impl<N: Real, D: DimName, R> Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Similarity<N, D, R>
where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -45,7 +45,7 @@ where
}
}
impl<N: Real, D: DimName, R> One for Similarity<N, D, R>
impl<N: RealField, D: DimName, R> One for Similarity<N, D, R>
where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -57,7 +57,7 @@ where
}
}
impl<N: Real, D: DimName, R> Distribution<Similarity<N, D, R>> for Standard
impl<N: RealField, D: DimName, R> Distribution<Similarity<N, D, R>> for Standard
where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -74,7 +74,7 @@ where
}
}
impl<N: Real, D: DimName, R> Similarity<N, D, R>
impl<N: RealField, D: DimName, R> Similarity<N, D, R>
where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
@ -104,7 +104,7 @@ where
#[cfg(feature = "arbitrary")]
impl<N, D: DimName, R> Arbitrary for Similarity<N, D, R>
where
N: Real + Arbitrary + Send,
N: RealField + Arbitrary + Send,
R: AlgaRotation<Point<N, D>> + Arbitrary + Send,
DefaultAllocator: Allocator<N, D>,
Owned<N, D>: Send,
@ -127,7 +127,7 @@ where
*/
// 2D rotation.
impl<N: Real> Similarity<N, U2, Rotation2<N>> {
impl<N: RealField> Similarity<N, U2, Rotation2<N>> {
/// Creates a new similarity from a translation, a rotation, and an uniform scaling factor.
///
/// # Example
@ -150,7 +150,7 @@ impl<N: Real> Similarity<N, U2, Rotation2<N>> {
}
}
impl<N: Real> Similarity<N, U2, UnitComplex<N>> {
impl<N: RealField> Similarity<N, U2, UnitComplex<N>> {
/// Creates a new similarity from a translation and a rotation angle.
///
/// # Example
@ -176,7 +176,7 @@ impl<N: Real> Similarity<N, U2, UnitComplex<N>> {
// 3D rotation.
macro_rules! similarity_construction_impl(
($Rot: ty) => {
impl<N: Real> Similarity<N, U3, $Rot> {
impl<N: RealField> Similarity<N, U3, $Rot> {
/// Creates a new similarity from a translation, rotation axis-angle, and scaling
/// factor.
///

View File

@ -1,4 +1,4 @@
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::general::{RealField, SubsetOf, SupersetOf};
use alga::linear::Rotation;
use crate::base::allocator::Allocator;
@ -18,8 +18,8 @@ use crate::geometry::{Isometry, Point, Similarity, SuperTCategoryOf, TAffine, Tr
impl<N1, N2, D: DimName, R1, R2> SubsetOf<Similarity<N2, D, R2>> for Similarity<N1, D, R1>
where
N1: Real + SubsetOf<N2>,
N2: Real + SupersetOf<N1>,
N1: RealField + SubsetOf<N2>,
N2: RealField + SupersetOf<N1>,
R1: Rotation<Point<N1, D>> + SubsetOf<R2>,
R2: Rotation<Point<N2, D>>,
DefaultAllocator: Allocator<N1, D> + Allocator<N2, D>,
@ -46,8 +46,8 @@ where
impl<N1, N2, D, R, C> SubsetOf<Transform<N2, D, C>> for Similarity<N1, D, R>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
C: SuperTCategoryOf<TAffine>,
R: Rotation<Point<N1, D>>
+ SubsetOf<MatrixN<N1, DimNameSum<D, U1>>>
@ -80,8 +80,8 @@ where
impl<N1, N2, D, R> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Similarity<N1, D, R>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: Rotation<Point<N1, D>>
+ SubsetOf<MatrixN<N1, DimNameSum<D, U1>>>
+ SubsetOf<MatrixN<N2, DimNameSum<D, U1>>>,
@ -163,7 +163,7 @@ where
}
}
impl<N: Real, D: DimName, R> From<Similarity<N, D, R>> for MatrixN<N, DimNameSum<D, U1>>
impl<N: RealField, D: DimName, R> From<Similarity<N, D, R>> for MatrixN<N, DimNameSum<D, U1>>
where
D: DimNameAdd<U1>,
R: SubsetOf<MatrixN<N, DimNameSum<D, U1>>>,

View File

@ -1,6 +1,6 @@
use std::ops::{Div, DivAssign, Mul, MulAssign};
use alga::general::Real;
use alga::general::RealField;
use alga::linear::Rotation as AlgaRotation;
use crate::base::allocator::Allocator;
@ -66,7 +66,7 @@ macro_rules! similarity_binop_impl(
($Op: ident, $op: ident;
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real, D: DimName, R> $Op<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField, D: DimName, R> $Op<$Rhs> for $Lhs
where R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> {
type Output = $Output;
@ -113,7 +113,7 @@ macro_rules! similarity_binop_assign_impl_all(
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty;
[val] => $action_val: expr;
[ref] => $action_ref: expr;) => {
impl<N: Real, D: DimName, R> $OpAssign<$Rhs> for $Lhs
impl<N: RealField, D: DimName, R> $OpAssign<$Rhs> for $Lhs
where R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> {
#[inline]
@ -122,7 +122,7 @@ macro_rules! similarity_binop_assign_impl_all(
}
}
impl<'b, N: Real, D: DimName, R> $OpAssign<&'b $Rhs> for $Lhs
impl<'b, N: RealField, D: DimName, R> $OpAssign<&'b $Rhs> for $Lhs
where R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D> {
#[inline]
@ -379,7 +379,7 @@ macro_rules! similarity_from_composition_impl(
($R1: ty, $C1: ty),($R2: ty, $C2: ty) $(for $Dims: ident: $DimsBound: ident),*;
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Output: ty;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs
where DefaultAllocator: Allocator<N, $R1, $C1> +
Allocator<N, $R2, $C2> {
type Output = $Output;

View File

@ -6,7 +6,7 @@ use std::marker::PhantomData;
#[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use alga::general::Real;
use alga::general::RealField;
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
@ -26,7 +26,7 @@ pub trait TCategory: Any + Debug + Copy + PartialEq + Send {
/// Checks that the given matrix is a valid homogeneous representation of an element of the
/// category `Self`.
fn check_homogeneous_invariants<N: Real, D: DimName>(mat: &MatrixN<N, D>) -> bool
fn check_homogeneous_invariants<N: RealField, D: DimName>(mat: &MatrixN<N, D>) -> bool
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, D, D>;
@ -69,7 +69,7 @@ pub enum TAffine {}
impl TCategory for TGeneral {
#[inline]
fn check_homogeneous_invariants<N: Real, D: DimName>(_: &MatrixN<N, D>) -> bool
fn check_homogeneous_invariants<N: RealField, D: DimName>(_: &MatrixN<N, D>) -> bool
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, D, D>,
@ -80,7 +80,7 @@ impl TCategory for TGeneral {
impl TCategory for TProjective {
#[inline]
fn check_homogeneous_invariants<N: Real, D: DimName>(mat: &MatrixN<N, D>) -> bool
fn check_homogeneous_invariants<N: RealField, D: DimName>(mat: &MatrixN<N, D>) -> bool
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, D, D>,
@ -96,7 +96,7 @@ impl TCategory for TAffine {
}
#[inline]
fn check_homogeneous_invariants<N: Real, D: DimName>(mat: &MatrixN<N, D>) -> bool
fn check_homogeneous_invariants<N: RealField, D: DimName>(mat: &MatrixN<N, D>) -> bool
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, D, D>,
@ -155,7 +155,7 @@ super_tcategory_impl!(
/// 3D transformation.
#[repr(C)]
#[derive(Debug)]
pub struct Transform<N: Real, D: DimNameAdd<U1>, C: TCategory>
pub struct Transform<N: RealField, D: DimNameAdd<U1>, C: TCategory>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
matrix: MatrixN<N, DimNameSum<D, U1>>,
@ -163,7 +163,7 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
}
// FIXME
// impl<N: Real + hash::Hash, D: DimNameAdd<U1> + hash::Hash, C: TCategory> hash::Hash for Transform<N, D, C>
// impl<N: RealField + hash::Hash, D: DimNameAdd<U1> + hash::Hash, C: TCategory> hash::Hash for Transform<N, D, C>
// where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
// Owned<N, DimNameSum<D, U1>, DimNameSum<D, U1>>: hash::Hash {
// fn hash<H: hash::Hasher>(&self, state: &mut H) {
@ -171,14 +171,14 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
// }
// }
impl<N: Real, D: DimNameAdd<U1> + Copy, C: TCategory> Copy for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1> + Copy, C: TCategory> Copy for Transform<N, D, C>
where
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
Owned<N, DimNameSum<D, U1>, DimNameSum<D, U1>>: Copy,
{
}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> Clone for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> Clone for Transform<N, D, C>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
#[inline]
@ -188,7 +188,7 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
}
#[cfg(feature = "serde-serialize")]
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> Serialize for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> Serialize for Transform<N, D, C>
where
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
Owned<N, DimNameSum<D, U1>, DimNameSum<D, U1>>: Serialize,
@ -200,7 +200,7 @@ where
}
#[cfg(feature = "serde-serialize")]
impl<'a, N: Real, D: DimNameAdd<U1>, C: TCategory> Deserialize<'a> for Transform<N, D, C>
impl<'a, N: RealField, D: DimNameAdd<U1>, C: TCategory> Deserialize<'a> for Transform<N, D, C>
where
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
Owned<N, DimNameSum<D, U1>, DimNameSum<D, U1>>: Deserialize<'a>,
@ -213,10 +213,10 @@ where
}
}
impl<N: Real + Eq, D: DimNameAdd<U1>, C: TCategory> Eq for Transform<N, D, C> where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
impl<N: RealField + Eq, D: DimNameAdd<U1>, C: TCategory> Eq for Transform<N, D, C> where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> PartialEq for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> PartialEq for Transform<N, D, C>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
#[inline]
@ -225,7 +225,7 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
}
}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> Transform<N, D, C>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
/// Creates a new transformation from the given homogeneous matrix. The transformation category
@ -452,7 +452,7 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
}
}
impl<N: Real, D: DimNameAdd<U1>> Transform<N, D, TGeneral>
impl<N: RealField, D: DimNameAdd<U1>> Transform<N, D, TGeneral>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
/// A mutable reference to underlying matrix. Use `.matrix_mut_unchecked` instead if this
@ -463,7 +463,7 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
}
}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> AbsDiffEq for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> AbsDiffEq for Transform<N, D, C>
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -481,7 +481,7 @@ where
}
}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> RelativeEq for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> RelativeEq for Transform<N, D, C>
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -504,7 +504,7 @@ where
}
}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> UlpsEq for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> UlpsEq for Transform<N, D, C>
where
N::Epsilon: Copy,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,

View File

@ -1,6 +1,6 @@
use alga::general::{
AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup,
AbstractSemigroup, Identity, TwoSidedInverse, Multiplicative, Real,
AbstractSemigroup, Identity, TwoSidedInverse, Multiplicative, RealField,
};
use alga::linear::{ProjectiveTransformation, Transformation};
@ -15,7 +15,7 @@ use crate::geometry::{Point, SubTCategoryOf, TCategory, TProjective, Transform};
* Algebraic structures.
*
*/
impl<N: Real, D: DimNameAdd<U1>, C> Identity<Multiplicative> for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C> Identity<Multiplicative> for Transform<N, D, C>
where
C: TCategory,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -26,7 +26,7 @@ where
}
}
impl<N: Real, D: DimNameAdd<U1>, C> TwoSidedInverse<Multiplicative> for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C> TwoSidedInverse<Multiplicative> for Transform<N, D, C>
where
C: SubTCategoryOf<TProjective>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -42,7 +42,7 @@ where
}
}
impl<N: Real, D: DimNameAdd<U1>, C> AbstractMagma<Multiplicative> for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C> AbstractMagma<Multiplicative> for Transform<N, D, C>
where
C: TCategory,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -55,7 +55,7 @@ where
macro_rules! impl_multiplicative_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real, D: DimNameAdd<U1>, C> $marker<$operator> for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C> $marker<$operator> for Transform<N, D, C>
where C: TCategory,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>> { }
)*}
@ -63,7 +63,7 @@ macro_rules! impl_multiplicative_structures(
macro_rules! impl_inversible_multiplicative_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real, D: DimNameAdd<U1>, C> $marker<$operator> for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C> $marker<$operator> for Transform<N, D, C>
where C: SubTCategoryOf<TProjective>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>> { }
)*}
@ -87,7 +87,7 @@ impl_inversible_multiplicative_structures!(
*/
impl<N, D: DimNameAdd<U1>, C> Transformation<Point<N, D>> for Transform<N, D, C>
where
N: Real,
N: RealField,
C: TCategory,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
+ Allocator<N, DimNameSum<D, U1>>
@ -107,7 +107,7 @@ where
impl<N, D: DimNameAdd<U1>, C> ProjectiveTransformation<Point<N, D>> for Transform<N, D, C>
where
N: Real,
N: RealField,
C: SubTCategoryOf<TProjective>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
+ Allocator<N, DimNameSum<D, U1>>
@ -128,7 +128,7 @@ where
// FIXME: we need to implement an SVD for this.
//
// impl<N, D: DimNameAdd<U1>, C> AffineTransformation<Point<N, D>> for Transform<N, D, C>
// where N: Real,
// where N: RealField,
// C: SubTCategoryOf<TAffine>,
// DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>> +
// Allocator<N, D, D> +

View File

@ -1,6 +1,6 @@
use num::One;
use alga::general::Real;
use alga::general::RealField;
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
@ -8,7 +8,7 @@ use crate::base::{DefaultAllocator, MatrixN};
use crate::geometry::{TCategory, Transform};
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> Transform<N, D, C>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
/// Creates a new identity transform.
@ -45,7 +45,7 @@ where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
}
}
impl<N: Real, D: DimNameAdd<U1>, C: TCategory> One for Transform<N, D, C>
impl<N: RealField, D: DimNameAdd<U1>, C: TCategory> One for Transform<N, D, C>
where DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>
{
/// Creates a new identity transform.

View File

@ -1,4 +1,4 @@
use alga::general::{Real, SubsetOf};
use alga::general::{RealField, SubsetOf};
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
@ -8,8 +8,8 @@ use crate::geometry::{SuperTCategoryOf, TCategory, Transform};
impl<N1, N2, D: DimName, C1, C2> SubsetOf<Transform<N2, D, C2>> for Transform<N1, D, C1>
where
N1: Real + SubsetOf<N2>,
N2: Real,
N1: RealField + SubsetOf<N2>,
N2: RealField,
C1: TCategory,
C2: SuperTCategoryOf<C1>,
D: DimNameAdd<U1>,
@ -36,8 +36,8 @@ where
impl<N1, N2, D: DimName, C> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Transform<N1, D, C>
where
N1: Real + SubsetOf<N2>,
N2: Real,
N1: RealField + SubsetOf<N2>,
N2: RealField,
C: TCategory,
D: DimNameAdd<U1>,
DefaultAllocator: Allocator<N1, DimNameSum<D, U1>, DimNameSum<D, U1>>
@ -61,7 +61,7 @@ where
}
}
impl<N: Real, D: DimName, C> From<Transform<N, D, C>> for MatrixN<N, DimNameSum<D, U1>>
impl<N: RealField, D: DimName, C> From<Transform<N, D, C>> for MatrixN<N, DimNameSum<D, U1>>
where
D: DimNameAdd<U1>,
C: TCategory,

View File

@ -1,7 +1,7 @@
use num::{One, Zero};
use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign};
use alga::general::{ClosedAdd, ClosedMul, Real, SubsetOf};
use alga::general::{ClosedAdd, ClosedMul, RealField, SubsetOf};
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1, U3, U4};
@ -79,7 +79,7 @@ use crate::geometry::{
* Indexing.
*
*/
impl<N: Real, D, C: TCategory> Index<(usize, usize)> for Transform<N, D, C>
impl<N: RealField, D, C: TCategory> Index<(usize, usize)> for Transform<N, D, C>
where
D: DimName + DimNameAdd<U1>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -93,7 +93,7 @@ where
}
// Only general transformations are mutably indexable.
impl<N: Real, D> IndexMut<(usize, usize)> for Transform<N, D, TGeneral>
impl<N: RealField, D> IndexMut<(usize, usize)> for Transform<N, D, TGeneral>
where
D: DimName + DimNameAdd<U1>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
@ -106,7 +106,7 @@ where
// Transform × Vector
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategory;
self: Transform<N, D, C>, rhs: VectorN<N, D>, Output = VectorN<N, D>;
[val val] => &self * &rhs;
@ -130,7 +130,7 @@ md_impl_all!(
// Transform × Point
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategory
where DefaultAllocator: Allocator<N, D, D>;
self: Transform<N, D, C>, rhs: Point<N, D>, Output = Point<N, D>;
@ -156,7 +156,7 @@ md_impl_all!(
// Transform × Transform
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, CA: TCategoryMul<CB>, CB: TCategory;
self: Transform<N, D, CA>, rhs: Transform<N, D, CB>, Output = Transform<N, D, CA::Representative>;
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.into_inner());
@ -167,7 +167,7 @@ md_impl_all!(
// Transform × Rotation
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, D) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Transform<N, D, C>, rhs: Rotation<N, D>, Output = Transform<N, D, C::Representative>;
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
@ -178,7 +178,7 @@ md_impl_all!(
// Rotation × Transform
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(D, D), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Rotation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
[val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner());
@ -189,7 +189,7 @@ md_impl_all!(
// Transform × UnitQuaternion
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(U4, U4), (U4, U1) for C: TCategoryMul<TAffine>;
self: Transform<N, U3, C>, rhs: UnitQuaternion<N>, Output = Transform<N, U3, C::Representative>;
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
@ -200,7 +200,7 @@ md_impl_all!(
// UnitQuaternion × Transform
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(U4, U1), (U4, U4) for C: TCategoryMul<TAffine>;
self: UnitQuaternion<N>, rhs: Transform<N, U3, C>, Output = Transform<N, U3, C::Representative>;
[val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner());
@ -211,7 +211,7 @@ md_impl_all!(
// Transform × Isometry
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >;
self: Transform<N, D, C>, rhs: Isometry<N, D, R>, Output = Transform<N, D, C::Representative>;
@ -223,7 +223,7 @@ md_impl_all!(
// Isometry × Transform
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >;
self: Isometry<N, D, R>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
@ -235,7 +235,7 @@ md_impl_all!(
// Transform × Similarity
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >;
self: Transform<N, D, C>, rhs: Similarity<N, D, R>, Output = Transform<N, D, C::Representative>;
@ -247,7 +247,7 @@ md_impl_all!(
// Similarity × Transform
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >;
self: Similarity<N, D, R>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
@ -267,7 +267,7 @@ md_impl_all!(
*/
// Transform × Translation
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Transform<N, D, C>, rhs: Translation<N, D>, Output = Transform<N, D, C::Representative>;
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
@ -278,7 +278,7 @@ md_impl_all!(
// Translation × Transform
md_impl_all!(
Mul, mul where N: Real;
Mul, mul where N: RealField;
(D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Translation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
@ -290,7 +290,7 @@ md_impl_all!(
// Transform ÷ Transform
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, CA: TCategoryMul<CB>, CB: SubTCategoryOf<TProjective>;
self: Transform<N, D, CA>, rhs: Transform<N, D, CB>, Output = Transform<N, D, CA::Representative>;
[val val] => self * rhs.inverse();
@ -301,7 +301,7 @@ md_impl_all!(
// Transform ÷ Rotation
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, D) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Transform<N, D, C>, rhs: Rotation<N, D>, Output = Transform<N, D, C::Representative>;
[val val] => self * rhs.inverse();
@ -312,7 +312,7 @@ md_impl_all!(
// Rotation ÷ Transform
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(D, D), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Rotation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
[val val] => self.inverse() * rhs;
@ -323,7 +323,7 @@ md_impl_all!(
// Transform ÷ UnitQuaternion
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(U4, U4), (U4, U1) for C: TCategoryMul<TAffine>;
self: Transform<N, U3, C>, rhs: UnitQuaternion<N>, Output = Transform<N, U3, C::Representative>;
[val val] => self * rhs.inverse();
@ -334,7 +334,7 @@ md_impl_all!(
// UnitQuaternion ÷ Transform
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(U4, U1), (U4, U4) for C: TCategoryMul<TAffine>;
self: UnitQuaternion<N>, rhs: Transform<N, U3, C>, Output = Transform<N, U3, C::Representative>;
[val val] => self.inverse() * rhs;
@ -345,7 +345,7 @@ md_impl_all!(
// // Transform ÷ Isometry
// md_impl_all!(
// Div, div where N: Real;
// Div, div where N: RealField;
// (DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1)
// for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >
// where SB::Alloc: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1> >;
@ -358,7 +358,7 @@ md_impl_all!(
// // Isometry ÷ Transform
// md_impl_all!(
// Div, div where N: Real;
// Div, div where N: RealField;
// (D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
// for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >
// where SA::Alloc: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1> >;
@ -371,7 +371,7 @@ md_impl_all!(
// // Transform ÷ Similarity
// md_impl_all!(
// Div, div where N: Real;
// Div, div where N: RealField;
// (DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1)
// for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >
// where SB::Alloc: Allocator<N, D, D >
@ -385,7 +385,7 @@ md_impl_all!(
// // Similarity ÷ Transform
// md_impl_all!(
// Div, div where N: Real;
// Div, div where N: RealField;
// (D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
// for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >
// where SA::Alloc: Allocator<N, D, D >
@ -399,7 +399,7 @@ md_impl_all!(
// Transform ÷ Translation
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Transform<N, D, C>, rhs: Translation<N, D>, Output = Transform<N, D, C::Representative>;
[val val] => self * rhs.inverse();
@ -410,7 +410,7 @@ md_impl_all!(
// Translation ÷ Transform
md_impl_all!(
Div, div where N: Real;
Div, div where N: RealField;
(D, U1), (DimNameSum<D, U1>, DimNameSum<D, U1>)
for D: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
self: Translation<N, D>, rhs: Transform<N, D, C>, Output = Transform<N, D, C::Representative>;
@ -422,7 +422,7 @@ md_impl_all!(
// Transform ×= Transform
md_assign_impl_all!(
MulAssign, mul_assign where N: Real;
MulAssign, mul_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (DimNameSum<D, U1>, DimNameSum<D, U1>) for D: DimNameAdd<U1>, CA: TCategory, CB: SubTCategoryOf<CA>;
self: Transform<N, D, CA>, rhs: Transform<N, D, CB>;
[val] => *self.matrix_mut_unchecked() *= rhs.into_inner();
@ -431,7 +431,7 @@ md_assign_impl_all!(
// Transform ×= Similarity
md_assign_impl_all!(
MulAssign, mul_assign where N: Real;
MulAssign, mul_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1)
for D: DimNameAdd<U1>, C: TCategory, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >;
self: Transform<N, D, C>, rhs: Similarity<N, D, R>;
@ -441,7 +441,7 @@ md_assign_impl_all!(
// Transform ×= Isometry
md_assign_impl_all!(
MulAssign, mul_assign where N: Real;
MulAssign, mul_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1)
for D: DimNameAdd<U1>, C: TCategory, R: SubsetOf<MatrixN<N, DimNameSum<D, U1>> >;
self: Transform<N, D, C>, rhs: Isometry<N, D, R>;
@ -459,7 +459,7 @@ md_assign_impl_all!(
*/
// Transform ×= Translation
md_assign_impl_all!(
MulAssign, mul_assign where N: Real;
MulAssign, mul_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategory;
self: Transform<N, D, C>, rhs: Translation<N, D>;
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
@ -468,7 +468,7 @@ md_assign_impl_all!(
// Transform ×= Rotation
md_assign_impl_all!(
MulAssign, mul_assign where N: Real;
MulAssign, mul_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, D) for D: DimNameAdd<U1>, C: TCategory;
self: Transform<N, D, C>, rhs: Rotation<N, D>;
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
@ -477,7 +477,7 @@ md_assign_impl_all!(
// Transform ×= UnitQuaternion
md_assign_impl_all!(
MulAssign, mul_assign where N: Real;
MulAssign, mul_assign where N: RealField;
(U4, U4), (U4, U1) for C: TCategory;
self: Transform<N, U3, C>, rhs: UnitQuaternion<N>;
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
@ -486,7 +486,7 @@ md_assign_impl_all!(
// Transform ÷= Transform
md_assign_impl_all!(
DivAssign, div_assign where N: Real;
DivAssign, div_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (DimNameSum<D, U1>, DimNameSum<D, U1>)
for D: DimNameAdd<U1>, CA: SuperTCategoryOf<CB>, CB: SubTCategoryOf<TProjective>;
self: Transform<N, D, CA>, rhs: Transform<N, D, CB>;
@ -517,7 +517,7 @@ md_assign_impl_all!(
// Transform ÷= Translation
md_assign_impl_all!(
DivAssign, div_assign where N: Real;
DivAssign, div_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, U1) for D: DimNameAdd<U1>, C: TCategory;
self: Transform<N, D, C>, rhs: Translation<N, D>;
[val] => *self *= rhs.inverse();
@ -526,7 +526,7 @@ md_assign_impl_all!(
// Transform ÷= Rotation
md_assign_impl_all!(
DivAssign, div_assign where N: Real;
DivAssign, div_assign where N: RealField;
(DimNameSum<D, U1>, DimNameSum<D, U1>), (D, D) for D: DimNameAdd<U1>, C: TCategory;
self: Transform<N, D, C>, rhs: Rotation<N, D>;
[val] => *self *= rhs.inverse();
@ -535,7 +535,7 @@ md_assign_impl_all!(
// Transform ÷= UnitQuaternion
md_assign_impl_all!(
DivAssign, div_assign where N: Real;
DivAssign, div_assign where N: RealField;
(U4, U4), (U4, U1) for C: TCategory;
self: Transform<N, U3, C>, rhs: UnitQuaternion<N>;
[val] => *self *= rhs.inverse();

View File

@ -11,7 +11,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use alga::general::{ClosedNeg, Real};
use alga::general::{ClosedNeg, RealField};
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
@ -263,7 +263,7 @@ where
* Display
*
*/
impl<N: Real + fmt::Display, D: DimName> fmt::Display for Translation<N, D>
impl<N: RealField + fmt::Display, D: DimName> fmt::Display for Translation<N, D>
where DefaultAllocator: Allocator<N, D> + Allocator<usize, D>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,6 +1,6 @@
use alga::general::{
AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, Real,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, RealField,
};
use alga::linear::Translation as AlgaTranslation;
use alga::linear::{
@ -19,7 +19,7 @@ use crate::geometry::{Point, Translation};
* Algebraic structures.
*
*/
impl<N: Real, D: DimName> Identity<Multiplicative> for Translation<N, D>
impl<N: RealField, D: DimName> Identity<Multiplicative> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -28,7 +28,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName> TwoSidedInverse<Multiplicative> for Translation<N, D>
impl<N: RealField, D: DimName> TwoSidedInverse<Multiplicative> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -42,7 +42,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName> AbstractMagma<Multiplicative> for Translation<N, D>
impl<N: RealField, D: DimName> AbstractMagma<Multiplicative> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -53,7 +53,7 @@ where DefaultAllocator: Allocator<N, D>
macro_rules! impl_multiplicative_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real, D: DimName> $marker<$operator> for Translation<N, D>
impl<N: RealField, D: DimName> $marker<$operator> for Translation<N, D>
where DefaultAllocator: Allocator<N, D> { }
)*}
);
@ -71,7 +71,7 @@ impl_multiplicative_structures!(
* Transformation groups.
*
*/
impl<N: Real, D: DimName> Transformation<Point<N, D>> for Translation<N, D>
impl<N: RealField, D: DimName> Transformation<Point<N, D>> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -85,7 +85,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName> ProjectiveTransformation<Point<N, D>> for Translation<N, D>
impl<N: RealField, D: DimName> ProjectiveTransformation<Point<N, D>> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
#[inline]
@ -99,7 +99,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName> AffineTransformation<Point<N, D>> for Translation<N, D>
impl<N: RealField, D: DimName> AffineTransformation<Point<N, D>> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
type Rotation = Id;
@ -142,7 +142,7 @@ where DefaultAllocator: Allocator<N, D>
}
}
impl<N: Real, D: DimName> Similarity<Point<N, D>> for Translation<N, D>
impl<N: RealField, D: DimName> Similarity<Point<N, D>> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
type Scaling = Id;
@ -165,7 +165,7 @@ where DefaultAllocator: Allocator<N, D>
macro_rules! marker_impl(
($($Trait: ident),*) => {$(
impl<N: Real, D: DimName> $Trait<Point<N, D>> for Translation<N, D>
impl<N: RealField, D: DimName> $Trait<Point<N, D>> for Translation<N, D>
where DefaultAllocator: Allocator<N, D> { }
)*}
);
@ -173,7 +173,7 @@ macro_rules! marker_impl(
marker_impl!(Isometry, DirectIsometry);
/// Subgroups of the n-dimensional translation group `T(n)`.
impl<N: Real, D: DimName> AlgaTranslation<Point<N, D>> for Translation<N, D>
impl<N: RealField, D: DimName> AlgaTranslation<Point<N, D>> for Translation<N, D>
where DefaultAllocator: Allocator<N, D>
{
#[inline]

View File

@ -1,6 +1,6 @@
use num::{One, Zero};
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::general::{RealField, SubsetOf, SupersetOf};
use alga::linear::Rotation;
use crate::base::allocator::Allocator;
@ -46,8 +46,8 @@ where
impl<N1, N2, D: DimName, R> SubsetOf<Isometry<N2, D, R>> for Translation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: Rotation<Point<N2, D>>,
DefaultAllocator: Allocator<N1, D> + Allocator<N2, D>,
{
@ -69,8 +69,8 @@ where
impl<N1, N2, D: DimName, R> SubsetOf<Similarity<N2, D, R>> for Translation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: Rotation<Point<N2, D>>,
DefaultAllocator: Allocator<N1, D> + Allocator<N2, D>,
{
@ -92,8 +92,8 @@ where
impl<N1, N2, D, C> SubsetOf<Transform<N2, D, C>> for Translation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
C: SuperTCategoryOf<TAffine>,
D: DimNameAdd<U1>,
DefaultAllocator: Allocator<N1, D>
@ -119,8 +119,8 @@ where
impl<N1, N2, D> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Translation<N1, D>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
D: DimNameAdd<U1>,
DefaultAllocator: Allocator<N1, D>
+ Allocator<N2, D>

View File

@ -2,14 +2,14 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use num_complex::Complex;
use std::fmt;
use alga::general::Real;
use alga::general::RealField;
use crate::base::{Matrix2, Matrix3, Unit, Vector1};
use crate::geometry::Rotation2;
/// A complex number with a norm equal to 1.
pub type UnitComplex<N> = Unit<Complex<N>>;
impl<N: Real> UnitComplex<N> {
impl<N: RealField> UnitComplex<N> {
/// The rotation angle in `]-pi; pi]` of this unit complex number.
///
/// # Example
@ -253,13 +253,13 @@ impl<N: Real> UnitComplex<N> {
}
}
impl<N: Real + fmt::Display> fmt::Display for UnitComplex<N> {
impl<N: RealField + fmt::Display> fmt::Display for UnitComplex<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "UnitComplex angle: {}", self.angle())
}
}
impl<N: Real> AbsDiffEq for UnitComplex<N> {
impl<N: RealField> AbsDiffEq for UnitComplex<N> {
type Epsilon = N;
#[inline]
@ -273,7 +273,7 @@ impl<N: Real> AbsDiffEq for UnitComplex<N> {
}
}
impl<N: Real> RelativeEq for UnitComplex<N> {
impl<N: RealField> RelativeEq for UnitComplex<N> {
#[inline]
fn default_max_relative() -> Self::Epsilon {
N::default_max_relative()
@ -292,7 +292,7 @@ impl<N: Real> RelativeEq for UnitComplex<N> {
}
}
impl<N: Real> UlpsEq for UnitComplex<N> {
impl<N: RealField> UlpsEq for UnitComplex<N> {
#[inline]
fn default_max_ulps() -> u32 {
N::default_max_ulps()

View File

@ -1,6 +1,6 @@
use alga::general::{
AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, Real,
AbstractSemigroup, Id, Identity, TwoSidedInverse, Multiplicative, RealField,
};
use alga::linear::{
AffineTransformation, DirectIsometry, Isometry, OrthogonalTransformation,
@ -17,21 +17,21 @@ use crate::geometry::{Point2, UnitComplex};
* Implementations for UnitComplex.
*
*/
impl<N: Real> Identity<Multiplicative> for UnitComplex<N> {
impl<N: RealField> Identity<Multiplicative> for UnitComplex<N> {
#[inline]
fn identity() -> Self {
Self::identity()
}
}
impl<N: Real> AbstractMagma<Multiplicative> for UnitComplex<N> {
impl<N: RealField> AbstractMagma<Multiplicative> for UnitComplex<N> {
#[inline]
fn operate(&self, rhs: &Self) -> Self {
self * rhs
}
}
impl<N: Real> TwoSidedInverse<Multiplicative> for UnitComplex<N> {
impl<N: RealField> TwoSidedInverse<Multiplicative> for UnitComplex<N> {
#[inline]
fn two_sided_inverse(&self) -> Self {
self.inverse()
@ -45,7 +45,7 @@ impl<N: Real> TwoSidedInverse<Multiplicative> for UnitComplex<N> {
macro_rules! impl_structures(
($($marker: ident<$operator: ident>),* $(,)*) => {$(
impl<N: Real> $marker<$operator> for UnitComplex<N> {
impl<N: RealField> $marker<$operator> for UnitComplex<N> {
}
)*}
);
@ -58,7 +58,7 @@ impl_structures!(
AbstractGroup<Multiplicative>
);
impl<N: Real> Transformation<Point2<N>> for UnitComplex<N>
impl<N: RealField> Transformation<Point2<N>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2>
{
#[inline]
@ -72,7 +72,7 @@ where DefaultAllocator: Allocator<N, U2>
}
}
impl<N: Real> ProjectiveTransformation<Point2<N>> for UnitComplex<N>
impl<N: RealField> ProjectiveTransformation<Point2<N>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2>
{
#[inline]
@ -88,7 +88,7 @@ where DefaultAllocator: Allocator<N, U2>
}
}
impl<N: Real> AffineTransformation<Point2<N>> for UnitComplex<N>
impl<N: RealField> AffineTransformation<Point2<N>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2>
{
type Rotation = Self;
@ -131,7 +131,7 @@ where DefaultAllocator: Allocator<N, U2>
}
}
impl<N: Real> Similarity<Point2<N>> for UnitComplex<N>
impl<N: RealField> Similarity<Point2<N>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2>
{
type Scaling = Id;
@ -154,14 +154,14 @@ where DefaultAllocator: Allocator<N, U2>
macro_rules! marker_impl(
($($Trait: ident),*) => {$(
impl<N: Real> $Trait<Point2<N>> for UnitComplex<N>
impl<N: RealField> $Trait<Point2<N>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2> { }
)*}
);
marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation);
impl<N: Real> Rotation<Point2<N>> for UnitComplex<N>
impl<N: RealField> Rotation<Point2<N>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2>
{
#[inline]

View File

@ -6,13 +6,13 @@ use num_complex::Complex;
use rand::distributions::{Distribution, OpenClosed01, Standard};
use rand::Rng;
use alga::general::Real;
use alga::general::RealField;
use crate::base::dimension::{U1, U2};
use crate::base::storage::Storage;
use crate::base::{Unit, Vector, Matrix2};
use crate::geometry::{Rotation2, UnitComplex};
impl<N: Real> UnitComplex<N> {
impl<N: RealField> UnitComplex<N> {
/// The unit complex number multiplicative identity.
///
/// # Example
@ -268,14 +268,14 @@ impl<N: Real> UnitComplex<N> {
}
}
impl<N: Real> One for UnitComplex<N> {
impl<N: RealField> One for UnitComplex<N> {
#[inline]
fn one() -> Self {
Self::identity()
}
}
impl<N: Real> Distribution<UnitComplex<N>> for Standard
impl<N: RealField> Distribution<UnitComplex<N>> for Standard
where OpenClosed01: Distribution<N>
{
/// Generate a uniformly distributed random `UnitComplex`.
@ -286,7 +286,7 @@ where OpenClosed01: Distribution<N>
}
#[cfg(feature = "arbitrary")]
impl<N: Real + Arbitrary> Arbitrary for UnitComplex<N> {
impl<N: RealField + Arbitrary> Arbitrary for UnitComplex<N> {
#[inline]
fn arbitrary<G: Gen>(g: &mut G) -> Self {
UnitComplex::from_angle(N::arbitrary(g))

View File

@ -1,7 +1,7 @@
use num::Zero;
use num_complex::Complex;
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::general::{RealField, SubsetOf, SupersetOf};
use alga::linear::Rotation as AlgaRotation;
use crate::base::dimension::U2;
@ -28,8 +28,8 @@ use crate::geometry::{
impl<N1, N2> SubsetOf<UnitComplex<N2>> for UnitComplex<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> UnitComplex<N2> {
@ -49,8 +49,8 @@ where
impl<N1, N2> SubsetOf<Rotation2<N2>> for UnitComplex<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
{
#[inline]
fn to_superset(&self) -> Rotation2<N2> {
@ -72,8 +72,8 @@ where
impl<N1, N2, R> SubsetOf<Isometry<N2, U2, R>> for UnitComplex<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: AlgaRotation<Point2<N2>> + SupersetOf<Self>,
{
#[inline]
@ -94,8 +94,8 @@ where
impl<N1, N2, R> SubsetOf<Similarity<N2, U2, R>> for UnitComplex<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
R: AlgaRotation<Point2<N2>> + SupersetOf<Self>,
{
#[inline]
@ -116,8 +116,8 @@ where
impl<N1, N2, C> SubsetOf<Transform<N2, U2, C>> for UnitComplex<N1>
where
N1: Real,
N2: Real + SupersetOf<N1>,
N1: RealField,
N2: RealField + SupersetOf<N1>,
C: SuperTCategoryOf<TAffine>,
{
#[inline]
@ -136,7 +136,7 @@ where
}
}
impl<N1: Real, N2: Real + SupersetOf<N1>> SubsetOf<Matrix3<N2>> for UnitComplex<N1> {
impl<N1: RealField, N2: RealField + SupersetOf<N1>> SubsetOf<Matrix3<N2>> for UnitComplex<N1> {
#[inline]
fn to_superset(&self) -> Matrix3<N2> {
self.to_homogeneous().to_superset()
@ -155,28 +155,28 @@ impl<N1: Real, N2: Real + SupersetOf<N1>> SubsetOf<Matrix3<N2>> for UnitComplex<
}
impl<N: Real> From<UnitComplex<N>> for Rotation2<N> {
impl<N: RealField> From<UnitComplex<N>> for Rotation2<N> {
#[inline]
fn from(q: UnitComplex<N>) -> Self {
q.to_rotation_matrix()
}
}
impl<N: Real> From<Rotation2<N>> for UnitComplex<N> {
impl<N: RealField> From<Rotation2<N>> for UnitComplex<N> {
#[inline]
fn from(q: Rotation2<N>) -> Self {
Self::from_rotation_matrix(&q)
}
}
impl<N: Real> From<UnitComplex<N>> for Matrix3<N> {
impl<N: RealField> From<UnitComplex<N>> for Matrix3<N> {
#[inline]
fn from(q: UnitComplex<N>) -> Matrix3<N> {
q.to_homogeneous()
}
}
impl<N: Real> From<UnitComplex<N>> for Matrix2<N> {
impl<N: RealField> From<UnitComplex<N>> for Matrix2<N> {
#[inline]
fn from(q: UnitComplex<N>) -> Self {
q.to_rotation_matrix().into_inner()

View File

@ -1,6 +1,6 @@
use std::ops::{Div, DivAssign, Mul, MulAssign};
use alga::general::Real;
use alga::general::RealField;
use crate::base::allocator::Allocator;
use crate::base::dimension::{U1, U2};
use crate::base::storage::Storage;
@ -44,7 +44,7 @@ use crate::geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitC
*/
// UnitComplex × UnitComplex
impl<N: Real> Mul<Self> for UnitComplex<N> {
impl<N: RealField> Mul<Self> for UnitComplex<N> {
type Output = Self;
#[inline]
@ -53,7 +53,7 @@ impl<N: Real> Mul<Self> for UnitComplex<N> {
}
}
impl<'a, N: Real> Mul<UnitComplex<N>> for &'a UnitComplex<N> {
impl<'a, N: RealField> Mul<UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>;
#[inline]
@ -62,7 +62,7 @@ impl<'a, N: Real> Mul<UnitComplex<N>> for &'a UnitComplex<N> {
}
}
impl<'b, N: Real> Mul<&'b UnitComplex<N>> for UnitComplex<N> {
impl<'b, N: RealField> Mul<&'b UnitComplex<N>> for UnitComplex<N> {
type Output = Self;
#[inline]
@ -71,7 +71,7 @@ impl<'b, N: Real> Mul<&'b UnitComplex<N>> for UnitComplex<N> {
}
}
impl<'a, 'b, N: Real> Mul<&'b UnitComplex<N>> for &'a UnitComplex<N> {
impl<'a, 'b, N: RealField> Mul<&'b UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>;
#[inline]
@ -81,7 +81,7 @@ impl<'a, 'b, N: Real> Mul<&'b UnitComplex<N>> for &'a UnitComplex<N> {
}
// UnitComplex ÷ UnitComplex
impl<N: Real> Div<Self> for UnitComplex<N> {
impl<N: RealField> Div<Self> for UnitComplex<N> {
type Output = Self;
#[inline]
@ -90,7 +90,7 @@ impl<N: Real> Div<Self> for UnitComplex<N> {
}
}
impl<'a, N: Real> Div<UnitComplex<N>> for &'a UnitComplex<N> {
impl<'a, N: RealField> Div<UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>;
#[inline]
@ -99,7 +99,7 @@ impl<'a, N: Real> Div<UnitComplex<N>> for &'a UnitComplex<N> {
}
}
impl<'b, N: Real> Div<&'b UnitComplex<N>> for UnitComplex<N> {
impl<'b, N: RealField> Div<&'b UnitComplex<N>> for UnitComplex<N> {
type Output = Self;
#[inline]
@ -108,7 +108,7 @@ impl<'b, N: Real> Div<&'b UnitComplex<N>> for UnitComplex<N> {
}
}
impl<'a, 'b, N: Real> Div<&'b UnitComplex<N>> for &'a UnitComplex<N> {
impl<'a, 'b, N: RealField> Div<&'b UnitComplex<N>> for &'a UnitComplex<N> {
type Output = UnitComplex<N>;
#[inline]
@ -122,7 +122,7 @@ macro_rules! complex_op_impl(
($RDim: ident, $CDim: ident) $(for $Storage: ident: $StoragesBound: ident $(<$($BoundParam: ty),*>)*),*;
$lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty;
$action: expr; $($lives: tt),*) => {
impl<$($lives ,)* N: Real $(, $Storage: $StoragesBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs
impl<$($lives ,)* N: RealField $(, $Storage: $StoragesBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs
where DefaultAllocator: Allocator<N, $RDim, $CDim> {
type Output = $Result;
@ -300,14 +300,14 @@ complex_op_impl_all!(
);
// UnitComplex ×= UnitComplex
impl<N: Real> MulAssign<UnitComplex<N>> for UnitComplex<N> {
impl<N: RealField> MulAssign<UnitComplex<N>> for UnitComplex<N> {
#[inline]
fn mul_assign(&mut self, rhs: UnitComplex<N>) {
*self = &*self * rhs
}
}
impl<'b, N: Real> MulAssign<&'b UnitComplex<N>> for UnitComplex<N> {
impl<'b, N: RealField> MulAssign<&'b UnitComplex<N>> for UnitComplex<N> {
#[inline]
fn mul_assign(&mut self, rhs: &'b UnitComplex<N>) {
*self = &*self * rhs
@ -315,14 +315,14 @@ impl<'b, N: Real> MulAssign<&'b UnitComplex<N>> for UnitComplex<N> {
}
// UnitComplex /= UnitComplex
impl<N: Real> DivAssign<UnitComplex<N>> for UnitComplex<N> {
impl<N: RealField> DivAssign<UnitComplex<N>> for UnitComplex<N> {
#[inline]
fn div_assign(&mut self, rhs: UnitComplex<N>) {
*self = &*self / rhs
}
}
impl<'b, N: Real> DivAssign<&'b UnitComplex<N>> for UnitComplex<N> {
impl<'b, N: RealField> DivAssign<&'b UnitComplex<N>> for UnitComplex<N> {
#[inline]
fn div_assign(&mut self, rhs: &'b UnitComplex<N>) {
*self = &*self / rhs
@ -330,7 +330,7 @@ impl<'b, N: Real> DivAssign<&'b UnitComplex<N>> for UnitComplex<N> {
}
// UnitComplex ×= Rotation
impl<N: Real> MulAssign<Rotation<N, U2>> for UnitComplex<N>
impl<N: RealField> MulAssign<Rotation<N, U2>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -339,7 +339,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
}
impl<'b, N: Real> MulAssign<&'b Rotation<N, U2>> for UnitComplex<N>
impl<'b, N: RealField> MulAssign<&'b Rotation<N, U2>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -349,7 +349,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
// UnitComplex ÷= Rotation
impl<N: Real> DivAssign<Rotation<N, U2>> for UnitComplex<N>
impl<N: RealField> DivAssign<Rotation<N, U2>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -358,7 +358,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
}
impl<'b, N: Real> DivAssign<&'b Rotation<N, U2>> for UnitComplex<N>
impl<'b, N: RealField> DivAssign<&'b Rotation<N, U2>> for UnitComplex<N>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -368,7 +368,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
// Rotation ×= UnitComplex
impl<N: Real> MulAssign<UnitComplex<N>> for Rotation<N, U2>
impl<N: RealField> MulAssign<UnitComplex<N>> for Rotation<N, U2>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -377,7 +377,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
}
impl<'b, N: Real> MulAssign<&'b UnitComplex<N>> for Rotation<N, U2>
impl<'b, N: RealField> MulAssign<&'b UnitComplex<N>> for Rotation<N, U2>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -387,7 +387,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
// Rotation ÷= UnitComplex
impl<N: Real> DivAssign<UnitComplex<N>> for Rotation<N, U2>
impl<N: RealField> DivAssign<UnitComplex<N>> for Rotation<N, U2>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]
@ -396,7 +396,7 @@ where DefaultAllocator: Allocator<N, U2, U2>
}
}
impl<'b, N: Real> DivAssign<&'b UnitComplex<N>> for Rotation<N, U2>
impl<'b, N: RealField> DivAssign<&'b UnitComplex<N>> for Rotation<N, U2>
where DefaultAllocator: Allocator<N, U2, U2>
{
#[inline]

View File

@ -3,7 +3,7 @@ use std::path::Path;
use pest::Parser;
use crate::sparse::CsMatrix;
use crate::Real;
use crate::RealField;
#[derive(Parser)]
#[grammar = "io/matrix_market.pest"]
@ -11,14 +11,14 @@ struct MatrixMarketParser;
// FIXME: return an Error instead of an Option.
/// Parses a Matrix Market file at the given path, and returns the corresponding sparse matrix.
pub fn cs_matrix_from_matrix_market<N: Real, P: AsRef<Path>>(path: P) -> Option<CsMatrix<N>> {
pub fn cs_matrix_from_matrix_market<N: RealField, P: AsRef<Path>>(path: P) -> Option<CsMatrix<N>> {
let file = fs::read_to_string(path).ok()?;
cs_matrix_from_matrix_market_str(&file)
}
// FIXME: return an Error instead of an Option.
/// Parses a Matrix Market file described by the given string, and returns the corresponding sparse matrix.
pub fn cs_matrix_from_matrix_market_str<N: Real>(data: &str) -> Option<CsMatrix<N>> {
pub fn cs_matrix_from_matrix_market_str<N: RealField>(data: &str) -> Option<CsMatrix<N>> {
let file = MatrixMarketParser::parse(Rule::Document, data)
.unwrap()
.next()?;

View File

@ -4,8 +4,8 @@
**nalgebra** is a linear algebra library written for Rust targeting:
* General-purpose linear algebra (still lacks a lot of features)
* Real time computer graphics.
* Real time computer physics.
* RealField time computer graphics.
* RealField time computer physics.
## Using **nalgebra**
You will need the last stable build of the [rust compiler](http://www.rust-lang.org)
@ -160,7 +160,7 @@ use alga::linear::SquareMatrix as AlgaSquareMatrix;
use alga::linear::{EuclideanSpace, FiniteDimVectorSpace, InnerSpace, NormedSpace};
use num::Signed;
pub use alga::general::{Id, Real, ComplexField};
pub use alga::general::{Id, RealField, ComplexField};
/*
*
@ -297,8 +297,8 @@ pub fn min<T: Ord>(a: T, b: T) -> T {
/// The absolute value of `a`.
///
/// Deprecated: Use [Matrix::abs] or [Real::abs] instead.
#[deprecated(note = "use `Matrix::abs` or `Real::abs` instead")]
/// Deprecated: Use [Matrix::abs] or [RealField::abs] instead.
#[deprecated(note = "use `Matrix::abs` or `RealField::abs` instead")]
#[inline]
pub fn abs<T: Signed>(a: &T) -> T {
a.abs()
@ -460,7 +460,7 @@ pub fn dot<V: FiniteDimVectorSpace>(a: &V, b: &V) -> V::Field {
/// Or, use [InnerSpace::angle](https://docs.rs/alga/0.7.2/alga/linear/trait.InnerSpace.html#method.angle).
#[deprecated(note = "use `Matrix::angle` instead")]
#[inline]
pub fn angle<V: InnerSpace>(a: &V, b: &V) -> V::Real {
pub fn angle<V: InnerSpace>(a: &V, b: &V) -> V::RealField {
a.angle(b)
}
@ -484,7 +484,7 @@ pub fn angle<V: InnerSpace>(a: &V, b: &V) -> V::Real {
/// Or, use [NormedSpace::norm](https://docs.rs/alga/0.7.2/alga/linear/trait.NormedSpace.html#tymethod.norm).
#[deprecated(note = "use `Matrix::norm` or `Quaternion::norm` instead")]
#[inline]
pub fn norm<V: NormedSpace>(v: &V) -> V::Real {
pub fn norm<V: NormedSpace>(v: &V) -> V::RealField {
v.norm()
}
@ -504,7 +504,7 @@ pub fn norm<V: NormedSpace>(v: &V) -> V::Real {
/// Or, use [NormedSpace::norm_squared](https://docs.rs/alga/0.7.2/alga/linear/trait.NormedSpace.html#tymethod.norm_squared).
#[deprecated(note = "use `Matrix::norm_squared` or `Quaternion::norm_squared` instead")]
#[inline]
pub fn norm_squared<V: NormedSpace>(v: &V) -> V::Real {
pub fn norm_squared<V: NormedSpace>(v: &V) -> V::RealField {
v.norm_squared()
}
@ -524,7 +524,7 @@ pub fn norm_squared<V: NormedSpace>(v: &V) -> V::Real {
/// Or, use [NormedSpace::norm](https://docs.rs/alga/0.7.2/alga/linear/trait.NormedSpace.html#tymethod.norm).
#[deprecated(note = "use `Matrix::magnitude` or `Quaternion::magnitude` instead")]
#[inline]
pub fn magnitude<V: NormedSpace>(v: &V) -> V::Real {
pub fn magnitude<V: NormedSpace>(v: &V) -> V::RealField {
v.norm()
}
@ -545,7 +545,7 @@ pub fn magnitude<V: NormedSpace>(v: &V) -> V::Real {
/// Or, use [NormedSpace::norm_squared](https://docs.rs/alga/0.7.2/alga/linear/trait.NormedSpace.html#tymethod.norm_squared).
#[deprecated(note = "use `Matrix::magnitude_squared` or `Quaternion::magnitude_squared` instead")]
#[inline]
pub fn magnitude_squared<V: NormedSpace>(v: &V) -> V::Real {
pub fn magnitude_squared<V: NormedSpace>(v: &V) -> V::RealField {
v.norm_squared()
}
@ -573,7 +573,7 @@ pub fn normalize<V: NormedSpace>(v: &V) -> V {
/// Or, use [NormedSpace::try_normalize](https://docs.rs/alga/0.7.2/alga/linear/trait.NormedSpace.html#tymethod.try_normalize).
#[deprecated(note = "use `Matrix::try_normalize` or `Quaternion::try_normalize` instead")]
#[inline]
pub fn try_normalize<V: NormedSpace>(v: &V, min_norm: V::Real) -> Option<V> {
pub fn try_normalize<V: NormedSpace>(v: &V, min_norm: V::RealField) -> Option<V> {
v.try_normalize(min_norm)
}
@ -600,7 +600,7 @@ pub fn center<P: EuclideanSpace>(p1: &P, p2: &P) -> P {
/// * [center](fn.center.html)
/// * [distance_squared](fn.distance_squared.html)
#[inline]
pub fn distance<P: EuclideanSpace>(p1: &P, p2: &P) -> P::Real {
pub fn distance<P: EuclideanSpace>(p1: &P, p2: &P) -> P::RealField {
(p2.coordinates() - p1.coordinates()).norm()
}
@ -611,7 +611,7 @@ pub fn distance<P: EuclideanSpace>(p1: &P, p2: &P) -> P::Real {
/// * [center](fn.center.html)
/// * [distance](fn.distance.html)
#[inline]
pub fn distance_squared<P: EuclideanSpace>(p1: &P, p2: &P) -> P::Real {
pub fn distance_squared<P: EuclideanSpace>(p1: &P, p2: &P) -> P::RealField {
(p2.coordinates() - p1.coordinates()).norm_squared()
}

View File

@ -1,6 +1,6 @@
//! Functions for balancing a matrix.
use alga::general::Real;
use alga::general::RealField;
use std::ops::{DivAssign, MulAssign};
use crate::allocator::Allocator;
@ -12,7 +12,7 @@ use crate::base::{DefaultAllocator, MatrixN, VectorN};
/// the corresponding diagonal transformation.
///
/// See https://arxiv.org/pdf/1401.5766.pdf
pub fn balance_parlett_reinsch<N: Real, D: Dim>(m: &mut MatrixN<N, D>) -> VectorN<N, D>
pub fn balance_parlett_reinsch<N: RealField, D: Dim>(m: &mut MatrixN<N, D>) -> VectorN<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D> {
assert!(m.is_square(), "Unable to balance a non-square matrix.");
@ -64,7 +64,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D> {
}
/// Computes in-place `D * m * D.inverse()`, where `D` is the matrix with diagonal `d`.
pub fn unbalance<N: Real, D: Dim>(m: &mut MatrixN<N, D>, d: &VectorN<N, D>)
pub fn unbalance<N: RealField, D: Dim>(m: &mut MatrixN<N, D>, d: &VectorN<N, D>)
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D> {
assert!(m.is_square(), "Unable to unbalance a non-square matrix.");
assert_eq!(m.nrows(), d.len(), "Unbalancing: mismatched dimensions.");

View File

@ -265,14 +265,14 @@ where
}
/// The diagonal part of this decomposed matrix.
pub fn diagonal(&self) -> VectorN<N::Real, DimMinimum<R, C>>
where DefaultAllocator: Allocator<N::Real, DimMinimum<R, C>> {
pub fn diagonal(&self) -> VectorN<N::RealField, DimMinimum<R, C>>
where DefaultAllocator: Allocator<N::RealField, DimMinimum<R, C>> {
self.diagonal.map(|e| e.modulus())
}
/// The off-diagonal part of this decomposed matrix.
pub fn off_diagonal(&self) -> VectorN<N::Real, DimDiff<DimMinimum<R, C>, U1>>
where DefaultAllocator: Allocator<N::Real, DimDiff<DimMinimum<R, C>, U1>> {
pub fn off_diagonal(&self) -> VectorN<N::RealField, DimDiff<DimMinimum<R, C>, U1>>
where DefaultAllocator: Allocator<N::RealField, DimDiff<DimMinimum<R, C>, U1>> {
self.off_diagonal.map(|e| e.modulus())
}

View File

@ -12,7 +12,7 @@ use crate::base::{Vector, Matrix};
/// A Givens rotation.
#[derive(Debug, Clone, Copy)]
pub struct GivensRotation<N: ComplexField> {
c: N::Real,
c: N::RealField,
s: N
}
@ -21,7 +21,7 @@ impl<N: ComplexField> GivensRotation<N> {
/// The Givents rotation that does nothing.
pub fn identity() -> Self {
Self {
c: N::Real::one(),
c: N::RealField::one(),
s: N::zero()
}
}
@ -30,7 +30,7 @@ impl<N: ComplexField> GivensRotation<N> {
///
/// The components are copies as-is. It is not checked whether they describe
/// an actually valid Givens rotation.
pub fn new_unchecked(c: N::Real, s: N) -> Self {
pub fn new_unchecked(c: N::RealField, s: N) -> Self {
Self {
c, s
}
@ -38,11 +38,11 @@ impl<N: ComplexField> GivensRotation<N> {
/// Initializes a Givens rotation from its non-normalized cosine an sine components.
pub fn new(c: N, s: N) -> (Self, N) {
Self::try_new(c, s, N::Real::zero()).unwrap()
Self::try_new(c, s, N::RealField::zero()).unwrap()
}
/// Initializes a Givens rotation form its non-normalized cosine an sine components.
pub fn try_new(c: N, s: N, eps: N::Real) -> Option<(Self, N)> {
pub fn try_new(c: N, s: N, eps: N::RealField) -> Option<(Self, N)> {
let (mod0, sign0) = c.to_exp();
let denom = (mod0 * mod0 + s.modulus_squared()).sqrt();
@ -91,7 +91,7 @@ impl<N: ComplexField> GivensRotation<N> {
}
/// The cos part of this roration.
pub fn c(&self) -> N::Real {
pub fn c(&self) -> N::RealField {
self.c
}

View File

@ -2,7 +2,7 @@
use serde::{Deserialize, Serialize};
use approx::AbsDiffEq;
use alga::general::{ComplexField, Real};
use alga::general::{ComplexField, RealField};
use num_complex::Complex as NumComplex;
use std::cmp;
@ -18,7 +18,7 @@ use crate::linalg::givens::GivensRotation;
/// Schur decomposition of a square matrix.
///
/// If this is a real matrix, this will be a Real Schur decomposition.
/// If this is a real matrix, this will be a RealField Schur decomposition.
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "serde-serialize",
@ -58,7 +58,7 @@ where
{
/// Computes the Schur decomposition of a square matrix.
pub fn new(m: MatrixN<N, D>) -> Self {
Self::try_new(m, N::Real::default_epsilon(), 0).unwrap()
Self::try_new(m, N::RealField::default_epsilon(), 0).unwrap()
}
/// Attempts to compute the Schur decomposition of a square matrix.
@ -72,7 +72,7 @@ where
/// * `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.
pub fn try_new(m: MatrixN<N, D>, eps: N::Real, 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) };
Self::do_decompose(m, &mut work, eps, max_niter, true).map(|(q, t)| Schur {
@ -84,7 +84,7 @@ where
fn do_decompose(
mut m: MatrixN<N, D>,
work: &mut VectorN<N, D>,
eps: N::Real,
eps: N::RealField,
max_niter: usize,
compute_q: bool,
) -> Option<(Option<MatrixN<N, D>>, MatrixN<N, D>)>
@ -291,7 +291,7 @@ where
/// Computes the complex eigenvalues of the decomposed matrix.
fn do_complex_eigenvalues(t: &MatrixN<N, D>, out: &mut VectorN<NumComplex<N>, D>)
where N: Real,
where N: RealField,
DefaultAllocator: Allocator<NumComplex<N>, D> {
let dim = t.nrows();
let mut m = 0;
@ -329,7 +329,7 @@ where
}
}
fn delimit_subproblem(t: &mut MatrixN<N, D>, eps: N::Real, end: usize) -> (usize, usize)
fn delimit_subproblem(t: &mut MatrixN<N, D>, eps: N::RealField, end: usize) -> (usize, usize)
where
D: DimSub<U1>,
DefaultAllocator: Allocator<N, DimDiff<D, U1>>,
@ -390,7 +390,7 @@ where
/// Computes the complex eigenvalues of the decomposed matrix.
pub fn complex_eigenvalues(&self) -> VectorN<NumComplex<N>, D>
where N: Real,
where N: RealField,
DefaultAllocator: Allocator<NumComplex<N>, D> {
let mut out = unsafe { VectorN::new_uninitialized_generic(self.t.data.shape().0, U1) };
Self::do_complex_eigenvalues(&self.t, &mut out);
@ -511,7 +511,7 @@ where
/// * `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.
pub fn try_schur(self, eps: N::Real, max_niter: usize) -> Option<Schur<N, D>> {
pub fn try_schur(self, eps: N::RealField, max_niter: usize) -> Option<Schur<N, D>> {
Schur::try_new(self.into_owned(), eps, max_niter)
}
@ -543,7 +543,7 @@ where
let schur = Schur::do_decompose(
self.clone_owned(),
&mut work,
N::Real::default_epsilon(),
N::RealField::default_epsilon(),
0,
false,
)
@ -558,7 +558,7 @@ where
/// Computes the eigenvalues of this matrix.
pub fn complex_eigenvalues(&self) -> VectorN<NumComplex<N>, D>
// FIXME: add balancing?
where N: Real,
where N: RealField,
DefaultAllocator: Allocator<NumComplex<N>, D> {
let dim = self.data.shape().0;
let mut work = unsafe { VectorN::new_uninitialized_generic(dim, U1) };

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use num::{Zero, One};
use approx::AbsDiffEq;
use alga::general::{Real, ComplexField};
use alga::general::{RealField, ComplexField};
use crate::allocator::Allocator;
use crate::base::{DefaultAllocator, Matrix, Matrix2x3, MatrixMN, Vector2, VectorN};
use crate::constraint::{SameNumberOfRows, ShapeConstraint};
@ -20,47 +20,47 @@ use crate::linalg::givens::GivensRotation;
#[cfg_attr(
feature = "serde-serialize",
serde(bound(
serialize = "DefaultAllocator: Allocator<N::Real, DimMinimum<R, C>> +
serialize = "DefaultAllocator: Allocator<N::RealField, DimMinimum<R, C>> +
Allocator<N, DimMinimum<R, C>, C> +
Allocator<N, R, DimMinimum<R, C>>,
MatrixMN<N, R, DimMinimum<R, C>>: Serialize,
MatrixMN<N, DimMinimum<R, C>, C>: Serialize,
VectorN<N::Real, DimMinimum<R, C>>: Serialize"
VectorN<N::RealField, DimMinimum<R, C>>: Serialize"
))
)]
#[cfg_attr(
feature = "serde-serialize",
serde(bound(
deserialize = "DefaultAllocator: Allocator<N::Real, DimMinimum<R, C>> +
deserialize = "DefaultAllocator: Allocator<N::RealField, DimMinimum<R, C>> +
Allocator<N, DimMinimum<R, C>, C> +
Allocator<N, R, DimMinimum<R, C>>,
MatrixMN<N, R, DimMinimum<R, C>>: Deserialize<'de>,
MatrixMN<N, DimMinimum<R, C>, C>: Deserialize<'de>,
VectorN<N::Real, DimMinimum<R, C>>: Deserialize<'de>"
VectorN<N::RealField, DimMinimum<R, C>>: Deserialize<'de>"
))
)]
#[derive(Clone, Debug)]
pub struct SVD<N: ComplexField, R: DimMin<C>, C: Dim>
where DefaultAllocator: Allocator<N, DimMinimum<R, C>, C>
+ Allocator<N, R, DimMinimum<R, C>>
+ Allocator<N::Real, DimMinimum<R, C>>
+ Allocator<N::RealField, DimMinimum<R, C>>
{
/// The left-singular vectors `U` of this SVD.
pub u: Option<MatrixMN<N, R, DimMinimum<R, C>>>,
/// The right-singular vectors `V^t` of this SVD.
pub v_t: Option<MatrixMN<N, DimMinimum<R, C>, C>>,
/// The singular values of this SVD.
pub singular_values: VectorN<N::Real, DimMinimum<R, C>>,
pub singular_values: VectorN<N::RealField, DimMinimum<R, C>>,
}
impl<N: ComplexField, R: DimMin<C>, C: Dim> Copy for SVD<N, R, C>
where
DefaultAllocator: Allocator<N, DimMinimum<R, C>, C>
+ Allocator<N, R, DimMinimum<R, C>>
+ Allocator<N::Real, DimMinimum<R, C>>,
+ Allocator<N::RealField, DimMinimum<R, C>>,
MatrixMN<N, R, DimMinimum<R, C>>: Copy,
MatrixMN<N, DimMinimum<R, C>, C>: Copy,
VectorN<N::Real, DimMinimum<R, C>>: Copy,
VectorN<N::RealField, DimMinimum<R, C>>: Copy,
{}
impl<N: ComplexField, R: DimMin<C>, C: Dim> SVD<N, R, C>
@ -73,12 +73,12 @@ where
+ Allocator<N, DimMinimum<R, C>, C>
+ Allocator<N, R, DimMinimum<R, C>>
+ Allocator<N, DimMinimum<R, C>>
+ Allocator<N::Real, DimMinimum<R, C>>
+ Allocator<N::Real, DimDiff<DimMinimum<R, C>, U1>>,
+ Allocator<N::RealField, DimMinimum<R, C>>
+ Allocator<N::RealField, DimDiff<DimMinimum<R, C>, U1>>,
{
/// Computes the Singular Value Decomposition of `matrix` using implicit shift.
pub fn new(matrix: MatrixMN<N, R, C>, compute_u: bool, compute_v: bool) -> Self {
Self::try_new(matrix, compute_u, compute_v, N::Real::default_epsilon(), 0).unwrap()
Self::try_new(matrix, compute_u, compute_v, N::RealField::default_epsilon(), 0).unwrap()
}
/// Attempts to compute the Singular Value Decomposition of `matrix` using implicit shift.
@ -95,7 +95,7 @@ where
mut matrix: MatrixMN<N, R, C>,
compute_u: bool,
compute_v: bool,
eps: N::Real,
eps: N::RealField,
max_niter: usize,
) -> Option<Self>
{
@ -150,7 +150,7 @@ where
for k in start..n {
let m12 = if k == n - 1 {
N::Real::zero()
N::RealField::zero()
} else {
off_diagonal[k + 1]
};
@ -158,8 +158,8 @@ where
let mut subm = Matrix2x3::new(
diagonal[k],
off_diagonal[k],
N::Real::zero(),
N::Real::zero(),
N::RealField::zero(),
N::RealField::zero(),
diagonal[k + 1],
m12,
);
@ -229,7 +229,7 @@ where
diagonal[start + 0] = s[0];
diagonal[start + 1] = s[1];
off_diagonal[start] = N::Real::zero();
off_diagonal[start] = N::RealField::zero();
if let Some(ref mut u) = u {
let rot = if b.is_upper_diagonal() {
@ -269,7 +269,7 @@ where
for i in 0..dim {
let sval = diagonal[i];
if sval < N::Real::zero() {
if sval < N::RealField::zero() {
diagonal[i] = -sval;
if let Some(ref mut u) = u {
@ -301,13 +301,13 @@ where
*/
fn delimit_subproblem(
diagonal: &mut VectorN<N::Real, DimMinimum<R, C>>,
off_diagonal: &mut VectorN<N::Real, DimDiff<DimMinimum<R, C>, U1>>,
diagonal: &mut VectorN<N::RealField, DimMinimum<R, C>>,
off_diagonal: &mut VectorN<N::RealField, DimDiff<DimMinimum<R, C>, U1>>,
u: &mut Option<MatrixMN<N, R, DimMinimum<R, C>>>,
v_t: &mut Option<MatrixMN<N, DimMinimum<R, C>, C>>,
is_upper_diagonal: bool,
end: usize,
eps: N::Real,
eps: N::RealField,
) -> (usize, usize)
{
let mut n = end;
@ -318,16 +318,16 @@ where
if off_diagonal[m].is_zero()
|| off_diagonal[m].norm1() <= eps * (diagonal[n].norm1() + diagonal[m].norm1())
{
off_diagonal[m] = N::Real::zero();
off_diagonal[m] = N::RealField::zero();
} else if diagonal[m].norm1() <= eps {
diagonal[m] = N::Real::zero();
diagonal[m] = N::RealField::zero();
Self::cancel_horizontal_off_diagonal_elt(diagonal, off_diagonal, u, v_t, is_upper_diagonal, m, m + 1);
if m != 0 {
Self::cancel_vertical_off_diagonal_elt(diagonal, off_diagonal, u, v_t, is_upper_diagonal, m - 1);
}
} else if diagonal[n].norm1() <= eps {
diagonal[n] = N::Real::zero();
diagonal[n] = N::RealField::zero();
Self::cancel_vertical_off_diagonal_elt(diagonal, off_diagonal, u, v_t, is_upper_diagonal, m);
} else {
break;
@ -346,12 +346,12 @@ where
if off_diagonal[m].norm1() <= eps * (diagonal[new_start].norm1() + diagonal[m].norm1())
{
off_diagonal[m] = N::Real::zero();
off_diagonal[m] = N::RealField::zero();
break;
}
// FIXME: write a test that enters this case.
else if diagonal[m].norm1() <= eps {
diagonal[m] = N::Real::zero();
diagonal[m] = N::RealField::zero();
Self::cancel_horizontal_off_diagonal_elt(diagonal, off_diagonal, u, v_t, is_upper_diagonal, m, n);
if m != 0 {
@ -368,8 +368,8 @@ where
// Cancels the i-th off-diagonal element using givens rotations.
fn cancel_horizontal_off_diagonal_elt(
diagonal: &mut VectorN<N::Real, DimMinimum<R, C>>,
off_diagonal: &mut VectorN<N::Real, DimDiff<DimMinimum<R, C>, U1>>,
diagonal: &mut VectorN<N::RealField, DimMinimum<R, C>>,
off_diagonal: &mut VectorN<N::RealField, DimDiff<DimMinimum<R, C>, U1>>,
u: &mut Option<MatrixMN<N, R, DimMinimum<R, C>>>,
v_t: &mut Option<MatrixMN<N, DimMinimum<R, C>, C>>,
is_upper_diagonal: bool,
@ -378,7 +378,7 @@ where
)
{
let mut v = Vector2::new(off_diagonal[i], diagonal[i + 1]);
off_diagonal[i] = N::Real::zero();
off_diagonal[i] = N::RealField::zero();
for k in i..end {
if let Some((rot, norm)) = GivensRotation::cancel_x(&v) {
@ -407,8 +407,8 @@ where
// Cancels the i-th off-diagonal element using givens rotations.
fn cancel_vertical_off_diagonal_elt(
diagonal: &mut VectorN<N::Real, DimMinimum<R, C>>,
off_diagonal: &mut VectorN<N::Real, DimDiff<DimMinimum<R, C>, U1>>,
diagonal: &mut VectorN<N::RealField, DimMinimum<R, C>>,
off_diagonal: &mut VectorN<N::RealField, DimDiff<DimMinimum<R, C>, U1>>,
u: &mut Option<MatrixMN<N, R, DimMinimum<R, C>>>,
v_t: &mut Option<MatrixMN<N, DimMinimum<R, C>, C>>,
is_upper_diagonal: bool,
@ -416,7 +416,7 @@ where
)
{
let mut v = Vector2::new(diagonal[i], off_diagonal[i]);
off_diagonal[i] = N::Real::zero();
off_diagonal[i] = N::RealField::zero();
for k in (0..i + 1).rev() {
if let Some((rot, norm)) = GivensRotation::cancel_y(&v) {
@ -445,9 +445,9 @@ where
/// Computes the rank of the decomposed matrix, i.e., the number of singular values greater
/// than `eps`.
pub fn rank(&self, eps: N::Real) -> usize {
pub fn rank(&self, eps: N::RealField) -> usize {
assert!(
eps >= N::Real::zero(),
eps >= N::RealField::zero(),
"SVD rank: the epsilon must be non-negative."
);
self.singular_values.iter().filter(|e| **e > eps).count()
@ -478,11 +478,11 @@ where
/// Any singular value smaller than `eps` is assumed to be zero.
/// Returns `Err` if the right- and left- singular vectors have not
/// been computed at construction-time.
pub fn pseudo_inverse(mut self, eps: N::Real) -> Result<MatrixMN<N, C, R>, &'static str>
pub fn pseudo_inverse(mut self, eps: N::RealField) -> Result<MatrixMN<N, C, R>, &'static str>
where
DefaultAllocator: Allocator<N, C, R>,
{
if eps < N::Real::zero() {
if eps < N::RealField::zero() {
Err("SVD pseudo inverse: the epsilon must be non-negative.")
}
else {
@ -490,9 +490,9 @@ where
let val = self.singular_values[i];
if val > eps {
self.singular_values[i] = N::Real::one() / val;
self.singular_values[i] = N::RealField::one() / val;
} else {
self.singular_values[i] = N::Real::zero();
self.singular_values[i] = N::RealField::zero();
}
}
@ -508,14 +508,14 @@ where
pub fn solve<R2: Dim, C2: Dim, S2>(
&self,
b: &Matrix<N, R2, C2, S2>,
eps: N::Real,
eps: N::RealField,
) -> Result<MatrixMN<N, C, C2>, &'static str>
where
S2: Storage<N, R2, C2>,
DefaultAllocator: Allocator<N, C, C2> + Allocator<N, DimMinimum<R, C>, C2>,
ShapeConstraint: SameNumberOfRows<R, R2>,
{
if eps < N::Real::zero() {
if eps < N::RealField::zero() {
Err("SVD solve: the epsilon must be non-negative.")
}
else {
@ -556,8 +556,8 @@ where
+ Allocator<N, DimMinimum<R, C>, C>
+ Allocator<N, R, DimMinimum<R, C>>
+ Allocator<N, DimMinimum<R, C>>
+ Allocator<N::Real, DimMinimum<R, C>>
+ Allocator<N::Real, DimDiff<DimMinimum<R, C>, U1>>,
+ Allocator<N::RealField, DimMinimum<R, C>>
+ Allocator<N::RealField, DimDiff<DimMinimum<R, C>, U1>>,
{
/// Computes the Singular Value Decomposition using implicit shift.
pub fn svd(self, compute_u: bool, compute_v: bool) -> SVD<N, R, C> {
@ -578,7 +578,7 @@ where
self,
compute_u: bool,
compute_v: bool,
eps: N::Real,
eps: N::RealField,
max_niter: usize,
) -> Option<SVD<N, R, C>>
{
@ -586,14 +586,14 @@ where
}
/// Computes the singular values of this matrix.
pub fn singular_values(&self) -> VectorN<N::Real, DimMinimum<R, C>> {
pub fn singular_values(&self) -> VectorN<N::RealField, DimMinimum<R, C>> {
SVD::new(self.clone_owned(), false, false).singular_values
}
/// Computes the rank of this matrix.
///
/// All singular values below `eps` are considered equal to 0.
pub fn rank(&self, eps: N::Real) -> usize {
pub fn rank(&self, eps: N::RealField) -> usize {
let svd = SVD::new(self.clone_owned(), false, false);
svd.rank(eps)
}
@ -601,7 +601,7 @@ where
/// Computes the pseudo-inverse of this matrix.
///
/// All singular values below `eps` are considered equal to 0.
pub fn pseudo_inverse(self, eps: N::Real) -> Result<MatrixMN<N, C, R>, &'static str>
pub fn pseudo_inverse(self, eps: N::RealField) -> Result<MatrixMN<N, C, R>, &'static str>
where
DefaultAllocator: Allocator<N, C, R>,
{
@ -613,7 +613,7 @@ where
// Explicit formulae inspired from the paper "Computing the Singular Values of 2-by-2 Complex
// Matrices", Sanzheng Qiao and Xiaohong Wang.
// http://www.cas.mcmaster.ca/sqrl/papers/sqrl5.pdf
fn compute_2x2_uptrig_svd<N: Real>(
fn compute_2x2_uptrig_svd<N: RealField>(
m11: N,
m12: N,
m22: N,
@ -621,8 +621,8 @@ fn compute_2x2_uptrig_svd<N: Real>(
compute_v: bool,
) -> (Option<GivensRotation<N>>, Vector2<N>, Option<GivensRotation<N>>)
{
let two: N::Real = crate::convert(2.0f64);
let half: N::Real = crate::convert(0.5f64);
let two: N::RealField = crate::convert(2.0f64);
let half: N::RealField = crate::convert(0.5f64);
let denom = (m11 + m22).hypot(m12) + (m11 - m22).hypot(m12);

View File

@ -19,8 +19,8 @@ use crate::linalg::SymmetricTridiagonal;
feature = "serde-serialize",
serde(bound(
serialize = "DefaultAllocator: Allocator<N, D, D> +
Allocator<N::Real, D>,
VectorN<N::Real, D>: Serialize,
Allocator<N::RealField, D>,
VectorN<N::RealField, D>: Serialize,
MatrixN<N, D>: Serialize"
))
)]
@ -28,31 +28,31 @@ use crate::linalg::SymmetricTridiagonal;
feature = "serde-serialize",
serde(bound(
deserialize = "DefaultAllocator: Allocator<N, D, D> +
Allocator<N::Real, D>,
VectorN<N::Real, D>: Deserialize<'de>,
Allocator<N::RealField, D>,
VectorN<N::RealField, D>: Deserialize<'de>,
MatrixN<N, D>: Deserialize<'de>"
))
)]
#[derive(Clone, Debug)]
pub struct SymmetricEigen<N: ComplexField, D: Dim>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N::RealField, D>
{
/// The eigenvectors of the decomposed matrix.
pub eigenvectors: MatrixN<N, D>,
/// The unsorted eigenvalues of the decomposed matrix.
pub eigenvalues: VectorN<N::Real, D>,
pub eigenvalues: VectorN<N::RealField, D>,
}
impl<N: ComplexField, D: Dim> Copy for SymmetricEigen<N, D>
where
DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>,
DefaultAllocator: Allocator<N, D, D> + Allocator<N::RealField, D>,
MatrixN<N, D>: Copy,
VectorN<N::Real, D>: Copy,
VectorN<N::RealField, D>: Copy,
{}
impl<N: ComplexField, D: Dim> SymmetricEigen<N, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N::RealField, D>
{
/// Computes the eigendecomposition of the given symmetric matrix.
///
@ -61,9 +61,9 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<N, DimDiff<D, U1>> + // For tridiagonalization
Allocator<N::Real, DimDiff<D, U1>>,
Allocator<N::RealField, DimDiff<D, U1>>,
{
Self::try_new(m, N::Real::default_epsilon(), 0).unwrap()
Self::try_new(m, N::RealField::default_epsilon(), 0).unwrap()
}
/// Computes the eigendecomposition of the given symmetric matrix with user-specified
@ -77,11 +77,11 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
/// * `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.
pub fn try_new(m: MatrixN<N, D>, eps: N::Real, max_niter: usize) -> Option<Self>
pub fn try_new(m: MatrixN<N, D>, eps: N::RealField, max_niter: usize) -> Option<Self>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<N, DimDiff<D, U1>> + // For tridiagonalization
Allocator<N::Real, DimDiff<D, U1>>,
Allocator<N::RealField, DimDiff<D, U1>>,
{
Self::do_decompose(m, true, eps, max_niter).map(|(vals, vecs)| SymmetricEigen {
eigenvectors: vecs.unwrap(),
@ -92,13 +92,13 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
fn do_decompose(
mut m: MatrixN<N, D>,
eigenvectors: bool,
eps: N::Real,
eps: N::RealField,
max_niter: usize,
) -> Option<(VectorN<N::Real, D>, Option<MatrixN<N, D>>)>
) -> Option<(VectorN<N::RealField, D>, Option<MatrixN<N, D>>)>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<N, DimDiff<D, U1>> + // For tridiagonalization
Allocator<N::Real, DimDiff<D, U1>>,
Allocator<N::RealField, DimDiff<D, U1>>,
{
assert!(
m.is_square(),
@ -226,14 +226,14 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
}
fn delimit_subproblem(
diag: &VectorN<N::Real, D>,
off_diag: &mut VectorN<N::Real, DimDiff<D, U1>>,
diag: &VectorN<N::RealField, D>,
off_diag: &mut VectorN<N::RealField, DimDiff<D, U1>>,
end: usize,
eps: N::Real,
eps: N::RealField,
) -> (usize, usize)
where
D: DimSub<U1>,
DefaultAllocator: Allocator<N::Real, DimDiff<D, U1>>,
DefaultAllocator: Allocator<N::RealField, DimDiff<D, U1>>,
{
let mut n = end;
@ -258,7 +258,7 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N::Real, D>
if off_diag[m].is_zero()
|| off_diag[m].norm1() <= eps * (diag[new_start].norm1() + diag[m].norm1())
{
off_diag[m] = N::Real::zero();
off_diag[m] = N::RealField::zero();
break;
}
@ -306,7 +306,7 @@ pub fn wilkinson_shift<N: ComplexField>(tmm: N, tnn: N, tmn: N) -> N {
*/
impl<N: ComplexField, D: DimSub<U1>, S: Storage<N, D, D>> SquareMatrix<N, D, S>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>> +
Allocator<N::Real, D> + Allocator<N::Real, DimDiff<D, U1>>
Allocator<N::RealField, D> + Allocator<N::RealField, DimDiff<D, U1>>
{
/// Computes the eigendecomposition of this symmetric matrix.
///
@ -326,15 +326,15 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>> +
/// * `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.
pub fn try_symmetric_eigen(self, eps: N::Real, max_niter: usize) -> Option<SymmetricEigen<N, D>> {
pub fn try_symmetric_eigen(self, eps: N::RealField, max_niter: usize) -> Option<SymmetricEigen<N, D>> {
SymmetricEigen::try_new(self.into_owned(), eps, max_niter)
}
/// Computes the eigenvalues of this symmetric matrix.
///
/// Only the lower-triangular part of the matrix is read.
pub fn symmetric_eigenvalues(&self) -> VectorN<N::Real, D> {
SymmetricEigen::do_decompose(self.clone_owned(), false, N::Real::default_epsilon(), 0)
pub fn symmetric_eigenvalues(&self) -> VectorN<N::RealField, D> {
SymmetricEigen::do_decompose(self.clone_owned(), false, N::RealField::default_epsilon(), 0)
.unwrap()
.0
}

View File

@ -98,9 +98,9 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>>
/// Retrieve the orthogonal transformation, diagonal, and off diagonal elements of this
/// decomposition.
pub fn unpack(self) -> (MatrixN<N, D>, VectorN<N::Real, D>, VectorN<N::Real, DimDiff<D, U1>>)
where DefaultAllocator: Allocator<N::Real, D>
+ Allocator<N::Real, DimDiff<D, U1>> {
pub fn unpack(self) -> (MatrixN<N, D>, VectorN<N::RealField, D>, VectorN<N::RealField, DimDiff<D, U1>>)
where DefaultAllocator: Allocator<N::RealField, D>
+ Allocator<N::RealField, DimDiff<D, U1>> {
let diag = self.diagonal();
let q = self.q();
@ -108,19 +108,19 @@ where DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>>
}
/// Retrieve the diagonal, and off diagonal elements of this decomposition.
pub fn unpack_tridiagonal(self) -> (VectorN<N::Real, D>, VectorN<N::Real, DimDiff<D, U1>>)
where DefaultAllocator: Allocator<N::Real, D>
+ Allocator<N::Real, DimDiff<D, U1>> {
pub fn unpack_tridiagonal(self) -> (VectorN<N::RealField, D>, VectorN<N::RealField, DimDiff<D, U1>>)
where DefaultAllocator: Allocator<N::RealField, D>
+ Allocator<N::RealField, DimDiff<D, U1>> {
(self.diagonal(), self.off_diagonal.map(N::modulus))
}
/// The diagonal components of this decomposition.
pub fn diagonal(&self) -> VectorN<N::Real, D>
where DefaultAllocator: Allocator<N::Real, D> { self.tri.map_diagonal(|e| e.real()) }
pub fn diagonal(&self) -> VectorN<N::RealField, D>
where DefaultAllocator: Allocator<N::RealField, D> { self.tri.map_diagonal(|e| e.real()) }
/// The off-diagonal components of this decomposition.
pub fn off_diagonal(&self) -> VectorN<N::Real, DimDiff<D, U1>>
where DefaultAllocator: Allocator<N::Real, DimDiff<D, U1>> {
pub fn off_diagonal(&self) -> VectorN<N::RealField, DimDiff<D, U1>>
where DefaultAllocator: Allocator<N::RealField, DimDiff<D, U1>> {
self.off_diagonal.map(N::modulus)
}

View File

@ -3,10 +3,10 @@ use std::mem;
use crate::allocator::Allocator;
use crate::sparse::{CsMatrix, CsStorage, CsStorageIter, CsStorageIterMut, CsVecStorage};
use crate::{DefaultAllocator, Dim, Real, VectorN, U1};
use crate::{DefaultAllocator, Dim, RealField, VectorN, U1};
/// The cholesky decomposition of a column compressed sparse matrix.
pub struct CsCholesky<N: Real, D: Dim>
pub struct CsCholesky<N: RealField, D: Dim>
where DefaultAllocator: Allocator<usize, D> + Allocator<N, D>
{
// Non-zero pattern of the original matrix upper-triangular part.
@ -25,7 +25,7 @@ where DefaultAllocator: Allocator<usize, D> + Allocator<N, D>
work_c: VectorN<usize, D>,
}
impl<N: Real, D: Dim> CsCholesky<N, D>
impl<N: RealField, D: Dim> CsCholesky<N, D>
where DefaultAllocator: Allocator<usize, D> + Allocator<N, D>
{
/// Computes the cholesky decomposition of the sparse matrix `m`.

View File

@ -2,9 +2,9 @@ use crate::allocator::Allocator;
use crate::constraint::{SameNumberOfRows, ShapeConstraint};
use crate::sparse::{CsMatrix, CsStorage, CsVector};
use crate::storage::{Storage, StorageMut};
use crate::{DefaultAllocator, Dim, Matrix, MatrixMN, Real, VectorN, U1};
use crate::{DefaultAllocator, Dim, Matrix, MatrixMN, RealField, VectorN, U1};
impl<N: Real, D: Dim, S: CsStorage<N, D, D>> CsMatrix<N, D, D, S> {
impl<N: RealField, D: Dim, S: CsStorage<N, D, D>> CsMatrix<N, D, D, S> {
/// Solve a lower-triangular system with a dense right-hand-side.
pub fn solve_lower_triangular<R2: Dim, C2: Dim, S2>(
&self,

View File

@ -5,12 +5,12 @@ use quickcheck::{Arbitrary, Gen};
use rand::distributions::{Standard, Distribution};
use rand::Rng;
use num_complex::Complex;
use na::Real;
use na::RealField;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct RandComplex<N>(pub Complex<N>);
impl<N: Arbitrary + Real> Arbitrary for RandComplex<N> {
impl<N: Arbitrary + RealField> Arbitrary for RandComplex<N> {
#[inline]
fn arbitrary<G: Gen>(rng: &mut G) -> Self {
let im = Arbitrary::arbitrary(rng);
@ -19,7 +19,7 @@ impl<N: Arbitrary + Real> Arbitrary for RandComplex<N> {
}
}
impl<N: Real> Distribution<RandComplex<N>> for Standard
impl<N: RealField> Distribution<RandComplex<N>> for Standard
where
Standard: Distribution<N>,
{
@ -43,7 +43,7 @@ impl<N: Arbitrary> Arbitrary for RandScalar<N> {
}
}
impl<N: Real> Distribution<RandScalar<N>> for Standard
impl<N: RealField> Distribution<RandScalar<N>> for Standard
where
Standard: Distribution<N>,
{

View File

@ -4,7 +4,7 @@ use std::cmp::Ordering;
use na::dimension::{U15, U8};
use na::{
self, DMatrix, DVector, Matrix2, Matrix2x3, Matrix2x4, Matrix3, Matrix3x2, Matrix3x4, Matrix4,
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, Real, RowVector3, RowVector4, RowVector5,
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RealField, RowVector3, RowVector4, RowVector5,
Vector1, Vector2, Vector3, Vector4, Vector5, Vector6,
};
@ -1022,7 +1022,7 @@ mod finite_dim_inner_space_tests {
*
*/
#[cfg(feature = "arbitrary")]
fn is_subspace_basis<T: FiniteDimInnerSpace<Real = f64, ComplexField = f64> + Display>(vs: &[T]) -> bool {
fn is_subspace_basis<T: FiniteDimInnerSpace<RealField = f64, ComplexField = f64> + Display>(vs: &[T]) -> bool {
for i in 0..vs.len() {
// Basis elements must be normalized.
if !relative_eq!(vs[i].norm(), 1.0, epsilon = 1.0e-7) {

View File

@ -1,4 +1,4 @@
use na::{Quaternion, Real, UnitQuaternion, Vector2, Vector3};
use na::{Quaternion, RealField, UnitQuaternion, Vector2, Vector3};
#[test]
fn angle_2() {
@ -32,7 +32,7 @@ fn quaternion_euler_angles_issue_494() {
#[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use alga::general::Real;
use alga::general::RealField;
use na::{self, Rotation2, Rotation3, Unit, Vector2, Vector3};
use std::f64;