diff --git a/Cargo.toml b/Cargo.toml index 53bf6ef..9075aef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,6 @@ authors = ["Brendan Zabarauskas ", name = "cgmath" [dependencies] -rustc-serialize="*" \ No newline at end of file +rustc-serialize="*" +rand_macros="*" +rand="*" \ No newline at end of file diff --git a/benches/construction.rs b/benches/construction.rs index ab382ae..de96c89 100644 --- a/benches/construction.rs +++ b/benches/construction.rs @@ -13,12 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(test)] - +extern crate rand; extern crate test; extern crate cgmath; -use std::rand::{IsaacRng, Rng}; +use rand::{IsaacRng, Rng}; use std::iter; use test::Bencher; use cgmath::{Quaternion, Basis2, Basis3, Vector3, Rotation2, Rotation3, Rad}; diff --git a/benches/mat.rs b/benches/mat.rs index 474191c..8c64ba3 100644 --- a/benches/mat.rs +++ b/benches/mat.rs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(test)] - - +extern crate rand; extern crate test; extern crate cgmath; -use std::rand::{IsaacRng, Rng}; +use rand::{IsaacRng, Rng}; use test::Bencher; use cgmath::*; diff --git a/benches/quat.rs b/benches/quat.rs index 1b00a1a..7474b29 100644 --- a/benches/quat.rs +++ b/benches/quat.rs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(test)] - - +extern crate rand; extern crate test; extern crate cgmath; -use std::rand::{IsaacRng, Rng}; +use rand::{IsaacRng, Rng}; use test::Bencher; use cgmath::*; diff --git a/benches/vec.rs b/benches/vec.rs index 084a841..ec692bb 100644 --- a/benches/vec.rs +++ b/benches/vec.rs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(test)] - - +extern crate rand; extern crate test; extern crate cgmath; -use std::rand::{IsaacRng, Rng}; +use rand::{IsaacRng, Rng}; use test::Bencher; use cgmath::*; diff --git a/src/aabb.rs b/src/aabb.rs index 2fae234..5cb8620 100644 --- a/src/aabb.rs +++ b/src/aabb.rs @@ -122,7 +122,7 @@ impl Aabb, Point2> for Aabb2 { } } -impl fmt::Show for Aabb2 { +impl fmt::Debug for Aabb2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?} - {:?}]", self.min, self.max) } @@ -169,7 +169,7 @@ impl Aabb, Point3> for Aabb3 { } } -impl fmt::Show for Aabb3 { +impl fmt::Debug for Aabb3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?} - {:?}]", self.min, self.max) } diff --git a/src/angle.rs b/src/angle.rs index f93768b..9dc3f24 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -24,10 +24,12 @@ use approx::ApproxEq; use num::{BaseFloat, One, one, Zero, zero}; /// An angle, in radians -#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable)] pub struct Rad { pub s: S } /// An angle, in degrees -#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable)] pub struct Deg { pub s: S } /// Create a new angle, in radians diff --git a/src/cgmath.rs b/src/cgmath.rs index 351eb13..b57986f 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -15,7 +15,7 @@ #![crate_type = "rlib"] #![crate_type = "dylib"] -#![feature(old_impl_check)] +#![feature(old_impl_check, plugin, core, std_misc)] //! Computer graphics-centric math. //! @@ -32,6 +32,9 @@ //! These are provided for convenience. extern crate "rustc-serialize" as rustc_serialize; +extern crate rand; +#[plugin] +extern crate rand_macros; // Re-exports diff --git a/src/matrix.rs b/src/matrix.rs index 6be723f..e015b04 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -30,15 +30,18 @@ use vector::{Vector, EuclideanVector}; use vector::{Vector2, Vector3, Vector4}; /// A 2 x 2, column major matrix -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Matrix2 { pub x: Vector2, pub y: Vector2 } /// A 3 x 3, column major matrix -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Matrix3 { pub x: Vector3, pub y: Vector3, pub z: Vector3 } /// A 4 x 4, column major matrix -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Matrix4 { pub x: Vector4, pub y: Vector4, pub z: Vector4, pub w: Vector4 } @@ -1375,7 +1378,7 @@ impl ToQuaternion for Matrix3 { } } -impl fmt::Show for Matrix2 { +impl fmt::Debug for Matrix2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[[{:?}, {:?}], [{:?}, {:?}]]", self[0][0], self[0][1], @@ -1383,7 +1386,7 @@ impl fmt::Show for Matrix2 { } } -impl fmt::Show for Matrix3 { +impl fmt::Debug for Matrix3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[[{:?}, {:?}, {:?}], [{:?}, {:?}, {:?}], [{:?}, {:?}, {:?}]]", self[0][0], self[0][1], self[0][2], @@ -1392,7 +1395,7 @@ impl fmt::Show for Matrix3 { } } -impl fmt::Show for Matrix4 { +impl fmt::Debug for Matrix4 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[[{:?}, {:?}, {:?}, {:?}], [{:?}, {:?}, {:?}, {:?}], [{:?}, {:?}, {:?}, {:?}], [{:?}, {:?}, {:?}, {:?}]]", self[0][0], self[0][1], self[0][2], self[0][3], diff --git a/src/plane.rs b/src/plane.rs index 5d4d739..ada76f4 100644 --- a/src/plane.rs +++ b/src/plane.rs @@ -129,7 +129,7 @@ ApproxEq for Plane { } } -impl fmt::Show for Plane { +impl fmt::Debug for Plane { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}x + {:?}y + {:?}z - {:?} = 0", self.n.x, self.n.y, self.n.z, self.d) diff --git a/src/point.rs b/src/point.rs index c5c2485..bd82adb 100644 --- a/src/point.rs +++ b/src/point.rs @@ -428,13 +428,13 @@ impl ApproxEq for Point3 { } } -impl fmt::Show for Point2 { +impl fmt::Debug for Point2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?}, {:?}]", self.x, self.y) } } -impl fmt::Show for Point3 { +impl fmt::Debug for Point3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?}, {:?}, {:?}]", self.x, self.y, self.z) } diff --git a/src/quaternion.rs b/src/quaternion.rs index 16420f7..3267a66 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -30,7 +30,8 @@ use vector::{Vector3, Vector, EuclideanVector}; /// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector /// form. -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Quaternion { pub s: S, pub v: Vector3 } /// Represents types which can be expressed as a quaternion. @@ -368,7 +369,7 @@ impl Neg for Quaternion { } } -impl fmt::Show for Quaternion { +impl fmt::Debug for Quaternion { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?} + {:?}i + {:?}j + {:?}k", self.s, diff --git a/src/transform.rs b/src/transform.rs index d76dc03..6611aea 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -151,7 +151,7 @@ impl> ToMatrix4 for Decomposed> Transform3 for Decomposed,R> where S: 'static {} -impl> fmt::Show for Decomposed,R> { +impl> fmt::Debug for Decomposed,R> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "(scale({:?}), rot({:?}), disp{:?})", self.scale, self.rot, self.disp) diff --git a/src/vector.rs b/src/vector.rs index b2b5ac8..e003c87 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -178,7 +178,8 @@ pub trait Vector: Array1 + Zero + One + Neg { // Utility macro for generating associated functions for the vectors macro_rules! vec( ($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr, $constructor:ident) => ( - #[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable, Rand)] + #[derive_Rand] + #[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)] pub struct $Self { $(pub $field: S),+ } impl<$S> $Self<$S> { @@ -557,19 +558,19 @@ impl EuclideanVector for Vector4 { } } -impl fmt::Show for Vector2 { +impl fmt::Debug for Vector2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?}, {:?}]", self.x, self.y) } } -impl fmt::Show for Vector3 { +impl fmt::Debug for Vector3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?}, {:?}, {:?}]", self.x, self.y, self.z) } } -impl fmt::Show for Vector4 { +impl fmt::Debug for Vector4 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?}, {:?}, {:?}, {:?}]", self.x, self.y, self.z, self.w) } diff --git a/tests/aabb.rs b/tests/aabb.rs index f2386cf..3bc0870 100644 --- a/tests/aabb.rs +++ b/tests/aabb.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - - extern crate cgmath; use cgmath::{Aabb, Aabb2, Aabb3}; @@ -24,46 +22,46 @@ use cgmath::{Ray, Intersect}; #[test] fn test_aabb() { - let aabb = Aabb2::new(Point2::new(-20i, 30i), Point2::new(10i, -10i)); - assert_eq!(aabb.min(), &Point2::new(-20i, -10i)); - assert_eq!(aabb.max(), &Point2::new(10i, 30i)); - assert_eq!(aabb.dim(), Vector2::new(30i, 40i)); - assert_eq!(aabb.volume(), 30i * 40i); - assert_eq!(aabb.center(), Point2::new(-5i, 10i)); + let aabb = Aabb2::new(Point2::new(-20is, 30is), Point2::new(10is, -10is)); + assert_eq!(aabb.min(), &Point2::new(-20is, -10is)); + assert_eq!(aabb.max(), &Point2::new(10is, 30is)); + assert_eq!(aabb.dim(), Vector2::new(30is, 40is)); + assert_eq!(aabb.volume(), 30is * 40is); + assert_eq!(aabb.center(), Point2::new(-5is, 10is)); - assert!(aabb.contains(&Point2::new(0i, 0i))); - assert!(!aabb.contains(&Point2::new(-50i, -50i))); - assert!(!aabb.contains(&Point2::new(50i, 50i))); + assert!(aabb.contains(&Point2::new(0is, 0is))); + assert!(!aabb.contains(&Point2::new(-50is, -50is))); + assert!(!aabb.contains(&Point2::new(50is, 50is))); - assert_eq!(aabb.grow(&Point2::new(0i, 0i)), aabb); - assert_eq!(aabb.grow(&Point2::new(100i, 100i)), - Aabb2::new(Point2::new(-20i, -10i), Point2::new(100i, 100i))); - assert_eq!(aabb.grow(&Point2::new(-100i, -100i)), - Aabb2::new(Point2::new(-100i, -100i), Point2::new(10i, 30i))); + assert_eq!(aabb.grow(&Point2::new(0is, 0is)), aabb); + assert_eq!(aabb.grow(&Point2::new(100is, 100is)), + Aabb2::new(Point2::new(-20is, -10is), Point2::new(100is, 100is))); + assert_eq!(aabb.grow(&Point2::new(-100is, -100is)), + Aabb2::new(Point2::new(-100is, -100is), Point2::new(10is, 30is))); - let aabb = Aabb3::new(Point3::new(-20i, 30i, 5i), Point3::new(10i, -10i, -5i)); - assert_eq!(aabb.min(), &Point3::new(-20i, -10i, -5i)); - assert_eq!(aabb.max(), &Point3::new(10i, 30i, 5i)); - assert_eq!(aabb.dim(), Vector3::new(30i, 40i, 10i)); - assert_eq!(aabb.volume(), 30i * 40i * 10i); - assert_eq!(aabb.center(), Point3::new(-5i, 10i, 0i)); + let aabb = Aabb3::new(Point3::new(-20is, 30is, 5is), Point3::new(10is, -10is, -5is)); + assert_eq!(aabb.min(), &Point3::new(-20is, -10is, -5is)); + assert_eq!(aabb.max(), &Point3::new(10is, 30is, 5is)); + assert_eq!(aabb.dim(), Vector3::new(30is, 40is, 10is)); + assert_eq!(aabb.volume(), 30is * 40is * 10is); + assert_eq!(aabb.center(), Point3::new(-5is, 10is, 0is)); - assert!(aabb.contains(&Point3::new(0i, 0i, 0i))); - assert!(!aabb.contains(&Point3::new(-100i, 0i, 0i))); - assert!(!aabb.contains(&Point3::new(100i, 0i, 0i))); - assert!(aabb.contains(&Point3::new(9i, 29i, -1i))); - assert!(!aabb.contains(&Point3::new(10i, 30i, 5i))); - assert!(aabb.contains(&Point3::new(-20i, -10i, -5i))); - assert!(!aabb.contains(&Point3::new(-21i, -11i, -6i))); + assert!(aabb.contains(&Point3::new(0is, 0is, 0is))); + assert!(!aabb.contains(&Point3::new(-100is, 0is, 0is))); + assert!(!aabb.contains(&Point3::new(100is, 0is, 0is))); + assert!(aabb.contains(&Point3::new(9is, 29is, -1is))); + assert!(!aabb.contains(&Point3::new(10is, 30is, 5is))); + assert!(aabb.contains(&Point3::new(-20is, -10is, -5is))); + assert!(!aabb.contains(&Point3::new(-21is, -11is, -6is))); - assert_eq!(aabb.add_v(&Vector3::new(1i, 2i, 3i)), - Aabb3::new(Point3::new(-19i, 32i, 8i), Point3::new(11i, -8i, -2i))); + assert_eq!(aabb.add_v(&Vector3::new(1is, 2is, 3is)), + Aabb3::new(Point3::new(-19is, 32is, 8is), Point3::new(11is, -8is, -2is))); - assert_eq!(aabb.mul_s(2i), - Aabb3::new(Point3::new(-40i, -20i, -10i), Point3::new(20i, 60i, 10i))); + assert_eq!(aabb.mul_s(2is), + Aabb3::new(Point3::new(-40is, -20is, -10is), Point3::new(20is, 60is, 10is))); - assert_eq!(aabb.mul_v(&Vector3::new(1i, 2i, 3i)), - Aabb3::new(Point3::new(-20i, -20i, -15i), Point3::new(10i, 60i, 15i))); + assert_eq!(aabb.mul_v(&Vector3::new(1is, 2is, 3is)), + Aabb3::new(Point3::new(-20is, -20is, -15is), Point3::new(10is, 60is, 15is))); } #[test] diff --git a/tests/angle.rs b/tests/angle.rs index b07e9bf..8e2b028 100644 --- a/tests/angle.rs +++ b/tests/angle.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - - extern crate cgmath; use cgmath::{Angle, Rad, Deg, rad, deg}; diff --git a/tests/approx.rs b/tests/approx.rs index c4964f7..c5194cc 100644 --- a/tests/approx.rs +++ b/tests/approx.rs @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - #[macro_use] extern crate cgmath; diff --git a/tests/line.rs b/tests/line.rs index 8f9611d..280b38a 100644 --- a/tests/line.rs +++ b/tests/line.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/matrix.rs b/tests/matrix.rs index 163de3d..5e698cb 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(core)] extern crate cgmath; diff --git a/tests/plane.rs b/tests/plane.rs index 11861a2..48ab8b8 100644 --- a/tests/plane.rs +++ b/tests/plane.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/point.rs b/tests/point.rs index 6247eae..93f8047 100644 --- a/tests/point.rs +++ b/tests/point.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::Point3; diff --git a/tests/quaternion.rs b/tests/quaternion.rs index 6440ed1..b0bb90b 100644 --- a/tests/quaternion.rs +++ b/tests/quaternion.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::{ToMatrix4, ToMatrix3}; diff --git a/tests/sphere.rs b/tests/sphere.rs index c12e611..b54ab83 100644 --- a/tests/sphere.rs +++ b/tests/sphere.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/transform.rs b/tests/transform.rs index fb0d85c..25d68f9 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/vector.rs b/tests/vector.rs index 9c5a36c..848e963 100644 --- a/tests/vector.rs +++ b/tests/vector.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(core)] + #[macro_use] extern crate cgmath; @@ -29,23 +31,23 @@ fn test_constructor() { #[test] fn test_from_value() { - assert_eq!(Vector2::from_value(102i), Vector2::new(102i, 102i)); - assert_eq!(Vector3::from_value(22i), Vector3::new(22i, 22i, 22i)); + assert_eq!(Vector2::from_value(102is), Vector2::new(102is, 102is)); + assert_eq!(Vector3::from_value(22is), Vector3::new(22is, 22is, 22is)); assert_eq!(Vector4::from_value(76.5f64), Vector4::new(76.5f64, 76.5f64, 76.5f64, 76.5f64)); } #[test] fn test_dot() { - assert_eq!(Vector2::new(1i, 2i).dot(&Vector2::new(3i, 4i)), 11i); - assert_eq!(Vector3::new(1i, 2i, 3i).dot(&Vector3::new(4i, 5i, 6i)), 32i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).dot(&Vector4::new(5i, 6i, 7i, 8i)), 70i); + assert_eq!(Vector2::new(1is, 2is).dot(&Vector2::new(3is, 4is)), 11is); + assert_eq!(Vector3::new(1is, 2is, 3is).dot(&Vector3::new(4is, 5is, 6is)), 32is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).dot(&Vector4::new(5is, 6is, 7is, 8is)), 70is); } #[test] fn test_comp_add() { - assert_eq!(Vector2::new(1i, 2i).comp_add(), 3i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_add(), 6i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_add(), 10i); + assert_eq!(Vector2::new(1is, 2is).comp_add(), 3is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_add(), 6is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_add(), 10is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_add(), 7.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_add(), 15.0f64); @@ -54,9 +56,9 @@ fn test_comp_add() { #[test] fn test_comp_mul() { - assert_eq!(Vector2::new(1i, 2i).comp_mul(), 2i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_mul(), 6i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_mul(), 24i); + assert_eq!(Vector2::new(1is, 2is).comp_mul(), 2is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_mul(), 6is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_mul(), 24is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_mul(), 12.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_mul(), 120.0f64); @@ -65,9 +67,9 @@ fn test_comp_mul() { #[test] fn test_comp_min() { - assert_eq!(Vector2::new(1i, 2i).comp_min(), 1i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_min(), 1i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_min(), 1i); + assert_eq!(Vector2::new(1is, 2is).comp_min(), 1is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_min(), 1is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_min(), 1is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_min(), 3.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_min(), 4.0f64); @@ -76,9 +78,9 @@ fn test_comp_min() { #[test] fn test_comp_max() { - assert_eq!(Vector2::new(1i, 2i).comp_max(), 2i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_max(), 3i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_max(), 4i); + assert_eq!(Vector2::new(1is, 2is).comp_max(), 2is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_max(), 3is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_max(), 4is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_max(), 4.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_max(), 6.0f64); @@ -87,9 +89,9 @@ fn test_comp_max() { #[test] fn test_cross() { - let a = Vector3::new(1i, 2i, 3i); - let b = Vector3::new(4i, 5i, 6i); - let r = Vector3::new(-3i, 6i, -3i); + let a = Vector3::new(1is, 2is, 3is); + let b = Vector3::new(4is, 5is, 6is); + let r = Vector3::new(-3is, 6is, -3is); assert_eq!(a.cross(&b), r); let mut a = a; @@ -110,8 +112,8 @@ mod test_length { #[test] fn test_vector2(){ - let (a, a_res) = (Vector2::new(3.0f64, 4.0f64), 5.0f64); // (3i, 4i, 5i) Pythagorean triple - let (b, b_res) = (Vector2::new(5.0f64, 12.0f64), 13.0f64); // (5i, 12i, 13i) Pythagorean triple + let (a, a_res) = (Vector2::new(3.0f64, 4.0f64), 5.0f64); // (3is, 4is, 5is) Pythagorean triple + let (b, b_res) = (Vector2::new(5.0f64, 12.0f64), 13.0f64); // (5is, 12is, 13is) Pythagorean triple assert_eq!(a.length2(), a_res * a_res); assert_eq!(b.length2(), b_res * b_res); @@ -122,8 +124,8 @@ mod test_length { #[test] fn test_vector3(){ - let (a, a_res) = (Vector3::new(2.0f64, 3.0f64, 6.0f64), 7.0f64); // (2i, 3i, 6i, 7i) Pythagorean quadruple - let (b, b_res) = (Vector3::new(1.0f64, 4.0f64, 8.0f64), 9.0f64); // (1i, 4i, 8i, 9i) Pythagorean quadruple + let (a, a_res) = (Vector3::new(2.0f64, 3.0f64, 6.0f64), 7.0f64); // (2is, 3is, 6is, 7is) Pythagorean quadruple + let (b, b_res) = (Vector3::new(1.0f64, 4.0f64, 8.0f64), 9.0f64); // (1is, 4is, 8is, 9is) Pythagorean quadruple assert_eq!(a.length2(), a_res * a_res); assert_eq!(b.length2(), b_res * b_res); @@ -134,8 +136,8 @@ mod test_length { #[test] fn test_vector4(){ - let (a, a_res) = (Vector4::new(1.0f64, 2.0f64, 4.0f64, 10.0f64), 11.0f64); // (1i, 2i, 4i, 10i, 11i) Pythagorean quintuple - let (b, b_res) = (Vector4::new(1.0f64, 2.0f64, 8.0f64, 10.0f64), 13.0f64); // (1i, 2i, 8i, 10i, 13i) Pythagorean quintuple + let (a, a_res) = (Vector4::new(1.0f64, 2.0f64, 4.0f64, 10.0f64), 11.0f64); // (1is, 2is, 4is, 10is, 11is) Pythagorean quintuple + let (b, b_res) = (Vector4::new(1.0f64, 2.0f64, 8.0f64, 10.0f64), 13.0f64); // (1is, 2is, 8is, 10is, 13is) Pythagorean quintuple assert_eq!(a.length2(), a_res * a_res); assert_eq!(b.length2(), b_res * b_res);