Start actually implementing the GLM functions.

This commit is contained in:
sebcrozet 2018-09-20 14:23:31 +02:00 committed by Sébastien Crozet
parent bee63859c0
commit e7edad5ebb
30 changed files with 510 additions and 413 deletions

View File

@ -5,5 +5,6 @@ authors = ["sebcrozet <developer@crozet.re>"]
[dependencies] [dependencies]
num-traits = { version = "0.2", default-features = false } num-traits = { version = "0.2", default-features = false }
approx = { version = "0.3", default-features = false }
alga = "0.7" alga = "0.7"
nalgebra = { path = ".." } nalgebra = { path = ".." }

View File

@ -1,7 +1,7 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::{Scalar, DefaultAllocator};
use aliases::Vec; use aliases::Vec;
use traits::Alloc; use traits::{Dimension, Alloc};
pub fn abs<T>(x: T) -> T { pub fn abs<T>(x: T) -> T {
@ -9,13 +9,13 @@ pub fn abs<T>(x: T) -> T {
} }
pub fn abs2<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn abs2<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn ceil<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn ceil<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -26,13 +26,13 @@ pub fn clamp<T>(x: T, minVal: T, maxVal: T) -> T {
} }
pub fn clamp2<N: Scalar, D: DimName>(x: &Vec<N, D>,minVal: N, maxVal: N) -> Vec<N, D> pub fn clamp2<N: Scalar, D: Dimension>(x: &Vec<N, D>,minVal: N, maxVal: N) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn clamp3<N: Scalar, D: DimName>(x: &Vec<N, D>, minVal: &Vec<N, D>, maxVal: &Vec<N, D>) -> Vec<N, D> pub fn clamp3<N: Scalar, D: Dimension>(x: &Vec<N, D>, minVal: &Vec<N, D>, maxVal: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -43,7 +43,7 @@ pub fn floatBitsToInt(v: f32) -> i32 {
} }
pub fn floatBitsToInt2<D: DimName>(v: Vec<f32, D>) -> Vec<i32, D> pub fn floatBitsToInt2<D: Dimension>(v: Vec<f32, D>) -> Vec<i32, D>
where DefaultAllocator: Alloc<f32, D> { where DefaultAllocator: Alloc<f32, D> {
unimplemented!() unimplemented!()
@ -54,12 +54,12 @@ pub fn floatBitsToUint(v: f32) -> u32 {
} }
pub fn floatBitsToUint2<D: DimName>(v: &Vec<f32, D>) -> Vec<u32, D> pub fn floatBitsToUint2<D: Dimension>(v: &Vec<f32, D>) -> Vec<u32, D>
where DefaultAllocator: Alloc<f32, D> { where DefaultAllocator: Alloc<f32, D> {
unimplemented!() unimplemented!()
} }
pub fn floor<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn floor<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -74,7 +74,7 @@ pub fn fract<T>(x: T) -> T {
} }
pub fn fract2<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn fract2<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -85,24 +85,24 @@ pub fn frexp<T, I>(x: T, exp: I) -> T {
} }
pub fn intBitsToFloat<N: Scalar, D: DimName>(v: i32) -> f32 { pub fn intBitsToFloat<N: Scalar, D: Dimension>(v: i32) -> f32 {
unimplemented!() unimplemented!()
} }
pub fn intBitsToFloat2<D: DimName>(v: &Vec<u32, D>) -> Vec<f32, D> pub fn intBitsToFloat2<D: Dimension>(v: &Vec<u32, D>) -> Vec<f32, D>
where DefaultAllocator: Alloc<f32, D> { where DefaultAllocator: Alloc<f32, D> {
unimplemented!() unimplemented!()
} }
pub fn isinf<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<bool, D> pub fn isinf<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn isnan<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<bool, D> pub fn isnan<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -118,12 +118,12 @@ pub fn max<T>(x: T, y: T) -> T {
} }
pub fn max2<N: Scalar, D: DimName>(x: &Vec<N, D>,y: N) -> Vec<N, D> pub fn max2<N: Scalar, D: Dimension>(x: &Vec<N, D>,y: N) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn max3<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D> pub fn max3<N: Scalar, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -133,12 +133,12 @@ pub fn min<T>(x: T, y: T) -> T {
} }
pub fn min2<N: Scalar, D: DimName>(x: &Vec<N, D>,y: N) -> Vec<N, D> pub fn min2<N: Scalar, D: Dimension>(x: &Vec<N, D>,y: N) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn min3<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D> pub fn min3<N: Scalar, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -148,7 +148,7 @@ pub fn mix<T>(x: T, y: T, a: T) -> T {
} }
pub fn mod_<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D> pub fn mod_<N: Scalar, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -158,17 +158,17 @@ pub fn modf<T>(x: T, i: &T) -> T {
} }
pub fn round<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn round<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn roundEven<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn roundEven<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn sign<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn sign<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -184,17 +184,17 @@ pub fn step<T>(edge: T, x: T) -> T {
} }
pub fn step2<N: Scalar, D: DimName>(edge: N, x: &Vec<N, D>) -> Vec<N, D> pub fn step2<N: Scalar, D: Dimension>(edge: N, x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn step3<N: Scalar, D: DimName>(edge: &Vec<N, D>, x: &Vec<N, D>) -> Vec<N, D> pub fn step3<N: Scalar, D: Dimension>(edge: &Vec<N, D>, x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn trunc<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn trunc<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
@ -203,7 +203,7 @@ pub fn uintBitsToFloat(v: u32) -> f32 {
unimplemented!() unimplemented!()
} }
pub fn uintBitsToFloat2<D: DimName>(v: &Vec<u32, D>) -> Vec<f32, D> pub fn uintBitsToFloat2<D: Dimension>(v: &Vec<u32, D>) -> Vec<f32, D>
where DefaultAllocator: Alloc<f32, D> { where DefaultAllocator: Alloc<f32, D> {
unimplemented!() unimplemented!()
} }

View File

@ -1,39 +1,40 @@
use na::{Real, DefaultAllocator, DimName}; use na::{Real, DefaultAllocator};
use aliases::Vec; use aliases::Vec;
use traits::Alloc; use traits::{Alloc, Dimension};
pub fn exp<N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn exp<N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() v.map(|x| x.exp())
} }
pub fn exp2<N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn exp2<N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() v.map(|x| x.exp2())
} }
pub fn inversesqrt<N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn inversesqrt<N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() v.map(|x| N::one() / x.sqrt())
} }
pub fn log<N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn log<N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() v.map(|x| x.ln())
} }
pub fn log2<N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn log2<N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() v.map(|x| x.log2())
} }
pub fn pow<N: Real, D: DimName>(base: &Vec<N, D>, exponent: &Vec<N, D>) pub fn pow<N: Real, D: Dimension>(base: &Vec<N, D>, exponent: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() base.zip_map(exponent, |b, e| b.powf(e))
} }
pub fn sqrt<N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn sqrt<N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() v.map(|x| x.sqrt())
} }

View File

@ -1,35 +1,59 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::DefaultAllocator;
use aliases::{Vec, Mat}; use aliases::{Vec, Mat};
use traits::Alloc; use traits::{Alloc, Number, Dimension};
pub fn equal<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>) -> Vec<bool, C> pub fn equal<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>) -> Vec<bool, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() let mut res = Vec::<_, C>::repeat(false);
for i in 0..C::dim() {
res[i] = x.column(i) == y.column(i)
}
res
} }
pub fn equal_eps<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>,epsilon: N) -> Vec<bool, C> pub fn equal_eps<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>, epsilon: N) -> Vec<bool, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() equal_eps_vec(x, y, &Vec::<_, C>::repeat(epsilon))
} }
pub fn equal_eps_vec<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>, epsilon: &Vec<N, C>) -> Vec<bool, C> pub fn equal_eps_vec<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>, epsilon: &Vec<N, C>) -> Vec<bool, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() let mut res = Vec::<_, C>::repeat(false);
for i in 0..C::dim() {
res[i] = (x.column(i) - y.column(i)).abs() < Vec::<_, R>::repeat(epsilon[i])
}
res
} }
pub fn not_equal<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>) -> Vec<bool, C> pub fn not_equal<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>) -> Vec<bool, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() let mut res = Vec::<_, C>::repeat(false);
for i in 0..C::dim() {
res[i] = x.column(i) != y.column(i)
}
res
} }
pub fn not_equal_eps<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>,epsilon: N) -> Vec<bool, C> pub fn not_equal_eps<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>, epsilon: N) -> Vec<bool, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() not_equal_eps_vec(x, y, &Vec::<_, C>::repeat(epsilon))
} }
pub fn not_equal_eps_vec<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>, epsilon: &Vec<N, C>) -> Vec<bool, C> pub fn not_equal_eps_vec<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>, epsilon: &Vec<N, C>) -> Vec<bool, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() let mut res = Vec::<_, C>::repeat(false);
for i in 0..C::dim() {
res[i] = (x.column(i) - y.column(i)).abs() >= Vec::<_, R>::repeat(epsilon[i])
}
res
} }

