From 93b184815f69cfaf684c77072cd30fe460a4e8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Tue, 28 Oct 2014 16:33:56 +0100 Subject: [PATCH] Always use `Cast` instead of `Cast`. --- src/lib.rs | 2 +- src/structs/dmat.rs | 8 ++++---- src/structs/iso_macros.rs | 4 ++-- src/structs/rot.rs | 2 +- src/structs/rot_macros.rs | 2 +- src/structs/spec/vec.rs | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index eb76abfb..c5d22a86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -383,7 +383,7 @@ pub fn sqdist, V: Norm>(a: &P, b: &P) -> N { /// Computes a projection matrix given the frustrum near plane width, height, the field of /// view, and the distance to the clipping planes (`znear` and `zfar`). #[deprecated = "Use `Persp3::new(width / height, fov, znear, zfar).as_mat()` instead"] -pub fn perspective3d + Zero + One>(width: N, height: N, fov: N, znear: N, zfar: N) -> Mat4 { +pub fn perspective3d + Zero + One>(width: N, height: N, fov: N, znear: N, zfar: N) -> Mat4 { let aspect = width / height; let _1: N = one(); diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index f3d0f979..45f86efd 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -500,10 +500,10 @@ impl Transpose for DMat { } } -impl + Clone> Mean> for DMat { +impl + Clone> Mean> for DMat { fn mean(m: &DMat) -> DVec { let mut res: DVec = DVec::new_zeros(m.ncols); - let normalizer: N = Cast::from(1.0f32 / Cast::from(m.nrows)); + let normalizer: N = Cast::from(1.0f64 / Cast::from(m.nrows)); for i in range(0u, m.nrows) { for j in range(0u, m.ncols) { @@ -518,7 +518,7 @@ impl + Clone> Mean> for DMat { } } -impl + DMatDivRhs>> Cov> for DMat { +impl + DMatDivRhs>> Cov> for DMat { // FIXME: this could be heavily optimized, removing all temporaries by merging loops. fn cov(m: &DMat) -> DMat { assert!(m.nrows > 1); @@ -536,7 +536,7 @@ impl + DMatDivRhs>> Cov> for DMat< } // FIXME: return a triangular matrix? - let fnormalizer: f32 = Cast::from(m.nrows() - 1); + let fnormalizer: f64 = Cast::from(m.nrows() - 1); let normalizer: N = Cast::from(fnormalizer); // FIXME: this will do 2 allocations for temporaries! (Transpose::transpose_cpy(¢ered) * centered) / normalizer diff --git a/src/structs/iso_macros.rs b/src/structs/iso_macros.rs index af573282..7a3f1258 100644 --- a/src/structs/iso_macros.rs +++ b/src/structs/iso_macros.rs @@ -26,7 +26,7 @@ macro_rules! iso_impl( macro_rules! rotation_matrix_impl( ($t: ident, $trot: ident, $tlv: ident, $tav: ident) => ( - impl + FloatMath + Num + Clone> + impl + FloatMath + Num + Clone> RotationMatrix, $tav, $trot> for $t { #[inline] fn to_rot_mat(&self) -> $trot { @@ -153,7 +153,7 @@ macro_rules! translate_impl( macro_rules! rotation_impl( ($t: ident, $trot: ident, $tav: ident) => ( - impl + FloatMath + Clone> Rotation<$tav> for $t { + impl + FloatMath + Clone> Rotation<$tav> for $t { #[inline] fn rotation(&self) -> $tav { self.rotation.rotation() diff --git a/src/structs/rot.rs b/src/structs/rot.rs index 3476b658..d8ae2763 100644 --- a/src/structs/rot.rs +++ b/src/structs/rot.rs @@ -205,7 +205,7 @@ impl Rot3 { } } -impl> +impl> Rotation> for Rot3 { #[inline] fn rotation(&self) -> Vec3 { diff --git a/src/structs/rot_macros.rs b/src/structs/rot_macros.rs index 07b660bc..108cb725 100644 --- a/src/structs/rot_macros.rs +++ b/src/structs/rot_macros.rs @@ -122,7 +122,7 @@ macro_rules! dim_impl( macro_rules! rotation_matrix_impl( ($t: ident, $tlv: ident, $tav: ident) => ( - impl + FloatMath> RotationMatrix, $tav, $t> for $t { + impl + FloatMath> RotationMatrix, $tav, $t> for $t { #[inline] fn to_rot_mat(&self) -> $t { self.clone() diff --git a/src/structs/spec/vec.rs b/src/structs/spec/vec.rs index 01da3a2c..a5e2154e 100644 --- a/src/structs/spec/vec.rs +++ b/src/structs/spec/vec.rs @@ -154,7 +154,7 @@ impl Basis for Vec3 { } // FIXME: this bad: this fixes definitly the number of samples… -static SAMPLES_2_F32: [Vec2, ..21] = [ +static SAMPLES_2_F64: [Vec2, ..21] = [ Vec2 { x: 1.0, y: 0.0 }, Vec2 { x: 0.95557281, y: 0.29475517 }, Vec2 { x: 0.82623877, y: 0.56332006 }, @@ -179,7 +179,7 @@ static SAMPLES_2_F32: [Vec2, ..21] = [ ]; // Those vectors come from bullet 3d -static SAMPLES_3_F32: [Vec3, ..42] = [ +static SAMPLES_3_F64: [Vec3, ..42] = [ Vec3 { x: 0.000000 , y: -0.000000, z: -1.000000 }, Vec3 { x: 0.723608 , y: -0.525725, z: -0.447219 }, Vec3 { x: -0.276388, y: -0.850649, z: -0.447219 }, @@ -231,25 +231,25 @@ impl UniformSphereSample for Vec1 { } } -impl + Clone> UniformSphereSample for Vec2 { +impl + Clone> UniformSphereSample for Vec2 { #[inline(always)] fn sample(f: |Vec2| -> ()) { - for sample in SAMPLES_2_F32.iter() { + for sample in SAMPLES_2_F64.iter() { f(Cast::from(*sample)) } } } -impl + Clone> UniformSphereSample for Vec3 { +impl + Clone> UniformSphereSample for Vec3 { #[inline(always)] fn sample(f: |Vec3| -> ()) { - for sample in SAMPLES_3_F32.iter() { + for sample in SAMPLES_3_F64.iter() { f(Cast::from(*sample)) } } } -impl + Clone> UniformSphereSample for Vec4 { +impl + Clone> UniformSphereSample for Vec4 { #[inline(always)] fn sample(_: |Vec4| -> ()) { panic!("UniformSphereSample::>::sample : Not yet implemented.")