Remove deprecated Float use from tests.

This commit is contained in:
Jameson Ernst 2014-11-24 20:24:04 -08:00
parent 08f9354efc
commit 12ec7318d0
4 changed files with 18 additions and 17 deletions

View file

@ -138,12 +138,12 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
/// use cgmath::{Matrix, ToMatrix2}; /// use cgmath::{Matrix, ToMatrix2};
/// use cgmath::{Rotation, Rotation2, Basis2}; /// use cgmath::{Rotation, Rotation2, Basis2};
/// use cgmath::ApproxEq; /// use cgmath::ApproxEq;
/// use std::num::Float; /// use std::f64;
/// ///
/// // For simplicity, we will rotate the unit x vector to the unit y vector -- /// // For simplicity, we will rotate the unit x vector to the unit y vector --
/// // so the angle is 90 degrees, or π/2. /// // so the angle is 90 degrees, or π/2.
/// let unit_x: Vector2<f64> = Vector2::unit_x(); /// let unit_x: Vector2<f64> = Vector2::unit_x();
/// let rot: Basis2<f64> = Rotation2::from_angle(rad(0.5f64 * Float::pi())); /// let rot: Basis2<f64> = Rotation2::from_angle(rad(0.5f64 * f64::consts::PI));
/// ///
/// // Rotate the vector using the two-dimensional rotation matrix: /// // Rotate the vector using the two-dimensional rotation matrix:
/// let unit_y = rot.rotate_vector(&unit_x); /// let unit_y = rot.rotate_vector(&unit_x);
@ -157,7 +157,7 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
/// assert_eq!(unit_y2, unit_y); /// assert_eq!(unit_y2, unit_y);
/// ///
/// // Note that we can also concatenate rotations: /// // Note that we can also concatenate rotations:
/// let rot_half: Basis2<f64> = Rotation2::from_angle(rad(0.25f64 * Float::pi())); /// let rot_half: Basis2<f64> = Rotation2::from_angle(rad(0.25f64 * f64::consts::PI));
/// let unit_y3 = rot_half.concat(&rot_half).rotate_vector(&unit_x); /// let unit_y3 = rot_half.concat(&rot_half).rotate_vector(&unit_x);
/// assert!(unit_y3.approx_eq(&unit_y2)); /// assert!(unit_y3.approx_eq(&unit_y2));
/// ``` /// ```

View file

@ -18,7 +18,7 @@
extern crate cgmath; extern crate cgmath;
use cgmath::*; use cgmath::*;
use std::num::Float; use std::f64;
pub mod matrix2 { pub mod matrix2 {
use cgmath::*; use cgmath::*;
@ -399,7 +399,7 @@ fn test_predicates() {
#[test] #[test]
fn test_from_angle() { fn test_from_angle() {
// Rotate the vector (1, 0) by π/2 radians to the vector (0, 1) // Rotate the vector (1, 0) by π/2 radians to the vector (0, 1)
let rot1 = Matrix2::from_angle(rad(0.5f64 * Float::pi())); let rot1 = Matrix2::from_angle(rad(0.5f64 * f64::consts::PI));
assert!(rot1.mul_v(&Vector2::unit_x()).approx_eq(&Vector2::unit_y())); assert!(rot1.mul_v(&Vector2::unit_x()).approx_eq(&Vector2::unit_y()));
// Rotate the vector (-1, 0) by -π/2 radians to the vector (0, 1) // Rotate the vector (-1, 0) by -π/2 radians to the vector (0, 1)
@ -407,6 +407,6 @@ fn test_from_angle() {
assert!(rot2.mul_v(&-Vector2::unit_x()).approx_eq(&Vector2::unit_y())); assert!(rot2.mul_v(&-Vector2::unit_x()).approx_eq(&Vector2::unit_y()));
// Rotate the vector (1, 1) by π radians to the vector (-1, -1) // Rotate the vector (1, 1) by π radians to the vector (-1, -1)
let rot3: Matrix2<f64> = Matrix2::from_angle(rad(Float::pi())); let rot3: Matrix2<f64> = Matrix2::from_angle(rad(f64::consts::PI));
assert!(rot3.mul_v(&Vector2::new(1.0, 1.0)).approx_eq(&Vector2::new(-1.0, -1.0))); assert!(rot3.mul_v(&Vector2::new(1.0, 1.0)).approx_eq(&Vector2::new(-1.0, -1.0)));
} }

View file

@ -23,7 +23,7 @@ use cgmath::Quaternion;
use cgmath::{Rad, rad, ApproxEq}; use cgmath::{Rad, rad, ApproxEq};
use cgmath::Rotation3; use cgmath::Rotation3;
use std::num::Float; use std::f32;
#[test] #[test]
fn to_matrix4() fn to_matrix4()
@ -49,7 +49,7 @@ fn to_and_from_quaternion()
} }
} }
let hpi = Float::frac_pi_2(); let hpi = f32::consts::FRAC_PI_2;
let zero: Quaternion<f32> = Rotation3::from_euler(rad(0f32), rad(0f32), rad(0f32)); let zero: Quaternion<f32> = Rotation3::from_euler(rad(0f32), rad(0f32), rad(0f32));
eq((rad(0f32), rad(0f32), rad(0f32)), zero.to_euler()); eq((rad(0f32), rad(0f32), rad(0f32)), zero.to_euler());