View File

@ -1,31 +1,34 @@
use na::{Scalar, U3, U4}; use na::{DefaultAllocator, Scalar, Real, U3, U4, Unit, Rotation3, Point3};
use traits::{Dimension, Number, Alloc};
use aliases::{Mat, Vec}; use aliases::{Mat, Vec};
pub fn identity<T>() -> T { pub fn identity<N: Number, D: Dimension>() -> Mat<N, D, D>
unimplemented!() where DefaultAllocator: Alloc<N, D, D> {
Mat::<N, D, D>::identity()
} }
pub fn lookAt<N: Scalar>(eye: &Vec<N, U3>, center: &Vec<N, U3>, up: &Vec<N, U3>) -> Mat<N, U4, U4> { /// Same as `look_at_rh`
unimplemented!() pub fn look_at<N: Real>(eye: &Vec<N, U3>, center: &Vec<N, U3>, up: &Vec<N, U3>) -> Mat<N, U4, U4> {
look_at_rh(eye, center, up)
} }
pub fn lookAtLH<N: Scalar>(eye: &Vec<N, U3>, center: &Vec<N, U3>, up: &Vec<N, U3>) -> Mat<N, U4, U4> { pub fn look_at_lh<N: Real>(eye: &Vec<N, U3>, center: &Vec<N, U3>, up: &Vec<N, U3>) -> Mat<N, U4, U4> {
unimplemented!() Mat::look_at_lh(&Point3::from_coordinates(*eye), &Point3::from_coordinates(*center), up)
} }
pub fn lookAtRH<N: Scalar>(eye: &Vec<N, U3>, center: &Vec<N, U3>, up: &Vec<N, U3>) -> Mat<N, U4, U4> { pub fn look_at_rh<N: Real>(eye: &Vec<N, U3>, center: &Vec<N, U3>, up: &Vec<N, U3>) -> Mat<N, U4, U4> {
unimplemented!() Mat::look_at_rh(&Point3::from_coordinates(*eye), &Point3::from_coordinates(*center), up)
} }
pub fn rotate<N: Scalar>(m: &Mat<N, U4, U4>,angle: N, axis: &Vec<N, U3>) -> Mat<N, U4, U4> { pub fn rotate<N: Real>(m: &Mat<N, U4, U4>, angle: N, axis: &Vec<N, U3>) -> Mat<N, U4, U4> {
unimplemented!() m * Rotation3::from_axis_angle(&Unit::new_normalize(*axis), angle).to_homogeneous()
} }
pub fn scale<N: Scalar>(m: &Mat<N, U4, U4>, v: &Vec<N, U3>) -> Mat<N, U4, U4> { pub fn scale<N: Number>(m: &Mat<N, U4, U4>, v: &Vec<N, U3>) -> Mat<N, U4, U4> {
unimplemented!() m.append_nonuniform_scaling(v)
} }
pub fn translate<N: Scalar>(m: &Mat<N, U4, U4>, v: &Vec<N, U3>) -> Mat<N, U4, U4> { pub fn translate<N: Number>(m: &Mat<N, U4, U4>, v: &Vec<N, U3>) -> Mat<N, U4, U4> {
unimplemented!() m.append_translation(v)
} }

View File

@ -1,31 +1,31 @@
use na::{Real, U4}; use na::{self, Real, Unit, U4};
use aliases::{Vec, Qua}; use aliases::{Vec, Qua};
pub fn conjugate<N: Real>(q: &Qua<N>) -> Qua<N> { pub fn conjugate<N: Real>(q: &Qua<N>) -> Qua<N> {
unimplemented!() q.conjugate()
} }
pub fn inverse<N: Real>(q: &Qua<N>) -> Qua<N> { pub fn inverse<N: Real>(q: &Qua<N>) -> Qua<N> {
unimplemented!() q.try_inverse().unwrap_or(na::zero())
} }
pub fn isinf<N: Real>(x: &Qua<N>) -> Vec<bool, U4> { //pub fn isinf<N: Real>(x: &Qua<N>) -> Vec<bool, U4> {
unimplemented!() // x.coords.map(|e| e.is_inf())
//}
//pub fn isnan<N: Real>(x: &Qua<N>) -> Vec<bool, U4> {
// x.coords.map(|e| e.is_nan())
//}
pub fn lerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
x.lerp(y, a)
} }
pub fn isnan<N: Real>(x: &Qua<N>) -> Vec<bool, U4> { pub fn mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
unimplemented!() x * (N::one() - a) + y * a
} }
pub fn lerp<N: Real>(x: &Qua<N>, y: &Qua<N>,a: N) -> Qua<N> { pub fn slerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
unimplemented!() Unit::new_normalize(*x).slerp(&Unit::new_normalize(*y), a).unwrap()
}
pub fn mix<N: Real>(x: &Qua<N>, y: &Qua<N>,a: N) -> Qua<N> {
unimplemented!()
}
pub fn slerp<N: Real>(x: &Qua<N>, y: &Qua<N>,a: N) -> Qua<N> {
unimplemented!()
} }

View File

@ -3,14 +3,14 @@ use na::Real;
use aliases::Qua; use aliases::Qua;
pub fn cross<N: Real>(q1: &Qua<N>, q2: &Qua<N>) -> Qua<N> { pub fn cross<N: Real>(q1: &Qua<N>, q2: &Qua<N>) -> Qua<N> {
unimplemented!() q1 * q2
} }
pub fn dot<N: Real>(x: &Qua<N>, y: &Qua<N>) -> N { pub fn dot<N: Real>(x: &Qua<N>, y: &Qua<N>) -> N {
unimplemented!() x.dot(y)
} }
pub fn length<N: Real>(q: &Qua<N>) -> N { pub fn length<N: Real>(q: &Qua<N>) -> N {
unimplemented!() q.norm()
} }
pub fn normalize<N: Real>(q: &Qua<N>) -> Qua<N> { pub fn normalize<N: Real>(q: &Qua<N>) -> Qua<N> {
unimplemented!() q.normalize()
} }

View File

@ -1,4 +1,20 @@
pub fn vec< 4, bool, Q > equal<N: Scalar>(x: &Qua<N>, y: &Qua<N>) use na::{Real, U4};
pub fn vec< 4, bool, Q > equal<N: Scalar>(x: &Qua<N>, y: &Qua<N>,epsilon: N)
pub fn vec< 4, bool, Q > notEqual<N: Scalar>(x: &Qua<N>, y: &Qua<N>)
pub fn vec< 4, bool, Q > notEqual<N: Scalar>(x: &Qua<N>, y: &Qua<N>,epsilon: N) use aliases::{Qua, Vec};
pub fn equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> {
::equal(&x.coords, &y.coords)
}
pub fn equal_eps<N: Real>(x: &Qua<N>, y: &Qua<N>, epsilon: N) -> Vec<bool, U4> {
::equal_eps(&x.coords, &y.coords, epsilon)
}
pub fn not_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> {
::not_equal(&x.coords, &y.coords)
}
pub fn not_equal_eps<N: Real>(x: &Qua<N>, y: &Qua<N>, epsilon: N) -> Vec<bool, U4> {
::not_equal_eps(&x.coords, &y.coords, epsilon)
}

View File

@ -1,19 +1,23 @@
use na::{Real, U3}; use na::{Real, U3, UnitQuaternion, Unit};
use aliases::{Vec, Qua}; use aliases::{Vec, Qua};
pub fn exp<N: Real>(q: &Qua<N>) -> Qua<N> { pub fn exp<N: Real>(q: &Qua<N>) -> Qua<N> {
unimplemented!() q.exp()
} }
pub fn log<N: Real>(q: &Qua<N>) -> Qua<N> { pub fn log<N: Real>(q: &Qua<N>) -> Qua<N> {
unimplemented!() q.ln()
} }
pub fn pow<N: Real>(q: &Qua<N>, y: N) -> Qua<N> { pub fn pow<N: Real>(q: &Qua<N>, y: N) -> Qua<N> {
unimplemented!() q.powf(y)
} }
pub fn rotate<N: Real>(q: &Qua<N>, angle: N, axis: &Vec<N, U3>) -> Qua<N> { pub fn rotate<N: Real>(q: &Qua<N>, angle: N, axis: &Vec<N, U3>) -> Qua<N> {
unimplemented!() q * UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).unwrap()
} }
pub fn sqrt<N: Real>(q: &Qua<N>) -> Qua<N> { pub fn sqrt<N: Real>(q: &Qua<N>) -> Qua<N> {
unimplemented!() unimplemented!()
} }

View File

