diff --git a/src/rotation.rs b/src/rotation.rs index 886c71f..74f2e44 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -138,12 +138,12 @@ pub trait Rotation3: Rotation, Point3> /// use cgmath::{Matrix, ToMatrix2}; /// use cgmath::{Rotation, Rotation2, Basis2}; /// use cgmath::ApproxEq; -/// use std::num::Float; +/// use std::f64; /// /// // For simplicity, we will rotate the unit x vector to the unit y vector -- /// // so the angle is 90 degrees, or π/2. /// let unit_x: Vector2 = Vector2::unit_x(); -/// let rot: Basis2 = Rotation2::from_angle(rad(0.5f64 * Float::pi())); +/// let rot: Basis2 = Rotation2::from_angle(rad(0.5f64 * f64::consts::PI)); /// /// // Rotate the vector using the two-dimensional rotation matrix: /// let unit_y = rot.rotate_vector(&unit_x); @@ -157,7 +157,7 @@ pub trait Rotation3: Rotation, Point3> /// assert_eq!(unit_y2, unit_y); /// /// // Note that we can also concatenate rotations: -/// let rot_half: Basis2 = Rotation2::from_angle(rad(0.25f64 * Float::pi())); +/// let rot_half: Basis2 = Rotation2::from_angle(rad(0.25f64 * f64::consts::PI)); /// let unit_y3 = rot_half.concat(&rot_half).rotate_vector(&unit_x); /// assert!(unit_y3.approx_eq(&unit_y2)); /// ``` diff --git a/tests/matrix.rs b/tests/matrix.rs index 7a6ad08..1bab3e5 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -18,7 +18,7 @@ extern crate cgmath; use cgmath::*; -use std::num::Float; +use std::f64; pub mod matrix2 { use cgmath::*; @@ -399,7 +399,7 @@ fn test_predicates() { #[test] fn test_from_angle() { // 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())); // 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())); // Rotate the vector (1, 1) by π radians to the vector (-1, -1) - let rot3: Matrix2 = Matrix2::from_angle(rad(Float::pi())); + let rot3: Matrix2 = 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))); } diff --git a/tests/quaternion.rs b/tests/quaternion.rs index a4e948f..ee8c98e 100644 --- a/tests/quaternion.rs +++ b/tests/quaternion.rs @@ -23,7 +23,7 @@ use cgmath::Quaternion; use cgmath::{Rad, rad, ApproxEq}; use cgmath::Rotation3; -use std::num::Float; +use std::f32; #[test] 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 = Rotation3::from_euler(rad(0f32), rad(0f32), rad(0f32)); eq((rad(0f32), rad(0f32), rad(0f32)), zero.to_euler()); diff --git a/tests/vector.rs b/tests/vector.rs index 446b53f..f7f1669 100644 --- a/tests/vector.rs +++ b/tests/vector.rs @@ -21,6 +21,7 @@ extern crate cgmath; extern crate cgmath; use cgmath::*; +use std::f64; use std::num::{Float, FloatMath}; #[test] @@ -143,17 +144,17 @@ mod test_length { #[test] 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(10.0f64, 0.0f64).angle(&Vector2::new(0.0f64, 5.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(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(f64::consts::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(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(-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(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(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 * 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(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(-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(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(f64::consts::FRAC_PI_2) )); } #[test]