View file

@ -21,6 +21,7 @@ extern crate cgmath;
extern crate cgmath; extern crate cgmath;
use cgmath::*; use cgmath::*;
use std::f64;
use std::num::{Float, FloatMath}; use std::num::{Float, FloatMath};
#[test] #[test]
@ -143,17 +144,17 @@ mod test_length {
#[test] #[test]
fn test_angle() { fn test_angle() {
assert!(Vector2::new(1.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 1.0f64)).approx_eq( &rad(Float::frac_pi_2()) )); assert!(Vector2::new(1.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 1.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_2) ));
assert!(Vector2::new(10.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 5.0f64)).approx_eq( &rad(Float::frac_pi_2()) )); assert!(Vector2::new(10.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 5.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_2) ));
assert!(Vector2::new(-1.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 1.0f64)).approx_eq( &-rad(Float::frac_pi_2()) )); assert!(Vector2::new(-1.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 1.0f64)).approx_eq( &-rad(f64::consts::FRAC_PI_2) ));
assert!(Vector3::new(1.0f64, 0.0f64, 1.0f64).angle(&Vector3::new(1.0f64, 1.0f64, 0.0f64)).approx_eq( &rad(Float::frac_pi_3()) )); assert!(Vector3::new(1.0f64, 0.0f64, 1.0f64).angle(&Vector3::new(1.0f64, 1.0f64, 0.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_3) ));
assert!(Vector3::new(10.0f64, 0.0f64, 10.0f64).angle(&Vector3::new(5.0f64, 5.0f64, 0.0f64)).approx_eq( &rad(Float::frac_pi_3()) )); assert!(Vector3::new(10.0f64, 0.0f64, 10.0f64).angle(&Vector3::new(5.0f64, 5.0f64, 0.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_3) ));
assert!(Vector3::new(-1.0f64, 0.0f64, -1.0f64).angle(&Vector3::new(1.0f64, -1.0f64, 0.0f64)).approx_eq( &rad(2.0f64 * Float::frac_pi_3()) )); assert!(Vector3::new(-1.0f64, 0.0f64, -1.0f64).angle(&Vector3::new(1.0f64, -1.0f64, 0.0f64)).approx_eq( &rad(2.0f64 * f64::consts::FRAC_PI_3) ));
assert!(Vector4::new(1.0f64, 0.0f64, 1.0f64, 0.0f64).angle(&Vector4::new(0.0f64, 1.0f64, 0.0f64, 1.0f64)).approx_eq( &rad(Float::frac_pi_2()) )); assert!(Vector4::new(1.0f64, 0.0f64, 1.0f64, 0.0f64).angle(&Vector4::new(0.0f64, 1.0f64, 0.0f64, 1.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_2) ));
assert!(Vector4::new(10.0f64, 0.0f64, 10.0f64, 0.0f64).angle(&Vector4::new(0.0f64, 5.0f64, 0.0f64, 5.0f64)).approx_eq( &rad(Float::frac_pi_2()) )); assert!(Vector4::new(10.0f64, 0.0f64, 10.0f64, 0.0f64).angle(&Vector4::new(0.0f64, 5.0f64, 0.0f64, 5.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_2) ));
assert!(Vector4::new(-1.0f64, 0.0f64, -1.0f64, 0.0f64).angle(&Vector4::new(0.0f64, 1.0f64, 0.0f64, 1.0f64)).approx_eq( &rad(Float::frac_pi_2()) )); assert!(Vector4::new(-1.0f64, 0.0f64, -1.0f64, 0.0f64).angle(&Vector4::new(0.0f64, 1.0f64, 0.0f64, 1.0f64)).approx_eq( &rad(f64::consts::FRAC_PI_2) ));
} }
#[test] #[test]