@ -1,13 +1,19 @@
use na::{Real, U3}; use na::{Real, U3, Unit, UnitQuaternion, Vector3};
use aliases::{Vec, Qua}; use aliases::{Vec, Qua};
pub fn angle<N: Real>(x: &Qua<N>) -> N { pub fn angle<N: Real>(x: &Qua<N>) -> N {
unimplemented!() UnitQuaternion::from_quaternion(*x).angle()
} }
pub fn angleAxis<N: Real>(angle: N, axis: &Vec<N, U3>) -> Qua<N> { pub fn angleAxis<N: Real>(angle: N, axis: &Vec<N, U3>) -> Qua<N> {
unimplemented!() UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).unwrap()
} }
pub fn axis<N: Real>(x: &Qua<N>) -> Vec<N, U3> { pub fn axis<N: Real>(x: &Qua<N>) -> Vec<N, U3> {
unimplemented!() if let Some(a) = UnitQuaternion::from_quaternion(*x).axis() {
a.unwrap()
} else {
Vector3::zeros()
}
} }

View File

@ -1,7 +1,10 @@
pub fn epsilon<T>() -> T { use approx::AbsDiffEq;
unimplemented!() use na::Real;
pub fn epsilon<N: AbsDiffEq<Epsilon = N>>() -> N {
N::default_epsilon()
} }
pub fn pi<T>() -> T { pub fn pi<N: Real>() -> N {
unimplemented!() N::pi()
} }

View File

@ -1,64 +1,44 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::{self, DefaultAllocator};
use traits::Alloc; use traits::{Alloc, Number, Dimension};
use aliases::Vec; use aliases::Vec;
pub fn fmax<N: Scalar, D: DimName>(a: &Vec<N, D>,b: N) -> Vec<N, D> pub fn max<N: Number, D: Dimension>(a: &Vec<N, D>, b: N) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() a.map(|a| na::sup(&a, &b))
} }
pub fn fmax2<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>) -> Vec<N, D> pub fn max2<N: Number, D: Dimension>(a: &Vec<N, D>, b: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() na::sup(a, b)
} }
pub fn fmax3<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>) -> Vec<N, D> pub fn max3<N: Number, D: Dimension>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() max2(&max2(a, b), c)
} }
pub fn fmax4<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>, d: &Vec<N, D>) -> Vec<N, D> pub fn max4<N: Number, D: Dimension>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>, d: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() max2(&max2(a, b), &max2(c, d))
} }
pub fn fmin<N: Scalar, D: DimName>(x: &Vec<N, D>,y: N) -> Vec<N, D> pub fn min<N: Number, D: Dimension>(x: &Vec<N, D>,y: N) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.map(|x| na::inf(&x, &y))
} }
pub fn fmin2<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D> pub fn min2<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() na::inf(x, y)
} }
pub fn fmin3<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>) -> Vec<N, D> pub fn min3<N: Number, D: Dimension>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() min2(&min2(a, b), c)
} }
pub fn fmin4<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>, d: &Vec<N, D>) -> Vec<N, D> pub fn min4<N: Number, D: Dimension>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>, d: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() min2(&min2(a, b), &min2(c, d))
}
pub fn max3<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, z: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn max4<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, z: &Vec<N, D>, w: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn min3<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn min4<N: Scalar, D: DimName>(a: &Vec<N, D>, b: &Vec<N, D>, c: &Vec<N, D>, d: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
} }

View File

@ -1,24 +1,24 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::{DefaultAllocator};
use traits::Alloc; use traits::{Alloc, Number, Dimension};
use aliases::Vec; use aliases::Vec;
pub fn equal<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D> pub fn equal_eps<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.zip_map(y, |x, y| abs_diff_eq!(x, y))
} }
pub fn equal2<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: &Vec<N, D>) -> Vec<bool, D> pub fn equal_eps_vec<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.zip_zip_map(y, epsilon, |x, y, eps| abs_diff_eq!(x, y, epsilon = eps))
} }
pub fn notEqual<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D> pub fn not_equal_eps<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.zip_map(y, |x, y| abs_diff_ne!(x, y))
} }
pub fn notEqual2<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: &Vec<N, D>) -> Vec<bool, D> pub fn not_equal_eps_vec<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.zip_zip_map(y, epsilon, |x, y, eps| abs_diff_ne!(x, y, epsilon = eps))
} }

View File

@ -1,43 +1,57 @@
use na::{Scalar, Real, DimName, U3, DefaultAllocator}; use na::{self, Scalar, Real, U3, DefaultAllocator};
use traits::{Number, Alloc}; use traits::{Number, Alloc, Dimension};
use aliases::Vec; use aliases::Vec;
pub fn cross<N: Number, D: DimName>(x: &Vec<N, U3>, y: &Vec<N, U3>) -> Vec<N, U3> { pub fn cross<N: Number, D: Dimension>(x: &Vec<N, U3>, y: &Vec<N, U3>) -> Vec<N, U3> {
x.cross(y) x.cross(y)
} }
pub fn distance<N: Real, D: DimName>(p0: &Vec<N, D>, p1: &Vec<N, D>) -> N pub fn distance<N: Real, D: Dimension>(p0: &Vec<N, D>, p1: &Vec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
(p1 - p0).norm() (p1 - p0).norm()
} }
pub fn dot<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> N pub fn dot<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.dot(y) x.dot(y)
} }
pub fn faceforward<N: Scalar, D: DimName>(N: &Vec<N, D>, I: &Vec<N, D>, Nref: &Vec<N, D>) -> Vec<N, D> pub fn faceforward<N: Number, D: Dimension>(n: &Vec<N, D>, i: &Vec<N, D>, nref: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() if nref.dot(i) < N::zero() {
n.clone()
} else {
-n.clone()
}
} }
pub fn length<N: Real, D: DimName>(x: &Vec<N, D>) -> N pub fn length<N: Real, D: Dimension>(x: &Vec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.norm() x.norm()
} }
pub fn normalize<N: Real, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn normalize<N: Real, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.normalize() x.normalize()
} }
pub fn reflect<N: Scalar, D: DimName>(I: &Vec<N, D>, N: &Vec<N, D>) -> Vec<N, D> pub fn reflect<N: Number, D: Dimension>(i: &Vec<N, D>, n: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() let _2 = N::one() + N::one();
i - n * (n.dot(i) * _2)
} }
pub fn refract<N: Scalar, D: DimName>(I: &Vec<N, D>, N: &Vec<N, D>, eta: N) -> Vec<N, D> pub fn refract<N: Real, D: Dimension>(i: &Vec<N, D>, n: &Vec<N, D>, eta: N) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!()
let ni = n.dot(i);
let k = N::one() - eta * eta * (N::one() - ni * ni);
if k < N::zero() {
Vec::<_, D>::zeros()
}
else {
i * eta - n * (eta * dot(n, i) + k.sqrt())
}
} }

View File

@ -1,6 +1,6 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::{Scalar, DefaultAllocator};
use traits::Alloc; use traits::{Alloc, Dimension};
use aliases::*; use aliases::*;
pub fn bitfieldDeinterleave(x: u16) -> U8Vec2 { pub fn bitfieldDeinterleave(x: u16) -> U8Vec2 {
@ -19,7 +19,7 @@ pub fn bitfieldFillOne<IU>(Value: IU, FirstBit: i32, BitCount: i32) -> IU {
unimplemented!() unimplemented!()
} }
pub fn bitfieldFillOne2<N: Scalar, D: DimName>(Value: &Vec<N, D>, FirstBit: i32, BitCount: i32) -> Vec<N, D> pub fn bitfieldFillOne2<N: Scalar, D: Dimension>(Value: &Vec<N, D>, FirstBit: i32, BitCount: i32) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -28,7 +28,7 @@ pub fn bitfieldFillZero<IU>(Value: IU, FirstBit: i32, BitCount: i32) -> IU {
unimplemented!() unimplemented!()
} }
pub fn bitfieldFillZero2<N: Scalar, D: DimName>(Value: &Vec<N, D>, FirstBit: i32, BitCount: i32) -> Vec<N, D> pub fn bitfieldFillZero2<N: Scalar, D: Dimension>(Value: &Vec<N, D>, FirstBit: i32, BitCount: i32) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -113,7 +113,7 @@ pub fn bitfieldRotateLeft<IU>(In: IU, Shift: i32) -> IU {
unimplemented!() unimplemented!()
} }
pub fn bitfieldRotateLeft2<N: Scalar, D: DimName>(In: &Vec<N, D>, Shift: i32) -> Vec<N, D> pub fn bitfieldRotateLeft2<N: Scalar, D: Dimension>(In: &Vec<N, D>, Shift: i32) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -122,7 +122,7 @@ pub fn bitfieldRotateRight<IU>(In: IU, Shift: i32) -> IU {
unimplemented!() unimplemented!()
} }
pub fn bitfieldRotateRight2<N: Scalar, D: DimName>(In: &Vec<N, D>, Shift: i32) -> Vec<N, D> pub fn bitfieldRotateRight2<N: Scalar, D: Dimension>(In: &Vec<N, D>, Shift: i32) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -131,7 +131,7 @@ pub fn mask<IU>(Bits: IU) -> IU {
unimplemented!() unimplemented!()
} }
pub fn mask2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn mask2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }

View File

@ -1,108 +1,111 @@
pub fn e<T>() -> T { use na::{self, Real};
unimplemented!() use traits::Number;
pub fn e<N: Real>() -> N {
N::e()
} }
pub fn euler<T>() -> T { pub fn euler<N: Real>() -> N {
unimplemented!() N::e()
} }
pub fn four_over_pi<T>() -> T { pub fn four_over_pi<N: Real>() -> N {
unimplemented!() na::convert::<_, N>(4.0) / N::pi()
} }
pub fn golden_ratio<T>() -> T { pub fn golden_ratio<N: Real>() -> N {
unimplemented!() (N::one() + root_five()) / na::convert(2.0)
} }
pub fn half_pi<T>() -> T { pub fn half_pi<N: Real>() -> N {
unimplemented!() N::frac_pi_2()
} }
pub fn ln_ln_two<T>() -> T { pub fn ln_ln_two<N: Real>() -> N {
unimplemented!() N::ln_2().ln()
} }
pub fn ln_ten<T>() -> T { pub fn ln_ten<N: Real>() -> N {
unimplemented!() N::ln_10()
} }
pub fn ln_two<T>() -> T { pub fn ln_two<N: Real>() -> N {
unimplemented!() N::ln_2()
} }
pub fn one<T>() -> T { pub fn one<N: Number>() -> N {
unimplemented!() N::one()
} }
pub fn one_over_pi<T>() -> T { pub fn one_over_pi<N: Real>() -> N {
unimplemented!() N::frac_1_pi()
} }
pub fn one_over_root_two<T>() -> T { pub fn one_over_root_two<N: Real>() -> N {
unimplemented!() N::one() / root_two()
} }
pub fn one_over_two_pi<T>() -> T { pub fn one_over_two_pi<N: Real>() -> N {
unimplemented!() N::frac_1_pi() * na::convert(0.5)
} }
pub fn quarter_pi<T>() -> T { pub fn quarter_pi<N: Real>() -> N {
unimplemented!() N::frac_pi_4()
} }
pub fn root_five<T>() -> T { pub fn root_five<N: Real>() -> N {
unimplemented!() na::convert::<_, N>(5.0).sqrt()
} }
pub fn root_half_pi<T>() -> T { pub fn root_half_pi<N: Real>() -> N {
unimplemented!() (N::pi() / na::convert(2.0)).sqrt()
} }
pub fn root_ln_four<T>() -> T { pub fn root_ln_four<N: Real>() -> N {
unimplemented!() na::convert::<_, N>(4.0).sqrt()
} }
pub fn root_pi<T>() -> T { pub fn root_pi<N: Real>() -> N {
unimplemented!() N::pi().sqrt()
} }
pub fn root_three<T>() -> T { pub fn root_three<N: Real>() -> N {
unimplemented!() na::convert::<_, N>(3.0).sqrt()
} }
pub fn root_two<T>() -> T { pub fn root_two<N: Real>() -> N {
unimplemented!() // FIXME: there should be a ::sqrt_2() on the Real trait.
na::convert::<_, N>(2.0).sqrt()
} }
pub fn root_two_pi<T>() -> T { pub fn root_two_pi<N: Real>() -> N {
unimplemented!() N::two_pi().sqrt()
} }
pub fn third<T>() -> T { pub fn third<N: Real>() -> N {
unimplemented!() na::convert(1.0 / 2.0)
} }
pub fn three_over_two_pi<T>() -> T { pub fn three_over_two_pi<N: Real>() -> N {
unimplemented!() na::convert::<_, N>(3.0) / N::two_pi()
} }
pub fn two_over_pi<T>() -> T { pub fn two_over_pi<N: Real>() -> N {
unimplemented!() N::frac_2_pi()
} }
pub fn two_over_root_pi<T>() -> T { pub fn two_over_root_pi<N: Real>() -> N {
unimplemented!() N::frac_2_pi()
} }
pub fn two_pi<T>() -> T { pub fn two_pi<N: Real>() -> N {
unimplemented!() N::two_pi()
} }
pub fn two_thirds<T>() -> T { pub fn two_thirds<N: Real>() -> N {
unimplemented!() na::convert(2.0 / 3.0)
} }
pub fn zero<T>() -> T { pub fn zero<N: Number>() -> N {
unimplemented!() N::zero()
} }

View File

@ -1,22 +1,23 @@
use na::{DimName, Scalar, DefaultAllocator}; use approx::AbsDiffEq;
use na::DefaultAllocator;
use traits::Alloc; use traits::{Alloc, Number, Dimension};
use aliases::Vec; use aliases::Vec;
pub fn epsilonEqual<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D> pub fn epsilonEqual<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.zip_map(y, |x, y| abs_diff_eq!(x, y, epsilon = epsilon))
} }
pub fn epsilonEqual2<T>(x: T, y: T, epsilon: T) -> bool { pub fn epsilonEqual2<N: AbsDiffEq<Epsilon = N>>(x: N, y: N, epsilon: N) -> bool {
unimplemented!() abs_diff_eq!(x, y, epsilon = epsilon)
} }
pub fn epsilonNotEqual<N: Scalar, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D> pub fn epsilonNotEqual<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>, epsilon: N) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() x.zip_map(y, |x, y| abs_diff_ne!(x, y, epsilon = epsilon))
} }
pub fn epsilonNotEqual2<T>(x: T, y: T, epsilon: T) -> bool { pub fn epsilonNotEqual2<N: AbsDiffEq<Epsilon = N>>(x: N, y: N, epsilon: N) -> bool {
unimplemented!() abs_diff_ne!(x, y, epsilon = epsilon)
} }

View File

@ -1,9 +1,9 @@
use na::{DimName, Scalar, DefaultAllocator}; use na::{Scalar, DefaultAllocator};
use traits::Alloc; use traits::{Alloc, Dimension};
use aliases::Vec; use aliases::Vec;
pub fn iround<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<i64, D> pub fn iround<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<i64, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -12,7 +12,7 @@ pub fn log2<I>(x: I) -> I {
unimplemented!() unimplemented!()
} }
pub fn uround<N: Scalar, D: DimName>(x: &Vec<N, D>) -> Vec<u64, D> pub fn uround<N: Scalar, D: Dimension>(x: &Vec<N, D>) -> Vec<u64, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }

View File

@ -1,24 +1,28 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::{Scalar, DefaultAllocator};
use traits::Alloc; use traits::{Alloc, Dimension};
use aliases::{Vec, Mat}; use aliases::{Vec, Mat};
pub fn column<N: Scalar, R: DimName, C: DimName>(m: &Mat<N, R, C>, index: usize) -> Vec<N, C> pub fn column<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize) -> Vec<N, R>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() m.column(index).into_owned()
} }
pub fn column2<N: Scalar, R: DimName, C: DimName>(m: &Mat<N, R, C>, index: usize, x: &Vec<N, C>) -> Mat<N, R, C> pub fn set_column<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize, x: &Vec<N, R>) -> Mat<N, R, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() let mut res = m.clone();
res.set_column(index, x);
res
} }
pub fn row<N: Scalar, R: DimName, C: DimName>(m: &Mat<N, R, C>, index: usize) -> Vec<N, R> pub fn row<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize) -> Vec<N, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() m.row(index).into_owned().transpose()
} }
pub fn row2<N: Scalar, R: DimName, C: DimName>(m: &Mat<N, R, C>, index: usize, x: &Vec<N, R>) -> Mat<N, R, C> pub fn set_row<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize, x: &Vec<N, C>) -> Mat<N, R, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
unimplemented!() let mut res = m.clone();
res.set_row(index, &x.transpose());
res
} }

View File

@ -1,14 +1,15 @@
use na::{Scalar, DimName, DefaultAllocator}; use na::{Real, DefaultAllocator, Transform, TAffine};
use traits::Alloc; use traits::{Alloc, Dimension};
use aliases::Mat; use aliases::Mat;
pub fn affineInverse<N: Scalar, D: DimName>(m: &Mat<N, D, D>) -> Mat<N, D, D> pub fn affine_inverse<N: Real, D: Dimension>(m: Mat<N, D, D>) -> Mat<N, D, D>
where DefaultAllocator: Alloc<N, D, D> { where DefaultAllocator: Alloc<N, D, D> {
unimplemented!() // FIXME: this should be optimized.
m.try_inverse().unwrap_or(Mat::<_, D, D>::zeros())
} }
pub fn inverseTranspose<N: Scalar, D: DimName>(m: &Mat<N, D, D>) -> Mat<N, D, D> pub fn inverse_transpose<N: Real, D: Dimension>(m: Mat<N, D, D>) -> Mat<N, D, D>
where DefaultAllocator: Alloc<N, D, D> { where DefaultAllocator: Alloc<N, D, D> {
unimplemented!() m.try_inverse().unwrap_or(Mat::<_, D, D>::zeros()).transpose()
} }

