diff --git a/examples/dimensional_genericity.rs b/examples/dimensional_genericity.rs index ca653d57..411a0666 100644 --- a/examples/dimensional_genericity.rs +++ b/examples/dimensional_genericity.rs @@ -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(plane_normal: &Unit, 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( +fn reflect_wrt_hyperplane_with_dimensional_genericity( plane_normal: &Unit>, vector: &VectorN, ) -> VectorN where - N: Real, + N: RealField, D: Dim, DefaultAllocator: Allocator, { @@ -29,7 +29,7 @@ where /// Reflects a 2D vector wrt. the 2D line with normal `plane_normal`. fn reflect_wrt_hyperplane2(plane_normal: &Unit>, vector: &Vector2) -> Vector2 -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(plane_normal: &Unit>, vector: &Vector3) -> Vector3 -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)) } diff --git a/examples/scalar_genericity.rs b/examples/scalar_genericity.rs index 246d1efd..75f6f9d4 100644 --- a/examples/scalar_genericity.rs +++ b/examples/scalar_genericity.rs @@ -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(m: &Vector3) { @@ -14,11 +14,11 @@ fn print_squared_norm(v: &Vector3) { println!("{:?}", sqnorm); } -fn print_norm(v: &Vector3) { +fn print_norm(v: &Vector3) { // 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) } diff --git a/nalgebra-glm/src/common.rs b/nalgebra-glm/src/common.rs index 23103299..c9f9c265 100644 --- a/nalgebra-glm/src/common.rs +++ b/nalgebra-glm/src/common.rs @@ -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 { /// * [`fract`](fn.fract.html) /// * [`round`](fn.round.html) /// * [`trunc`](fn.trunc.html) -pub fn ceil(x: &TVec) -> TVec +pub fn ceil(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|x| x.ceil()) } @@ -222,7 +222,7 @@ where DefaultAllocator: Alloc { /// * [`fract`](fn.fract.html) /// * [`round`](fn.round.html) /// * [`trunc`](fn.trunc.html) -pub fn floor(x: &TVec) -> TVec +pub fn floor(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|x| x.floor()) } @@ -249,14 +249,14 @@ where DefaultAllocator: Alloc { /// * [`floor`](fn.floor.html) /// * [`round`](fn.round.html) /// * [`trunc`](fn.trunc.html) -pub fn fract(x: &TVec) -> TVec +pub fn fract(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|x| x.fract()) } //// FIXME: should be implemented for TVec/TMat? ///// Returns the (significant, exponent) of this float number. -//pub fn frexp(x: N, exp: N) -> (N, N) { +//pub fn frexp(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 { //} ///// Returns the (significant, exponent) of this float number. -//pub fn ldexp(x: N, exp: N) -> N { +//pub fn ldexp(x: N, exp: N) -> N { // // FIXME: is there a better approach? // x * (exp).exp2() //} @@ -499,7 +499,7 @@ pub fn modf(x: N, i: N) -> N { /// * [`floor`](fn.floor.html) /// * [`fract`](fn.fract.html) /// * [`trunc`](fn.trunc.html) -pub fn round(x: &TVec) -> TVec +pub fn round(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|x| x.round()) } @@ -576,7 +576,7 @@ where DefaultAllocator: Alloc { /// * [`floor`](fn.floor.html) /// * [`fract`](fn.fract.html) /// * [`round`](fn.round.html) -pub fn trunc(x: &TVec) -> TVec +pub fn trunc(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|x| x.trunc()) } diff --git a/nalgebra-glm/src/constructors.rs b/nalgebra-glm/src/constructors.rs index fb692d5c..949ea9e4 100644 --- a/nalgebra-glm/src/constructors.rs +++ b/nalgebra-glm/src/constructors.rs @@ -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(m11: N, m12: N, m13: N, m14: N, } /// Creates a new quaternion. -pub fn quat(x: N, y: N, z: N, w: N) -> Qua { +pub fn quat(x: N, y: N, z: N, w: N) -> Qua { Qua::new(w, x, y, z) } diff --git a/nalgebra-glm/src/exponential.rs b/nalgebra-glm/src/exponential.rs index e080805d..fd54fb34 100644 --- a/nalgebra-glm/src/exponential.rs +++ b/nalgebra-glm/src/exponential.rs @@ -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(v: &TVec) -> TVec +pub fn exp(v: &TVec) -> TVec where DefaultAllocator: Alloc { v.map(|x| x.exp()) } @@ -17,7 +17,7 @@ where DefaultAllocator: Alloc { /// # See also: /// /// * [`exp`](fn.exp.html) -pub fn exp2(v: &TVec) -> TVec +pub fn exp2(v: &TVec) -> TVec where DefaultAllocator: Alloc { v.map(|x| x.exp2()) } @@ -27,7 +27,7 @@ where DefaultAllocator: Alloc { /// # See also: /// /// * [`sqrt`](fn.sqrt.html) -pub fn inversesqrt(v: &TVec) -> TVec +pub fn inversesqrt(v: &TVec) -> TVec where DefaultAllocator: Alloc { v.map(|x| N::one() / x.sqrt()) } @@ -37,7 +37,7 @@ where DefaultAllocator: Alloc { /// # See also: /// /// * [`log2`](fn.log2.html) -pub fn log(v: &TVec) -> TVec +pub fn log(v: &TVec) -> TVec where DefaultAllocator: Alloc { v.map(|x| x.ln()) } @@ -47,13 +47,13 @@ where DefaultAllocator: Alloc { /// # See also: /// /// * [`log`](fn.log.html) -pub fn log2(v: &TVec) -> TVec +pub fn log2(v: &TVec) -> TVec where DefaultAllocator: Alloc { v.map(|x| x.log2()) } /// Component-wise power. -pub fn pow(base: &TVec, exponent: &TVec) -> TVec +pub fn pow(base: &TVec, exponent: &TVec) -> TVec where DefaultAllocator: Alloc { base.zip_map(exponent, |b, e| b.powf(e)) } @@ -66,7 +66,7 @@ where DefaultAllocator: Alloc { /// * [`exp2`](fn.exp2.html) /// * [`inversesqrt`](fn.inversesqrt.html) /// * [`pow`](fn.pow.html) -pub fn sqrt(v: &TVec) -> TVec +pub fn sqrt(v: &TVec) -> TVec where DefaultAllocator: Alloc { v.map(|x| x.sqrt()) } diff --git a/nalgebra-glm/src/ext/matrix_clip_space.rs b/nalgebra-glm/src/ext/matrix_clip_space.rs index fe7cc973..6ef1404b 100644 --- a/nalgebra-glm/src/ext/matrix_clip_space.rs +++ b/nalgebra-glm/src/ext/matrix_clip_space.rs @@ -1,55 +1,55 @@ use crate::aliases::TMat4; -use na::{Real}; +use na::{RealField}; -//pub fn frustum(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} -//pub fn frustum_lh(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_lh(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_lr_no(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_lr_no(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_lh_zo(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_lh_zo(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_no(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_no(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_rh(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_rh(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_rh_no(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_rh_no(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_rh_zo(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_rh_zo(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} // -//pub fn frustum_zo(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { +//pub fn frustum_zo(left: N, right: N, bottom: N, top: N, near: N, far: N) -> TMat4 { // unimplemented!() //} -//pub fn infinite_perspective(fovy: N, aspect: N, near: N) -> TMat4 { +//pub fn infinite_perspective(fovy: N, aspect: N, near: N) -> TMat4 { // unimplemented!() //} // -//pub fn infinite_perspective_lh(fovy: N, aspect: N, near: N) -> TMat4 { +//pub fn infinite_perspective_lh(fovy: N, aspect: N, near: N) -> TMat4 { // unimplemented!() //} // -//pub fn infinite_perspective_rh(fovy: N, aspect: N, near: N) -> TMat4 { +//pub fn infinite_perspective_rh(fovy: N, aspect: N, near: N) -> TMat4 { // unimplemented!() //} // -//pub fn infinite_ortho(left: N, right: N, bottom: N, top: N) -> TMat4 { +//pub fn infinite_ortho(left: N, right: N, bottom: N, top: N) -> TMat4 { // 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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { ortho_rh_no(left, right, bottom, top, znear, zfar) } @@ -79,7 +79,7 @@ pub fn ortho(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_lh(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { ortho_lh_no(left, right, bottom, top, znear, zfar) } @@ -94,7 +94,7 @@ pub fn ortho_lh(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_lh_no(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { let two : N = crate::convert(2.0); let mut mat : TMat4 = TMat4::::identity(); @@ -119,7 +119,7 @@ pub fn ortho_lh_no(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_lh_zo(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { let one : N = N::one(); let two : N = crate::convert(2.0); let mut mat : TMat4 = TMat4::::identity(); @@ -145,7 +145,7 @@ pub fn ortho_lh_zo(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_no(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { ortho_rh_no(left, right, bottom, top, znear, zfar) } @@ -160,7 +160,7 @@ pub fn ortho_no(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_rh(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { ortho_rh_no(left, right, bottom, top, znear, zfar) } @@ -175,7 +175,7 @@ pub fn ortho_rh(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_rh_no(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { let two : N = crate::convert(2.0); let mut mat : TMat4 = TMat4::::identity(); @@ -200,7 +200,7 @@ pub fn ortho_rh_no(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_rh_zo(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { let one : N = N::one(); let two : N = crate::convert(2.0); let mut mat : TMat4 = TMat4::::identity(); @@ -226,7 +226,7 @@ pub fn ortho_rh_zo(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(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { +pub fn ortho_zo(left: N, right: N, bottom: N, top: N, znear: N, zfar: N) -> TMat4 { ortho_rh_zo(left, right, bottom, top, znear, zfar) } @@ -240,7 +240,7 @@ pub fn ortho_zo(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { perspective_fov_rh_no(fov, width, height, near, far) } @@ -254,7 +254,7 @@ pub fn perspective_fov(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_lh(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { perspective_fov_lh_no(fov, width, height, near, far) } @@ -268,7 +268,7 @@ pub fn perspective_fov_lh(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_lh_no(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { assert!( width > N::zero(), "The width must be greater than zero" @@ -307,7 +307,7 @@ pub fn perspective_fov_lh_no(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_lh_zo(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { assert!( width > N::zero(), "The width must be greater than zero" @@ -346,7 +346,7 @@ pub fn perspective_fov_lh_zo(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_no(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { perspective_fov_rh_no(fov, width, height, near, far) } @@ -360,7 +360,7 @@ pub fn perspective_fov_no(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_rh(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { perspective_fov_rh_no(fov, width, height, near, far) } @@ -374,7 +374,7 @@ pub fn perspective_fov_rh(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_rh_no(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { assert!( width > N::zero(), "The width must be greater than zero" @@ -413,7 +413,7 @@ pub fn perspective_fov_rh_no(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_rh_zo(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { assert!( width > N::zero(), "The width must be greater than zero" @@ -452,7 +452,7 @@ pub fn perspective_fov_rh_zo(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(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { +pub fn perspective_fov_zo(fov: N, width: N, height: N, near: N, far: N) -> TMat4 { perspective_fov_rh_zo(fov, width, height, near, far) } @@ -467,7 +467,7 @@ pub fn perspective_fov_zo(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective(aspect: N, fovy: N, near: N, far: N) -> TMat4 { // 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(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_lh(aspect: N, fovy: N, near: N, far: N) -> TMat4 { perspective_lh_no(aspect, fovy, near, far) } @@ -511,7 +511,7 @@ pub fn perspective_lh(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_no(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_lh_no(aspect: N, fovy: N, near: N, far: N) -> TMat4 { 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(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_lh_zo(aspect: N, fovy: N, near: N, far: N) -> TMat4 { 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(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_no(aspect: N, fovy: N, near: N, far: N) -> TMat4 { perspective_rh_no(aspect, fovy, near, far) } @@ -598,7 +598,7 @@ pub fn perspective_no(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_rh(aspect: N, fovy: N, near: N, far: N) -> TMat4 { perspective_rh_no(aspect, fovy, near, far) } @@ -613,7 +613,7 @@ pub fn perspective_rh(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_no(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_rh_no(aspect: N, fovy: N, near: N, far: N) -> TMat4 { 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(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_rh_zo(aspect: N, fovy: N, near: N, far: N) -> TMat4 { 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(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(aspect: N, fovy: N, near: N, far: N) -> TMat4 { +pub fn perspective_zo(aspect: N, fovy: N, near: N, far: N) -> TMat4 { perspective_rh_zo(aspect, fovy, near, far) } -//pub fn tweaked_infinite_perspective(fovy: N, aspect: N, near: N) -> TMat4 { +//pub fn tweaked_infinite_perspective(fovy: N, aspect: N, near: N) -> TMat4 { // unimplemented!() //} // -//pub fn tweaked_infinite_perspective_ep(fovy: N, aspect: N, near: N, ep: N) -> TMat4 { +//pub fn tweaked_infinite_perspective_ep(fovy: N, aspect: N, near: N, ep: N) -> TMat4 { // unimplemented!() //} diff --git a/nalgebra-glm/src/ext/matrix_projection.rs b/nalgebra-glm/src/ext/matrix_projection.rs index 8083b1eb..3048b77c 100644 --- a/nalgebra-glm/src/ext/matrix_projection.rs +++ b/nalgebra-glm/src/ext/matrix_projection.rs @@ -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(center: &TVec2, delta: &TVec2, viewport: &TVec4) -> TMat4 { +pub fn pick_matrix(center: &TVec2, delta: &TVec2, viewport: &TVec4) -> TMat4 { 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(center: &TVec2, delta: &TVec2, viewport: &TVec /// * [`unproject`](fn.unproject.html) /// * [`unproject_no`](fn.unproject_no.html) /// * [`unproject_zo`](fn.unproject_zo.html) -pub fn project( +pub fn project( obj: &TVec3, model: &TMat4, proj: &TMat4, @@ -69,7 +69,7 @@ pub fn project( /// * [`unproject`](fn.unproject.html) /// * [`unproject_no`](fn.unproject_no.html) /// * [`unproject_zo`](fn.unproject_zo.html) -pub fn project_no( +pub fn project_no( obj: &TVec3, model: &TMat4, proj: &TMat4, @@ -98,7 +98,7 @@ pub fn project_no( /// * [`unproject`](fn.unproject.html) /// * [`unproject_no`](fn.unproject_no.html) /// * [`unproject_zo`](fn.unproject_zo.html) -pub fn project_zo( +pub fn project_zo( obj: &TVec3, model: &TMat4, proj: &TMat4, @@ -132,7 +132,7 @@ pub fn project_zo( /// * [`project_zo`](fn.project_zo.html) /// * [`unproject_no`](fn.unproject_no.html) /// * [`unproject_zo`](fn.unproject_zo.html) -pub fn unproject( +pub fn unproject( win: &TVec3, model: &TMat4, proj: &TMat4, @@ -160,7 +160,7 @@ pub fn unproject( /// * [`project_zo`](fn.project_zo.html) /// * [`unproject`](fn.unproject.html) /// * [`unproject_zo`](fn.unproject_zo.html) -pub fn unproject_no( +pub fn unproject_no( win: &TVec3, model: &TMat4, proj: &TMat4, @@ -198,7 +198,7 @@ pub fn unproject_no( /// * [`project_zo`](fn.project_zo.html) /// * [`unproject`](fn.unproject.html) /// * [`unproject_no`](fn.unproject_no.html) -pub fn unproject_zo( +pub fn unproject_zo( win: &TVec3, model: &TMat4, proj: &TMat4, diff --git a/nalgebra-glm/src/ext/matrix_transform.rs b/nalgebra-glm/src/ext/matrix_transform.rs index 8265cc19..c7f6b72d 100644 --- a/nalgebra-glm/src/ext/matrix_transform.rs +++ b/nalgebra-glm/src/ext/matrix_transform.rs @@ -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 { /// /// * [`look_at_lh`](fn.look_at_lh.html) /// * [`look_at_rh`](fn.look_at_rh.html) -pub fn look_at(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { +pub fn look_at(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { look_at_rh(eye, center, up) } @@ -37,7 +37,7 @@ pub fn look_at(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMa /// /// * [`look_at`](fn.look_at.html) /// * [`look_at_rh`](fn.look_at_rh.html) -pub fn look_at_lh(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { +pub fn look_at_lh(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { TMat::look_at_lh(&Point3::from(*eye), &Point3::from(*center), up) } @@ -53,7 +53,7 @@ pub fn look_at_lh(eye: &TVec3, center: &TVec3, up: &TVec3) -> /// /// * [`look_at`](fn.look_at.html) /// * [`look_at_lh`](fn.look_at_lh.html) -pub fn look_at_rh(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { +pub fn look_at_rh(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { TMat::look_at_rh(&Point3::from(*eye), &Point3::from(*center), up) } @@ -72,7 +72,7 @@ pub fn look_at_rh(eye: &TVec3, center: &TVec3, up: &TVec3) -> /// * [`rotate_z`](fn.rotate_z.html) /// * [`scale`](fn.scale.html) /// * [`translate`](fn.translate.html) -pub fn rotate(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { +pub fn rotate(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { m * Rotation3::from_axis_angle(&Unit::new_normalize(*axis), angle).to_homogeneous() } @@ -90,7 +90,7 @@ pub fn rotate(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { /// * [`rotate_z`](fn.rotate_z.html) /// * [`scale`](fn.scale.html) /// * [`translate`](fn.translate.html) -pub fn rotate_x(m: &TMat4, angle: N) -> TMat4 { +pub fn rotate_x(m: &TMat4, angle: N) -> TMat4 { rotate(m, angle, &TVec::x()) } @@ -108,7 +108,7 @@ pub fn rotate_x(m: &TMat4, angle: N) -> TMat4 { /// * [`rotate_z`](fn.rotate_z.html) /// * [`scale`](fn.scale.html) /// * [`translate`](fn.translate.html) -pub fn rotate_y(m: &TMat4, angle: N) -> TMat4 { +pub fn rotate_y(m: &TMat4, angle: N) -> TMat4 { rotate(m, angle, &TVec::y()) } @@ -126,7 +126,7 @@ pub fn rotate_y(m: &TMat4, angle: N) -> TMat4 { /// * [`rotate_y`](fn.rotate_y.html) /// * [`scale`](fn.scale.html) /// * [`translate`](fn.translate.html) -pub fn rotate_z(m: &TMat4, angle: N) -> TMat4 { +pub fn rotate_z(m: &TMat4, angle: N) -> TMat4 { rotate(m, angle, &TVec::z()) } diff --git a/nalgebra-glm/src/ext/quaternion_common.rs b/nalgebra-glm/src/ext/quaternion_common.rs index 29150bf6..072b57e2 100644 --- a/nalgebra-glm/src/ext/quaternion_common.rs +++ b/nalgebra-glm/src/ext/quaternion_common.rs @@ -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(q: &Qua) -> Qua { +pub fn quat_conjugate(q: &Qua) -> Qua { q.conjugate() } /// The inverse of `q`. -pub fn quat_inverse(q: &Qua) -> Qua { +pub fn quat_inverse(q: &Qua) -> Qua { q.try_inverse().unwrap_or_else(na::zero) } -//pub fn quat_isinf(x: &Qua) -> TVec { +//pub fn quat_isinf(x: &Qua) -> TVec { // x.coords.map(|e| e.is_inf()) //} -//pub fn quat_isnan(x: &Qua) -> TVec { +//pub fn quat_isnan(x: &Qua) -> TVec { // x.coords.map(|e| e.is_nan()) //} /// Interpolate linearly between `x` and `y`. -pub fn quat_lerp(x: &Qua, y: &Qua, a: N) -> Qua { +pub fn quat_lerp(x: &Qua, y: &Qua, a: N) -> Qua { x.lerp(y, a) } -//pub fn quat_mix(x: &Qua, y: &Qua, a: N) -> Qua { +//pub fn quat_mix(x: &Qua, y: &Qua, a: N) -> Qua { // x * (N::one() - a) + y * a //} /// Interpolate spherically between `x` and `y`. -pub fn quat_slerp(x: &Qua, y: &Qua, a: N) -> Qua { +pub fn quat_slerp(x: &Qua, y: &Qua, a: N) -> Qua { Unit::new_normalize(*x) .slerp(&Unit::new_normalize(*y), a) .into_inner() diff --git a/nalgebra-glm/src/ext/quaternion_geometric.rs b/nalgebra-glm/src/ext/quaternion_geometric.rs index 29356869..24d9310d 100644 --- a/nalgebra-glm/src/ext/quaternion_geometric.rs +++ b/nalgebra-glm/src/ext/quaternion_geometric.rs @@ -1,28 +1,28 @@ -use na::Real; +use na::RealField; use crate::aliases::Qua; /// Multiplies two quaternions. -pub fn quat_cross(q1: &Qua, q2: &Qua) -> Qua { +pub fn quat_cross(q1: &Qua, q2: &Qua) -> Qua { q1 * q2 } /// The scalar product of two quaternions. -pub fn quat_dot(x: &Qua, y: &Qua) -> N { +pub fn quat_dot(x: &Qua, y: &Qua) -> N { x.dot(y) } /// The magnitude of the quaternion `q`. -pub fn quat_length(q: &Qua) -> N { +pub fn quat_length(q: &Qua) -> N { q.norm() } /// The magnitude of the quaternion `q`. -pub fn quat_magnitude(q: &Qua) -> N { +pub fn quat_magnitude(q: &Qua) -> N { q.norm() } /// Normalizes the quaternion `q`. -pub fn quat_normalize(q: &Qua) -> Qua { +pub fn quat_normalize(q: &Qua) -> Qua { q.normalize() } diff --git a/nalgebra-glm/src/ext/quaternion_relational.rs b/nalgebra-glm/src/ext/quaternion_relational.rs index ff4c6b01..bd24edbe 100644 --- a/nalgebra-glm/src/ext/quaternion_relational.rs +++ b/nalgebra-glm/src/ext/quaternion_relational.rs @@ -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(x: &Qua, y: &Qua) -> TVec { +pub fn quat_equal(x: &Qua, y: &Qua) -> TVec { crate::equal(&x.coords, &y.coords) } /// Component-wise approximate equality comparison between two quaternions. -pub fn quat_equal_eps(x: &Qua, y: &Qua, epsilon: N) -> TVec { +pub fn quat_equal_eps(x: &Qua, y: &Qua, epsilon: N) -> TVec { crate::equal_eps(&x.coords, &y.coords, epsilon) } /// Component-wise non-equality comparison between two quaternions. -pub fn quat_not_equal(x: &Qua, y: &Qua) -> TVec { +pub fn quat_not_equal(x: &Qua, y: &Qua) -> TVec { crate::not_equal(&x.coords, &y.coords) } /// Component-wise approximate non-equality comparison between two quaternions. -pub fn quat_not_equal_eps(x: &Qua, y: &Qua, epsilon: N) -> TVec { +pub fn quat_not_equal_eps(x: &Qua, y: &Qua, epsilon: N) -> TVec { crate::not_equal_eps(&x.coords, &y.coords, epsilon) } diff --git a/nalgebra-glm/src/ext/quaternion_transform.rs b/nalgebra-glm/src/ext/quaternion_transform.rs index 4f3f4211..1e4e9771 100644 --- a/nalgebra-glm/src/ext/quaternion_transform.rs +++ b/nalgebra-glm/src/ext/quaternion_transform.rs @@ -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(q: &Qua) -> Qua { +pub fn quat_exp(q: &Qua) -> Qua { q.exp() } /// Computes the quaternion logarithm. -pub fn quat_log(q: &Qua) -> Qua { +pub fn quat_log(q: &Qua) -> Qua { q.ln() } /// Raises the quaternion `q` to the power `y`. -pub fn quat_pow(q: &Qua, y: N) -> Qua { +pub fn quat_pow(q: &Qua, y: N) -> Qua { q.powf(y) } /// Builds a quaternion from an axis and an angle, and right-multiply it to the quaternion `q`. -pub fn quat_rotate(q: &Qua, angle: N, axis: &TVec3) -> Qua { +pub fn quat_rotate(q: &Qua, angle: N, axis: &TVec3) -> Qua { q * UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).into_inner() } -//pub fn quat_sqrt(q: &Qua) -> Qua { +//pub fn quat_sqrt(q: &Qua) -> Qua { // unimplemented!() //} diff --git a/nalgebra-glm/src/ext/quaternion_trigonometric.rs b/nalgebra-glm/src/ext/quaternion_trigonometric.rs index 42833f05..a711e69a 100644 --- a/nalgebra-glm/src/ext/quaternion_trigonometric.rs +++ b/nalgebra-glm/src/ext/quaternion_trigonometric.rs @@ -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(x: &Qua) -> N { +pub fn quat_angle(x: &Qua) -> N { UnitQuaternion::from_quaternion(*x).angle() } /// Creates a quaternion from an axis and an angle. -pub fn quat_angle_axis(angle: N, axis: &TVec3) -> Qua { +pub fn quat_angle_axis(angle: N, axis: &TVec3) -> Qua { 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(x: &Qua) -> TVec3 { +pub fn quat_axis(x: &Qua) -> TVec3 { if let Some(a) = UnitQuaternion::from_quaternion(*x).axis() { a.into_inner() } else { diff --git a/nalgebra-glm/src/ext/scalar_constants.rs b/nalgebra-glm/src/ext/scalar_constants.rs index 2b9ed14d..e0741465 100644 --- a/nalgebra-glm/src/ext/scalar_constants.rs +++ b/nalgebra-glm/src/ext/scalar_constants.rs @@ -1,5 +1,5 @@ use approx::AbsDiffEq; -use na::Real; +use na::RealField; /// Default epsilon value used for approximate comparison. pub fn epsilon>() -> N { @@ -22,6 +22,6 @@ pub fn epsilon>() -> 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 { +pub fn pi() -> N { N::pi() } diff --git a/nalgebra-glm/src/geometric.rs b/nalgebra-glm/src/geometric.rs index a0706f75..ffdc825a 100644 --- a/nalgebra-glm/src/geometric.rs +++ b/nalgebra-glm/src/geometric.rs @@ -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(x: &TVec3, y: &TVec3) -> TVec3 { /// # See also: /// /// * [`distance2`](fn.distance2.html) -pub fn distance(p0: &TVec, p1: &TVec) -> N +pub fn distance(p0: &TVec, p1: &TVec) -> N where DefaultAllocator: Alloc { (p1 - p0).norm() } @@ -49,7 +49,7 @@ where /// * [`length2`](fn.length2.html) /// * [`magnitude`](fn.magnitude.html) /// * [`magnitude2`](fn.magnitude2.html) -pub fn length(x: &TVec) -> N +pub fn length(x: &TVec) -> N where DefaultAllocator: Alloc { x.norm() } @@ -63,13 +63,13 @@ where DefaultAllocator: Alloc { /// * [`length`](fn.length.html) /// * [`magnitude2`](fn.magnitude2.html) /// * [`nalgebra::norm`](../nalgebra/fn.norm.html) -pub fn magnitude(x: &TVec) -> N +pub fn magnitude(x: &TVec) -> N where DefaultAllocator: Alloc { x.norm() } /// Normalizes a vector. -pub fn normalize(x: &TVec) -> TVec +pub fn normalize(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.normalize() } @@ -82,7 +82,7 @@ where DefaultAllocator: Alloc { } /// 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(i: &TVec, n: &TVec, eta: N) -> TVec +pub fn refract_vec(i: &TVec, n: &TVec, eta: N) -> TVec where DefaultAllocator: Alloc { let ni = n.dot(i); let k = N::one() - eta * eta * (N::one() - ni * ni); diff --git a/nalgebra-glm/src/gtc/constants.rs b/nalgebra-glm/src/gtc/constants.rs index 9407cf29..4112d65e 100644 --- a/nalgebra-glm/src/gtc/constants.rs +++ b/nalgebra-glm/src/gtc/constants.rs @@ -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 { +pub fn e() -> N { N::e() } /// The Euler constant. -pub fn euler() -> N { +pub fn euler() -> N { N::e() } @@ -28,12 +28,12 @@ pub fn euler() -> 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 { +pub fn four_over_pi() -> N { na::convert::<_, N>(4.0) / N::pi() } /// Returns the golden ratio. -pub fn golden_ratio() -> N { +pub fn golden_ratio() -> N { (N::one() + root_five()) / na::convert(2.0) } @@ -53,7 +53,7 @@ pub fn golden_ratio() -> 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 { +pub fn half_pi() -> N { N::frac_pi_2() } @@ -63,7 +63,7 @@ pub fn half_pi() -> N { /// /// * [`ln_ten`](fn.ln_ten.html) /// * [`ln_two`](fn.ln_two.html) -pub fn ln_ln_two() -> N { +pub fn ln_ln_two() -> N { N::ln_2().ln() } @@ -73,7 +73,7 @@ pub fn ln_ln_two() -> N { /// /// * [`ln_ln_two`](fn.ln_ln_two.html) /// * [`ln_two`](fn.ln_two.html) -pub fn ln_ten() -> N { +pub fn ln_ten() -> N { N::ln_10() } @@ -83,7 +83,7 @@ pub fn ln_ten() -> N { /// /// * [`ln_ln_two`](fn.ln_ln_two.html) /// * [`ln_ten`](fn.ln_ten.html) -pub fn ln_two() -> N { +pub fn ln_two() -> 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 { +pub fn one_over_pi() -> N { N::frac_1_pi() } /// Returns `1 / sqrt(2)`. -pub fn one_over_root_two() -> N { +pub fn one_over_root_two() -> N { N::one() / root_two() } @@ -131,7 +131,7 @@ pub fn one_over_root_two() -> 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 { +pub fn one_over_two_pi() -> N { N::frac_1_pi() * na::convert(0.5) } @@ -151,7 +151,7 @@ pub fn one_over_two_pi() -> 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 { +pub fn quarter_pi() -> N { N::frac_pi_4() } @@ -161,7 +161,7 @@ pub fn quarter_pi() -> N { /// /// * [`root_three`](fn.root_three.html) /// * [`root_two`](fn.root_two.html) -pub fn root_five() -> N { +pub fn root_five() -> N { na::convert::<_, N>(5.0).sqrt() } @@ -181,12 +181,12 @@ pub fn root_five() -> 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 { +pub fn root_half_pi() -> N { (N::pi() / na::convert(2.0)).sqrt() } /// Returns `sqrt(ln(4))`. -pub fn root_ln_four() -> N { +pub fn root_ln_four() -> N { na::convert::<_, N>(4.0).ln().sqrt() } @@ -206,7 +206,7 @@ pub fn root_ln_four() -> 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 { +pub fn root_pi() -> N { N::pi().sqrt() } @@ -216,7 +216,7 @@ pub fn root_pi() -> N { /// /// * [`root_five`](fn.root_five.html) /// * [`root_two`](fn.root_two.html) -pub fn root_three() -> N { +pub fn root_three() -> N { na::convert::<_, N>(3.0).sqrt() } @@ -226,8 +226,8 @@ pub fn root_three() -> N { /// /// * [`root_five`](fn.root_five.html) /// * [`root_three`](fn.root_three.html) -pub fn root_two() -> N { - // FIXME: there should be a crate::sqrt_2() on the Real trait. +pub fn root_two() -> 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 { /// * [`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 { +pub fn root_two_pi() -> N { N::two_pi().sqrt() } @@ -256,7 +256,7 @@ pub fn root_two_pi() -> N { /// # See also: /// /// * [`two_thirds`](fn.two_thirds.html) -pub fn third() -> N { +pub fn third() -> N { na::convert(1.0 / 3.0) } @@ -276,7 +276,7 @@ pub fn third() -> 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 { +pub fn three_over_two_pi() -> N { na::convert::<_, N>(3.0) / N::two_pi() } @@ -295,7 +295,7 @@ pub fn three_over_two_pi() -> 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 { +pub fn two_over_pi() -> N { N::frac_2_pi() } @@ -315,7 +315,7 @@ pub fn two_over_pi() -> 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 { +pub fn two_over_root_pi() -> N { N::frac_2_sqrt_pi() } @@ -335,7 +335,7 @@ pub fn two_over_root_pi() -> 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 { +pub fn two_pi() -> N { N::two_pi() } @@ -344,7 +344,7 @@ pub fn two_pi() -> N { /// # See also: /// /// * [`third`](fn.third.html) -pub fn two_thirds() -> N { +pub fn two_thirds() -> N { na::convert(2.0 / 3.0) } diff --git a/nalgebra-glm/src/gtc/matrix_inverse.rs b/nalgebra-glm/src/gtc/matrix_inverse.rs index ca390bb9..eab0b995 100644 --- a/nalgebra-glm/src/gtc/matrix_inverse.rs +++ b/nalgebra-glm/src/gtc/matrix_inverse.rs @@ -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(m: TMat) -> TMat +pub fn affine_inverse(m: TMat) -> TMat where DefaultAllocator: Alloc { // 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(m: TMat) -> TMat +pub fn inverse_transpose(m: TMat) -> TMat where DefaultAllocator: Alloc { m.try_inverse() .unwrap_or_else(TMat::<_, D, D>::zeros) diff --git a/nalgebra-glm/src/gtc/packing.rs b/nalgebra-glm/src/gtc/packing.rs index ab6019b3..ea5acac4 100644 --- a/nalgebra-glm/src/gtc/packing.rs +++ b/nalgebra-glm/src/gtc/packing.rs @@ -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(rgb: &TVec3) -> TVec4 { unimplemented!() } -pub fn packSnorm(v: TVec) -> TVec +pub fn packSnorm(v: TVec) -> TVec where DefaultAllocator: Alloc + Alloc { unimplemented!() } @@ -102,7 +102,7 @@ pub fn packUint4x8(v: &U8Vec4) -> i32 { unimplemented!() } -pub fn packUnorm(v: &TVec) -> TVec +pub fn packUnorm(v: &TVec) -> TVec where DefaultAllocator: Alloc + Alloc { unimplemented!() } @@ -196,7 +196,7 @@ pub fn unpackRGBM(rgbm: &TVec4) -> TVec3 { unimplemented!() } -pub fn unpackSnorm(v: &TVec) -> TVec +pub fn unpackSnorm(v: &TVec) -> TVec where DefaultAllocator: Alloc + Alloc { unimplemented!() } @@ -245,7 +245,7 @@ pub fn unpackUint4x8(p: i32) -> U8Vec4 { unimplemented!() } -pub fn unpackUnorm(v: &TVec) -> TVec +pub fn unpackUnorm(v: &TVec) -> TVec where DefaultAllocator: Alloc + Alloc { unimplemented!() } diff --git a/nalgebra-glm/src/gtc/quaternion.rs b/nalgebra-glm/src/gtc/quaternion.rs index 9322ec0a..36977e96 100644 --- a/nalgebra-glm/src/gtc/quaternion.rs +++ b/nalgebra-glm/src/gtc/quaternion.rs @@ -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(x: &Qua) -> TVec3 { +pub fn quat_euler_angles(x: &Qua) -> TVec3 { 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(x: &Qua, y: &Qua) -> TVec { +pub fn quat_greater_than(x: &Qua, y: &Qua) -> TVec { crate::greater_than(&x.coords, &y.coords) } /// Component-wise `>=` comparison between two quaternions. -pub fn quat_greater_than_equal(x: &Qua, y: &Qua) -> TVec { +pub fn quat_greater_than_equal(x: &Qua, y: &Qua) -> TVec { crate::greater_than_equal(&x.coords, &y.coords) } /// Component-wise `<` comparison between two quaternions. -pub fn quat_less_than(x: &Qua, y: &Qua) -> TVec { +pub fn quat_less_than(x: &Qua, y: &Qua) -> TVec { crate::less_than(&x.coords, &y.coords) } /// Component-wise `<=` comparison between two quaternions. -pub fn quat_less_than_equal(x: &Qua, y: &Qua) -> TVec { +pub fn quat_less_than_equal(x: &Qua, y: &Qua) -> TVec { crate::less_than_equal(&x.coords, &y.coords) } /// Convert a quaternion to a rotation matrix in homogeneous coordinates. -pub fn quat_cast(x: &Qua) -> TMat4 { +pub fn quat_cast(x: &Qua) -> TMat4 { crate::quat_to_mat4(x) } @@ -41,34 +41,34 @@ pub fn quat_cast(x: &Qua) -> TMat4 { /// * `direction` - Direction vector point at where to look /// * `up` - Object up vector /// -pub fn quat_look_at(direction: &TVec3, up: &TVec3) -> Qua { +pub fn quat_look_at(direction: &TVec3, up: &TVec3) -> Qua { 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(direction: &TVec3, up: &TVec3) -> Qua { +pub fn quat_look_at_lh(direction: &TVec3, up: &TVec3) -> Qua { 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(direction: &TVec3, up: &TVec3) -> Qua { +pub fn quat_look_at_rh(direction: &TVec3, up: &TVec3) -> Qua { UnitQuaternion::look_at_rh(direction, up).into_inner() } /// The "roll" Euler angle of the quaternion `x` assumed to be normalized. -pub fn quat_roll(x: &Qua) -> N { +pub fn quat_roll(x: &Qua) -> 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(x: &Qua) -> N { +pub fn quat_yaw(x: &Qua) -> 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(x: &Qua) -> N { +pub fn quat_pitch(x: &Qua) -> N { // FIXME: optimize this. quat_euler_angles(x).x } diff --git a/nalgebra-glm/src/gtc/round.rs b/nalgebra-glm/src/gtc/round.rs index 8dde578d..5ad95780 100644 --- a/nalgebra-glm/src/gtc/round.rs +++ b/nalgebra-glm/src/gtc/round.rs @@ -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; diff --git a/nalgebra-glm/src/gtc/type_ptr.rs b/nalgebra-glm/src/gtc/type_ptr.rs index 48ef9da5..4029bf01 100644 --- a/nalgebra-glm/src/gtc/type_ptr.rs +++ b/nalgebra-glm/src/gtc/type_ptr.rs @@ -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(m: &TMat4) -> TMat2 { } /// Creates a quaternion from a slice arranged as `[x, y, z, w]`. -pub fn make_quat(ptr: &[N]) -> Qua { +pub fn make_quat(ptr: &[N]) -> Qua { Quaternion::from(TVec4::from_column_slice(ptr)) } diff --git a/nalgebra-glm/src/gtx/euler_angles.rs b/nalgebra-glm/src/gtx/euler_angles.rs index 30be40bf..c9d16738 100644 --- a/nalgebra-glm/src/gtx/euler_angles.rs +++ b/nalgebra-glm/src/gtx/euler_angles.rs @@ -1,163 +1,163 @@ -use na::{Real, U3, U4}; +use na::{RealField, U3, U4}; use crate::aliases::{TVec, TMat}; -pub fn derivedEulerAngleX(angleX: N, angularVelocityX: N) -> TMat4 { +pub fn derivedEulerAngleX(angleX: N, angularVelocityX: N) -> TMat4 { unimplemented!() } -pub fn derivedEulerAngleY(angleY: N, angularVelocityY: N) -> TMat4 { +pub fn derivedEulerAngleY(angleY: N, angularVelocityY: N) -> TMat4 { unimplemented!() } -pub fn derivedEulerAngleZ(angleZ: N, angularVelocityZ: N) -> TMat4 { +pub fn derivedEulerAngleZ(angleZ: N, angularVelocityZ: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleX(angleX: N) -> TMat4 { +pub fn eulerAngleX(angleX: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleXY(angleX: N, angleY: N) -> TMat4 { +pub fn eulerAngleXY(angleX: N, angleY: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleXYX(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleXYX(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleXYZ(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleXYZ(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleXZ(angleX: N, angleZ: N) -> TMat4 { +pub fn eulerAngleXZ(angleX: N, angleZ: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleXZX(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleXZX(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleXZY(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleXZY(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleY(angleY: N) -> TMat4 { +pub fn eulerAngleY(angleY: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleYX(angleY: N, angleX: N) -> TMat4 { +pub fn eulerAngleYX(angleY: N, angleX: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleYXY(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleYXY(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleYXZ(yaw: N, pitch: N, roll: N) -> TMat4 { +pub fn eulerAngleYXZ(yaw: N, pitch: N, roll: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleYZ(angleY: N, angleZ: N) -> TMat4 { +pub fn eulerAngleYZ(angleY: N, angleZ: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleYZX(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleYZX(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleYZY(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleYZY(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZ(angleZ: N) -> TMat4 { +pub fn eulerAngleZ(angleZ: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZX(angle: N, angleX: N) -> TMat4 { +pub fn eulerAngleZX(angle: N, angleX: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZXY(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleZXY(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZXZ(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleZXZ(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZY(angleZ: N, angleY: N) -> TMat4 { +pub fn eulerAngleZY(angleZ: N, angleY: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZYX(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleZYX(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn eulerAngleZYZ(t1: N, t2: N, t3: N) -> TMat4 { +pub fn eulerAngleZYZ(t1: N, t2: N, t3: N) -> TMat4 { unimplemented!() } -pub fn extractEulerAngleXYX(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleXYX(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleXYZ(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleXYZ(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleXZX(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleXZX(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleXZY(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleXZY(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleYXY(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleYXY(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleYXZ(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleYXZ(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleYZX(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleYZX(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleYZY(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleYZY(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleZXY(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleZXY(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleZXZ(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleZXZ(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleZYX(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleZYX(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn extractEulerAngleZYZ(M: &TMat4) -> (N, N, N) { +pub fn extractEulerAngleZYZ(M: &TMat4) -> (N, N, N) { unimplemented!() } -pub fn orientate2(angle: N) -> TMat3x3 { +pub fn orientate2(angle: N) -> TMat3x3 { unimplemented!() } -pub fn orientate3(angles: TVec3) -> TMat3x3 { +pub fn orientate3(angles: TVec3) -> TMat3x3 { unimplemented!() } -pub fn orientate4(angles: TVec3) -> TMat4 { +pub fn orientate4(angles: TVec3) -> TMat4 { unimplemented!() } -pub fn yawPitchRoll(yaw: N, pitch: N, roll: N) -> TMat4 { +pub fn yawPitchRoll(yaw: N, pitch: N, roll: N) -> TMat4 { unimplemented!() } diff --git a/nalgebra-glm/src/gtx/matrix_cross_product.rs b/nalgebra-glm/src/gtx/matrix_cross_product.rs index ac113e42..40aa03e8 100644 --- a/nalgebra-glm/src/gtx/matrix_cross_product.rs +++ b/nalgebra-glm/src/gtx/matrix_cross_product.rs @@ -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(x: &TVec3) -> TMat3 { +pub fn matrix_cross3(x: &TVec3) -> TMat3 { x.cross_matrix() } @@ -16,6 +16,6 @@ pub fn matrix_cross3(x: &TVec3) -> TMat3 { /// # See also: /// /// * [`matrix_cross3`](fn.matrix_cross3.html) -pub fn matrix_cross(x: &TVec3) -> TMat4 { +pub fn matrix_cross(x: &TVec3) -> TMat4 { crate::mat3_to_mat4(&x.cross_matrix()) } diff --git a/nalgebra-glm/src/gtx/norm.rs b/nalgebra-glm/src/gtx/norm.rs index 4450cdff..9332c010 100644 --- a/nalgebra-glm/src/gtx/norm.rs +++ b/nalgebra-glm/src/gtx/norm.rs @@ -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(p0: &TVec, p1: &TVec) -> N +pub fn distance2(p0: &TVec, p1: &TVec) -> N where DefaultAllocator: Alloc { (p1 - p0).norm_squared() } @@ -20,7 +20,7 @@ where DefaultAllocator: Alloc { /// * [`l1_norm`](fn.l1_norm.html) /// * [`l2_distance`](fn.l2_distance.html) /// * [`l2_norm`](fn.l2_norm.html) -pub fn l1_distance(x: &TVec, y: &TVec) -> N +pub fn l1_distance(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { l1_norm(&(y - x)) } @@ -35,7 +35,7 @@ where DefaultAllocator: Alloc { /// * [`l1_distance`](fn.l1_distance.html) /// * [`l2_distance`](fn.l2_distance.html) /// * [`l2_norm`](fn.l2_norm.html) -pub fn l1_norm(v: &TVec) -> N +pub fn l1_norm(v: &TVec) -> N where DefaultAllocator: Alloc { crate::comp_add(&v.abs()) } @@ -54,7 +54,7 @@ where DefaultAllocator: Alloc { /// * [`length2`](fn.length2.html) /// * [`magnitude`](fn.magnitude.html) /// * [`magnitude2`](fn.magnitude2.html) -pub fn l2_distance(x: &TVec, y: &TVec) -> N +pub fn l2_distance(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { l2_norm(&(y - x)) } @@ -75,7 +75,7 @@ where DefaultAllocator: Alloc { /// * [`length2`](fn.length2.html) /// * [`magnitude`](fn.magnitude.html) /// * [`magnitude2`](fn.magnitude2.html) -pub fn l2_norm(x: &TVec) -> N +pub fn l2_norm(x: &TVec) -> N where DefaultAllocator: Alloc { x.norm() } @@ -91,7 +91,7 @@ where DefaultAllocator: Alloc { /// * [`length`](fn.length.html) /// * [`magnitude`](fn.magnitude.html) /// * [`magnitude2`](fn.magnitude2.html) -pub fn length2(x: &TVec) -> N +pub fn length2(x: &TVec) -> N where DefaultAllocator: Alloc { x.norm_squared() } @@ -107,17 +107,17 @@ where DefaultAllocator: Alloc { /// * [`length2`](fn.length2.html) /// * [`magnitude`](fn.magnitude.html) /// * [`nalgebra::norm_squared`](../nalgebra/fn.norm_squared.html) -pub fn magnitude2(x: &TVec) -> N +pub fn magnitude2(x: &TVec) -> N where DefaultAllocator: Alloc { x.norm_squared() } -//pub fn lxNorm(x: &TVec, y: &TVec, unsigned int Depth) -> N +//pub fn lxNorm(x: &TVec, y: &TVec, unsigned int Depth) -> N // where DefaultAllocator: Alloc { // unimplemented!() //} // -//pub fn lxNorm(x: &TVec, unsigned int Depth) -> N +//pub fn lxNorm(x: &TVec, unsigned int Depth) -> N // where DefaultAllocator: Alloc { // unimplemented!() //} diff --git a/nalgebra-glm/src/gtx/normal.rs b/nalgebra-glm/src/gtx/normal.rs index da3287fb..d9f48034 100644 --- a/nalgebra-glm/src/gtx/normal.rs +++ b/nalgebra-glm/src/gtx/normal.rs @@ -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(p1: &TVec3, p2: &TVec3, p3: &TVec3) -> TVec3 { +pub fn triangle_normal(p1: &TVec3, p2: &TVec3, p3: &TVec3) -> TVec3 { (p2 - p1).cross(&(p3 - p1)).normalize() } diff --git a/nalgebra-glm/src/gtx/normalize_dot.rs b/nalgebra-glm/src/gtx/normalize_dot.rs index 6bce441b..06ce6978 100644 --- a/nalgebra-glm/src/gtx/normalize_dot.rs +++ b/nalgebra-glm/src/gtx/normalize_dot.rs @@ -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(x: &TVec, y: &TVec) -> N +pub fn fast_normalize_dot(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { // XXX: improve those. x.normalize().dot(&y.normalize()) @@ -21,7 +21,7 @@ where DefaultAllocator: Alloc { /// # See also: /// /// * [`fast_normalize_dot`](fn.fast_normalize_dot.html`) -pub fn normalize_dot(x: &TVec, y: &TVec) -> N +pub fn normalize_dot(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { // XXX: improve those. x.normalize().dot(&y.normalize()) diff --git a/nalgebra-glm/src/gtx/quaternion.rs b/nalgebra-glm/src/gtx/quaternion.rs index 5c9a783c..a90760d4 100644 --- a/nalgebra-glm/src/gtx/quaternion.rs +++ b/nalgebra-glm/src/gtx/quaternion.rs @@ -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(q: &Qua, v: &TVec3) -> TVec3 { +pub fn quat_cross_vec(q: &Qua, v: &TVec3) -> TVec3 { 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(v: &TVec3, q: &Qua) -> TVec3 { +pub fn quat_inv_cross_vec(v: &TVec3, q: &Qua) -> TVec3 { UnitQuaternion::new_unchecked(*q).inverse() * v } /// The quaternion `w` component. -pub fn quat_extract_real_component(q: &Qua) -> N { +pub fn quat_extract_real_component(q: &Qua) -> N { q.w } /// Normalized linear interpolation between two quaternions. -pub fn quat_fast_mix(x: &Qua, y: &Qua, a: N) -> Qua { +pub fn quat_fast_mix(x: &Qua, y: &Qua, a: N) -> Qua { Unit::new_unchecked(*x) .nlerp(&Unit::new_unchecked(*y), a) .into_inner() } -//pub fn quat_intermediate(prev: &Qua, curr: &Qua, next: &Qua) -> Qua { +//pub fn quat_intermediate(prev: &Qua, curr: &Qua, next: &Qua) -> Qua { // unimplemented!() //} /// The squared magnitude of a quaternion `q`. -pub fn quat_length2(q: &Qua) -> N { +pub fn quat_length2(q: &Qua) -> N { q.norm_squared() } /// The squared magnitude of a quaternion `q`. -pub fn quat_magnitude2(q: &Qua) -> N { +pub fn quat_magnitude2(q: &Qua) -> N { q.norm_squared() } /// The quaternion representing the identity rotation. -pub fn quat_identity() -> Qua { +pub fn quat_identity() -> Qua { UnitQuaternion::identity().into_inner() } /// Rotates a vector by a quaternion assumed to be normalized. -pub fn quat_rotate_vec3(q: &Qua, v: &TVec3) -> TVec3 { +pub fn quat_rotate_vec3(q: &Qua, v: &TVec3) -> TVec3 { UnitQuaternion::new_unchecked(*q) * v } /// Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized. -pub fn quat_rotate_vec(q: &Qua, v: &TVec4) -> TVec4 { +pub fn quat_rotate_vec(q: &Qua, v: &TVec4) -> TVec4 { let rotated = Unit::new_unchecked(*q) * v.fixed_rows::(0); TVec4::new(rotated.x, rotated.y, rotated.z, v.w) } /// The rotation required to align `orig` to `dest`. -pub fn quat_rotation(orig: &TVec3, dest: &TVec3) -> Qua { +pub fn quat_rotation(orig: &TVec3, dest: &TVec3) -> Qua { UnitQuaternion::rotation_between(orig, dest) .unwrap_or_else(UnitQuaternion::identity) .into_inner() } /// The spherical linear interpolation between two quaternions. -pub fn quat_short_mix(x: &Qua, y: &Qua, a: N) -> Qua { +pub fn quat_short_mix(x: &Qua, y: &Qua, a: N) -> Qua { Unit::new_normalize(*x) .slerp(&Unit::new_normalize(*y), a) .into_inner() } -//pub fn quat_squad(q1: &Qua, q2: &Qua, s1: &Qua, s2: &Qua, h: N) -> Qua { +//pub fn quat_squad(q1: &Qua, q2: &Qua, s1: &Qua, s2: &Qua, h: N) -> Qua { // unimplemented!() //} /// Converts a quaternion to a rotation matrix. -pub fn quat_to_mat3(x: &Qua) -> TMat3 { +pub fn quat_to_mat3(x: &Qua) -> TMat3 { UnitQuaternion::new_unchecked(*x) .to_rotation_matrix() .into_inner() } /// Converts a quaternion to a rotation matrix in homogenous coordinates. -pub fn quat_to_mat4(x: &Qua) -> TMat4 { +pub fn quat_to_mat4(x: &Qua) -> TMat4 { UnitQuaternion::new_unchecked(*x).to_homogeneous() } /// Converts a rotation matrix to a quaternion. -pub fn mat3_to_quat(x: &TMat3) -> Qua { +pub fn mat3_to_quat(x: &TMat3) -> Qua { 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(x: &TMat4) -> Qua { +pub fn to_quat(x: &TMat4) -> Qua { let rot = x.fixed_slice::(0, 0).into_owned(); mat3_to_quat(&rot) } diff --git a/nalgebra-glm/src/gtx/rotate_normalized_axis.rs b/nalgebra-glm/src/gtx/rotate_normalized_axis.rs index 6767248c..1672b978 100644 --- a/nalgebra-glm/src/gtx/rotate_normalized_axis.rs +++ b/nalgebra-glm/src/gtx/rotate_normalized_axis.rs @@ -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(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { +pub fn rotate_normalized_axis(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { m * Rotation3::from_axis_angle(&Unit::new_unchecked(*axis), angle).to_homogeneous() } @@ -20,6 +20,6 @@ pub fn rotate_normalized_axis(m: &TMat4, angle: N, axis: &TVec3) /// * `q` - Source orientation. /// * `angle` - Angle expressed in radians. /// * `axis` - Normalized axis of the rotation, must be normalized. -pub fn quat_rotate_normalized_axis(q: &Qua, angle: N, axis: &TVec3) -> Qua { +pub fn quat_rotate_normalized_axis(q: &Qua, angle: N, axis: &TVec3) -> Qua { q * UnitQuaternion::from_axis_angle(&Unit::new_unchecked(*axis), angle).into_inner() } diff --git a/nalgebra-glm/src/gtx/rotate_vector.rs b/nalgebra-glm/src/gtx/rotate_vector.rs index a8cdd72b..30abc767 100644 --- a/nalgebra-glm/src/gtx/rotate_vector.rs +++ b/nalgebra-glm/src/gtx/rotate_vector.rs @@ -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(normal: &TVec3, up: &TVec3) -> TMat4 { +pub fn orientation(normal: &TVec3, up: &TVec3) -> TMat4 { if let Some(r) = Rotation3::rotation_between(normal, up) { r.to_homogeneous() } else { @@ -12,52 +12,52 @@ pub fn orientation(normal: &TVec3, up: &TVec3) -> TMat4 { } /// Rotate a two dimensional vector. -pub fn rotate_vec2(v: &TVec2, angle: N) -> TVec2 { +pub fn rotate_vec2(v: &TVec2, angle: N) -> TVec2 { UnitComplex::new(angle) * v } /// Rotate a three dimensional vector around an axis. -pub fn rotate_vec3(v: &TVec3, angle: N, normal: &TVec3) -> TVec3 { +pub fn rotate_vec3(v: &TVec3, angle: N, normal: &TVec3) -> TVec3 { 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(v: &TVec4, angle: N, normal: &TVec3) -> TVec4 { +pub fn rotate_vec4(v: &TVec4, angle: N, normal: &TVec3) -> TVec4 { 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(v: &TVec3, angle: N) -> TVec3 { +pub fn rotate_x_vec3(v: &TVec3, angle: N) -> TVec3 { 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(v: &TVec4, angle: N) -> TVec4 { +pub fn rotate_x_vec4(v: &TVec4, angle: N) -> TVec4 { 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(v: &TVec3, angle: N) -> TVec3 { +pub fn rotate_y_vec3(v: &TVec3, angle: N) -> TVec3 { 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(v: &TVec4, angle: N) -> TVec4 { +pub fn rotate_y_vec4(v: &TVec4, angle: N) -> TVec4 { 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(v: &TVec3, angle: N) -> TVec3 { +pub fn rotate_z_vec3(v: &TVec3, angle: N) -> TVec3 { 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(v: &TVec4, angle: N) -> TVec4 { +pub fn rotate_z_vec4(v: &TVec4, angle: N) -> TVec4 { 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(x: &TVec3, y: &TVec3, a: N) -> TVec3 { +pub fn slerp(x: &TVec3, y: &TVec3, a: N) -> TVec3 { Unit::new_unchecked(*x) .slerp(&Unit::new_unchecked(*y), a) .into_inner() diff --git a/nalgebra-glm/src/gtx/transform.rs b/nalgebra-glm/src/gtx/transform.rs index 1e3e404d..17a853c1 100644 --- a/nalgebra-glm/src/gtx/transform.rs +++ b/nalgebra-glm/src/gtx/transform.rs @@ -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(angle: N, v: &TVec3) -> TMat4 { +pub fn rotation(angle: N, v: &TVec3) -> TMat4 { Rotation3::from_axis_angle(&Unit::new_normalize(*v), angle).to_homogeneous() } @@ -51,7 +51,7 @@ pub fn translation(v: &TVec3) -> TMat4 { /// * [`translation`](fn.translation.html) /// * [`scaling2d`](fn.scaling2d.html) /// * [`translation2d`](fn.translation2d.html) -pub fn rotation2d(angle: N) -> TMat3 { +pub fn rotation2d(angle: N) -> TMat3 { Rotation2::new(angle).to_homogeneous() } diff --git a/nalgebra-glm/src/gtx/transform2d.rs b/nalgebra-glm/src/gtx/transform2d.rs index 9e80bb52..0c7deb18 100644 --- a/nalgebra-glm/src/gtx/transform2d.rs +++ b/nalgebra-glm/src/gtx/transform2d.rs @@ -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(m: &TMat3, angle: N) -> TMat3 { +pub fn rotate2d(m: &TMat3, angle: N) -> TMat3 { m * UnitComplex::new(angle).to_homogeneous() } diff --git a/nalgebra-glm/src/gtx/vector_angle.rs b/nalgebra-glm/src/gtx/vector_angle.rs index 8cfe813b..8753ccd0 100644 --- a/nalgebra-glm/src/gtx/vector_angle.rs +++ b/nalgebra-glm/src/gtx/vector_angle.rs @@ -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(x: &TVec, y: &TVec) -> N +pub fn angle(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { x.angle(y) } -//pub fn oriented_angle(x: &TVec2, y: &TVec2) -> N { +//pub fn oriented_angle(x: &TVec2, y: &TVec2) -> N { // unimplemented!() //} // -//pub fn oriented_angle_ref(x: &TVec3, y: &TVec3, refv: &TVec3) -> N { +//pub fn oriented_angle_ref(x: &TVec3, y: &TVec3, refv: &TVec3) -> N { // unimplemented!() //} diff --git a/nalgebra-glm/src/gtx/vector_query.rs b/nalgebra-glm/src/gtx/vector_query.rs index da23704d..2a127f00 100644 --- a/nalgebra-glm/src/gtx/vector_query.rs +++ b/nalgebra-glm/src/gtx/vector_query.rs @@ -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 { } /// Returns `true` if `v` has a magnitude of 1 (up to an epsilon). -pub fn is_normalized(v: &TVec, epsilon: N) -> bool +pub fn is_normalized(v: &TVec, epsilon: N) -> bool where DefaultAllocator: Alloc { abs_diff_eq!(v.norm_squared(), N::one(), epsilon = epsilon * epsilon) } diff --git a/nalgebra-glm/src/integer.rs b/nalgebra-glm/src/integer.rs index dbf39cb0..198d737a 100644 --- a/nalgebra-glm/src/integer.rs +++ b/nalgebra-glm/src/integer.rs @@ -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; diff --git a/nalgebra-glm/src/lib.rs b/nalgebra-glm/src/lib.rs index b2fe8b8f..66502e73 100644 --- a/nalgebra-glm/src/lib.rs +++ b/nalgebra-glm/src/lib.rs @@ -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; diff --git a/nalgebra-glm/src/matrix.rs b/nalgebra-glm/src/matrix.rs index 26b2f3ab..a4c4efe9 100644 --- a/nalgebra-glm/src/matrix.rs +++ b/nalgebra-glm/src/matrix.rs @@ -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(m: &TMat) -> N +pub fn determinant(m: &TMat) -> N where DefaultAllocator: Alloc { m.determinant() } /// The inverse of the matrix `m`. -pub fn inverse(m: &TMat) -> TMat +pub fn inverse(m: &TMat) -> TMat where DefaultAllocator: Alloc { m.clone() .try_inverse() diff --git a/nalgebra-glm/src/trigonometric.rs b/nalgebra-glm/src/trigonometric.rs index 661bd2ae..139a48da 100644 --- a/nalgebra-glm/src/trigonometric.rs +++ b/nalgebra-glm/src/trigonometric.rs @@ -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(x: &TVec) -> TVec +pub fn acos(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|e| e.acos()) } /// Component-wise hyperbolic arc-cosinus. -pub fn acosh(x: &TVec) -> TVec +pub fn acosh(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|e| e.acosh()) } /// Component-wise arc-sinus. -pub fn asin(x: &TVec) -> TVec +pub fn asin(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|e| e.asin()) } /// Component-wise hyperbolic arc-sinus. -pub fn asinh(x: &TVec) -> TVec +pub fn asinh(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|e| e.asinh()) } /// Component-wise arc-tangent of `y / x`. -pub fn atan2(y: &TVec, x: &TVec) -> TVec +pub fn atan2(y: &TVec, x: &TVec) -> TVec where DefaultAllocator: Alloc { y.zip_map(x, |y, x| y.atan2(x)) } /// Component-wise arc-tangent. -pub fn atan(y_over_x: &TVec) -> TVec +pub fn atan(y_over_x: &TVec) -> TVec where DefaultAllocator: Alloc { y_over_x.map(|e| e.atan()) } /// Component-wise hyperbolic arc-tangent. -pub fn atanh(x: &TVec) -> TVec +pub fn atanh(x: &TVec) -> TVec where DefaultAllocator: Alloc { x.map(|e| e.atanh()) } /// Component-wise cosinus. -pub fn cos(angle: &TVec) -> TVec +pub fn cos(angle: &TVec) -> TVec where DefaultAllocator: Alloc { angle.map(|e| e.cos()) } /// Component-wise hyperbolic cosinus. -pub fn cosh(angle: &TVec) -> TVec +pub fn cosh(angle: &TVec) -> TVec where DefaultAllocator: Alloc { angle.map(|e| e.cosh()) } /// Component-wise conversion from radians to degrees. -pub fn degrees(radians: &TVec) -> TVec +pub fn degrees(radians: &TVec) -> TVec where DefaultAllocator: Alloc { radians.map(|e| e * na::convert(180.0) / N::pi()) } /// Component-wise conversion fro degrees to radians. -pub fn radians(degrees: &TVec) -> TVec +pub fn radians(degrees: &TVec) -> TVec where DefaultAllocator: Alloc { degrees.map(|e| e * N::pi() / na::convert(180.0)) } /// Component-wise sinus. -pub fn sin(angle: &TVec) -> TVec +pub fn sin(angle: &TVec) -> TVec where DefaultAllocator: Alloc { angle.map(|e| e.sin()) } /// Component-wise hyperbolic sinus. -pub fn sinh(angle: &TVec) -> TVec +pub fn sinh(angle: &TVec) -> TVec where DefaultAllocator: Alloc { angle.map(|e| e.sinh()) } /// Component-wise tangent. -pub fn tan(angle: &TVec) -> TVec +pub fn tan(angle: &TVec) -> TVec where DefaultAllocator: Alloc { angle.map(|e| e.tan()) } /// Component-wise hyperbolic tangent. -pub fn tanh(angle: &TVec) -> TVec +pub fn tanh(angle: &TVec) -> TVec where DefaultAllocator: Alloc { angle.map(|e| e.tanh()) } diff --git a/nalgebra-lapack/src/eigen.rs b/nalgebra-lapack/src/eigen.rs index 628b532f..d5397841 100644 --- a/nalgebra-lapack/src/eigen.rs +++ b/nalgebra-lapack/src/eigen.rs @@ -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: Copy, {} -impl Eigen +impl Eigen where DefaultAllocator: Allocator + Allocator { /// Computes the eigenvalues and eigenvectors of the square matrix `m`. diff --git a/nalgebra-lapack/src/schur.rs b/nalgebra-lapack/src/schur.rs index f928afda..eb618fe9 100644 --- a/nalgebra-lapack/src/schur.rs +++ b/nalgebra-lapack/src/schur.rs @@ -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: Copy, {} -impl Schur +impl Schur where DefaultAllocator: Allocator + Allocator { /// Computes the eigenvalues and real Schur form of the matrix `m`. @@ -161,7 +161,7 @@ where DefaultAllocator: Allocator + Allocator * 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( diff --git a/nalgebra-lapack/src/symmetric_eigen.rs b/nalgebra-lapack/src/symmetric_eigen.rs index af0575fd..d34b3fce 100644 --- a/nalgebra-lapack/src/symmetric_eigen.rs +++ b/nalgebra-lapack/src/symmetric_eigen.rs @@ -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: Copy, {} -impl SymmetricEigen +impl SymmetricEigen where DefaultAllocator: Allocator + Allocator { /// Computes the eigenvalues and eigenvectors of the symmetric matrix `m`. diff --git a/src/base/cg.rs b/src/base/cg.rs index 5c1a7c11..4029dbc3 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -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 MatrixN @@ -65,7 +65,7 @@ where } } -impl Matrix3 { +impl Matrix3 { /// 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 Matrix3 { } } -impl Matrix4 { +impl Matrix4 { /// 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> SquareMatrix } } -impl, S: Storage> SquareMatrix +impl, S: Storage> SquareMatrix where DefaultAllocator: Allocator + Allocator> + Allocator, DimNameDiff> @@ -364,7 +364,7 @@ where DefaultAllocator: Allocator } } -impl> Transformation>> for MatrixN +impl> Transformation>> for MatrixN where DefaultAllocator: Allocator + Allocator> + Allocator, DimNameDiff> diff --git a/src/base/construction.rs b/src/base/construction.rs index 1b05fe61..5eace4bb 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -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 Distribution>> for Standard +impl Distribution>> for Standard where DefaultAllocator: Allocator, StandardNormal: Distribution, diff --git a/src/base/matrix.rs b/src/base/matrix.rs index ad188a26..6c1db1d6 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -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> Matrix { /// Divides each component of the complex matrix `self` by the given real. #[inline] - pub fn unscale(&self, real: N::Real) -> MatrixMN + pub fn unscale(&self, real: N::RealField) -> MatrixMN where DefaultAllocator: Allocator { 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 + pub fn scale(&self, real: N::RealField) -> MatrixMN where DefaultAllocator: Allocator { self.map(|e| e.scale(real)) } @@ -1005,13 +1005,13 @@ impl> Matrix /// 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 impl> Matrix { /// The smallest angle between two vectors. #[inline] - pub fn angle(&self, other: &Matrix) -> N::Real + pub fn angle(&self, other: &Matrix) -> N::RealField where SB: Storage, ShapeConstraint: DimEq + DimEq, @@ -1554,14 +1554,14 @@ impl> Matrix { 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> Unit> { pub fn slerp>( &self, rhs: &Unit>, - t: N::Real, + t: N::RealField, ) -> Unit> where DefaultAllocator: Allocator, { // 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> Unit> { pub fn try_slerp>( &self, rhs: &Unit>, - t: N::Real, - epsilon: N::Real, + t: N::RealField, + epsilon: N::RealField, ) -> Option>> where DefaultAllocator: Allocator, @@ -1623,18 +1623,18 @@ impl> Unit> { 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()); diff --git a/src/base/matrix_alga.rs b/src/base/matrix_alga.rs index 790d60d3..ac6aced7 100644 --- a/src/base/matrix_alga.rs +++ b/src/base/matrix_alga.rs @@ -148,16 +148,16 @@ where impl NormedSpace for MatrixMN where DefaultAllocator: Allocator { - 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 } #[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 { + fn try_normalize(&self, min_norm: N::RealField) -> Option { self.try_normalize(min_norm) } #[inline] - fn try_normalize_mut(&mut self, min_norm: N::Real) -> Option { + fn try_normalize_mut(&mut self, min_norm: N::RealField) -> Option { self.try_normalize_mut(min_norm) } } @@ -186,7 +186,7 @@ impl InnerSpace for MatrixMN where DefaultAllocator: Allocator { #[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 } } - 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 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; }; diff --git a/src/base/norm.rs b/src/base/norm.rs index 06bca851..93319ddc 100644 --- a/src/base/norm.rs +++ b/src/base/norm.rs @@ -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 { /// Apply this norm to the given matrix. - fn norm(&self, m: &Matrix) -> N::Real + fn norm(&self, m: &Matrix) -> N::RealField where R: Dim, C: Dim, S: Storage; /// Use the metric induced by this norm to compute the metric distance between the two given matrices. - fn metric_distance(&self, m1: &Matrix, m2: &Matrix) -> N::Real + fn metric_distance(&self, m1: &Matrix, m2: &Matrix) -> N::RealField where R1: Dim, C1: Dim, S1: Storage, R2: Dim, C2: Dim, S2: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns; @@ -31,17 +31,17 @@ pub struct UniformNorm; impl Norm for EuclideanNorm { #[inline] - fn norm(&self, m: &Matrix) -> N::Real + fn norm(&self, m: &Matrix) -> N::RealField where R: Dim, C: Dim, S: Storage { m.norm_squared().sqrt() } #[inline] - fn metric_distance(&self, m1: &Matrix, m2: &Matrix) -> N::Real + fn metric_distance(&self, m1: &Matrix, m2: &Matrix) -> N::RealField where R1: Dim, C1: Dim, S1: Storage, R2: Dim, C2: Dim, S2: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { - 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 Norm for EuclideanNorm { impl Norm for LpNorm { #[inline] - fn norm(&self, m: &Matrix) -> N::Real + fn norm(&self, m: &Matrix) -> N::RealField where R: Dim, C: Dim, S: Storage { - 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(&self, m1: &Matrix, m2: &Matrix) -> N::Real + fn metric_distance(&self, m1: &Matrix, m2: &Matrix) -> N::RealField where R1: Dim, C1: Dim, S1: Storage, R2: Dim, C2: Dim, S2: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { - 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 Norm for LpNorm { impl Norm for UniformNorm { #[inline] - fn norm(&self, m: &Matrix) -> N::Real + fn norm(&self, m: &Matrix) -> N::RealField where R: Dim, C: Dim, S: Storage { // 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(&self, m1: &Matrix, m2: &Matrix) -> N::Real + fn metric_distance(&self, m1: &Matrix, m2: &Matrix) -> N::RealField where R1: Dim, C1: Dim, S1: Storage, R2: Dim, C2: Dim, S2: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { - 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 Norm for UniformNorm { impl> Matrix { /// 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> Matrix { /// /// 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> Matrix { /// /// Use `.apply_metric_distance` to apply a custom norm. #[inline] - pub fn metric_distance(&self, rhs: &Matrix) -> N::Real + pub fn metric_distance(&self, rhs: &Matrix) -> N::RealField where R2: Dim, C2: Dim, S2: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { self.apply_metric_distance(rhs, &EuclideanNorm) @@ -140,7 +140,7 @@ impl> Matrix { /// assert_eq!(v.apply_norm(&EuclideanNorm), v.norm()); /// ``` #[inline] - pub fn apply_norm(&self, norm: &impl Norm) -> N::Real { + pub fn apply_norm(&self, norm: &impl Norm) -> N::RealField { norm.norm(self) } @@ -159,7 +159,7 @@ impl> Matrix { /// assert_eq!(v1.apply_metric_distance(&v2, &EuclideanNorm), (v1 - v2).norm()); /// ``` #[inline] - pub fn apply_metric_distance(&self, rhs: &Matrix, norm: &impl Norm) -> N::Real + pub fn apply_metric_distance(&self, rhs: &Matrix, norm: &impl Norm) -> N::RealField where R2: Dim, C2: Dim, S2: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { norm.metric_distance(self, rhs) @@ -171,7 +171,7 @@ impl> Matrix { /// /// 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> Matrix { /// /// 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> Matrix { /// 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> + pub fn try_normalize(&self, min_norm: N::RealField) -> Option> where DefaultAllocator: Allocator { let n = self.norm(); @@ -207,7 +207,7 @@ impl> Matrix { /// 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> Matrix { impl> Matrix { /// 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> Matrix /// /// If the normalization succeeded, returns the old normal of this matrix. #[inline] - pub fn try_normalize_mut(&mut self, min_norm: N::Real) -> Option { + pub fn try_normalize_mut(&mut self, min_norm: N::RealField) -> Option { let n = self.norm(); if n <= min_norm { diff --git a/src/base/ops.rs b/src/base/ops.rs index 8a6fe5a1..9f3d44c3 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -832,7 +832,7 @@ impl> Matrix { /// 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> Matrix { /// 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) } diff --git a/src/base/properties.rs b/src/base/properties.rs index acb7dfb4..8ca49568 100644 --- a/src/base/properties.rs +++ b/src/base/properties.rs @@ -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> Matrix { } } -impl> SquareMatrix +impl> SquareMatrix where DefaultAllocator: Allocator { /// Checks that this matrix is orthogonal and has a determinant equal to 1. diff --git a/src/base/unit.rs b/src/base/unit.rs index 60aa1ae2..0c397e52 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -64,13 +64,13 @@ impl Unit { /// /// Returns `None` if the norm was smaller or equal to `min_norm`. #[inline] - pub fn try_new(value: T, min_norm: T::Real) -> Option { + pub fn try_new(value: T, min_norm: T::RealField) -> Option { 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 Unit { /// /// 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 Unit { /// 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 Unit { #[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)); } } diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index f77d4d60..6df20039 100644 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -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, Owned: Deserialize<'de>")) )] -pub struct Isometry +pub struct Isometry where DefaultAllocator: Allocator { /// The pure rotational part of this isometry. @@ -55,7 +55,7 @@ where DefaultAllocator: Allocator #[cfg(feature = "abomonation-serialize")] impl Abomonation for Isometry where - N: Real, + N: RealField, D: DimName, R: Abomonation, Translation: Abomonation, @@ -77,7 +77,7 @@ where } } -impl hash::Hash for Isometry +impl hash::Hash for Isometry where DefaultAllocator: Allocator, Owned: hash::Hash, @@ -88,14 +88,14 @@ where } } -impl> + Copy> Copy for Isometry +impl> + Copy> Copy for Isometry where DefaultAllocator: Allocator, Owned: Copy, { } -impl> + Clone> Clone for Isometry +impl> + Clone> Clone for Isometry where DefaultAllocator: Allocator { #[inline] @@ -104,7 +104,7 @@ where DefaultAllocator: Allocator } } -impl>> Isometry +impl>> Isometry where DefaultAllocator: Allocator { /// Creates a new isometry from its rotational and translational parts. @@ -260,7 +260,7 @@ where DefaultAllocator: Allocator // 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 Isometry +impl Isometry where DefaultAllocator: Allocator { /// Converts this isometry into its equivalent homogeneous transformation matrix. @@ -293,14 +293,14 @@ where DefaultAllocator: Allocator } } -impl Eq for Isometry +impl Eq for Isometry where R: Rotation> + Eq, DefaultAllocator: Allocator, { } -impl PartialEq for Isometry +impl PartialEq for Isometry where R: Rotation> + PartialEq, DefaultAllocator: Allocator, @@ -311,7 +311,7 @@ where } } -impl AbsDiffEq for Isometry +impl AbsDiffEq for Isometry where R: Rotation> + AbsDiffEq, DefaultAllocator: Allocator, @@ -331,7 +331,7 @@ where } } -impl RelativeEq for Isometry +impl RelativeEq for Isometry where R: Rotation> + RelativeEq, DefaultAllocator: Allocator, @@ -358,7 +358,7 @@ where } } -impl UlpsEq for Isometry +impl UlpsEq for Isometry where R: Rotation> + UlpsEq, DefaultAllocator: Allocator, @@ -382,7 +382,7 @@ where * Display * */ -impl fmt::Display for Isometry +impl fmt::Display for Isometry where R: fmt::Display, DefaultAllocator: Allocator + Allocator, diff --git a/src/geometry/isometry_alga.rs b/src/geometry/isometry_alga.rs index eb9a5cd5..8402c5cb 100644 --- a/src/geometry/isometry_alga.rs +++ b/src/geometry/isometry_alga.rs @@ -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 Identity for Isometry +impl Identity for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -30,7 +30,7 @@ where } } -impl TwoSidedInverse for Isometry +impl TwoSidedInverse for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -46,7 +46,7 @@ where } } -impl AbstractMagma for Isometry +impl AbstractMagma for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -59,7 +59,7 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Isometry + impl $marker<$operator> for Isometry where R: Rotation>, DefaultAllocator: Allocator { } )*} @@ -78,7 +78,7 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> for Isometry +impl Transformation> for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -94,7 +94,7 @@ where } } -impl ProjectiveTransformation> for Isometry +impl ProjectiveTransformation> for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -111,7 +111,7 @@ where } } -impl AffineTransformation> for Isometry +impl AffineTransformation> for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -169,7 +169,7 @@ where } } -impl Similarity> for Isometry +impl Similarity> for Isometry where R: Rotation>, DefaultAllocator: Allocator, @@ -194,7 +194,7 @@ where macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for Isometry + impl $Trait> for Isometry where R: Rotation>, DefaultAllocator: Allocator { } )*} diff --git a/src/geometry/isometry_construction.rs b/src/geometry/isometry_construction.rs index 3863051c..979c3955 100644 --- a/src/geometry/isometry_construction.rs +++ b/src/geometry/isometry_construction.rs @@ -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>> Isometry +impl>> Isometry where DefaultAllocator: Allocator { /// Creates a new identity isometry. @@ -65,7 +65,7 @@ where DefaultAllocator: Allocator } } -impl>> One for Isometry +impl>> One for Isometry where DefaultAllocator: Allocator { /// Creates a new identity isometry. @@ -75,7 +75,7 @@ where DefaultAllocator: Allocator } } -impl Distribution> for Standard +impl Distribution> for Standard where R: AlgaRotation>, Standard: Distribution + Distribution, @@ -90,7 +90,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for Isometry where - N: Real + Arbitrary + Send, + N: RealField + Arbitrary + Send, R: AlgaRotation> + Arbitrary + Send, Owned: Send, DefaultAllocator: Allocator, @@ -108,7 +108,7 @@ where */ // 2D rotation. -impl Isometry> { +impl Isometry> { /// 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 Isometry> { } } -impl Isometry> { +impl Isometry> { /// 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 Isometry> { // 3D rotation. macro_rules! isometry_construction_impl( ($RotId: ident < $($RotParams: ident),*>, $RRDim: ty, $RCDim: ty) => { - impl Isometry> { + impl Isometry> { /// Creates a new isometry from a translation and a rotation axis-angle. /// /// # Example diff --git a/src/geometry/isometry_conversion.rs b/src/geometry/isometry_conversion.rs index 0ce92aca..4a794f55 100644 --- a/src/geometry/isometry_conversion.rs +++ b/src/geometry/isometry_conversion.rs @@ -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 SubsetOf> for Isometry where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R1: Rotation> + SubsetOf, R2: Rotation>, DefaultAllocator: Allocator + Allocator, @@ -47,8 +47,8 @@ where impl SubsetOf> for Isometry where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R1: Rotation> + SubsetOf, R2: Rotation>, DefaultAllocator: Allocator + Allocator, @@ -71,8 +71,8 @@ where impl SubsetOf> for Isometry where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, C: SuperTCategoryOf, R: Rotation> + SubsetOf>> @@ -105,8 +105,8 @@ where impl SubsetOf>> for Isometry where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: Rotation> + SubsetOf>> + SubsetOf>>, @@ -149,7 +149,7 @@ where } } -impl From> for MatrixN> +impl From> for MatrixN> where D: DimNameAdd, R: SubsetOf>>, diff --git a/src/geometry/isometry_ops.rs b/src/geometry/isometry_ops.rs index b0da4b62..6ba9eb3e 100644 --- a/src/geometry/isometry_ops.rs +++ b/src/geometry/isometry_ops.rs @@ -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>, DefaultAllocator: Allocator { 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 $OpAssign<$Rhs> for $Lhs + impl $OpAssign<$Rhs> for $Lhs where R: AlgaRotation>, DefaultAllocator: Allocator { #[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>, DefaultAllocator: Allocator { #[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 + Allocator { type Output = $Output; diff --git a/src/geometry/orthographic.rs b/src/geometry/orthographic.rs index af86a876..2c713118 100644 --- a/src/geometry/orthographic.rs +++ b/src/geometry/orthographic.rs @@ -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 { +pub struct Orthographic3 { matrix: Matrix4, } -impl Copy for Orthographic3 {} +impl Copy for Orthographic3 {} -impl Clone for Orthographic3 { +impl Clone for Orthographic3 { #[inline] fn clone(&self) -> Self { Self::from_matrix_unchecked(self.matrix.clone()) } } -impl fmt::Debug for Orthographic3 { +impl fmt::Debug for Orthographic3 { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.matrix.fmt(f) } } -impl PartialEq for Orthographic3 { +impl PartialEq for Orthographic3 { #[inline] fn eq(&self, right: &Self) -> bool { self.matrix == right.matrix @@ -44,7 +44,7 @@ impl PartialEq for Orthographic3 { } #[cfg(feature = "serde-serialize")] -impl Serialize for Orthographic3 { +impl Serialize for Orthographic3 { fn serialize(&self, serializer: S) -> Result where S: Serializer { self.matrix.serialize(serializer) @@ -52,7 +52,7 @@ impl Serialize for Orthographic3 { } #[cfg(feature = "serde-serialize")] -impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Orthographic3 { +impl<'a, N: RealField + Deserialize<'a>> Deserialize<'a> for Orthographic3 { fn deserialize(deserializer: Des) -> Result where Des: Deserializer<'a> { let matrix = Matrix4::::deserialize(deserializer)?; @@ -61,7 +61,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Orthographic3 { } } -impl Orthographic3 { +impl Orthographic3 { /// Creates a new orthographic projection matrix. /// /// This follows the OpenGL convention, so this will flip the `z` axis. @@ -678,7 +678,7 @@ impl Orthographic3 { } } -impl Distribution> for Standard +impl Distribution> for Standard where Standard: Distribution { fn sample(&self, r: &mut R) -> Orthographic3 { @@ -694,7 +694,7 @@ where Standard: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for Orthographic3 +impl Arbitrary for Orthographic3 where Matrix4: Send { fn arbitrary(g: &mut G) -> Self { @@ -709,7 +709,7 @@ where Matrix4: Send } } -impl From> for Matrix4 { +impl From> for Matrix4 { #[inline] fn from(orth: Orthographic3) -> Self { orth.into_inner() diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index c8125d99..8020c0cf 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -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 { matrix: Matrix4, } -impl Copy for Perspective3 {} +impl Copy for Perspective3 {} -impl Clone for Perspective3 { +impl Clone for Perspective3 { #[inline] fn clone(&self) -> Self { Self::from_matrix_unchecked(self.matrix.clone()) } } -impl fmt::Debug for Perspective3 { +impl fmt::Debug for Perspective3 { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.matrix.fmt(f) } } -impl PartialEq for Perspective3 { +impl PartialEq for Perspective3 { #[inline] fn eq(&self, right: &Self) -> bool { self.matrix == right.matrix @@ -45,7 +45,7 @@ impl PartialEq for Perspective3 { } #[cfg(feature = "serde-serialize")] -impl Serialize for Perspective3 { +impl Serialize for Perspective3 { fn serialize(&self, serializer: S) -> Result where S: Serializer { self.matrix.serialize(serializer) @@ -53,7 +53,7 @@ impl Serialize for Perspective3 { } #[cfg(feature = "serde-serialize")] -impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Perspective3 { +impl<'a, N: RealField + Deserialize<'a>> Deserialize<'a> for Perspective3 { fn deserialize(deserializer: Des) -> Result where Des: Deserializer<'a> { let matrix = Matrix4::::deserialize(deserializer)?; @@ -62,7 +62,7 @@ impl<'a, N: Real + Deserialize<'a>> Deserialize<'a> for Perspective3 { } } -impl Perspective3 { +impl Perspective3 { /// 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 Perspective3 { } } -impl Distribution> for Standard +impl Distribution> for Standard where Standard: Distribution { fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3 { @@ -274,7 +274,7 @@ where Standard: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for Perspective3 { +impl Arbitrary for Perspective3 { fn arbitrary(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 Arbitrary for Perspective3 { } } -impl From> for Matrix4 { +impl From> for Matrix4 { #[inline] fn from(orth: Perspective3) -> Self { orth.into_inner() diff --git a/src/geometry/point_alga.rs b/src/geometry/point_alga.rs index c95cb5b2..162e6c68 100644 --- a/src/geometry/point_alga.rs +++ b/src/geometry/point_alga.rs @@ -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; } -impl EuclideanSpace for Point +impl EuclideanSpace for Point where DefaultAllocator: Allocator { type Coordinates = VectorN; - type Real = N; + type RealField = N; #[inline] fn origin() -> Self { diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 3beab4bb..5306f9c1 100644 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -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 { +pub struct Quaternion { /// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order. pub coords: Vector4, } #[cfg(feature = "abomonation-serialize")] -impl Abomonation for Quaternion +impl Abomonation for Quaternion where Vector4: Abomonation { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { @@ -47,9 +47,9 @@ where Vector4: Abomonation } } -impl Eq for Quaternion {} +impl Eq for Quaternion {} -impl PartialEq for Quaternion { +impl PartialEq for Quaternion { 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 PartialEq for Quaternion { } } -impl hash::Hash for Quaternion { +impl hash::Hash for Quaternion { fn hash(&self, state: &mut H) { self.coords.hash(state) } } -impl Copy for Quaternion {} +impl Copy for Quaternion {} -impl Clone for Quaternion { +impl Clone for Quaternion { #[inline] fn clone(&self) -> Self { Self::from(self.coords.clone()) @@ -73,7 +73,7 @@ impl Clone for Quaternion { } #[cfg(feature = "serde-serialize")] -impl Serialize for Quaternion +impl Serialize for Quaternion where Owned: Serialize { fn serialize(&self, serializer: S) -> Result @@ -83,7 +83,7 @@ where Owned: Serialize } #[cfg(feature = "serde-serialize")] -impl<'a, N: Real> Deserialize<'a> for Quaternion +impl<'a, N: RealField> Deserialize<'a> for Quaternion where Owned: Deserialize<'a> { fn deserialize(deserializer: Des) -> Result @@ -94,7 +94,7 @@ where Owned: Deserialize<'a> } } -impl Quaternion { +impl Quaternion { /// 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 Quaternion { } } -impl> AbsDiffEq for Quaternion { +impl> AbsDiffEq for Quaternion { type Epsilon = N; #[inline] @@ -524,7 +524,7 @@ impl> AbsDiffEq for Quaternion { } } -impl> RelativeEq for Quaternion { +impl> RelativeEq for Quaternion { #[inline] fn default_max_relative() -> Self::Epsilon { N::default_max_relative() @@ -544,7 +544,7 @@ impl> RelativeEq for Quaternion { } } -impl> UlpsEq for Quaternion { +impl> UlpsEq for Quaternion { #[inline] fn default_max_ulps() -> u32 { N::default_max_ulps() @@ -558,7 +558,7 @@ impl> UlpsEq for Quaternion { } } -impl fmt::Display for Quaternion { +impl fmt::Display for Quaternion { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, @@ -571,7 +571,7 @@ impl fmt::Display for Quaternion { /// A unit quaternions. May be used to represent a rotation. pub type UnitQuaternion = Unit>; -impl UnitQuaternion { +impl UnitQuaternion { /// Moves this unit quaternion into one that owns its data. #[inline] #[deprecated( @@ -1007,7 +1007,7 @@ impl UnitQuaternion { } } -impl fmt::Display for UnitQuaternion { +impl fmt::Display for UnitQuaternion { 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 fmt::Display for UnitQuaternion { } } -impl> AbsDiffEq for UnitQuaternion { +impl> AbsDiffEq for UnitQuaternion { type Epsilon = N; #[inline] @@ -1043,7 +1043,7 @@ impl> AbsDiffEq for UnitQuaternion { } } -impl> RelativeEq for UnitQuaternion { +impl> RelativeEq for UnitQuaternion { #[inline] fn default_max_relative() -> Self::Epsilon { N::default_max_relative() @@ -1062,7 +1062,7 @@ impl> RelativeEq for UnitQuaternion { } } -impl> UlpsEq for UnitQuaternion { +impl> UlpsEq for UnitQuaternion { #[inline] fn default_max_ulps() -> u32 { N::default_max_ulps() diff --git a/src/geometry/quaternion_alga.rs b/src/geometry/quaternion_alga.rs index a73beff7..d9864cb1 100644 --- a/src/geometry/quaternion_alga.rs +++ b/src/geometry/quaternion_alga.rs @@ -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 Identity for Quaternion { +impl Identity for Quaternion { #[inline] fn identity() -> Self { Self::identity() } } -impl Identity for Quaternion { +impl Identity for Quaternion { #[inline] fn identity() -> Self { Self::zero() } } -impl AbstractMagma for Quaternion { +impl AbstractMagma for Quaternion { #[inline] fn operate(&self, rhs: &Self) -> Self { self * rhs } } -impl AbstractMagma for Quaternion { +impl AbstractMagma for Quaternion { #[inline] fn operate(&self, rhs: &Self) -> Self { self + rhs } } -impl TwoSidedInverse for Quaternion { +impl TwoSidedInverse for Quaternion { #[inline] fn two_sided_inverse(&self) -> Self { -self @@ -51,7 +51,7 @@ impl TwoSidedInverse for Quaternion { macro_rules! impl_structures( ($Quaternion: ident; $($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for $Quaternion { } + impl $marker<$operator> for $Quaternion { } )*} ); @@ -73,7 +73,7 @@ impl_structures!( * Vector space. * */ -impl AbstractModule for Quaternion { +impl AbstractModule for Quaternion { type AbstractRing = N; #[inline] @@ -82,15 +82,15 @@ impl AbstractModule for Quaternion { } } -impl Module for Quaternion { +impl Module for Quaternion { type Ring = N; } -impl VectorSpace for Quaternion { +impl VectorSpace for Quaternion { type Field = N; } -impl FiniteDimVectorSpace for Quaternion { +impl FiniteDimVectorSpace for Quaternion { #[inline] fn dimension() -> usize { 4 @@ -117,8 +117,8 @@ impl FiniteDimVectorSpace for Quaternion { } } -impl NormedSpace for Quaternion { - type Real = N; +impl NormedSpace for Quaternion { + type RealField = N; type ComplexField = N; #[inline] @@ -162,21 +162,21 @@ impl NormedSpace for Quaternion { * Implementations for UnitQuaternion. * */ -impl Identity for UnitQuaternion { +impl Identity for UnitQuaternion { #[inline] fn identity() -> Self { Self::identity() } } -impl AbstractMagma for UnitQuaternion { +impl AbstractMagma for UnitQuaternion { #[inline] fn operate(&self, rhs: &Self) -> Self { self * rhs } } -impl TwoSidedInverse for UnitQuaternion { +impl TwoSidedInverse for UnitQuaternion { #[inline] fn two_sided_inverse(&self) -> Self { self.inverse() @@ -197,7 +197,7 @@ impl_structures!( AbstractGroup ); -impl Transformation> for UnitQuaternion { +impl Transformation> for UnitQuaternion { #[inline] fn transform_point(&self, pt: &Point3) -> Point3 { self * pt @@ -209,7 +209,7 @@ impl Transformation> for UnitQuaternion { } } -impl ProjectiveTransformation> for UnitQuaternion { +impl ProjectiveTransformation> for UnitQuaternion { #[inline] fn inverse_transform_point(&self, pt: &Point3) -> Point3 { // FIXME: would it be useful performancewise not to call inverse explicitly (i-e. implement @@ -223,7 +223,7 @@ impl ProjectiveTransformation> for UnitQuaternion { } } -impl AffineTransformation> for UnitQuaternion { +impl AffineTransformation> for UnitQuaternion { type Rotation = Self; type NonUniformScaling = Id; type Translation = Id; @@ -264,7 +264,7 @@ impl AffineTransformation> for UnitQuaternion { } } -impl Similarity> for UnitQuaternion { +impl Similarity> for UnitQuaternion { type Scaling = Id; #[inline] @@ -285,13 +285,13 @@ impl Similarity> for UnitQuaternion { macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for UnitQuaternion { } + impl $Trait> for UnitQuaternion { } )*} ); marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation); -impl Rotation> for UnitQuaternion { +impl Rotation> for UnitQuaternion { #[inline] fn powf(&self, n: N) -> Option { Some(self.powf(n)) diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index ff72061f..132ede13 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -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 Quaternion { +impl Quaternion { /// Creates a quaternion from a 4D vector. The quaternion scalar part corresponds to the `w` /// vector component. #[inline] @@ -96,14 +96,14 @@ impl Quaternion { } } -impl One for Quaternion { +impl One for Quaternion { #[inline] fn one() -> Self { Self::identity() } } -impl Zero for Quaternion { +impl Zero for Quaternion { #[inline] fn zero() -> Self { Self::new(N::zero(), N::zero(), N::zero(), N::zero()) @@ -115,7 +115,7 @@ impl Zero for Quaternion { } } -impl Distribution> for Standard +impl Distribution> for Standard where Standard: Distribution { #[inline] @@ -125,7 +125,7 @@ where Standard: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for Quaternion +impl Arbitrary for Quaternion where Owned: Send { #[inline] @@ -139,7 +139,7 @@ where Owned: Send } } -impl UnitQuaternion { +impl UnitQuaternion { /// The rotation identity. /// /// # Example @@ -669,14 +669,14 @@ impl UnitQuaternion { } } -impl One for UnitQuaternion { +impl One for UnitQuaternion { #[inline] fn one() -> Self { Self::identity() } } -impl Distribution> for Standard +impl Distribution> for Standard where OpenClosed01: Distribution { /// Generate a uniformly distributed random rotation quaternion. @@ -701,7 +701,7 @@ where OpenClosed01: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for UnitQuaternion +impl Arbitrary for UnitQuaternion where Owned: Send, Owned: Send, diff --git a/src/geometry/quaternion_conversion.rs b/src/geometry/quaternion_conversion.rs index cd5d9f0c..4ac8b5a7 100644 --- a/src/geometry/quaternion_conversion.rs +++ b/src/geometry/quaternion_conversion.rs @@ -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 SubsetOf> for Quaternion where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> Quaternion { @@ -57,8 +57,8 @@ where impl SubsetOf> for UnitQuaternion where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> UnitQuaternion { @@ -78,8 +78,8 @@ where impl SubsetOf> for UnitQuaternion where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> Rotation3 { @@ -101,8 +101,8 @@ where impl SubsetOf> for UnitQuaternion where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: AlgaRotation> + SupersetOf, { #[inline] @@ -123,8 +123,8 @@ where impl SubsetOf> for UnitQuaternion where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: AlgaRotation> + SupersetOf, { #[inline] @@ -145,8 +145,8 @@ where impl SubsetOf> for UnitQuaternion where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, C: SuperTCategoryOf, { #[inline] @@ -165,7 +165,7 @@ where } } -impl> SubsetOf> for UnitQuaternion { +impl> SubsetOf> for UnitQuaternion { #[inline] fn to_superset(&self) -> Matrix4 { self.to_homogeneous().to_superset() @@ -184,14 +184,14 @@ impl> SubsetOf> for UnitQuaterni } #[cfg(feature = "mint")] -impl From> for Quaternion { +impl From> for Quaternion { fn from(q: mint::Quaternion) -> Self { Self::new(q.s, q.v.x, q.v.y, q.v.z) } } #[cfg(feature = "mint")] -impl Into> for Quaternion { +impl Into> for Quaternion { fn into(self) -> mint::Quaternion { mint::Quaternion { v: mint::Vector3 { @@ -205,7 +205,7 @@ impl Into> for Quaternion { } #[cfg(feature = "mint")] -impl Into> for UnitQuaternion { +impl Into> for UnitQuaternion { fn into(self) -> mint::Quaternion { mint::Quaternion { v: mint::Vector3 { @@ -218,35 +218,35 @@ impl Into> for UnitQuaternion { } } -impl From> for Matrix4 { +impl From> for Matrix4 { #[inline] fn from(q: UnitQuaternion) -> Self { q.to_homogeneous() } } -impl From> for Rotation3 { +impl From> for Rotation3 { #[inline] fn from(q: UnitQuaternion) -> Self { q.to_rotation_matrix() } } -impl From> for UnitQuaternion { +impl From> for UnitQuaternion { #[inline] fn from(q: Rotation3) -> Self { Self::from_rotation_matrix(&q) } } -impl From> for Matrix3 { +impl From> for Matrix3 { #[inline] fn from(q: UnitQuaternion) -> Self { q.to_rotation_matrix().into_inner() } } -impl From> for Quaternion { +impl From> for Quaternion { #[inline] fn from(coords: Vector4) -> Self { Self { coords } diff --git a/src/geometry/quaternion_coordinates.rs b/src/geometry/quaternion_coordinates.rs index 05d5af13..a9399f18 100644 --- a/src/geometry/quaternion_coordinates.rs +++ b/src/geometry/quaternion_coordinates.rs @@ -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 Deref for Quaternion { +impl Deref for Quaternion { type Target = IJKW; #[inline] @@ -16,7 +16,7 @@ impl Deref for Quaternion { } } -impl DerefMut for Quaternion { +impl DerefMut for Quaternion { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { unsafe { mem::transmute(self) } diff --git a/src/geometry/quaternion_ops.rs b/src/geometry/quaternion_ops.rs index 3fc840ff..5e31364b 100644 --- a/src/geometry/quaternion_ops.rs +++ b/src/geometry/quaternion_ops.rs @@ -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 Index for Quaternion { +impl Index for Quaternion { type Output = N; #[inline] @@ -72,7 +72,7 @@ impl Index for Quaternion { } } -impl IndexMut for Quaternion { +impl IndexMut for Quaternion { #[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 + Allocator { 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 $Op for Quaternion { + impl $Op for Quaternion { type Output = Quaternion; #[inline] @@ -499,7 +499,7 @@ macro_rules! scalar_op_impl( } } - impl<'a, N: Real> $Op for &'a Quaternion { + impl<'a, N: RealField> $Op for &'a Quaternion { type Output = Quaternion; #[inline] @@ -508,7 +508,7 @@ macro_rules! scalar_op_impl( } } - impl $OpAssign for Quaternion { + impl $OpAssign for Quaternion { #[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 Neg for Quaternion { +impl Neg for Quaternion { type Output = Quaternion; #[inline] @@ -556,7 +556,7 @@ impl Neg for Quaternion { } } -impl<'a, N: Real> Neg for &'a Quaternion { +impl<'a, N: RealField> Neg for &'a Quaternion { type Output = Quaternion; #[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 + Allocator { diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 21e240fe..f5d0ad30 100644 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -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 fmt::Display for Rotation where - N: Real + fmt::Display, + N: RealField + fmt::Display, DefaultAllocator: Allocator + Allocator, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/geometry/rotation_alga.rs b/src/geometry/rotation_alga.rs index e5c1edad..46bdaa8d 100644 --- a/src/geometry/rotation_alga.rs +++ b/src/geometry/rotation_alga.rs @@ -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 Identity for Rotation +impl Identity for Rotation where DefaultAllocator: Allocator { #[inline] @@ -27,7 +27,7 @@ where DefaultAllocator: Allocator } } -impl TwoSidedInverse for Rotation +impl TwoSidedInverse for Rotation where DefaultAllocator: Allocator { #[inline] @@ -41,7 +41,7 @@ where DefaultAllocator: Allocator } } -impl AbstractMagma for Rotation +impl AbstractMagma for Rotation where DefaultAllocator: Allocator { #[inline] @@ -52,7 +52,7 @@ where DefaultAllocator: Allocator macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Rotation + impl $marker<$operator> for Rotation where DefaultAllocator: Allocator { } )*} ); @@ -70,7 +70,7 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> for Rotation +impl Transformation> for Rotation where DefaultAllocator: Allocator + Allocator { #[inline] @@ -84,7 +84,7 @@ where DefaultAllocator: Allocator + Allocator } } -impl ProjectiveTransformation> for Rotation +impl ProjectiveTransformation> for Rotation where DefaultAllocator: Allocator + Allocator { #[inline] @@ -98,7 +98,7 @@ where DefaultAllocator: Allocator + Allocator } } -impl AffineTransformation> for Rotation +impl AffineTransformation> for Rotation where DefaultAllocator: Allocator + Allocator { type Rotation = Self; @@ -141,7 +141,7 @@ where DefaultAllocator: Allocator + Allocator } } -impl Similarity> for Rotation +impl Similarity> for Rotation where DefaultAllocator: Allocator + Allocator { type Scaling = Id; @@ -164,7 +164,7 @@ where DefaultAllocator: Allocator + Allocator macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for Rotation + impl $Trait> for Rotation where DefaultAllocator: Allocator + Allocator { } )*} @@ -173,7 +173,7 @@ macro_rules! marker_impl( marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation); /// Subgroups of the n-dimensional rotation group `SO(n)`. -impl linear::Rotation> for Rotation +impl linear::Rotation> for Rotation where DefaultAllocator: Allocator + Allocator { #[inline] @@ -199,7 +199,7 @@ where DefaultAllocator: Allocator + Allocator } /* -impl Matrix for Rotation { +impl Matrix for Rotation { type Field = N; type Row = Matrix; type Column = Matrix; @@ -241,7 +241,7 @@ impl Matrix for Rotation { } } -impl SquareMatrix for Rotation { +impl SquareMatrix for Rotation { type Vector = Matrix; #[inline] @@ -271,5 +271,5 @@ impl SquareMatrix for Rotation { } } -impl InversibleSquareMatrix for Rotation { } +impl InversibleSquareMatrix for Rotation { } */ diff --git a/src/geometry/rotation_conversion.rs b/src/geometry/rotation_conversion.rs index 6adee2d8..ac314221 100644 --- a/src/geometry/rotation_conversion.rs +++ b/src/geometry/rotation_conversion.rs @@ -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 SubsetOf> for Rotation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -54,8 +54,8 @@ where impl SubsetOf> for Rotation3 where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> UnitQuaternion { @@ -77,8 +77,8 @@ where impl SubsetOf> for Rotation2 where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> UnitComplex { @@ -100,8 +100,8 @@ where impl SubsetOf> for Rotation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: AlgaRotation> + SupersetOf, DefaultAllocator: Allocator + Allocator, { @@ -123,8 +123,8 @@ where impl SubsetOf> for Rotation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: AlgaRotation> + SupersetOf, DefaultAllocator: Allocator + Allocator, { @@ -146,8 +146,8 @@ where impl SubsetOf> for Rotation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, C: SuperTCategoryOf, D: DimNameAdd + DimMin, // needed by .is_special_orthogonal() DefaultAllocator: Allocator @@ -175,8 +175,8 @@ where impl SubsetOf>> for Rotation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, D: DimNameAdd + DimMin, // needed by .is_special_orthogonal() DefaultAllocator: Allocator + Allocator @@ -211,34 +211,34 @@ where } #[cfg(feature = "mint")] -impl From> for Rotation3 { +impl From> for Rotation3 { fn from(euler: mint::EulerAngles) -> Self { Self::from_euler_angles(euler.a, euler.b, euler.c) } } -impl From> for Matrix3 { +impl From> for Matrix3 { #[inline] fn from(q: Rotation2) ->Self { q.to_homogeneous() } } -impl From> for Matrix2 { +impl From> for Matrix2 { #[inline] fn from(q: Rotation2) -> Self { q.into_inner() } } -impl From> for Matrix4 { +impl From> for Matrix4 { #[inline] fn from(q: Rotation3) -> Self { q.to_homogeneous() } } -impl From> for Matrix3 { +impl From> for Matrix3 { #[inline] fn from(q: Rotation3) -> Self { q.into_inner() diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index 95fa3c07..8d40a51e 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -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 Rotation2 { +impl Rotation2 { /// Builds a 2 dimensional rotation matrix from an angle in radian. /// /// # Example @@ -232,7 +232,7 @@ impl Rotation2 { } } -impl Distribution> for Standard +impl Distribution> for Standard where OpenClosed01: Distribution { /// Generate a uniformly distributed random rotation. @@ -243,7 +243,7 @@ where OpenClosed01: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for Rotation2 +impl Arbitrary for Rotation2 where Owned: Send { #[inline] @@ -257,7 +257,7 @@ where Owned: Send * 3D Rotation matrix. * */ -impl Rotation3 { +impl Rotation3 { /// Builds a 3 dimensional rotation matrix from an axis and an angle. /// /// # Arguments @@ -819,7 +819,7 @@ impl Rotation3 { } } -impl Distribution> for Standard +impl Distribution> for Standard where OpenClosed01: Distribution { /// Generate a uniformly distributed random rotation. @@ -859,7 +859,7 @@ where OpenClosed01: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for Rotation3 +impl Arbitrary for Rotation3 where Owned: Send, Owned: Send, diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index f0bc6d2e..14e50af0 100644 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -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: Deserialize<'de>" )) )] -pub struct Similarity +pub struct Similarity where DefaultAllocator: Allocator { /// The part of this similarity that does not include the scaling factor. @@ -50,7 +50,7 @@ where DefaultAllocator: Allocator } #[cfg(feature = "abomonation-serialize")] -impl Abomonation for Similarity +impl Abomonation for Similarity where Isometry: Abomonation, DefaultAllocator: Allocator, @@ -68,7 +68,7 @@ where } } -impl hash::Hash +impl hash::Hash for Similarity where DefaultAllocator: Allocator, @@ -80,13 +80,13 @@ where } } -impl> + Copy> Copy for Similarity +impl> + Copy> Copy for Similarity where DefaultAllocator: Allocator, Owned: Copy, {} -impl> + Clone> Clone for Similarity +impl> + Clone> Clone for Similarity where DefaultAllocator: Allocator { #[inline] @@ -95,7 +95,7 @@ where DefaultAllocator: Allocator } } -impl Similarity +impl Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -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 Similarity +impl Similarity where DefaultAllocator: Allocator { /// Converts this similarity into its equivalent homogeneous transformation matrix. @@ -265,13 +265,13 @@ where DefaultAllocator: Allocator } } -impl Eq for Similarity +impl Eq for Similarity where R: Rotation> + Eq, DefaultAllocator: Allocator, {} -impl PartialEq for Similarity +impl PartialEq for Similarity where R: Rotation> + PartialEq, DefaultAllocator: Allocator, @@ -282,7 +282,7 @@ where } } -impl AbsDiffEq for Similarity +impl AbsDiffEq for Similarity where R: Rotation> + AbsDiffEq, DefaultAllocator: Allocator, @@ -302,7 +302,7 @@ where } } -impl RelativeEq for Similarity +impl RelativeEq for Similarity where R: Rotation> + RelativeEq, DefaultAllocator: Allocator, @@ -329,7 +329,7 @@ where } } -impl UlpsEq for Similarity +impl UlpsEq for Similarity where R: Rotation> + UlpsEq, DefaultAllocator: Allocator, @@ -354,7 +354,7 @@ where */ impl fmt::Display for Similarity where - N: Real + fmt::Display, + N: RealField + fmt::Display, R: Rotation> + fmt::Display, DefaultAllocator: Allocator + Allocator, { diff --git a/src/geometry/similarity_alga.rs b/src/geometry/similarity_alga.rs index 9aaefe48..122ec7b2 100644 --- a/src/geometry/similarity_alga.rs +++ b/src/geometry/similarity_alga.rs @@ -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 Identity for Similarity +impl Identity for Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -27,7 +27,7 @@ where } } -impl TwoSidedInverse for Similarity +impl TwoSidedInverse for Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -43,7 +43,7 @@ where } } -impl AbstractMagma for Similarity +impl AbstractMagma for Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -56,7 +56,7 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Similarity + impl $marker<$operator> for Similarity where R: Rotation>, DefaultAllocator: Allocator { } )*} @@ -75,7 +75,7 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> for Similarity +impl Transformation> for Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -91,7 +91,7 @@ where } } -impl ProjectiveTransformation> for Similarity +impl ProjectiveTransformation> for Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -107,7 +107,7 @@ where } } -impl AffineTransformation> for Similarity +impl AffineTransformation> for Similarity where R: Rotation>, DefaultAllocator: Allocator, @@ -164,7 +164,7 @@ where } } -impl AlgaSimilarity> for Similarity +impl AlgaSimilarity> for Similarity where R: Rotation>, DefaultAllocator: Allocator, diff --git a/src/geometry/similarity_construction.rs b/src/geometry/similarity_construction.rs index 0875c189..a3722ba9 100644 --- a/src/geometry/similarity_construction.rs +++ b/src/geometry/similarity_construction.rs @@ -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 Similarity +impl Similarity where R: AlgaRotation>, DefaultAllocator: Allocator, @@ -45,7 +45,7 @@ where } } -impl One for Similarity +impl One for Similarity where R: AlgaRotation>, DefaultAllocator: Allocator, @@ -57,7 +57,7 @@ where } } -impl Distribution> for Standard +impl Distribution> for Standard where R: AlgaRotation>, DefaultAllocator: Allocator, @@ -74,7 +74,7 @@ where } } -impl Similarity +impl Similarity where R: AlgaRotation>, DefaultAllocator: Allocator, @@ -104,7 +104,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for Similarity where - N: Real + Arbitrary + Send, + N: RealField + Arbitrary + Send, R: AlgaRotation> + Arbitrary + Send, DefaultAllocator: Allocator, Owned: Send, @@ -127,7 +127,7 @@ where */ // 2D rotation. -impl Similarity> { +impl Similarity> { /// Creates a new similarity from a translation, a rotation, and an uniform scaling factor. /// /// # Example @@ -150,7 +150,7 @@ impl Similarity> { } } -impl Similarity> { +impl Similarity> { /// Creates a new similarity from a translation and a rotation angle. /// /// # Example @@ -176,7 +176,7 @@ impl Similarity> { // 3D rotation. macro_rules! similarity_construction_impl( ($Rot: ty) => { - impl Similarity { + impl Similarity { /// Creates a new similarity from a translation, rotation axis-angle, and scaling /// factor. /// diff --git a/src/geometry/similarity_conversion.rs b/src/geometry/similarity_conversion.rs index a040def3..a0d207e4 100644 --- a/src/geometry/similarity_conversion.rs +++ b/src/geometry/similarity_conversion.rs @@ -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 SubsetOf> for Similarity where - N1: Real + SubsetOf, - N2: Real + SupersetOf, + N1: RealField + SubsetOf, + N2: RealField + SupersetOf, R1: Rotation> + SubsetOf, R2: Rotation>, DefaultAllocator: Allocator + Allocator, @@ -46,8 +46,8 @@ where impl SubsetOf> for Similarity where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, C: SuperTCategoryOf, R: Rotation> + SubsetOf>> @@ -80,8 +80,8 @@ where impl SubsetOf>> for Similarity where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: Rotation> + SubsetOf>> + SubsetOf>>, @@ -163,7 +163,7 @@ where } } -impl From> for MatrixN> +impl From> for MatrixN> where D: DimNameAdd, R: SubsetOf>>, diff --git a/src/geometry/similarity_ops.rs b/src/geometry/similarity_ops.rs index fec4bdeb..80d84b86 100644 --- a/src/geometry/similarity_ops.rs +++ b/src/geometry/similarity_ops.rs @@ -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>, DefaultAllocator: Allocator { 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 $OpAssign<$Rhs> for $Lhs + impl $OpAssign<$Rhs> for $Lhs where R: AlgaRotation>, DefaultAllocator: Allocator { #[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>, DefaultAllocator: Allocator { #[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 + Allocator { type Output = $Output; diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 9b62d531..f5cf92a3 100644 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -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(mat: &MatrixN) -> bool + fn check_homogeneous_invariants(mat: &MatrixN) -> bool where N::Epsilon: Copy, DefaultAllocator: Allocator; @@ -69,7 +69,7 @@ pub enum TAffine {} impl TCategory for TGeneral { #[inline] - fn check_homogeneous_invariants(_: &MatrixN) -> bool + fn check_homogeneous_invariants(_: &MatrixN) -> bool where N::Epsilon: Copy, DefaultAllocator: Allocator, @@ -80,7 +80,7 @@ impl TCategory for TGeneral { impl TCategory for TProjective { #[inline] - fn check_homogeneous_invariants(mat: &MatrixN) -> bool + fn check_homogeneous_invariants(mat: &MatrixN) -> bool where N::Epsilon: Copy, DefaultAllocator: Allocator, @@ -96,7 +96,7 @@ impl TCategory for TAffine { } #[inline] - fn check_homogeneous_invariants(mat: &MatrixN) -> bool + fn check_homogeneous_invariants(mat: &MatrixN) -> bool where N::Epsilon: Copy, DefaultAllocator: Allocator, @@ -155,7 +155,7 @@ super_tcategory_impl!( /// 3D transformation. #[repr(C)] #[derive(Debug)] -pub struct Transform, C: TCategory> +pub struct Transform, C: TCategory> where DefaultAllocator: Allocator, DimNameSum> { matrix: MatrixN>, @@ -163,7 +163,7 @@ where DefaultAllocator: Allocator, DimNameSum> } // FIXME -// impl + hash::Hash, C: TCategory> hash::Hash for Transform +// impl + hash::Hash, C: TCategory> hash::Hash for Transform // where DefaultAllocator: Allocator, DimNameSum>, // Owned, DimNameSum>: hash::Hash { // fn hash(&self, state: &mut H) { @@ -171,14 +171,14 @@ where DefaultAllocator: Allocator, DimNameSum> // } // } -impl + Copy, C: TCategory> Copy for Transform +impl + Copy, C: TCategory> Copy for Transform where DefaultAllocator: Allocator, DimNameSum>, Owned, DimNameSum>: Copy, { } -impl, C: TCategory> Clone for Transform +impl, C: TCategory> Clone for Transform where DefaultAllocator: Allocator, DimNameSum> { #[inline] @@ -188,7 +188,7 @@ where DefaultAllocator: Allocator, DimNameSum> } #[cfg(feature = "serde-serialize")] -impl, C: TCategory> Serialize for Transform +impl, C: TCategory> Serialize for Transform where DefaultAllocator: Allocator, DimNameSum>, Owned, DimNameSum>: Serialize, @@ -200,7 +200,7 @@ where } #[cfg(feature = "serde-serialize")] -impl<'a, N: Real, D: DimNameAdd, C: TCategory> Deserialize<'a> for Transform +impl<'a, N: RealField, D: DimNameAdd, C: TCategory> Deserialize<'a> for Transform where DefaultAllocator: Allocator, DimNameSum>, Owned, DimNameSum>: Deserialize<'a>, @@ -213,10 +213,10 @@ where } } -impl, C: TCategory> Eq for Transform where DefaultAllocator: Allocator, DimNameSum> +impl, C: TCategory> Eq for Transform where DefaultAllocator: Allocator, DimNameSum> {} -impl, C: TCategory> PartialEq for Transform +impl, C: TCategory> PartialEq for Transform where DefaultAllocator: Allocator, DimNameSum> { #[inline] @@ -225,7 +225,7 @@ where DefaultAllocator: Allocator, DimNameSum> } } -impl, C: TCategory> Transform +impl, C: TCategory> Transform where DefaultAllocator: Allocator, DimNameSum> { /// Creates a new transformation from the given homogeneous matrix. The transformation category @@ -452,7 +452,7 @@ where DefaultAllocator: Allocator, DimNameSum> } } -impl> Transform +impl> Transform where DefaultAllocator: Allocator, DimNameSum> { /// A mutable reference to underlying matrix. Use `.matrix_mut_unchecked` instead if this @@ -463,7 +463,7 @@ where DefaultAllocator: Allocator, DimNameSum> } } -impl, C: TCategory> AbsDiffEq for Transform +impl, C: TCategory> AbsDiffEq for Transform where N::Epsilon: Copy, DefaultAllocator: Allocator, DimNameSum>, @@ -481,7 +481,7 @@ where } } -impl, C: TCategory> RelativeEq for Transform +impl, C: TCategory> RelativeEq for Transform where N::Epsilon: Copy, DefaultAllocator: Allocator, DimNameSum>, @@ -504,7 +504,7 @@ where } } -impl, C: TCategory> UlpsEq for Transform +impl, C: TCategory> UlpsEq for Transform where N::Epsilon: Copy, DefaultAllocator: Allocator, DimNameSum>, diff --git a/src/geometry/transform_alga.rs b/src/geometry/transform_alga.rs index 0ece3862..5d0e8bf8 100644 --- a/src/geometry/transform_alga.rs +++ b/src/geometry/transform_alga.rs @@ -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, C> Identity for Transform +impl, C> Identity for Transform where C: TCategory, DefaultAllocator: Allocator, DimNameSum>, @@ -26,7 +26,7 @@ where } } -impl, C> TwoSidedInverse for Transform +impl, C> TwoSidedInverse for Transform where C: SubTCategoryOf, DefaultAllocator: Allocator, DimNameSum>, @@ -42,7 +42,7 @@ where } } -impl, C> AbstractMagma for Transform +impl, C> AbstractMagma for Transform where C: TCategory, DefaultAllocator: Allocator, DimNameSum>, @@ -55,7 +55,7 @@ where macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl, C> $marker<$operator> for Transform + impl, C> $marker<$operator> for Transform where C: TCategory, DefaultAllocator: Allocator, DimNameSum> { } )*} @@ -63,7 +63,7 @@ macro_rules! impl_multiplicative_structures( macro_rules! impl_inversible_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl, C> $marker<$operator> for Transform + impl, C> $marker<$operator> for Transform where C: SubTCategoryOf, DefaultAllocator: Allocator, DimNameSum> { } )*} @@ -87,7 +87,7 @@ impl_inversible_multiplicative_structures!( */ impl, C> Transformation> for Transform where - N: Real, + N: RealField, C: TCategory, DefaultAllocator: Allocator, DimNameSum> + Allocator> @@ -107,7 +107,7 @@ where impl, C> ProjectiveTransformation> for Transform where - N: Real, + N: RealField, C: SubTCategoryOf, DefaultAllocator: Allocator, DimNameSum> + Allocator> @@ -128,7 +128,7 @@ where // FIXME: we need to implement an SVD for this. // // impl, C> AffineTransformation> for Transform -// where N: Real, +// where N: RealField, // C: SubTCategoryOf, // DefaultAllocator: Allocator, DimNameSum> + // Allocator + diff --git a/src/geometry/transform_construction.rs b/src/geometry/transform_construction.rs index 55733a90..1b23daba 100644 --- a/src/geometry/transform_construction.rs +++ b/src/geometry/transform_construction.rs @@ -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, C: TCategory> Transform +impl, C: TCategory> Transform where DefaultAllocator: Allocator, DimNameSum> { /// Creates a new identity transform. @@ -45,7 +45,7 @@ where DefaultAllocator: Allocator, DimNameSum> } } -impl, C: TCategory> One for Transform +impl, C: TCategory> One for Transform where DefaultAllocator: Allocator, DimNameSum> { /// Creates a new identity transform. diff --git a/src/geometry/transform_conversion.rs b/src/geometry/transform_conversion.rs index 651ab69b..a0e00291 100644 --- a/src/geometry/transform_conversion.rs +++ b/src/geometry/transform_conversion.rs @@ -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 SubsetOf> for Transform where - N1: Real + SubsetOf, - N2: Real, + N1: RealField + SubsetOf, + N2: RealField, C1: TCategory, C2: SuperTCategoryOf, D: DimNameAdd, @@ -36,8 +36,8 @@ where impl SubsetOf>> for Transform where - N1: Real + SubsetOf, - N2: Real, + N1: RealField + SubsetOf, + N2: RealField, C: TCategory, D: DimNameAdd, DefaultAllocator: Allocator, DimNameSum> @@ -61,7 +61,7 @@ where } } -impl From> for MatrixN> +impl From> for MatrixN> where D: DimNameAdd, C: TCategory, diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 9d03038d..4aa943e8 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -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 Index<(usize, usize)> for Transform +impl Index<(usize, usize)> for Transform where D: DimName + DimNameAdd, DefaultAllocator: Allocator, DimNameSum>, @@ -93,7 +93,7 @@ where } // Only general transformations are mutably indexable. -impl IndexMut<(usize, usize)> for Transform +impl IndexMut<(usize, usize)> for Transform where D: DimName + DimNameAdd, DefaultAllocator: Allocator, DimNameSum>, @@ -106,7 +106,7 @@ where // Transform × Vector md_impl_all!( - Mul, mul where N: Real; + Mul, mul where N: RealField; (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory; self: Transform, rhs: VectorN, Output = VectorN; [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, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory where DefaultAllocator: Allocator; self: Transform, rhs: Point, Output = Point; @@ -156,7 +156,7 @@ md_impl_all!( // Transform × Transform md_impl_all!( - Mul, mul where N: Real; + Mul, mul where N: RealField; (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategoryMul, CB: TCategory; self: Transform, rhs: Transform, Output = Transform; [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, DimNameSum), (D, D) for D: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Rotation, Output = Transform; [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, DimNameSum) for D: DimNameAdd, C: TCategoryMul; self: Rotation, rhs: Transform, Output = Transform; [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; self: Transform, rhs: UnitQuaternion, Output = Transform; [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; self: UnitQuaternion, rhs: Transform, Output = Transform; [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, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Transform, rhs: Isometry, Output = Transform; @@ -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, DimNameSum) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Isometry, rhs: Transform, Output = Transform; @@ -235,7 +235,7 @@ md_impl_all!( // Transform × Similarity md_impl_all!( - Mul, mul where N: Real; + Mul, mul where N: RealField; (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Transform, rhs: Similarity, Output = Transform; @@ -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, DimNameSum) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Similarity, rhs: Transform, Output = Transform; @@ -267,7 +267,7 @@ md_impl_all!( */ // Transform × Translation md_impl_all!( - Mul, mul where N: Real; + Mul, mul where N: RealField; (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Translation, Output = Transform; [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, DimNameSum) for D: DimNameAdd, C: TCategoryMul; self: Translation, rhs: Transform, Output = Transform; @@ -290,7 +290,7 @@ md_impl_all!( // Transform ÷ Transform md_impl_all!( - Div, div where N: Real; + Div, div where N: RealField; (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategoryMul, CB: SubTCategoryOf; self: Transform, rhs: Transform, Output = Transform; [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, DimNameSum), (D, D) for D: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Rotation, Output = Transform; [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, DimNameSum) for D: DimNameAdd, C: TCategoryMul; self: Rotation, rhs: Transform, Output = Transform; [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; self: Transform, rhs: UnitQuaternion, Output = Transform; [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; self: UnitQuaternion, rhs: Transform, Output = Transform; [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, DimNameSum), (D, U1) // for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > // where SB::Alloc: Allocator, DimNameSum >; @@ -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, DimNameSum) // for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > // where SA::Alloc: Allocator, DimNameSum >; @@ -371,7 +371,7 @@ md_impl_all!( // // Transform ÷ Similarity // md_impl_all!( -// Div, div where N: Real; +// Div, div where N: RealField; // (DimNameSum, DimNameSum), (D, U1) // for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > // where SB::Alloc: Allocator @@ -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, DimNameSum) // for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > // where SA::Alloc: Allocator @@ -399,7 +399,7 @@ md_impl_all!( // Transform ÷ Translation md_impl_all!( - Div, div where N: Real; + Div, div where N: RealField; (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Translation, Output = Transform; [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, DimNameSum) for D: DimNameAdd, C: TCategoryMul; self: Translation, rhs: Transform, Output = Transform; @@ -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, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategory, CB: SubTCategoryOf; self: Transform, rhs: Transform; [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, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory, R: SubsetOf> >; self: Transform, rhs: Similarity; @@ -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, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory, R: SubsetOf> >; self: Transform, rhs: Isometry; @@ -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, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory; self: Transform, rhs: Translation; [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, DimNameSum), (D, D) for D: DimNameAdd, C: TCategory; self: Transform, rhs: Rotation; [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, rhs: UnitQuaternion; [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, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: SuperTCategoryOf, CB: SubTCategoryOf; self: Transform, rhs: Transform; @@ -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, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategory; self: Transform, rhs: Translation; [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, DimNameSum), (D, D) for D: DimNameAdd, C: TCategory; self: Transform, rhs: Rotation; [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, rhs: UnitQuaternion; [val] => *self *= rhs.inverse(); diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 3b620b20..43a340f3 100644 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "abomonation-serialize")] use abomonation::Abomonation; -use 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 fmt::Display for Translation +impl fmt::Display for Translation where DefaultAllocator: Allocator + Allocator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/geometry/translation_alga.rs b/src/geometry/translation_alga.rs index 00b54421..f2ced0b3 100644 --- a/src/geometry/translation_alga.rs +++ b/src/geometry/translation_alga.rs @@ -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 Identity for Translation +impl Identity for Translation where DefaultAllocator: Allocator { #[inline] @@ -28,7 +28,7 @@ where DefaultAllocator: Allocator } } -impl TwoSidedInverse for Translation +impl TwoSidedInverse for Translation where DefaultAllocator: Allocator { #[inline] @@ -42,7 +42,7 @@ where DefaultAllocator: Allocator } } -impl AbstractMagma for Translation +impl AbstractMagma for Translation where DefaultAllocator: Allocator { #[inline] @@ -53,7 +53,7 @@ where DefaultAllocator: Allocator macro_rules! impl_multiplicative_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for Translation + impl $marker<$operator> for Translation where DefaultAllocator: Allocator { } )*} ); @@ -71,7 +71,7 @@ impl_multiplicative_structures!( * Transformation groups. * */ -impl Transformation> for Translation +impl Transformation> for Translation where DefaultAllocator: Allocator { #[inline] @@ -85,7 +85,7 @@ where DefaultAllocator: Allocator } } -impl ProjectiveTransformation> for Translation +impl ProjectiveTransformation> for Translation where DefaultAllocator: Allocator { #[inline] @@ -99,7 +99,7 @@ where DefaultAllocator: Allocator } } -impl AffineTransformation> for Translation +impl AffineTransformation> for Translation where DefaultAllocator: Allocator { type Rotation = Id; @@ -142,7 +142,7 @@ where DefaultAllocator: Allocator } } -impl Similarity> for Translation +impl Similarity> for Translation where DefaultAllocator: Allocator { type Scaling = Id; @@ -165,7 +165,7 @@ where DefaultAllocator: Allocator macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for Translation + impl $Trait> for Translation where DefaultAllocator: Allocator { } )*} ); @@ -173,7 +173,7 @@ macro_rules! marker_impl( marker_impl!(Isometry, DirectIsometry); /// Subgroups of the n-dimensional translation group `T(n)`. -impl AlgaTranslation> for Translation +impl AlgaTranslation> for Translation where DefaultAllocator: Allocator { #[inline] diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index 9f0e9a25..b44412e6 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -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 SubsetOf> for Translation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: Rotation>, DefaultAllocator: Allocator + Allocator, { @@ -69,8 +69,8 @@ where impl SubsetOf> for Translation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: Rotation>, DefaultAllocator: Allocator + Allocator, { @@ -92,8 +92,8 @@ where impl SubsetOf> for Translation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, C: SuperTCategoryOf, D: DimNameAdd, DefaultAllocator: Allocator @@ -119,8 +119,8 @@ where impl SubsetOf>> for Translation where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, D: DimNameAdd, DefaultAllocator: Allocator + Allocator diff --git a/src/geometry/unit_complex.rs b/src/geometry/unit_complex.rs index d02b46b6..2530cc25 100644 --- a/src/geometry/unit_complex.rs +++ b/src/geometry/unit_complex.rs @@ -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 = Unit>; -impl UnitComplex { +impl UnitComplex { /// The rotation angle in `]-pi; pi]` of this unit complex number. /// /// # Example @@ -253,13 +253,13 @@ impl UnitComplex { } } -impl fmt::Display for UnitComplex { +impl fmt::Display for UnitComplex { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "UnitComplex angle: {}", self.angle()) } } -impl AbsDiffEq for UnitComplex { +impl AbsDiffEq for UnitComplex { type Epsilon = N; #[inline] @@ -273,7 +273,7 @@ impl AbsDiffEq for UnitComplex { } } -impl RelativeEq for UnitComplex { +impl RelativeEq for UnitComplex { #[inline] fn default_max_relative() -> Self::Epsilon { N::default_max_relative() @@ -292,7 +292,7 @@ impl RelativeEq for UnitComplex { } } -impl UlpsEq for UnitComplex { +impl UlpsEq for UnitComplex { #[inline] fn default_max_ulps() -> u32 { N::default_max_ulps() diff --git a/src/geometry/unit_complex_alga.rs b/src/geometry/unit_complex_alga.rs index d49a3e57..685a588e 100644 --- a/src/geometry/unit_complex_alga.rs +++ b/src/geometry/unit_complex_alga.rs @@ -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 Identity for UnitComplex { +impl Identity for UnitComplex { #[inline] fn identity() -> Self { Self::identity() } } -impl AbstractMagma for UnitComplex { +impl AbstractMagma for UnitComplex { #[inline] fn operate(&self, rhs: &Self) -> Self { self * rhs } } -impl TwoSidedInverse for UnitComplex { +impl TwoSidedInverse for UnitComplex { #[inline] fn two_sided_inverse(&self) -> Self { self.inverse() @@ -45,7 +45,7 @@ impl TwoSidedInverse for UnitComplex { macro_rules! impl_structures( ($($marker: ident<$operator: ident>),* $(,)*) => {$( - impl $marker<$operator> for UnitComplex { + impl $marker<$operator> for UnitComplex { } )*} ); @@ -58,7 +58,7 @@ impl_structures!( AbstractGroup ); -impl Transformation> for UnitComplex +impl Transformation> for UnitComplex where DefaultAllocator: Allocator { #[inline] @@ -72,7 +72,7 @@ where DefaultAllocator: Allocator } } -impl ProjectiveTransformation> for UnitComplex +impl ProjectiveTransformation> for UnitComplex where DefaultAllocator: Allocator { #[inline] @@ -88,7 +88,7 @@ where DefaultAllocator: Allocator } } -impl AffineTransformation> for UnitComplex +impl AffineTransformation> for UnitComplex where DefaultAllocator: Allocator { type Rotation = Self; @@ -131,7 +131,7 @@ where DefaultAllocator: Allocator } } -impl Similarity> for UnitComplex +impl Similarity> for UnitComplex where DefaultAllocator: Allocator { type Scaling = Id; @@ -154,14 +154,14 @@ where DefaultAllocator: Allocator macro_rules! marker_impl( ($($Trait: ident),*) => {$( - impl $Trait> for UnitComplex + impl $Trait> for UnitComplex where DefaultAllocator: Allocator { } )*} ); marker_impl!(Isometry, DirectIsometry, OrthogonalTransformation); -impl Rotation> for UnitComplex +impl Rotation> for UnitComplex where DefaultAllocator: Allocator { #[inline] diff --git a/src/geometry/unit_complex_construction.rs b/src/geometry/unit_complex_construction.rs index 7e24559c..046142c8 100644 --- a/src/geometry/unit_complex_construction.rs +++ b/src/geometry/unit_complex_construction.rs @@ -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 UnitComplex { +impl UnitComplex { /// The unit complex number multiplicative identity. /// /// # Example @@ -268,14 +268,14 @@ impl UnitComplex { } } -impl One for UnitComplex { +impl One for UnitComplex { #[inline] fn one() -> Self { Self::identity() } } -impl Distribution> for Standard +impl Distribution> for Standard where OpenClosed01: Distribution { /// Generate a uniformly distributed random `UnitComplex`. @@ -286,7 +286,7 @@ where OpenClosed01: Distribution } #[cfg(feature = "arbitrary")] -impl Arbitrary for UnitComplex { +impl Arbitrary for UnitComplex { #[inline] fn arbitrary(g: &mut G) -> Self { UnitComplex::from_angle(N::arbitrary(g)) diff --git a/src/geometry/unit_complex_conversion.rs b/src/geometry/unit_complex_conversion.rs index 3adb372c..f7fe4532 100644 --- a/src/geometry/unit_complex_conversion.rs +++ b/src/geometry/unit_complex_conversion.rs @@ -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 SubsetOf> for UnitComplex where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> UnitComplex { @@ -49,8 +49,8 @@ where impl SubsetOf> for UnitComplex where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, { #[inline] fn to_superset(&self) -> Rotation2 { @@ -72,8 +72,8 @@ where impl SubsetOf> for UnitComplex where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: AlgaRotation> + SupersetOf, { #[inline] @@ -94,8 +94,8 @@ where impl SubsetOf> for UnitComplex where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, R: AlgaRotation> + SupersetOf, { #[inline] @@ -116,8 +116,8 @@ where impl SubsetOf> for UnitComplex where - N1: Real, - N2: Real + SupersetOf, + N1: RealField, + N2: RealField + SupersetOf, C: SuperTCategoryOf, { #[inline] @@ -136,7 +136,7 @@ where } } -impl> SubsetOf> for UnitComplex { +impl> SubsetOf> for UnitComplex { #[inline] fn to_superset(&self) -> Matrix3 { self.to_homogeneous().to_superset() @@ -155,28 +155,28 @@ impl> SubsetOf> for UnitComplex< } -impl From> for Rotation2 { +impl From> for Rotation2 { #[inline] fn from(q: UnitComplex) -> Self { q.to_rotation_matrix() } } -impl From> for UnitComplex { +impl From> for UnitComplex { #[inline] fn from(q: Rotation2) -> Self { Self::from_rotation_matrix(&q) } } -impl From> for Matrix3 { +impl From> for Matrix3 { #[inline] fn from(q: UnitComplex) -> Matrix3 { q.to_homogeneous() } } -impl From> for Matrix2 { +impl From> for Matrix2 { #[inline] fn from(q: UnitComplex) -> Self { q.to_rotation_matrix().into_inner() diff --git a/src/geometry/unit_complex_ops.rs b/src/geometry/unit_complex_ops.rs index ee8eca64..11ffdc4a 100644 --- a/src/geometry/unit_complex_ops.rs +++ b/src/geometry/unit_complex_ops.rs @@ -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 Mul for UnitComplex { +impl Mul for UnitComplex { type Output = Self; #[inline] @@ -53,7 +53,7 @@ impl Mul for UnitComplex { } } -impl<'a, N: Real> Mul> for &'a UnitComplex { +impl<'a, N: RealField> Mul> for &'a UnitComplex { type Output = UnitComplex; #[inline] @@ -62,7 +62,7 @@ impl<'a, N: Real> Mul> for &'a UnitComplex { } } -impl<'b, N: Real> Mul<&'b UnitComplex> for UnitComplex { +impl<'b, N: RealField> Mul<&'b UnitComplex> for UnitComplex { type Output = Self; #[inline] @@ -71,7 +71,7 @@ impl<'b, N: Real> Mul<&'b UnitComplex> for UnitComplex { } } -impl<'a, 'b, N: Real> Mul<&'b UnitComplex> for &'a UnitComplex { +impl<'a, 'b, N: RealField> Mul<&'b UnitComplex> for &'a UnitComplex { type Output = UnitComplex; #[inline] @@ -81,7 +81,7 @@ impl<'a, 'b, N: Real> Mul<&'b UnitComplex> for &'a UnitComplex { } // UnitComplex ÷ UnitComplex -impl Div for UnitComplex { +impl Div for UnitComplex { type Output = Self; #[inline] @@ -90,7 +90,7 @@ impl Div for UnitComplex { } } -impl<'a, N: Real> Div> for &'a UnitComplex { +impl<'a, N: RealField> Div> for &'a UnitComplex { type Output = UnitComplex; #[inline] @@ -99,7 +99,7 @@ impl<'a, N: Real> Div> for &'a UnitComplex { } } -impl<'b, N: Real> Div<&'b UnitComplex> for UnitComplex { +impl<'b, N: RealField> Div<&'b UnitComplex> for UnitComplex { type Output = Self; #[inline] @@ -108,7 +108,7 @@ impl<'b, N: Real> Div<&'b UnitComplex> for UnitComplex { } } -impl<'a, 'b, N: Real> Div<&'b UnitComplex> for &'a UnitComplex { +impl<'a, 'b, N: RealField> Div<&'b UnitComplex> for &'a UnitComplex { type Output = UnitComplex; #[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 { type Output = $Result; @@ -300,14 +300,14 @@ complex_op_impl_all!( ); // UnitComplex ×= UnitComplex -impl MulAssign> for UnitComplex { +impl MulAssign> for UnitComplex { #[inline] fn mul_assign(&mut self, rhs: UnitComplex) { *self = &*self * rhs } } -impl<'b, N: Real> MulAssign<&'b UnitComplex> for UnitComplex { +impl<'b, N: RealField> MulAssign<&'b UnitComplex> for UnitComplex { #[inline] fn mul_assign(&mut self, rhs: &'b UnitComplex) { *self = &*self * rhs @@ -315,14 +315,14 @@ impl<'b, N: Real> MulAssign<&'b UnitComplex> for UnitComplex { } // UnitComplex /= UnitComplex -impl DivAssign> for UnitComplex { +impl DivAssign> for UnitComplex { #[inline] fn div_assign(&mut self, rhs: UnitComplex) { *self = &*self / rhs } } -impl<'b, N: Real> DivAssign<&'b UnitComplex> for UnitComplex { +impl<'b, N: RealField> DivAssign<&'b UnitComplex> for UnitComplex { #[inline] fn div_assign(&mut self, rhs: &'b UnitComplex) { *self = &*self / rhs @@ -330,7 +330,7 @@ impl<'b, N: Real> DivAssign<&'b UnitComplex> for UnitComplex { } // UnitComplex ×= Rotation -impl MulAssign> for UnitComplex +impl MulAssign> for UnitComplex where DefaultAllocator: Allocator { #[inline] @@ -339,7 +339,7 @@ where DefaultAllocator: Allocator } } -impl<'b, N: Real> MulAssign<&'b Rotation> for UnitComplex +impl<'b, N: RealField> MulAssign<&'b Rotation> for UnitComplex where DefaultAllocator: Allocator { #[inline] @@ -349,7 +349,7 @@ where DefaultAllocator: Allocator } // UnitComplex ÷= Rotation -impl DivAssign> for UnitComplex +impl DivAssign> for UnitComplex where DefaultAllocator: Allocator { #[inline] @@ -358,7 +358,7 @@ where DefaultAllocator: Allocator } } -impl<'b, N: Real> DivAssign<&'b Rotation> for UnitComplex +impl<'b, N: RealField> DivAssign<&'b Rotation> for UnitComplex where DefaultAllocator: Allocator { #[inline] @@ -368,7 +368,7 @@ where DefaultAllocator: Allocator } // Rotation ×= UnitComplex -impl MulAssign> for Rotation +impl MulAssign> for Rotation where DefaultAllocator: Allocator { #[inline] @@ -377,7 +377,7 @@ where DefaultAllocator: Allocator } } -impl<'b, N: Real> MulAssign<&'b UnitComplex> for Rotation +impl<'b, N: RealField> MulAssign<&'b UnitComplex> for Rotation where DefaultAllocator: Allocator { #[inline] @@ -387,7 +387,7 @@ where DefaultAllocator: Allocator } // Rotation ÷= UnitComplex -impl DivAssign> for Rotation +impl DivAssign> for Rotation where DefaultAllocator: Allocator { #[inline] @@ -396,7 +396,7 @@ where DefaultAllocator: Allocator } } -impl<'b, N: Real> DivAssign<&'b UnitComplex> for Rotation +impl<'b, N: RealField> DivAssign<&'b UnitComplex> for Rotation where DefaultAllocator: Allocator { #[inline] diff --git a/src/io/matrix_market.rs b/src/io/matrix_market.rs index c2653c16..f0e817a1 100644 --- a/src/io/matrix_market.rs +++ b/src/io/matrix_market.rs @@ -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>(path: P) -> Option> { +pub fn cs_matrix_from_matrix_market>(path: P) -> Option> { 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(data: &str) -> Option> { +pub fn cs_matrix_from_matrix_market_str(data: &str) -> Option> { let file = MatrixMarketParser::parse(Rule::Document, data) .unwrap() .next()?; diff --git a/src/lib.rs b/src/lib.rs index f66ae4f0..0388290b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(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(a: &T) -> T { a.abs() @@ -460,7 +460,7 @@ pub fn dot(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(a: &V, b: &V) -> V::Real { +pub fn angle(a: &V, b: &V) -> V::RealField { a.angle(b) } @@ -484,7 +484,7 @@ pub fn angle(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: &V) -> V::Real { +pub fn norm(v: &V) -> V::RealField { v.norm() } @@ -504,7 +504,7 @@ pub fn norm(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: &V) -> V::Real { +pub fn norm_squared(v: &V) -> V::RealField { v.norm_squared() } @@ -524,7 +524,7 @@ pub fn norm_squared(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: &V) -> V::Real { +pub fn magnitude(v: &V) -> V::RealField { v.norm() } @@ -545,7 +545,7 @@ pub fn magnitude(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: &V) -> V::Real { +pub fn magnitude_squared(v: &V) -> V::RealField { v.norm_squared() } @@ -573,7 +573,7 @@ pub fn normalize(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: &V, min_norm: V::Real) -> Option { +pub fn try_normalize(v: &V, min_norm: V::RealField) -> Option { v.try_normalize(min_norm) } @@ -600,7 +600,7 @@ pub fn center(p1: &P, p2: &P) -> P { /// * [center](fn.center.html) /// * [distance_squared](fn.distance_squared.html) #[inline] -pub fn distance(p1: &P, p2: &P) -> P::Real { +pub fn distance(p1: &P, p2: &P) -> P::RealField { (p2.coordinates() - p1.coordinates()).norm() } @@ -611,7 +611,7 @@ pub fn distance(p1: &P, p2: &P) -> P::Real { /// * [center](fn.center.html) /// * [distance](fn.distance.html) #[inline] -pub fn distance_squared(p1: &P, p2: &P) -> P::Real { +pub fn distance_squared(p1: &P, p2: &P) -> P::RealField { (p2.coordinates() - p1.coordinates()).norm_squared() } diff --git a/src/linalg/balancing.rs b/src/linalg/balancing.rs index 33dcbff6..e8abbefb 100644 --- a/src/linalg/balancing.rs +++ b/src/linalg/balancing.rs @@ -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(m: &mut MatrixN) -> VectorN +pub fn balance_parlett_reinsch(m: &mut MatrixN) -> VectorN where DefaultAllocator: Allocator + Allocator { assert!(m.is_square(), "Unable to balance a non-square matrix."); @@ -64,7 +64,7 @@ where DefaultAllocator: Allocator + Allocator { } /// Computes in-place `D * m * D.inverse()`, where `D` is the matrix with diagonal `d`. -pub fn unbalance(m: &mut MatrixN, d: &VectorN) +pub fn unbalance(m: &mut MatrixN, d: &VectorN) where DefaultAllocator: Allocator + Allocator { assert!(m.is_square(), "Unable to unbalance a non-square matrix."); assert_eq!(m.nrows(), d.len(), "Unbalancing: mismatched dimensions."); diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index e61c98ec..f766c91e 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -265,14 +265,14 @@ where } /// The diagonal part of this decomposed matrix. - pub fn diagonal(&self) -> VectorN> - where DefaultAllocator: Allocator> { + pub fn diagonal(&self) -> VectorN> + where DefaultAllocator: Allocator> { self.diagonal.map(|e| e.modulus()) } /// The off-diagonal part of this decomposed matrix. - pub fn off_diagonal(&self) -> VectorN, U1>> - where DefaultAllocator: Allocator, U1>> { + pub fn off_diagonal(&self) -> VectorN, U1>> + where DefaultAllocator: Allocator, U1>> { self.off_diagonal.map(|e| e.modulus()) } diff --git a/src/linalg/givens.rs b/src/linalg/givens.rs index 3dd56ee3..ed93a83c 100644 --- a/src/linalg/givens.rs +++ b/src/linalg/givens.rs @@ -12,7 +12,7 @@ use crate::base::{Vector, Matrix}; /// A Givens rotation. #[derive(Debug, Clone, Copy)] pub struct GivensRotation { - c: N::Real, + c: N::RealField, s: N } @@ -21,7 +21,7 @@ impl GivensRotation { /// 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 GivensRotation { /// /// 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 GivensRotation { /// 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 GivensRotation { } /// The cos part of this roration. - pub fn c(&self) -> N::Real { + pub fn c(&self) -> N::RealField { self.c } diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index 9407cf7f..b31be9f6 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -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) -> 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, eps: N::Real, max_niter: usize) -> Option { + pub fn try_new(m: MatrixN, eps: N::RealField, max_niter: usize) -> Option { 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, work: &mut VectorN, - eps: N::Real, + eps: N::RealField, max_niter: usize, compute_q: bool, ) -> Option<(Option>, MatrixN)> @@ -291,7 +291,7 @@ where /// Computes the complex eigenvalues of the decomposed matrix. fn do_complex_eigenvalues(t: &MatrixN, out: &mut VectorN, D>) - where N: Real, + where N: RealField, DefaultAllocator: Allocator, D> { let dim = t.nrows(); let mut m = 0; @@ -329,7 +329,7 @@ where } } - fn delimit_subproblem(t: &mut MatrixN, eps: N::Real, end: usize) -> (usize, usize) + fn delimit_subproblem(t: &mut MatrixN, eps: N::RealField, end: usize) -> (usize, usize) where D: DimSub, DefaultAllocator: Allocator>, @@ -390,7 +390,7 @@ where /// Computes the complex eigenvalues of the decomposed matrix. pub fn complex_eigenvalues(&self) -> VectorN, D> - where N: Real, + where N: RealField, DefaultAllocator: Allocator, 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> { + pub fn try_schur(self, eps: N::RealField, max_niter: usize) -> Option> { 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, D> // FIXME: add balancing? - where N: Real, + where N: RealField, DefaultAllocator: Allocator, D> { let dim = self.data.shape().0; let mut work = unsafe { VectorN::new_uninitialized_generic(dim, U1) }; diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index 714f398f..b608ec0c 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -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> + + serialize = "DefaultAllocator: Allocator> + Allocator, C> + Allocator>, MatrixMN>: Serialize, MatrixMN, C>: Serialize, - VectorN>: Serialize" + VectorN>: Serialize" )) )] #[cfg_attr( feature = "serde-serialize", serde(bound( - deserialize = "DefaultAllocator: Allocator> + + deserialize = "DefaultAllocator: Allocator> + Allocator, C> + Allocator>, MatrixMN>: Deserialize<'de>, MatrixMN, C>: Deserialize<'de>, - VectorN>: Deserialize<'de>" + VectorN>: Deserialize<'de>" )) )] #[derive(Clone, Debug)] pub struct SVD, C: Dim> where DefaultAllocator: Allocator, C> + Allocator> - + Allocator> + + Allocator> { /// The left-singular vectors `U` of this SVD. pub u: Option>>, /// The right-singular vectors `V^t` of this SVD. pub v_t: Option, C>>, /// The singular values of this SVD. - pub singular_values: VectorN>, + pub singular_values: VectorN>, } impl, C: Dim> Copy for SVD where DefaultAllocator: Allocator, C> + Allocator> - + Allocator>, + + Allocator>, MatrixMN>: Copy, MatrixMN, C>: Copy, - VectorN>: Copy, + VectorN>: Copy, {} impl, C: Dim> SVD @@ -73,12 +73,12 @@ where + Allocator, C> + Allocator> + Allocator> - + Allocator> - + Allocator, U1>>, + + Allocator> + + Allocator, U1>>, { /// Computes the Singular Value Decomposition of `matrix` using implicit shift. pub fn new(matrix: MatrixMN, 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, compute_u: bool, compute_v: bool, - eps: N::Real, + eps: N::RealField, max_niter: usize, ) -> Option { @@ -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>, - off_diagonal: &mut VectorN, U1>>, + diagonal: &mut VectorN>, + off_diagonal: &mut VectorN, U1>>, u: &mut Option>>, v_t: &mut Option, 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>, - off_diagonal: &mut VectorN, U1>>, + diagonal: &mut VectorN>, + off_diagonal: &mut VectorN, U1>>, u: &mut Option>>, v_t: &mut Option, 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>, - off_diagonal: &mut VectorN, U1>>, + diagonal: &mut VectorN>, + off_diagonal: &mut VectorN, U1>>, u: &mut Option>>, v_t: &mut Option, 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, &'static str> + pub fn pseudo_inverse(mut self, eps: N::RealField) -> Result, &'static str> where DefaultAllocator: Allocator, { - 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( &self, b: &Matrix, - eps: N::Real, + eps: N::RealField, ) -> Result, &'static str> where S2: Storage, DefaultAllocator: Allocator + Allocator, C2>, ShapeConstraint: SameNumberOfRows, { - 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, C> + Allocator> + Allocator> - + Allocator> - + Allocator, U1>>, + + Allocator> + + Allocator, U1>>, { /// Computes the Singular Value Decomposition using implicit shift. pub fn svd(self, compute_u: bool, compute_v: bool) -> SVD { @@ -578,7 +578,7 @@ where self, compute_u: bool, compute_v: bool, - eps: N::Real, + eps: N::RealField, max_niter: usize, ) -> Option> { @@ -586,14 +586,14 @@ where } /// Computes the singular values of this matrix. - pub fn singular_values(&self) -> VectorN> { + pub fn singular_values(&self) -> VectorN> { 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, &'static str> + pub fn pseudo_inverse(self, eps: N::RealField) -> Result, &'static str> where DefaultAllocator: Allocator, { @@ -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( +fn compute_2x2_uptrig_svd( m11: N, m12: N, m22: N, @@ -621,8 +621,8 @@ fn compute_2x2_uptrig_svd( compute_v: bool, ) -> (Option>, Vector2, Option>) { - 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); diff --git a/src/linalg/symmetric_eigen.rs b/src/linalg/symmetric_eigen.rs index 78e00509..fc493dca 100644 --- a/src/linalg/symmetric_eigen.rs +++ b/src/linalg/symmetric_eigen.rs @@ -19,8 +19,8 @@ use crate::linalg::SymmetricTridiagonal; feature = "serde-serialize", serde(bound( serialize = "DefaultAllocator: Allocator + - Allocator, - VectorN: Serialize, + Allocator, + VectorN: Serialize, MatrixN: Serialize" )) )] @@ -28,31 +28,31 @@ use crate::linalg::SymmetricTridiagonal; feature = "serde-serialize", serde(bound( deserialize = "DefaultAllocator: Allocator + - Allocator, - VectorN: Deserialize<'de>, + Allocator, + VectorN: Deserialize<'de>, MatrixN: Deserialize<'de>" )) )] #[derive(Clone, Debug)] pub struct SymmetricEigen -where DefaultAllocator: Allocator + Allocator +where DefaultAllocator: Allocator + Allocator { /// The eigenvectors of the decomposed matrix. pub eigenvectors: MatrixN, /// The unsorted eigenvalues of the decomposed matrix. - pub eigenvalues: VectorN, + pub eigenvalues: VectorN, } impl Copy for SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, MatrixN: Copy, - VectorN: Copy, + VectorN: Copy, {} impl SymmetricEigen -where DefaultAllocator: Allocator + Allocator +where DefaultAllocator: Allocator + Allocator { /// Computes the eigendecomposition of the given symmetric matrix. /// @@ -61,9 +61,9 @@ where DefaultAllocator: Allocator + Allocator where D: DimSub, DefaultAllocator: Allocator> + // For tridiagonalization - Allocator>, + Allocator>, { - 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 + Allocator /// * `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, eps: N::Real, max_niter: usize) -> Option + pub fn try_new(m: MatrixN, eps: N::RealField, max_niter: usize) -> Option where D: DimSub, DefaultAllocator: Allocator> + // For tridiagonalization - Allocator>, + Allocator>, { Self::do_decompose(m, true, eps, max_niter).map(|(vals, vecs)| SymmetricEigen { eigenvectors: vecs.unwrap(), @@ -92,13 +92,13 @@ where DefaultAllocator: Allocator + Allocator fn do_decompose( mut m: MatrixN, eigenvectors: bool, - eps: N::Real, + eps: N::RealField, max_niter: usize, - ) -> Option<(VectorN, Option>)> + ) -> Option<(VectorN, Option>)> where D: DimSub, DefaultAllocator: Allocator> + // For tridiagonalization - Allocator>, + Allocator>, { assert!( m.is_square(), @@ -226,14 +226,14 @@ where DefaultAllocator: Allocator + Allocator } fn delimit_subproblem( - diag: &VectorN, - off_diag: &mut VectorN>, + diag: &VectorN, + off_diag: &mut VectorN>, end: usize, - eps: N::Real, + eps: N::RealField, ) -> (usize, usize) where D: DimSub, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let mut n = end; @@ -258,7 +258,7 @@ where DefaultAllocator: Allocator + Allocator 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(tmm: N, tnn: N, tmn: N) -> N { */ impl, S: Storage> SquareMatrix where DefaultAllocator: Allocator + Allocator> + - Allocator + Allocator> + Allocator + Allocator> { /// Computes the eigendecomposition of this symmetric matrix. /// @@ -326,15 +326,15 @@ where DefaultAllocator: Allocator + Allocator> + /// * `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> { + pub fn try_symmetric_eigen(self, eps: N::RealField, max_niter: usize) -> Option> { 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 { - SymmetricEigen::do_decompose(self.clone_owned(), false, N::Real::default_epsilon(), 0) + pub fn symmetric_eigenvalues(&self) -> VectorN { + SymmetricEigen::do_decompose(self.clone_owned(), false, N::RealField::default_epsilon(), 0) .unwrap() .0 } diff --git a/src/linalg/symmetric_tridiagonal.rs b/src/linalg/symmetric_tridiagonal.rs index 0a04dae8..40da8677 100644 --- a/src/linalg/symmetric_tridiagonal.rs +++ b/src/linalg/symmetric_tridiagonal.rs @@ -98,9 +98,9 @@ where DefaultAllocator: Allocator + Allocator> /// Retrieve the orthogonal transformation, diagonal, and off diagonal elements of this /// decomposition. - pub fn unpack(self) -> (MatrixN, VectorN, VectorN>) - where DefaultAllocator: Allocator - + Allocator> { + pub fn unpack(self) -> (MatrixN, VectorN, VectorN>) + where DefaultAllocator: Allocator + + Allocator> { let diag = self.diagonal(); let q = self.q(); @@ -108,19 +108,19 @@ where DefaultAllocator: Allocator + Allocator> } /// Retrieve the diagonal, and off diagonal elements of this decomposition. - pub fn unpack_tridiagonal(self) -> (VectorN, VectorN>) - where DefaultAllocator: Allocator - + Allocator> { + pub fn unpack_tridiagonal(self) -> (VectorN, VectorN>) + where DefaultAllocator: Allocator + + Allocator> { (self.diagonal(), self.off_diagonal.map(N::modulus)) } /// The diagonal components of this decomposition. - pub fn diagonal(&self) -> VectorN - where DefaultAllocator: Allocator { self.tri.map_diagonal(|e| e.real()) } + pub fn diagonal(&self) -> VectorN + where DefaultAllocator: Allocator { self.tri.map_diagonal(|e| e.real()) } /// The off-diagonal components of this decomposition. - pub fn off_diagonal(&self) -> VectorN> - where DefaultAllocator: Allocator> { + pub fn off_diagonal(&self) -> VectorN> + where DefaultAllocator: Allocator> { self.off_diagonal.map(N::modulus) } diff --git a/src/sparse/cs_matrix_cholesky.rs b/src/sparse/cs_matrix_cholesky.rs index fc7e97f9..4c3fffd8 100644 --- a/src/sparse/cs_matrix_cholesky.rs +++ b/src/sparse/cs_matrix_cholesky.rs @@ -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 +pub struct CsCholesky where DefaultAllocator: Allocator + Allocator { // Non-zero pattern of the original matrix upper-triangular part. @@ -25,7 +25,7 @@ where DefaultAllocator: Allocator + Allocator work_c: VectorN, } -impl CsCholesky +impl CsCholesky where DefaultAllocator: Allocator + Allocator { /// Computes the cholesky decomposition of the sparse matrix `m`. diff --git a/src/sparse/cs_matrix_solve.rs b/src/sparse/cs_matrix_solve.rs index a6bb628d..1dfd7843 100644 --- a/src/sparse/cs_matrix_solve.rs +++ b/src/sparse/cs_matrix_solve.rs @@ -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> CsMatrix { +impl> CsMatrix { /// Solve a lower-triangular system with a dense right-hand-side. pub fn solve_lower_triangular( &self, diff --git a/tests/core/helper.rs b/tests/core/helper.rs index 9b9dfa75..625a4a46 100644 --- a/tests/core/helper.rs +++ b/tests/core/helper.rs @@ -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(pub Complex); -impl Arbitrary for RandComplex { +impl Arbitrary for RandComplex { #[inline] fn arbitrary(rng: &mut G) -> Self { let im = Arbitrary::arbitrary(rng); @@ -19,7 +19,7 @@ impl Arbitrary for RandComplex { } } -impl Distribution> for Standard +impl Distribution> for Standard where Standard: Distribution, { @@ -43,7 +43,7 @@ impl Arbitrary for RandScalar { } } -impl Distribution> for Standard +impl Distribution> for Standard where Standard: Distribution, { diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 81de11b0..1517091b 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -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 + Display>(vs: &[T]) -> bool { + fn is_subspace_basis + 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) { diff --git a/tests/geometry/rotation.rs b/tests/geometry/rotation.rs index e4b1f9d7..c0886754 100644 --- a/tests/geometry/rotation.rs +++ b/tests/geometry/rotation.rs @@ -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;