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
// 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<f32> = 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<f32> = 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<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 },

View file

@ -28,13 +28,6 @@ pub trait Array1<Element: Copy>: Index<uint, Element> + IndexMut<uint, Element>
&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<Element: Copy>: Index<uint, Element> + IndexMut<uint, Element>
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<Column: Array1<Element>, Row: Array1<Element>, 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)) {

View file

@ -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;

View file

@ -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;

View file

@ -133,11 +133,11 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
/// 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.

View file

@ -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<f64> = Vector2::new(3.0, 4.0);
//! let b: Vector2<f64> = 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<f64> = Vector2::new(3.0, 6.0);

View file

@ -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() {

View file

@ -17,8 +17,9 @@
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() {

View file

@ -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() {

View file

@ -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<f64> = 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<f64> = 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<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 },

View file

@ -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() {

View file

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

View file

@ -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()

View file

@ -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() {

View file

@ -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() {

View file

@ -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(){