View File

@ -1,6 +1,6 @@
use na::{Scalar, Real, DimName, DefaultAllocator, U3, U4}; use na::{Scalar, Real, DefaultAllocator, U3, U4};
use traits::Alloc; use traits::{Alloc, Dimension};
use aliases::*; use aliases::*;
@ -12,7 +12,7 @@ pub fn packF3x9_E1x5(v: &Vec3) -> i32 {
unimplemented!() unimplemented!()
} }
pub fn packHalf<D: DimName>(v: &Vec<f32, D>) -> Vec<u16, D> pub fn packHalf<D: Dimension>(v: &Vec<f32, D>) -> Vec<u16, D>
where DefaultAllocator: Alloc<u16, D> { where DefaultAllocator: Alloc<u16, D> {
unimplemented!() unimplemented!()
} }
@ -53,7 +53,7 @@ pub fn packRGBM<N: Scalar>(rgb: &Vec<N, U3>) -> Vec<N, U4> {
unimplemented!() unimplemented!()
} }
pub fn packSnorm<I: Scalar, N: Real, D: DimName>(v: Vec<N, D>) -> Vec<I, D> pub fn packSnorm<I: Scalar, N: Real, D: Dimension>(v: Vec<N, D>) -> Vec<I, D>
where DefaultAllocator: Alloc<N, D> + Alloc<I, D> { where DefaultAllocator: Alloc<N, D> + Alloc<I, D> {
unimplemented!() unimplemented!()
} }
@ -102,7 +102,7 @@ pub fn packUint4x8(v: &U8Vec4) -> i32 {
unimplemented!() unimplemented!()
} }
pub fn packUnorm<UI: Scalar, N: Real, D: DimName>(v: &Vec<N, D>) -> Vec<UI, D> pub fn packUnorm<UI: Scalar, N: Real, D: Dimension>(v: &Vec<N, D>) -> Vec<UI, D>
where DefaultAllocator: Alloc<N, D> + Alloc<UI, D> { where DefaultAllocator: Alloc<N, D> + Alloc<UI, D> {
unimplemented!() unimplemented!()
} }
@ -155,7 +155,7 @@ pub fn unpackF3x9_E1x5(p: i32) -> Vec3 {
unimplemented!() unimplemented!()
} }
pub fn unpackHalf<N: Scalar, D: DimName>(p: Vec<i16, D>) -> Vec<N, D> pub fn unpackHalf<N: Scalar, D: Dimension>(p: Vec<i16, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -196,7 +196,7 @@ pub fn unpackRGBM<N: Scalar>(rgbm: &Vec<N, U4>) -> Vec<N, U3> {
unimplemented!() unimplemented!()
} }
pub fn unpackSnorm<I: Scalar, N: Real, D: DimName>(v: &Vec<I, D>) -> Vec<N, D> pub fn unpackSnorm<I: Scalar, N: Real, D: Dimension>(v: &Vec<I, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> + Alloc<I, D> { where DefaultAllocator: Alloc<N, D> + Alloc<I, D> {
unimplemented!() unimplemented!()
} }
@ -245,7 +245,7 @@ pub fn unpackUint4x8(p: i32) -> U8Vec4 {
unimplemented!() unimplemented!()
} }
pub fn unpackUnorm<UI: Scalar, N: Real, D: DimName>(v: &Vec<UI, D>) -> Vec<N, D> pub fn unpackUnorm<UI: Scalar, N: Real, D: Dimension>(v: &Vec<UI, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> + Alloc<UI, D> { where DefaultAllocator: Alloc<N, D> + Alloc<UI, D> {
unimplemented!() unimplemented!()
} }

View File

@ -1,64 +1,73 @@
use na::{Real, U3, U4}; use na::{self, Real, U3, U4, UnitQuaternion, Vector3, Rotation3};
use aliases::{Qua, Vec, Mat}; use aliases::{Qua, Vec, Mat};
pub fn eulerAngles<N: Real>(x: &Qua<N>) -> Vec<N, U3> { /// Euler angles of the quaternion as (pitch, yaw, roll).
unimplemented!() pub fn euler_angles<N: Real>(x: &Qua<N>) -> Vec<N, U3> {
let q = UnitQuaternion::new_unchecked(*x);
let a = q.to_euler_angles();
Vector3::new(a.2, a.1, a.0)
} }
pub fn greaterThan<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> { pub fn greater_than<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> {
unimplemented!() ::greater_than(&x.coords, &y.coords)
} }
pub fn greaterThanEqual<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> { pub fn greater_than_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> {
unimplemented!() ::greater_than_equal(&x.coords, &y.coords)
} }
pub fn lessThan<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> { pub fn less_than<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> {
unimplemented!() ::less_than(&x.coords, &y.coords)
} }
pub fn lessThanEqual<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> { pub fn less_than_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> Vec<bool, U4> {
unimplemented!() ::less_than_equal(&x.coords, &y.coords)
} }
pub fn mat3_cast<N: Real>(x: &Qua<N>) -> Mat<N, U3, U3> { pub fn mat3_cast<N: Real>(x: Qua<N>) -> Mat<N, U3, U3> {
unimplemented!() let q = UnitQuaternion::new_unchecked(x);
q.to_rotation_matrix().unwrap()
} }
pub fn mat4_cast<N: Real>(x: &Qua<N>) -> Mat<N, U4, U4> { pub fn mat4_cast<N: Real>(x: Qua<N>) -> Mat<N, U4, U4> {
unimplemented!() let q = UnitQuaternion::new_unchecked(x);
q.to_homogeneous()
} }
pub fn pitch<N: Real>(x: &Qua<N>) -> N { pub fn quat_cast<N: Real>(x: Mat<N, U3, U3>) -> Qua<N> {
unimplemented!() let rot = Rotation3::from_matrix_unchecked(x);
UnitQuaternion::from_rotation_matrix(&rot).unwrap()
} }
pub fn quat_cast<N: Real>(x: &Mat<N, U3, U3>) -> Qua<N> { pub fn quat_cast2<N: Real>(x: Mat<N, U4, U4>) -> Qua<N> {
unimplemented!() quat_cast(x.fixed_slice::<U3, U3>(0, 0).into_owned())
} }
pub fn quat_cast2<N: Real>(x: &Mat<N, U4, U4>) -> Qua<N> { pub fn quat_look_at<N: Real>(direction: &Vec<N, U3>, up: &Vec<N, U3>) -> Qua<N> {
unimplemented!() quat_look_at_rh(direction, up)
} }
pub fn quatLookAt<N: Real>(direction: &Vec<N, U3>, up: &Vec<N, U3>) -> Qua<N> { pub fn quat_look_at_lh<N: Real>(direction: &Vec<N, U3>, up: &Vec<N, U3>) -> Qua<N> {
unimplemented!() UnitQuaternion::look_at_lh(direction, up).unwrap()
} }
pub fn quatLookAtLH<N: Real>(direction: &Vec<N, U3>, up: &Vec<N, U3>) -> Qua<N> { pub fn quat_look_at_rh<N: Real>(direction: &Vec<N, U3>, up: &Vec<N, U3>) -> Qua<N> {
unimplemented!() UnitQuaternion::look_at_rh(direction, up).unwrap()
}
pub fn quatLookAtRH<N: Real>(direction: &Vec<N, U3>, up: &Vec<N, U3>) -> Qua<N> {
unimplemented!()
} }
pub fn roll<N: Real>(x: &Qua<N>) -> N { pub fn roll<N: Real>(x: &Qua<N>) -> N {
unimplemented!() // FIXME: optimize this.
euler_angles(x).z
} }
pub fn yaw<N: Real>(x: &Qua<N>) -> N { pub fn yaw<N: Real>(x: &Qua<N>) -> N {
unimplemented!() // FIXME: optimize this.
euler_angles(x).y
}
pub fn pitch<N: Real>(x: &Qua<N>) -> N {
// FIXME: optimize this.
euler_angles(x).x
} }

View File

@ -1,6 +1,6 @@
use na::{Scalar, Real, DimName, U3, DefaultAllocator}; use na::{Scalar, Real, U3, DefaultAllocator};
use traits::{Number, Alloc}; use traits::{Number, Alloc, Dimension};
use aliases::Vec; use aliases::Vec;
@ -8,7 +8,7 @@ pub fn ceilMultiple<T>(v: T, Multiple: T) -> T {
unimplemented!() unimplemented!()
} }
pub fn ceilMultiple2<N: Scalar, D: DimName>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<N, D> pub fn ceilMultiple2<N: Scalar, D: Dimension>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -17,7 +17,7 @@ pub fn ceilPowerOfTwo<IU>(v: IU) -> IU {
unimplemented!() unimplemented!()
} }
pub fn ceilPowerOfTwo2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn ceilPowerOfTwo2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -26,7 +26,7 @@ pub fn floorMultiple<T>(v: T, Multiple: T) -> T {
unimplemented!() unimplemented!()
} }
pub fn floorMultiple2<N: Scalar, D: DimName>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<N, D> pub fn floorMultiple2<N: Scalar, D: Dimension>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -35,7 +35,7 @@ pub fn floorPowerOfTwo<IU>(v: IU) -> IU {
unimplemented!() unimplemented!()
} }
pub fn floorPowerOfTwo2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn floorPowerOfTwo2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -44,12 +44,12 @@ pub fn isMultiple<IU>(v: IU, Multiple: IU) -> bool {
unimplemented!() unimplemented!()
} }
pub fn isMultiple2<N: Scalar, D: DimName>(v: &Vec<N, D>,Multiple: N) -> Vec<bool, D> pub fn isMultiple2<N: Scalar, D: Dimension>(v: &Vec<N, D>,Multiple: N) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn isMultiple3<N: Scalar, D: DimName>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<bool, D> pub fn isMultiple3<N: Scalar, D: Dimension>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -58,7 +58,7 @@ pub fn isPowerOfTwo2<IU>(v: IU) -> bool {
unimplemented!() unimplemented!()
} }
pub fn isPowerOfTwo<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<bool, D> pub fn isPowerOfTwo<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -67,7 +67,7 @@ pub fn roundMultiple<T>(v: T, Multiple: T) -> T {
unimplemented!() unimplemented!()
} }
pub fn roundMultiple2<N: Scalar, D: DimName>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<N, D> pub fn roundMultiple2<N: Scalar, D: Dimension>(v: &Vec<N, D>, Multiple: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -76,7 +76,7 @@ pub fn roundPowerOfTwo<IU>(v: IU) -> IU {
unimplemented!() unimplemented!()
} }
pub fn roundPowerOfTwo2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn roundPowerOfTwo2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }

