diff --git a/bench/matrix.rs b/bench/matrix.rs index fd1d59b..f167a12 100644 --- a/bench/matrix.rs +++ b/bench/matrix.rs @@ -13,14 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use cgmath::matrix::*; -use cgmath::vector::*; +use cgmath::*; use test::Bencher; pub mod matrix2 { - use cgmath::matrix::*; - use cgmath::vector::*; + use cgmath::*; pub static A: Matrix2 = Matrix2 { x: Vector2 { x: 1.0, y: 3.0 }, y: Vector2 { x: 2.0, y: 4.0 } }; @@ -29,8 +27,7 @@ pub mod matrix2 { } pub mod matrix3 { - use cgmath::matrix::*; - use cgmath::vector::*; + use cgmath::*; pub static A: Matrix3 = Matrix3 { x: Vector3 { x: 1.0, y: 4.0, z: 7.0 }, y: Vector3 { x: 2.0, y: 5.0, z: 8.0 }, @@ -41,8 +38,7 @@ pub mod matrix3 { } pub mod matrix4 { - use cgmath::matrix::*; - use cgmath::vector::*; + use cgmath::*; pub static A: Matrix4 = Matrix4 { x: Vector4 { x: 1.0, y: 5.0, z: 9.0, w: 13.0 }, y: Vector4 { x: 2.0, y: 6.0, z: 10.0, w: 14.0 }, diff --git a/src/array.rs b/src/array.rs index 821cdc4..87ff916 100644 --- a/src/array.rs +++ b/src/array.rs @@ -28,13 +28,6 @@ pub trait Array1: Index + IndexMut &mut (*self)[0] } - #[deprecated = "Use `Array1::swap_elems` instead"] - #[inline] - /// Swap the elements at indices `i` and `j` in-place. - fn swap_i(&mut self, i: uint, j: uint) { - self.swap_i(i, j) - } - /// Swap the elements at indices `i` and `j` in-place. #[inline] fn swap_elems(&mut self, i: uint, j: uint) { @@ -42,13 +35,6 @@ pub trait Array1: Index + IndexMut unsafe { ptr::swap(&mut (*self)[i], &mut (*self)[j]) }; } - /// Replace an element in the array. - #[deprecated = "Use `Array1::replace_elem` instead"] - #[inline] - fn replace_i(&mut self, i: uint, src: Element) -> Element { - self.replace_i(i, src) - } - /// Replace an element in the array. #[inline] fn replace_elem(&mut self, i: uint, src: Element) -> Element { @@ -72,58 +58,24 @@ pub trait Array2, Row: Array1, Element: Copy>: &mut (*self)[0][0] } - /// Swap two columns of this array. - #[deprecated = "Use `Array2::swap_cols` instead"] - #[inline] - fn swap_c(&mut self, a: uint, b: uint) { - self.swap_cols(a, b) - } - /// Swap two columns of this array. #[inline] fn swap_cols(&mut self, a: uint, b: uint) { unsafe { ptr::swap(&mut (*self)[a], &mut (*self)[b]) }; } - /// Replace a column in the array. - #[deprecated = "Use `Array2::replace_col` instead"] - #[inline] - fn replace_c(&mut self, c: uint, src: Column) -> Column { - self.replace_col(c, src) - } - /// Replace a column in the array. #[inline] fn replace_col(&mut self, c: uint, src: Column) -> Column { mem::replace(&mut (*self)[c], src) } - /// Get a row from this array by-value. - #[deprecated = "Use `Array2::row` instead"] - #[inline] - fn r(&self, r: uint) -> Row { - self.row(r) - } - /// Get a row from this array by-value. fn row(&self, r: uint) -> Row; - #[deprecated = "Use `Array2::swap_rows` instead"] - #[inline] - fn swap_r(&mut self, a: uint, b: uint) { - self.swap_rows(a, b) - } - /// Swap two rows of this array. fn swap_rows(&mut self, a: uint, b: uint); - /// Swap the values at index `a` and `b` - #[deprecated = "Use `Array2::swap_elems` instead"] - #[inline] - fn swap_cr(&mut self, a: (uint, uint), b: (uint, uint)) { - self.swap_elems(a, b) - } - /// Swap the values at index `a` and `b` #[inline] fn swap_elems(&mut self, a: (uint, uint), b: (uint, uint)) { diff --git a/src/cgmath.rs b/src/cgmath.rs index 9da848f..eeac906 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -35,28 +35,72 @@ //! `look_at`, `from_angle`, `from_euler`, and `from_axis_angle` methods. //! These are provided for convenience. -pub mod array; +// Re-exports -pub mod matrix; -pub mod quaternion; -pub mod vector; +pub use array::{Array1, Array2, FixedArray}; -pub mod angle; -pub mod plane; -pub mod point; -pub mod line; -pub mod ray; -pub mod rotation; -pub mod transform; +pub use matrix::Matrix; +pub use matrix::{Matrix2, Matrix3, Matrix4}; +pub use matrix::{ToMatrix2, ToMatrix3, ToMatrix4}; +pub use quaternion::{Quaternion, ToQuaternion}; +pub use vector::{Vector, EuclideanVector}; +pub use vector::{Vector2, Vector3, Vector4}; +pub use vector::dot; -pub mod projection; +pub use angle::{rad, deg}; +pub use angle::{Angle, Rad, Deg}; +pub use angle::{ToRad, ToDeg}; +pub use angle::bisect; +pub use angle::{sin, cos, tan, sin_cos}; +pub use angle::{cot, sec, csc}; +pub use angle::{acos, asin, atan, atan2}; +pub use plane::Plane; +pub use point::{Point, Point2, Point3}; +pub use line::{Line, Line2, Line3}; +pub use ray::{Ray, Ray2, Ray3}; +pub use rotation::{Rotation, Rotation2, Rotation3}; +pub use rotation::{Basis3, Basis2}; +pub use rotation::{ToBasis2, ToBasis3}; +pub use transform::{Transform, Transform3}; +pub use transform::{Decomposed, AffineMatrix3}; -pub mod aabb; -pub mod cylinder; -pub mod frustum; -pub mod intersect; -pub mod obb; -pub mod sphere; +pub use projection::{perspective, frustum, ortho}; +pub use projection::{Projection, PerspectiveFov, Perspective, Ortho}; -pub mod approx; -pub mod num; +pub use aabb::{Aabb, Aabb2, Aabb3, Aabb3}; +pub use cylinder::Cylinder; +pub use frustum::{Frustum, FrustumPoints}; +pub use intersect::Intersect; +pub use obb::{Obb2, Obb3}; +pub use sphere::Sphere; + +pub use approx::ApproxEq; +pub use num::{PartialOrd, BaseNum, BaseInt, BaseFloat}; + +// Modules + +mod array; + +mod matrix; +mod quaternion; +mod vector; + +mod angle; +mod plane; +mod point; +mod line; +mod ray; +mod rotation; +mod transform; + +mod projection; + +mod aabb; +mod cylinder; +mod frustum; +mod intersect; +mod obb; +mod sphere; + +mod approx; +mod num; diff --git a/src/num.rs b/src/num.rs index 4527f6b..65b4562 100644 --- a/src/num.rs +++ b/src/num.rs @@ -18,9 +18,7 @@ use approx::ApproxEq; use std::cmp; use std::fmt; -/// A trait providing a [partial ordering][po] -/// -/// [po]: http://mathworld.wolfram.com/PartialOrder.html +/// A trait providing a [partial ordering](http://mathworld.wolfram.com/PartialOrder.html). pub trait PartialOrd { fn partial_min(self, other: Self) -> Self; fn partial_max(self, other: Self) -> Self; diff --git a/src/rotation.rs b/src/rotation.rs index 7b8b5ee..3d58b5c 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -127,17 +127,17 @@ pub trait Rotation3: Rotation, Point3> /// to a subset of those implemented on `Matrix2`. /// /// ## Example -/// +/// /// Suppose we want to rotate a vector that lies in the x-y plane by some /// angle. We can accomplish this quite easily with a two-dimensional rotation /// matrix: /// /// ```rust -/// use cgmath::angle::rad; -/// use cgmath::vector::Vector2; -/// use cgmath::matrix::{Matrix, ToMatrix2}; -/// use cgmath::rotation::{Rotation, Rotation2, Basis2}; -/// use cgmath::approx::ApproxEq; +/// use cgmath::rad; +/// use cgmath::Vector2; +/// use cgmath::{Matrix, ToMatrix2}; +/// use cgmath::{Rotation, Rotation2, Basis2}; +/// use cgmath::ApproxEq; /// /// // For simplicity, we will rotate the unit x vector to the unit y vector -- /// // so the angle is 90 degrees, or π/2. diff --git a/src/vector.rs b/src/vector.rs index 5834462..80e0d5e 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -22,7 +22,7 @@ //! vector are also provided: //! //! ```rust -//! use cgmath::vector::{Vector2, Vector3, Vector4}; +//! use cgmath::{Vector2, Vector3, Vector4}; //! //! assert_eq!(Vector2::new(1.0f64, 0.0f64), Vector2::unit_x()); //! assert_eq!(Vector3::new(0.0f64, 0.0f64, 0.0f64), Vector3::zero()); @@ -37,7 +37,7 @@ //! //! ```rust //! use std::num::{Zero, One}; -//! use cgmath::vector::{Vector2, Vector3, Vector4}; +//! use cgmath::{Vector2, Vector3, Vector4}; //! //! let a: Vector2 = Vector2::new(3.0, 4.0); //! let b: Vector2 = Vector2::new(-3.0, -4.0); @@ -67,7 +67,7 @@ //! //! ```rust //! use std::num::Zero; -//! use cgmath::vector::{Vector, Vector2, Vector3, Vector4, dot}; +//! use cgmath::{Vector, Vector2, Vector3, Vector4, dot}; //! //! // All vectors implement the dot product as a method: //! let a: Vector2 = Vector2::new(3.0, 6.0); diff --git a/tests/aabb.rs b/tests/aabb.rs index 1b61100..228d111 100644 --- a/tests/aabb.rs +++ b/tests/aabb.rs @@ -17,11 +17,10 @@ extern crate cgmath; -use cgmath::aabb::*; -use cgmath::point::{Point2, Point3}; -use cgmath::vector::{Vector2, Vector3}; -use cgmath::ray::{Ray}; -use cgmath::intersect::Intersect; +use cgmath::{Aabb, Aabb2, Aabb3}; +use cgmath::{Point2, Point3}; +use cgmath::{Vector2, Vector3}; +use cgmath::{Ray, Intersect}; #[test] fn test_aabb() { diff --git a/tests/angle.rs b/tests/angle.rs index 0782d27..a567081 100644 --- a/tests/angle.rs +++ b/tests/angle.rs @@ -17,16 +17,17 @@ extern crate cgmath; -use cgmath::angle::*; -use cgmath::approx::ApproxEq; +use cgmath::{Angle, Rad, Deg, rad, deg}; +use cgmath::{ToRad, ToDeg}; +use cgmath::ApproxEq; #[test] fn conv() { - assert!(deg(-5.0f64).to_rad().to_deg().approx_eq( °(-5.0f64) )); - assert!(deg(30.0f64).to_rad().to_deg().approx_eq( °(30.0f64) )); + assert!(deg(-5.0f64).to_rad().to_deg().approx_eq(°(-5.0f64))); + assert!(deg(30.0f64).to_rad().to_deg().approx_eq(°(30.0f64))); - assert!(rad(-5.0f64).to_deg().to_rad().approx_eq( &rad(-5.0f64) )); - assert!(rad(30.0f64).to_deg().to_rad().approx_eq( &rad(30.0f64) )); + assert!(rad(-5.0f64).to_deg().to_rad().approx_eq(&rad(-5.0f64))); + assert!(rad(30.0f64).to_deg().to_rad().approx_eq(&rad(30.0f64))); } #[test] diff --git a/tests/line.rs b/tests/line.rs index 3ada281..ff22dbb 100644 --- a/tests/line.rs +++ b/tests/line.rs @@ -17,11 +17,7 @@ extern crate cgmath; -use cgmath::line::*; -use cgmath::point::*; -use cgmath::ray::*; -use cgmath::vector::*; -use cgmath::intersect::Intersect; +use cgmath::*; #[test] fn test_line_intersection() { diff --git a/tests/matrix.rs b/tests/matrix.rs index ada78fc..2e443bb 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -17,14 +17,10 @@ extern crate cgmath; -use cgmath::matrix::*; -use cgmath::vector::*; -use cgmath::angle::rad; -use cgmath::approx::ApproxEq; +use cgmath::*; pub mod matrix2 { - use cgmath::matrix::*; - use cgmath::vector::*; + use cgmath::*; pub static A: Matrix2 = Matrix2 { x: Vector2 { x: 1.0f64, y: 3.0f64 }, y: Vector2 { x: 2.0f64, y: 4.0f64 } }; @@ -38,8 +34,7 @@ pub mod matrix2 { } pub mod matrix3 { - use cgmath::matrix::*; - use cgmath::vector::*; + use cgmath::*; pub static A: Matrix3 = Matrix3 { x: Vector3 { x: 1.0f64, y: 4.0f64, z: 7.0f64 }, y: Vector3 { x: 2.0f64, y: 5.0f64, z: 8.0f64 }, @@ -59,8 +54,7 @@ pub mod matrix3 { } pub mod matrix4 { - use cgmath::matrix::*; - use cgmath::vector::*; + use cgmath::*; pub static A: Matrix4 = Matrix4 { x: Vector4 { x: 1.0f64, y: 5.0f64, z: 9.0f64, w: 13.0f64 }, y: Vector4 { x: 2.0f64, y: 6.0f64, z: 10.0f64, w: 14.0f64 }, diff --git a/tests/plane.rs b/tests/plane.rs index 5e980e3..25492ea 100644 --- a/tests/plane.rs +++ b/tests/plane.rs @@ -17,11 +17,7 @@ extern crate cgmath; -use cgmath::plane::*; -use cgmath::point::*; -use cgmath::vector::*; -use cgmath::ray::*; -use cgmath::intersect::Intersect; +use cgmath::*; #[test] fn test_from_points() { diff --git a/tests/point.rs b/tests/point.rs index aef43b6..b779d67 100644 --- a/tests/point.rs +++ b/tests/point.rs @@ -17,8 +17,8 @@ extern crate cgmath; -use cgmath::point::*; -use cgmath::approx::ApproxEq; +use cgmath::Point3; +use cgmath::ApproxEq; #[test] fn test_homogeneous() { diff --git a/tests/quaternion.rs b/tests/quaternion.rs index cf665cc..2aad708 100644 --- a/tests/quaternion.rs +++ b/tests/quaternion.rs @@ -17,8 +17,8 @@ extern crate cgmath; -use cgmath::matrix::{ToMatrix4, ToMatrix3}; -use cgmath::quaternion::Quaternion; +use cgmath::{ToMatrix4, ToMatrix3}; +use cgmath::Quaternion; #[test] fn to_matrix4() diff --git a/tests/sphere.rs b/tests/sphere.rs index 6f2f001..2651423 100644 --- a/tests/sphere.rs +++ b/tests/sphere.rs @@ -17,12 +17,7 @@ extern crate cgmath; -use cgmath::sphere::*; -use cgmath::point::*; -use cgmath::vector::*; -use cgmath::ray::*; -use cgmath::approx::ApproxEq; -use cgmath::intersect::Intersect; +use cgmath::*; #[test] fn test_intersection() { diff --git a/tests/transform.rs b/tests/transform.rs index 00126e0..c6dabd2 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -17,11 +17,7 @@ extern crate cgmath; -use cgmath::quaternion::*; -use cgmath::transform::*; -use cgmath::point::*; -use cgmath::vector::*; -use cgmath::approx::ApproxEq; +use cgmath::*; #[test] fn test_invert() { diff --git a/tests/vector.rs b/tests/vector.rs index afc02f1..c541ced 100644 --- a/tests/vector.rs +++ b/tests/vector.rs @@ -17,10 +17,7 @@ extern crate cgmath; -use cgmath::angle::*; -use cgmath::array::*; -use cgmath::vector::*; -use cgmath::approx::ApproxEq; +use cgmath::*; #[test] fn test_from_value() { @@ -101,7 +98,7 @@ fn test_is_perpendicular() { #[cfg(test)] mod test_length { - use cgmath::vector::*; + use cgmath::*; #[test] fn test_vector2(){