From 987b91767acce1e2dd29cb10c01da396aafc80fa Mon Sep 17 00:00:00 2001 From: Vincent Barrielle Date: Fri, 16 May 2014 21:04:35 +0200 Subject: [PATCH] update to the latest rust: FloatMath for math functions (sin/exp/...) Also removed a bunch of duplicate trait usages --- src/na.rs | 4 ++-- src/structs/dmat.rs | 6 +++--- src/structs/dvec.rs | 4 ++-- src/structs/iso.rs | 2 +- src/structs/iso_macros.rs | 16 ++++++++-------- src/structs/rot.rs | 16 ++++++++-------- src/structs/rot_macros.rs | 2 +- src/structs/spec/vec0.rs | 2 +- src/structs/vec_macros.rs | 6 +++--- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/na.rs b/src/na.rs index b3bab4e8..49c49b8d 100644 --- a/src/na.rs +++ b/src/na.rs @@ -1,6 +1,6 @@ //! **nalgebra** prelude. -use std::num::{Zero, One}; +use std::num::{Zero, One, FloatMath}; use std::cmp; pub use traits::{PartialLess, PartialEqual, PartialGreater, NotComparable}; pub use traits::{ @@ -217,7 +217,7 @@ pub fn one() -> T { */ /// 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`). -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 6d101698..8f905d78 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -576,11 +576,11 @@ impl Show for DMat { fn fmt(&self, form:&mut Formatter) -> Result { for i in range(0u, self.nrows()) { for j in range(0u, self.ncols()) { - let _ = write!(form.buf, "{} ", self.at((i, j))); + let _ = write!(form, "{} ", self.at((i, j))); } - let _ = write!(form.buf, "\n"); + let _ = write!(form, "\n"); } - write!(form.buf, "\n") + write!(form, "\n") } } diff --git a/src/structs/dvec.rs b/src/structs/dvec.rs index 4da43229..662d3bfe 100644 --- a/src/structs/dvec.rs +++ b/src/structs/dvec.rs @@ -198,7 +198,7 @@ impl FromIterator for DVec { } } -impl + DVecMulRhs>> DVec { +impl + DVecMulRhs>> DVec { /// Computes the canonical basis for the given dimension. A canonical basis is a set of /// vectors, mutually orthogonal, with all its component equal to 0.0 except one which is equal /// to 1.0. @@ -305,7 +305,7 @@ impl Dot for DVec { } } -impl Norm for DVec { +impl Norm for DVec { #[inline] fn sqnorm(v: &DVec) -> N { Dot::dot(v, v) diff --git a/src/structs/iso.rs b/src/structs/iso.rs index fc543ace..de4a78e2 100644 --- a/src/structs/iso.rs +++ b/src/structs/iso.rs @@ -51,7 +51,7 @@ pub struct Iso4 { pub translation: Vec4 } -impl Iso3 { +impl Iso3 { /// Reorient and translate this transformation such that its local `x` axis points to a given /// direction. Note that the usually known `look_at` function does the same thing but with the /// `z` axis. See `look_at_z` for that. diff --git a/src/structs/iso_macros.rs b/src/structs/iso_macros.rs index 43c05edb..1c618df4 100644 --- a/src/structs/iso_macros.rs +++ b/src/structs/iso_macros.rs @@ -2,7 +2,7 @@ macro_rules! iso_impl( ($t: ident, $submat: ident, $subvec: ident, $subrotvec: ident) => ( - impl $t { + impl $t { /// Creates a new isometry from a rotation matrix and a vector. #[inline] pub fn new(translation: $subvec, rotation: $subrotvec) -> $t { @@ -26,7 +26,7 @@ macro_rules! iso_impl( macro_rules! rotation_matrix_impl( ($t: ident, $trot: ident, $tlv: ident, $tav: ident) => ( - impl + Float + Float + Num + Clone> + impl + FloatMath + Num + Clone> RotationMatrix<$tlv, $tav, $trot> for $t { #[inline] fn to_rot_mat(&self) -> $trot { @@ -50,7 +50,7 @@ macro_rules! dim_impl( macro_rules! one_impl( ($t: ident) => ( - impl One for $t { + impl One for $t { #[inline] fn one() -> $t { $t::new_with_rotmat(Zero::zero(), One::one()) @@ -61,7 +61,7 @@ macro_rules! one_impl( macro_rules! iso_mul_iso_impl( ($t: ident, $tmul: ident) => ( - impl $tmul> for $t { + impl $tmul> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new_with_rotmat( @@ -96,7 +96,7 @@ macro_rules! vec_mul_iso_impl( macro_rules! translation_impl( ($t: ident, $tv: ident) => ( - impl Translation<$tv> for $t { + impl Translation<$tv> for $t { #[inline] fn translation(&self) -> $tv { self.translation.clone() @@ -153,7 +153,7 @@ macro_rules! translate_impl( macro_rules! rotation_impl( ($t: ident, $trot: ident, $tav: ident) => ( - impl + Num + Float + Float + Clone> Rotation<$tav> for $t { + impl + FloatMath + Clone> Rotation<$tav> for $t { #[inline] fn rotation(&self) -> $tav { self.rotation.rotation() @@ -220,7 +220,7 @@ macro_rules! rotate_impl( macro_rules! transformation_impl( ($t: ident) => ( - impl Transformation<$t> for $t { + impl Transformation<$t> for $t { fn transformation(&self) -> $t { self.clone() } @@ -336,7 +336,7 @@ macro_rules! approx_eq_impl( macro_rules! rand_impl( ($t: ident) => ( - impl Rand for $t { + impl Rand for $t { #[inline] fn rand(rng: &mut R) -> $t { $t::new(rng.gen(), rng.gen()) diff --git a/src/structs/rot.rs b/src/structs/rot.rs index 4bdcb84d..b184dd6d 100644 --- a/src/structs/rot.rs +++ b/src/structs/rot.rs @@ -20,7 +20,7 @@ pub struct Rot2 { submat: Mat2 } -impl> Rot2 { +impl> Rot2 { /// Builds a 2 dimensional rotation matrix from an angle in radian. pub fn new(angle: Vec1) -> Rot2 { let (sia, coa) = angle.x.sin_cos(); @@ -31,7 +31,7 @@ impl> Rot2 { } } -impl +impl Rotation> for Rot2 { #[inline] fn rotation(&self) -> Vec1 { @@ -69,7 +69,7 @@ Rotation> for Rot2 { } } -impl> Rand for Rot2 { +impl> Rand for Rot2 { #[inline] fn rand(rng: &mut R) -> Rot2 { Rot2::new(rng.gen()) @@ -99,7 +99,7 @@ pub struct Rot3 { } -impl Rot3 { +impl Rot3 { /// Builds a 3 dimensional rotation matrix from an axis and an angle. /// /// # Arguments @@ -140,7 +140,7 @@ impl Rot3 { } } -impl Rot3 { +impl Rot3 { /// Reorient this matrix such that its local `x` axis points to a given point. Note that the /// usually known `look_at` function does the same thing but with the `z` axis. See `look_at_z` /// for that. @@ -180,7 +180,7 @@ impl Rot3 { } } -impl> +impl> Rotation> for Rot3 { #[inline] fn rotation(&self) -> Vec3 { @@ -245,7 +245,7 @@ Rotation> for Rot3 { } } -impl +impl Rand for Rot3 { #[inline] fn rand(rng: &mut R) -> Rot3 { @@ -309,7 +309,7 @@ impl AbsoluteRotate> for Rot4 { } } -impl +impl Rotation> for Rot4 { #[inline] fn rotation(&self) -> Vec4 { diff --git a/src/structs/rot_macros.rs b/src/structs/rot_macros.rs index cee3972c..1a168080 100644 --- a/src/structs/rot_macros.rs +++ b/src/structs/rot_macros.rs @@ -56,7 +56,7 @@ macro_rules! dim_impl( macro_rules! rotation_matrix_impl( ($t: ident, $tlv: ident, $tav: ident) => ( - impl + Float + Float + Num + Clone> + impl + FloatMath + Clone> RotationMatrix<$tlv, $tav, $t> for $t { #[inline] fn to_rot_mat(&self) -> $t { diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs index 1ea49bc2..3ca49091 100644 --- a/src/structs/spec/vec0.rs +++ b/src/structs/spec/vec0.rs @@ -164,7 +164,7 @@ impl + Neg> Translation> for vec::Vec0 { } } -impl Norm for vec::Vec0 { +impl Norm for vec::Vec0 { #[inline] fn sqnorm(_: &vec::Vec0) -> N { Zero::zero() diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index a86fdfbf..6f4e2595 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -38,7 +38,7 @@ macro_rules! at_fast_impl( // However, f32/f64 does not implement TotalOrd… macro_rules! ord_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl PartialOrd for $t { + impl PartialOrd for $t { #[inline] fn inf(a: &$t, b: &$t) -> $t { $t::new(a.$comp0.min(b.$comp0.clone()) @@ -255,7 +255,7 @@ macro_rules! container_impl( macro_rules! basis_impl( ($t: ident, $trhs: ident, $dim: expr) => ( - impl + $trhs>> Basis for $t { + impl + $trhs>> Basis for $t { #[inline] fn canonical_basis(f: |$t| -> bool) { for i in range(0u, $dim) { @@ -465,7 +465,7 @@ macro_rules! translation_impl( macro_rules! norm_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl Norm for $t { + impl Norm for $t { #[inline] fn sqnorm(v: &$t) -> N { Dot::dot(v, v)