View File

@ -1,137 +1,146 @@
use na::{Scalar, Real, U1, U2, U3, U4}; use na::{Scalar, Real, U1, U2, U3, U4, DefaultAllocator,
Quaternion, Matrix2, Matrix3, Matrix4, Vector1, Vector2, Vector3, Vector4,
Matrix2x3, Matrix2x4, Matrix3x2, Matrix3x4, Matrix4x2, Matrix4x3};
use traits::{Number, Alloc, Dimension};
use aliases::{Qua, Vec, Mat}; use aliases::{Qua, Vec, Mat};
pub fn make_mat2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> { pub fn make_mat2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> {
unimplemented!() Matrix2::from_column_slice(ptr)
} }
pub fn make_mat2x2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> { pub fn make_mat2x2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> {
unimplemented!() Matrix2::from_column_slice(ptr)
} }
pub fn make_mat2x3<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U3> { pub fn make_mat2x3<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U3> {
unimplemented!() Matrix2x3::from_column_slice(ptr)
} }
pub fn make_mat2x4<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U4> { pub fn make_mat2x4<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U4> {
unimplemented!() Matrix2x4::from_column_slice(ptr)
} }
pub fn make_mat3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> { pub fn make_mat3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> {
unimplemented!() Matrix3::from_column_slice(ptr)
} }
pub fn make_mat3x2<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U2> { pub fn make_mat3x2<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U2> {
unimplemented!() Matrix3x2::from_column_slice(ptr)
} }
pub fn make_mat3x3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> { pub fn make_mat3x3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> {
unimplemented!() Matrix3::from_column_slice(ptr)
} }
pub fn make_mat3x4<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U4> { pub fn make_mat3x4<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U4> {
unimplemented!() Matrix3x4::from_column_slice(ptr)
} }
pub fn make_mat4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> { pub fn make_mat4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> {
unimplemented!() Matrix4::from_column_slice(ptr)
} }
pub fn make_mat4x2<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U2> { pub fn make_mat4x2<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U2> {
unimplemented!() Matrix4x2::from_column_slice(ptr)
} }
pub fn make_mat4x3<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U3> { pub fn make_mat4x3<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U3> {
unimplemented!() Matrix4x3::from_column_slice(ptr)
} }
pub fn make_mat4x4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> { pub fn make_mat4x4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> {
unimplemented!() Matrix4::from_column_slice(ptr)
} }
pub fn make_quat<N: Real>(ptr: &[N]) -> Qua<N> { pub fn make_quat<N: Real>(ptr: &[N]) -> Qua<N> {
unimplemented!() Quaternion::from_vector(Vector4::from_column_slice(ptr))
} }
pub fn make_vec1<N: Scalar>(v: &Vec<N, U1>) -> Vec<N, U1> { pub fn make_vec1<N: Scalar>(v: &Vec<N, U1>) -> Vec<N, U1> {
unimplemented!() *v
} }
pub fn make_vec1_2<N: Scalar>(v: &Vec<N, U2>) -> Vec<N, U1> { pub fn make_vec1_2<N: Scalar>(v: &Vec<N, U2>) -> Vec<N, U1> {
unimplemented!() Vector1::new(v.x)
} }
pub fn make_vec1_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U1> { pub fn make_vec1_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U1> {
unimplemented!() Vector1::new(v.x)
} }
pub fn make_vec1_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U1> { pub fn make_vec1_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U1> {
unimplemented!() Vector1::new(v.x)
} }
pub fn make_vec2_1<N: Scalar>(v: &Vec<N, U1>) -> Vec<N, U2> { pub fn make_vec2_1<N: Number>(v: &Vec<N, U1>) -> Vec<N, U2> {
unimplemented!() Vector2::new(v.x, N::zero())
} }
pub fn make_vec2_2<N: Scalar>(v: &Vec<N, U2>) -> Vec<N, U2> { pub fn make_vec2_2<N: Scalar>(v: &Vec<N, U2>) -> Vec<N, U2> {
unimplemented!() *v
} }
pub fn make_vec2_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U2> { pub fn make_vec2_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U2> {
unimplemented!() Vector2::new(v.x, v.y)
} }
pub fn make_vec2_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U2> { pub fn make_vec2_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U2> {
unimplemented!() Vector2::new(v.x, v.y)
} }
pub fn make_vec2<N: Scalar>(ptr: &[N]) -> Vec<N, U2> { pub fn make_vec2<N: Scalar>(ptr: &[N]) -> Vec<N, U2> {
unimplemented!() Vector2::from_column_slice(ptr)
} }
pub fn make_vec3_1<N: Scalar>(v: &Vec<N, U1>) -> Vec<N, U3> { pub fn make_vec3_1<N: Number>(v: &Vec<N, U1>) -> Vec<N, U3> {
unimplemented!() Vector3::new(v.x, N::zero(), N::zero())
} }
pub fn make_vec3_2<N: Scalar>(v: &Vec<N, U2>) -> Vec<N, U3> { pub fn make_vec3_2<N: Number>(v: &Vec<N, U2>) -> Vec<N, U3> {
unimplemented!() Vector3::new(v.x, v.y, N::zero())
} }
pub fn make_vec3_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U3> { pub fn make_vec3_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U3> {
unimplemented!() *v
} }
pub fn make_vec3_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U3> { pub fn make_vec3_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U3> {
unimplemented!() Vector3::new(v.x, v.y, v.z)
} }
pub fn make_vec3<N: Scalar>(ptr: &[N]) -> Vec<N, U3> { pub fn make_vec3<N: Scalar>(ptr: &[N]) -> Vec<N, U3> {
unimplemented!() Vector3::from_column_slice(ptr)
} }
pub fn make_vec4_1<N: Scalar>(v: &Vec<N, U1>) -> Vec<N, U4> { pub fn make_vec4_1<N: Number>(v: &Vec<N, U1>) -> Vec<N, U4> {
unimplemented!() Vector4::new(v.x, N::zero(), N::zero(), N::zero())
} }
pub fn make_vec4_2<N: Scalar>(v: &Vec<N, U2>) -> Vec<N, U4> { pub fn make_vec4_2<N: Number>(v: &Vec<N, U2>) -> Vec<N, U4> {
unimplemented!() Vector4::new(v.x, v.y, N::zero(), N::zero())
} }
pub fn make_vec4_3<N: Scalar>(v: &Vec<N, U3>) -> Vec<N, U4> { pub fn make_vec4_3<N: Number>(v: &Vec<N, U3>) -> Vec<N, U4> {
unimplemented!() Vector4::new(v.x, v.y, v.z, N::zero())
} }
pub fn make_vec4_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U4> { pub fn make_vec4_4<N: Scalar>(v: &Vec<N, U4>) -> Vec<N, U4> {
unimplemented!() *v
} }
pub fn make_vec4<N: Scalar>(ptr: &[N]) -> Vec<N, U4> { pub fn make_vec4<N: Scalar>(ptr: &[N]) -> Vec<N, U4> {
unimplemented!() Vector4::from_column_slice(ptr)
} }
pub fn value_ptr<T, V>(x: &T) -> &V { pub fn value_ptr<N: Scalar, R: Dimension, C: Dimension>(x: &Mat<N, R, C>) -> &[N]
unimplemented!() where DefaultAllocator: Alloc<N, R, C> {
x.as_slice()
}
pub fn value_ptr_mut<N: Scalar, R: Dimension, C: Dimension>(x: &mut Mat<N, R, C>) -> &mut [N]
where DefaultAllocator: Alloc<N, R, C> {
x.as_mut_slice()
} }

