Merge pull request #115 from bjz/re-export

Publicly re-export everything from the root crate
This commit is contained in:
Corey Richardson 2014-08-16 01:14:39 -04:00
commit 62cbb44e1c
16 changed files with 103 additions and 139 deletions

View file

@ -13,14 +13,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
use test::Bencher; use test::Bencher;
pub mod matrix2 { pub mod matrix2 {
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
pub static A: Matrix2<f32> = Matrix2 { x: Vector2 { x: 1.0, y: 3.0 }, pub static A: Matrix2<f32> = Matrix2 { x: Vector2 { x: 1.0, y: 3.0 },
y: Vector2 { x: 2.0, y: 4.0 } }; y: Vector2 { x: 2.0, y: 4.0 } };
@ -29,8 +27,7 @@ pub mod matrix2 {
} }
pub mod matrix3 { pub mod matrix3 {
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
pub static A: Matrix3<f32> = Matrix3 { x: Vector3 { x: 1.0, y: 4.0, z: 7.0 }, pub static A: Matrix3<f32> = Matrix3 { x: Vector3 { x: 1.0, y: 4.0, z: 7.0 },
y: Vector3 { x: 2.0, y: 5.0, z: 8.0 }, y: Vector3 { x: 2.0, y: 5.0, z: 8.0 },
@ -41,8 +38,7 @@ pub mod matrix3 {
} }
pub mod matrix4 { pub mod matrix4 {
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
pub static A: Matrix4<f32> = Matrix4 { x: Vector4 { x: 1.0, y: 5.0, z: 9.0, w: 13.0 }, pub static A: Matrix4<f32> = 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 }, y: Vector4 { x: 2.0, y: 6.0, z: 10.0, w: 14.0 },

View file

@ -28,13 +28,6 @@ pub trait Array1<Element: Copy>: Index<uint, Element> + IndexMut<uint, Element>
&mut (*self)[0] &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. /// Swap the elements at indices `i` and `j` in-place.
#[inline] #[inline]
fn swap_elems(&mut self, i: uint, j: uint) { fn swap_elems(&mut self, i: uint, j: uint) {
@ -42,13 +35,6 @@ pub trait Array1<Element: Copy>: Index<uint, Element> + IndexMut<uint, Element>
unsafe { ptr::swap(&mut (*self)[i], &mut (*self)[j]) }; 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. /// Replace an element in the array.
#[inline] #[inline]
fn replace_elem(&mut self, i: uint, src: Element) -> Element { fn replace_elem(&mut self, i: uint, src: Element) -> Element {
@ -72,58 +58,24 @@ pub trait Array2<Column: Array1<Element>, Row: Array1<Element>, Element: Copy>:
&mut (*self)[0][0] &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. /// Swap two columns of this array.
#[inline] #[inline]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
unsafe { ptr::swap(&mut (*self)[a], &mut (*self)[b]) }; 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. /// Replace a column in the array.
#[inline] #[inline]
fn replace_col(&mut self, c: uint, src: Column) -> Column { fn replace_col(&mut self, c: uint, src: Column) -> Column {
mem::replace(&mut (*self)[c], src) 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. /// Get a row from this array by-value.
fn row(&self, r: uint) -> Row; 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. /// Swap two rows of this array.
fn swap_rows(&mut self, a: uint, b: uint); 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` /// Swap the values at index `a` and `b`
#[inline] #[inline]
fn swap_elems(&mut self, a: (uint, uint), b: (uint, uint)) { fn swap_elems(&mut self, a: (uint, uint), b: (uint, uint)) {

View file

@ -35,28 +35,72 @@
//! `look_at`, `from_angle`, `from_euler`, and `from_axis_angle` methods. //! `look_at`, `from_angle`, `from_euler`, and `from_axis_angle` methods.
//! These are provided for convenience. //! These are provided for convenience.
pub mod array; // Re-exports
pub mod matrix; pub use array::{Array1, Array2, FixedArray};
pub mod quaternion;
pub mod vector;
pub mod angle; pub use matrix::Matrix;
pub mod plane; pub use matrix::{Matrix2, Matrix3, Matrix4};
pub mod point; pub use matrix::{ToMatrix2, ToMatrix3, ToMatrix4};
pub mod line; pub use quaternion::{Quaternion, ToQuaternion};
pub mod ray; pub use vector::{Vector, EuclideanVector};
pub mod rotation; pub use vector::{Vector2, Vector3, Vector4};
pub mod transform; 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 use projection::{perspective, frustum, ortho};
pub mod cylinder; pub use projection::{Projection, PerspectiveFov, Perspective, Ortho};
pub mod frustum;
pub mod intersect;
pub mod obb;
pub mod sphere;
pub mod approx; pub use aabb::{Aabb, Aabb2, Aabb3, Aabb3};
pub mod num; 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;

View file

@ -18,9 +18,7 @@ use approx::ApproxEq;
use std::cmp; use std::cmp;
use std::fmt; use std::fmt;
/// A trait providing a [partial ordering][po] /// A trait providing a [partial ordering](http://mathworld.wolfram.com/PartialOrder.html).
///
/// [po]: http://mathworld.wolfram.com/PartialOrder.html
pub trait PartialOrd { pub trait PartialOrd {
fn partial_min(self, other: Self) -> Self; fn partial_min(self, other: Self) -> Self;
fn partial_max(self, other: Self) -> Self; fn partial_max(self, other: Self) -> Self;

View file

@ -127,17 +127,17 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
/// to a subset of those implemented on `Matrix2`. /// to a subset of those implemented on `Matrix2`.
/// ///
/// ## Example /// ## Example
/// ///
/// Suppose we want to rotate a vector that lies in the x-y plane by some /// 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 /// angle. We can accomplish this quite easily with a two-dimensional rotation
/// matrix: /// matrix:
/// ///
/// ```rust /// ```rust
/// use cgmath::angle::rad; /// use cgmath::rad;
/// use cgmath::vector::Vector2; /// use cgmath::Vector2;
/// use cgmath::matrix::{Matrix, ToMatrix2}; /// use cgmath::{Matrix, ToMatrix2};
/// use cgmath::rotation::{Rotation, Rotation2, Basis2}; /// use cgmath::{Rotation, Rotation2, Basis2};
/// use cgmath::approx::ApproxEq; /// use cgmath::ApproxEq;
/// ///
/// // 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.

View file

@ -22,7 +22,7 @@
//! vector are also provided: //! vector are also provided:
//! //!
//! ```rust //! ```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!(Vector2::new(1.0f64, 0.0f64), Vector2::unit_x());
//! assert_eq!(Vector3::new(0.0f64, 0.0f64, 0.0f64), Vector3::zero()); //! assert_eq!(Vector3::new(0.0f64, 0.0f64, 0.0f64), Vector3::zero());
@ -37,7 +37,7 @@
//! //!
//! ```rust //! ```rust
//! use std::num::{Zero, One}; //! use std::num::{Zero, One};
//! use cgmath::vector::{Vector2, Vector3, Vector4}; //! use cgmath::{Vector2, Vector3, Vector4};
//! //!
//! let a: Vector2<f64> = Vector2::new(3.0, 4.0); //! let a: Vector2<f64> = Vector2::new(3.0, 4.0);
//! let b: Vector2<f64> = Vector2::new(-3.0, -4.0); //! let b: Vector2<f64> = Vector2::new(-3.0, -4.0);
@ -67,7 +67,7 @@
//! //!
//! ```rust //! ```rust
//! use std::num::Zero; //! 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: //! // All vectors implement the dot product as a method:
//! let a: Vector2<f64> = Vector2::new(3.0, 6.0); //! let a: Vector2<f64> = Vector2::new(3.0, 6.0);

View file

@ -17,11 +17,10 @@
extern crate cgmath; extern crate cgmath;
use cgmath::aabb::*; use cgmath::{Aabb, Aabb2, Aabb3};
use cgmath::point::{Point2, Point3}; use cgmath::{Point2, Point3};
use cgmath::vector::{Vector2, Vector3}; use cgmath::{Vector2, Vector3};
use cgmath::ray::{Ray}; use cgmath::{Ray, Intersect};
use cgmath::intersect::Intersect;
#[test] #[test]
fn test_aabb() { fn test_aabb() {

View file

@ -17,16 +17,17 @@
extern crate cgmath; extern crate cgmath;
use cgmath::angle::*; use cgmath::{Angle, Rad, Deg, rad, deg};
use cgmath::approx::ApproxEq; use cgmath::{ToRad, ToDeg};
use cgmath::ApproxEq;
#[test] #[test]
fn conv() { fn conv() {
assert!(deg(-5.0f64).to_rad().to_deg().approx_eq( &deg(-5.0f64) )); assert!(deg(-5.0f64).to_rad().to_deg().approx_eq(&deg(-5.0f64)));
assert!(deg(30.0f64).to_rad().to_deg().approx_eq( &deg(30.0f64) )); assert!(deg(30.0f64).to_rad().to_deg().approx_eq(&deg(30.0f64)));
assert!(rad(-5.0f64).to_deg().to_rad().approx_eq( &rad(-5.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(30.0f64).to_deg().to_rad().approx_eq(&rad(30.0f64)));
} }
#[test] #[test]

View file

@ -17,11 +17,7 @@
extern crate cgmath; extern crate cgmath;
use cgmath::line::*; use cgmath::*;
use cgmath::point::*;
use cgmath::ray::*;
use cgmath::vector::*;
use cgmath::intersect::Intersect;
#[test] #[test]
fn test_line_intersection() { fn test_line_intersection() {

View file

@ -17,14 +17,10 @@
extern crate cgmath; extern crate cgmath;
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
use cgmath::angle::rad;
use cgmath::approx::ApproxEq;
pub mod matrix2 { pub mod matrix2 {
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
pub static A: Matrix2<f64> = Matrix2 { x: Vector2 { x: 1.0f64, y: 3.0f64 }, pub static A: Matrix2<f64> = Matrix2 { x: Vector2 { x: 1.0f64, y: 3.0f64 },
y: Vector2 { x: 2.0f64, y: 4.0f64 } }; y: Vector2 { x: 2.0f64, y: 4.0f64 } };
@ -38,8 +34,7 @@ pub mod matrix2 {
} }
pub mod matrix3 { pub mod matrix3 {
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
pub static A: Matrix3<f64> = Matrix3 { x: Vector3 { x: 1.0f64, y: 4.0f64, z: 7.0f64 }, pub static A: Matrix3<f64> = Matrix3 { x: Vector3 { x: 1.0f64, y: 4.0f64, z: 7.0f64 },
y: Vector3 { x: 2.0f64, y: 5.0f64, z: 8.0f64 }, y: Vector3 { x: 2.0f64, y: 5.0f64, z: 8.0f64 },
@ -59,8 +54,7 @@ pub mod matrix3 {
} }
pub mod matrix4 { pub mod matrix4 {
use cgmath::matrix::*; use cgmath::*;
use cgmath::vector::*;
pub static A: Matrix4<f64> = Matrix4 { x: Vector4 { x: 1.0f64, y: 5.0f64, z: 9.0f64, w: 13.0f64 }, pub static A: Matrix4<f64> = 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 }, y: Vector4 { x: 2.0f64, y: 6.0f64, z: 10.0f64, w: 14.0f64 },

View file

@ -17,11 +17,7 @@
extern crate cgmath; extern crate cgmath;
use cgmath::plane::*; use cgmath::*;
use cgmath::point::*;
use cgmath::vector::*;
use cgmath::ray::*;
use cgmath::intersect::Intersect;
#[test] #[test]
fn test_from_points() { fn test_from_points() {

View file

@ -17,8 +17,8 @@
extern crate cgmath; extern crate cgmath;
use cgmath::point::*; use cgmath::Point3;
use cgmath::approx::ApproxEq; use cgmath::ApproxEq;
#[test] #[test]
fn test_homogeneous() { fn test_homogeneous() {

View file

@ -17,8 +17,8 @@
extern crate cgmath; extern crate cgmath;
use cgmath::matrix::{ToMatrix4, ToMatrix3}; use cgmath::{ToMatrix4, ToMatrix3};
use cgmath::quaternion::Quaternion; use cgmath::Quaternion;
#[test] #[test]
fn to_matrix4() fn to_matrix4()

View file

@ -17,12 +17,7 @@
extern crate cgmath; extern crate cgmath;
use cgmath::sphere::*; use cgmath::*;
use cgmath::point::*;
use cgmath::vector::*;
use cgmath::ray::*;
use cgmath::approx::ApproxEq;
use cgmath::intersect::Intersect;
#[test] #[test]
fn test_intersection() { fn test_intersection() {

View file

@ -17,11 +17,7 @@
extern crate cgmath; extern crate cgmath;
use cgmath::quaternion::*; use cgmath::*;
use cgmath::transform::*;
use cgmath::point::*;
use cgmath::vector::*;
use cgmath::approx::ApproxEq;
#[test] #[test]
fn test_invert() { fn test_invert() {

View file

@ -17,10 +17,7 @@
extern crate cgmath; extern crate cgmath;
use cgmath::angle::*; use cgmath::*;
use cgmath::array::*;
use cgmath::vector::*;
use cgmath::approx::ApproxEq;
#[test] #[test]
fn test_from_value() { fn test_from_value() {
@ -101,7 +98,7 @@ fn test_is_perpendicular() {
#[cfg(test)] #[cfg(test)]
mod test_length { mod test_length {
use cgmath::vector::*; use cgmath::*;
#[test] #[test]
fn test_vector2(){ fn test_vector2(){