View File

@ -1,28 +1,28 @@
use na::{Scalar, Real, DimName, U3, DefaultAllocator}; use na::{Scalar, Real, U3, DefaultAllocator};
use traits::{Number, Alloc}; use traits::{Number, Alloc, Dimension};
use aliases::Vec; use aliases::Vec;
pub fn bitCount<T>(v: T) -> i32 { pub fn bitCount<T>(v: T) -> i32 {
unimplemented!() unimplemented!()
} }
pub fn bitCount2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<i32, D> pub fn bitCount2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<i32, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn bitfieldExtract<N: Scalar, D: DimName>(Value: &Vec<N, D>, Offset: i32, Bits: i32) -> Vec<N, D> pub fn bitfieldExtract<N: Scalar, D: Dimension>(Value: &Vec<N, D>, Offset: i32, Bits: i32) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn bitfieldInsert<N: Scalar, D: DimName>(Base: &Vec<N, D>, Insert: &Vec<N, D>, Offset: i32, Bits: i32) -> Vec<N, D> pub fn bitfieldInsert<N: Scalar, D: Dimension>(Base: &Vec<N, D>, Insert: &Vec<N, D>, Offset: i32, Bits: i32) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn bitfieldReverse<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<N, D> pub fn bitfieldReverse<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -31,7 +31,7 @@ pub fn findLSB<IU>(x: IU) -> u32 {
unimplemented!() unimplemented!()
} }
pub fn findLSB2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<i32, D> pub fn findLSB2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<i32, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
@ -40,27 +40,27 @@ pub fn findMSB<IU>(x: IU) -> i32 {
unimplemented!() unimplemented!()
} }
pub fn findMSB2<N: Scalar, D: DimName>(v: &Vec<N, D>) -> Vec<i32, D> pub fn findMSB2<N: Scalar, D: Dimension>(v: &Vec<N, D>) -> Vec<i32, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn imulExtended<N: Scalar, D: DimName>(x: &Vec<i32, D>, y: &Vec<i32, D>, msb: &Vec<i32, D>, lsb: &Vec<i32, D>) pub fn imulExtended<N: Scalar, D: Dimension>(x: &Vec<i32, D>, y: &Vec<i32, D>, msb: &Vec<i32, D>, lsb: &Vec<i32, D>)
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn uaddCarry<N: Scalar, D: DimName>(x: &Vec<u32, D>, y: &Vec<u32, D>, carry: &Vec<u32, D>) -> Vec<u32, D> pub fn uaddCarry<N: Scalar, D: Dimension>(x: &Vec<u32, D>, y: &Vec<u32, D>, carry: &Vec<u32, D>) -> Vec<u32, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn umulExtended<N: Scalar, D: DimName>(x: &Vec<u32, D>, y: &Vec<u32, D>, msb: &Vec<u32, D>, lsb: &Vec<u32, D>) pub fn umulExtended<N: Scalar, D: Dimension>(x: &Vec<u32, D>, y: &Vec<u32, D>, msb: &Vec<u32, D>, lsb: &Vec<u32, D>)
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }
pub fn usubBorrow<N: Scalar, D: DimName>(x: &Vec<u32, D>, y: &Vec<u32, D>, borrow: &Vec<u32, D>) -> Vec<u32, D> pub fn usubBorrow<N: Scalar, D: Dimension>(x: &Vec<u32, D>, y: &Vec<u32, D>, borrow: &Vec<u32, D>) -> Vec<u32, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
unimplemented!() unimplemented!()
} }

View File

@ -1,4 +1,6 @@
extern crate num_traits as num; extern crate num_traits as num;
#[macro_use]
extern crate approx;
extern crate alga; extern crate alga;
extern crate nalgebra as na; extern crate nalgebra as na;
@ -11,6 +13,8 @@ pub use trigonometric::*;
pub use vector_relational::*; pub use vector_relational::*;
pub use exponential::*; pub use exponential::*;
pub use ext_vector_relational::*;
mod aliases; mod aliases;
pub mod constructors; pub mod constructors;
mod common; mod common;
@ -30,6 +34,7 @@ pub mod ext_quaternion_common;
pub mod ext_quaternion_geometric; pub mod ext_quaternion_geometric;
pub mod ext_quaternion_transform; pub mod ext_quaternion_transform;
pub mod ext_quaternion_trigonometric; pub mod ext_quaternion_trigonometric;
pub mod ext_quaternion_relational;
pub mod ext_scalar_common; pub mod ext_scalar_common;
pub mod ext_scalar_constants; pub mod ext_scalar_constants;
pub mod ext_vector_common; pub mod ext_vector_common;

View File

@ -1,32 +1,31 @@
use num::Num; use num::Num;
use traits::{Alloc, Number}; use na::{Scalar, Real, DefaultAllocator, U1};
use na::{Scalar, Real, DimName, DefaultAllocator, U1};
use na::allocator::Allocator;
use traits::{Alloc, Dimension, Number};
use aliases::{Mat, Vec}; use aliases::{Mat, Vec};
//pub fn determinant<N: Real, D: DimName>(m: &Mat<N, D, D>) -> N pub fn determinant<N: Real, D: Dimension>(m: &Mat<N, D, D>) -> N
// where DefaultAllocator: Allocator<N, D, D> { where DefaultAllocator: Alloc<N, D, D> {
// m.determinant() m.determinant()
//} }
pub fn inverse<N: Real, D: DimName>(m: &Mat<N, D, D>) -> Mat<N, D, D> pub fn inverse<N: Real, D: Dimension>(m: &Mat<N, D, D>) -> Mat<N, D, D>
where DefaultAllocator: Alloc<N, D, D> { where DefaultAllocator: Alloc<N, D, D> {
m.clone().try_inverse().unwrap_or(Mat::<N, D, D>::zeros()) m.clone().try_inverse().unwrap_or(Mat::<N, D, D>::zeros())
} }
pub fn matrix_comp_mult<N: Number, R: DimName, C: DimName>(x: &Mat<N, R, C>, y: &Mat<N, R, C>) -> Mat<N, R, C> pub fn matrix_comp_mult<N: Number, R: Dimension, C: Dimension>(x: &Mat<N, R, C>, y: &Mat<N, R, C>) -> Mat<N, R, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
x.component_mul(y) x.component_mul(y)
} }
pub fn outer_product<N: Number, R: DimName, C: DimName>(c: &Vec<N, R>, r: &Vec<N, C>) -> Mat<N, R, C> pub fn outer_product<N: Number, R: Dimension, C: Dimension>(c: &Vec<N, R>, r: &Vec<N, C>) -> Mat<N, R, C>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
c * r.transpose() c * r.transpose()
} }
pub fn transpose<N: Scalar, R: DimName, C: DimName>(x: &Mat<N, R, C>) -> Mat<N, C, R> pub fn transpose<N: Scalar, R: Dimension, C: Dimension>(x: &Mat<N, R, C>) -> Mat<N, C, R>
where DefaultAllocator: Alloc<N, R, C> { where DefaultAllocator: Alloc<N, R, C> {
x.transpose() x.transpose()
} }

View File

@ -1,18 +1,23 @@
use std::cmp::{PartialOrd, PartialEq}; use std::cmp::{PartialOrd, PartialEq};
use num::Signed;
use approx::AbsDiffEq;
use alga::general::Ring; use alga::general::{Ring, Lattice};
use na::{Scalar, DimName, U1}; use na::{Scalar, DimName, DimMin, U1};
use na::allocator::Allocator; use na::allocator::Allocator;
pub trait Dimension: DimName + DimMin<Self, Output = Self> {}
impl<D: DimName + DimMin<D, Output = Self>> Dimension for D {}
pub trait Number: Scalar + Ring + PartialOrd + PartialEq {
pub trait Number: Scalar + Ring + Lattice + AbsDiffEq<Epsilon = Self> + Signed {
} }
impl<T: Scalar + Ring + PartialOrd + PartialEq> Number for T { impl<T: Scalar + Ring + Lattice + AbsDiffEq<Epsilon = Self> + Signed> Number for T {
} }
#[doc(hidden)] #[doc(hidden)]
pub trait Alloc<N: Scalar, R: DimName, C: DimName = U1>: pub trait Alloc<N: Scalar, R: Dimension, C: Dimension = U1>:
Allocator<N, R> + Allocator<N, C> + Allocator<N, U1, R> + Allocator<N, U1, C> + Allocator<N, R, C> + Allocator<N, C, R> + Allocator<N, R, R> + Allocator<N, C, C> + Allocator<N, R> + Allocator<N, C> + Allocator<N, U1, R> + Allocator<N, U1, C> + Allocator<N, R, C> + Allocator<N, C, R> + Allocator<N, R, R> + Allocator<N, C, C> +
Allocator<bool, R> + Allocator<bool, C> + Allocator<bool, R> + Allocator<bool, C> +
Allocator<f32, R> + Allocator<f32, C> + Allocator<f32, R> + Allocator<f32, C> +
@ -21,11 +26,12 @@ Allocator<i32, R> + Allocator<i32, C> +
Allocator<f64, R> + Allocator<f64, C> + Allocator<f64, R> + Allocator<f64, C> +
Allocator<u64, R> + Allocator<u64, C> + Allocator<u64, R> + Allocator<u64, C> +
Allocator<i64, R> + Allocator<i64, C> + Allocator<i64, R> + Allocator<i64, C> +
Allocator<i16, R> + Allocator<i16, C> Allocator<i16, R> + Allocator<i16, C> +
Allocator<(usize, usize), R> + Allocator<(usize, usize), C>
{ {
} }
impl<N: Scalar, R: DimName, C: DimName, T> impl<N: Scalar, R: Dimension, C: Dimension, T>
Alloc<N, R, C> for T Alloc<N, R, C> for T
where T: Allocator<N, R> + Allocator<N, C> + Allocator<N, U1, R> + Allocator<N, U1, C> + Allocator<N, R, C> + Allocator<N, C, R> + Allocator<N, R, R> + Allocator<N, C, C> + where T: Allocator<N, R> + Allocator<N, C> + Allocator<N, U1, R> + Allocator<N, U1, C> + Allocator<N, R, C> + Allocator<N, C, R> + Allocator<N, R, R> + Allocator<N, C, C> +
Allocator<bool, R> + Allocator<bool, C> + Allocator<bool, R> + Allocator<bool, C> +
@ -35,5 +41,7 @@ where T: Allocator<N, R> + Allocator<N, C> + Allocator<N, U1, R> + Allocator<N,
Allocator<f64, R> + Allocator<f64, C> + Allocator<f64, R> + Allocator<f64, C> +
Allocator<u64, R> + Allocator<u64, C> + Allocator<u64, R> + Allocator<u64, C> +
Allocator<i64, R> + Allocator<i64, C> + Allocator<i64, R> + Allocator<i64, C> +
Allocator<i16, R> + Allocator<i16, C> { Allocator<i16, R> + Allocator<i16, C> +
Allocator<(usize, usize), R> + Allocator<(usize, usize), C>
{
} }

View File

@ -1,73 +1,79 @@
use na::{self, Real, DimName, DefaultAllocator}; use na::{self, Real, DefaultAllocator};
use aliases::Vec; use aliases::Vec;
use traits::Alloc; use traits::{Alloc, Dimension};
pub fn acos<N: Real, D: DimName>(x: &Vec<N, D>) -> Vec<N, D> pub fn acos<N: Real, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.acos()) x.map(|e| e.acos())
} }
pub fn acosh<N: Real, D: DimName>(x: &Vec<N, D>) -> Vec<N, D>
pub fn acosh<N: Real, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.acosh()) x.map(|e| e.acosh())
} }
pub fn asin<N: Real, D: DimName>(x: &Vec<N, D>) -> Vec<N, D>
pub fn asin<N: Real, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.asin()) x.map(|e| e.asin())
} }
pub fn asinh<N: Real, D: DimName>(x: &Vec<N, D>) -> Vec<N, D>
pub fn asinh<N: Real, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.asinh()) x.map(|e| e.asinh())
} }
pub fn atan2<N: Real, D: DimName>(y: &Vec<N, D>, x: &Vec<N, D>) -> Vec<N, D>
pub fn atan2<N: Real, D: Dimension>(y: &Vec<N, D>, x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
y.zip_map(x, |y, x| y.atan2(x)) y.zip_map(x, |y, x| y.atan2(x))
} }
pub fn atan<N: Real, D: DimName>(y_over_x: &Vec<N, D>) -> Vec<N, D>
pub fn atan<N: Real, D: Dimension>(y_over_x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
y_over_x.map(|e| e.atan()) y_over_x.map(|e| e.atan())
} }
pub fn atanh<N: Real, D: DimName>(x: &Vec<N, D>) -> Vec<N, D>
pub fn atanh<N: Real, D: Dimension>(x: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.map(|e| e.atanh()) x.map(|e| e.atanh())
} }
pub fn cos<N: Real, D: DimName>(angle: &Vec<N, D>) -> Vec<N, D> pub fn cos<N: Real, D: Dimension>(angle: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.cos()) angle.map(|e| e.cos())
} }
pub fn cosh<N: Real, D: DimName>(angle: &Vec<N, D>) -> Vec<N, D> pub fn cosh<N: Real, D: Dimension>(angle: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.cosh()) angle.map(|e| e.cosh())
} }
pub fn degrees<N: Real, D: DimName>(radians: &Vec<N, D>) -> Vec<N, D> pub fn degrees<N: Real, D: Dimension>(radians: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
radians.map(|e| e * na::convert(180.0) / N::pi()) radians.map(|e| e * na::convert(180.0) / N::pi())
} }
pub fn radians<N: Real, D: DimName>(degrees: &Vec<N, D>) -> Vec<N, D> pub fn radians<N: Real, D: Dimension>(degrees: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
degrees.map(|e| e * N::pi() / na::convert(180.0)) degrees.map(|e| e * N::pi() / na::convert(180.0))
} }
pub fn sin<N: Real, D: DimName>(angle: &Vec<N, D>) -> Vec<N, D> pub fn sin<N: Real, D: Dimension>(angle: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.sin()) angle.map(|e| e.sin())
} }
pub fn sinh<N: Real, D: DimName>(angle: &Vec<N, D>) -> Vec<N, D> pub fn sinh<N: Real, D: Dimension>(angle: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.sinh()) angle.map(|e| e.sinh())
} }
pub fn tan<N: Real, D: DimName>(angle: &Vec<N, D>) -> Vec<N, D> pub fn tan<N: Real, D: Dimension>(angle: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.tan()) angle.map(|e| e.tan())
} }
pub fn tanh<N: Real, D: DimName>(angle: &Vec<N, D>) -> Vec<N, D> pub fn tanh<N: Real, D: Dimension>(angle: &Vec<N, D>) -> Vec<N, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
angle.map(|e| e.tanh()) angle.map(|e| e.tanh())
} }

View File

@ -1,50 +1,50 @@
use na::{self, Real, DimName, DefaultAllocator}; use na::{self, Real, DefaultAllocator};
use aliases::Vec; use aliases::Vec;
use traits::{Number, Alloc}; use traits::{Number, Alloc, Dimension};
pub fn all<D: DimName>(v: &Vec<bool, D>) -> bool pub fn all<D: Dimension>(v: &Vec<bool, D>) -> bool
where DefaultAllocator: Alloc<bool, D> { where DefaultAllocator: Alloc<bool, D> {
v.iter().all(|x| *x) v.iter().all(|x| *x)
} }
pub fn any<D: DimName>(v: &Vec<bool, D>) -> bool pub fn any<D: Dimension>(v: &Vec<bool, D>) -> bool
where DefaultAllocator: Alloc<bool, D> { where DefaultAllocator: Alloc<bool, D> {
v.iter().any(|x| *x) v.iter().any(|x| *x)
} }
pub fn equal<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D> pub fn equal<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.zip_map(y, |x, y| x == y) x.zip_map(y, |x, y| x == y)
} }
pub fn greaterThan<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D> pub fn greater_than<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.zip_map(y, |x, y| x > y) x.zip_map(y, |x, y| x > y)
} }
pub fn greaterThanEqual<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D> pub fn greater_than_equal<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.zip_map(y, |x, y| x >= y) x.zip_map(y, |x, y| x >= y)
} }
pub fn lessThan<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D> pub fn less_than<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.zip_map(y, |x, y| x < y) x.zip_map(y, |x, y| x < y)
} }
pub fn lessThanEqual<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D> pub fn less_than_equal<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.zip_map(y, |x, y| x <= y) x.zip_map(y, |x, y| x <= y)
} }
pub fn not<D: DimName>(v: &Vec<bool, D>) -> Vec<bool, D> pub fn not<D: Dimension>(v: &Vec<bool, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<bool, D> { where DefaultAllocator: Alloc<bool, D> {
v.map(|x| !x) v.map(|x| !x)
} }
pub fn notEqual<N: Number, D: DimName>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D> pub fn not_equal<N: Number, D: Dimension>(x: &Vec<N, D>, y: &Vec<N, D>) -> Vec<bool, D>
where DefaultAllocator: Alloc<N, D> { where DefaultAllocator: Alloc<N, D> {
x.zip_map(y, |x, y| x != y) x.zip_map(y, |x, y| x != y)
} }