Fix imports

This commit is contained in:
Brendan Zabarauskas 2013-01-26 08:41:23 +11:00
parent 8818c9ffbf
commit 759baea596
10 changed files with 126 additions and 64 deletions

View file

@ -13,9 +13,15 @@ extern mod numeric;
pub mod gltypes; pub mod gltypes;
pub mod mat; pub mod mat;
pub mod mat2;
pub mod mat3;
pub mod mat4;
pub mod quat; pub mod quat;
pub mod rot; pub mod rot;
pub mod vec; pub mod vec;
pub mod vec2;
pub mod vec3;
pub mod vec4;
#[test] #[test]
mod test { mod test {

View file

@ -4,13 +4,9 @@ use numeric::types::angle::Angle;
use quat::Quat; use quat::Quat;
pub mod mat2; pub use mat2::Mat2;
pub mod mat3; pub use mat3::Mat3;
pub mod mat4; pub use mat4::Mat4;
pub use self::mat2::Mat2;
pub use self::mat3::Mat3;
pub use self::mat4::Mat4;
/** /**
* The base square matrix trait * The base square matrix trait

View file

@ -1,16 +1,24 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::Eq; use core::cmp::Eq;
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::funs::*; use numeric::funs::*;
use numeric::types::angle::Angle; use numeric::types::{Angle, Float};
use numeric::types::float::Float;
use numeric::types::number::Number::{one, zero}; use numeric::types::number::Number::{one, zero};
use vec::Vec2; use vec::Vec2;
use mat::{
Mat3,
Mat4,
Matrix,
MutableMatrix,
Matrix2,
};
/** /**
* A 2 x 2 column major matrix * A 2 x 2 column major matrix
* *
@ -270,7 +278,7 @@ pub impl<T:Copy Float> Mat2<T>: MutableMatrix<T, Vec2<T>> {
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
util::swap(self.col_mut(a), swap(self.col_mut(a),
self.col_mut(b)); self.col_mut(b));
} }
@ -323,8 +331,8 @@ pub impl<T:Copy Float> Mat2<T>: MutableMatrix<T, Vec2<T>> {
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
util::swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0));
util::swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1));
} }
} }

View file

@ -1,12 +1,12 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::Eq; use core::cmp::Eq;
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::funs::*; use numeric::funs::*;
use numeric::types::angle::Angle; use numeric::types::{Angle, Float};
use numeric::types::float::Float;
use numeric::types::number::Number; use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero}; use numeric::types::number::Number::{one, zero};
@ -14,6 +14,13 @@ use quat::Quat;
use rot::Rotation; use rot::Rotation;
use vec::Vec3; use vec::Vec3;
use mat::{
Mat4,
Matrix,
MutableMatrix,
Matrix3,
};
/** /**
* A 3 x 3 column major matrix * A 3 x 3 column major matrix
* *
@ -476,7 +483,7 @@ pub impl<T:Copy Float> Mat3<T>: MutableMatrix<T, Vec3<T>> {
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
util::swap(self.col_mut(a), swap(self.col_mut(a),
self.col_mut(b)); self.col_mut(b));
} }
@ -533,14 +540,14 @@ pub impl<T:Copy Float> Mat3<T>: MutableMatrix<T, Vec3<T>> {
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
util::swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0));
util::swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0)); swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0));
util::swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1));
util::swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1));
util::swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2));
util::swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2));
} }
} }

View file

@ -1,16 +1,23 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::Eq; use core::cmp::Eq;
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::funs::*; use numeric::funs::*;
use numeric::types::angle::Angle; use numeric::types::{Angle, Float};
use numeric::types::float::Float;
use numeric::types::number::Number::{one, zero}; use numeric::types::number::Number::{one, zero};
use vec::Vec4; use vec::Vec4;
use mat::{
Mat3,
Matrix,
MutableMatrix,
Matrix4,
};
/** /**
* A 4 x 4 column major matrix * A 4 x 4 column major matrix
* *
@ -402,7 +409,7 @@ pub impl<T:Copy Float> Mat4<T>: MutableMatrix<T, Vec4<T>> {
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
util::swap(self.col_mut(a), swap(self.col_mut(a),
self.col_mut(b)); self.col_mut(b));
} }
@ -463,21 +470,21 @@ pub impl<T:Copy Float> Mat4<T>: MutableMatrix<T, Vec4<T>> {
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
util::swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0));
util::swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0)); swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0));
util::swap(self.col_mut(0).index_mut(3), self.col_mut(3).index_mut(0)); swap(self.col_mut(0).index_mut(3), self.col_mut(3).index_mut(0));
util::swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1));
util::swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1));
util::swap(self.col_mut(1).index_mut(3), self.col_mut(3).index_mut(1)); swap(self.col_mut(1).index_mut(3), self.col_mut(3).index_mut(1));
util::swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2));
util::swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2));
util::swap(self.col_mut(2).index_mut(3), self.col_mut(3).index_mut(2)); swap(self.col_mut(2).index_mut(3), self.col_mut(3).index_mut(2));
util::swap(self.col_mut(3).index_mut(0), self.col_mut(0).index_mut(3)); swap(self.col_mut(3).index_mut(0), self.col_mut(0).index_mut(3));
util::swap(self.col_mut(3).index_mut(1), self.col_mut(1).index_mut(3)); swap(self.col_mut(3).index_mut(1), self.col_mut(1).index_mut(3));
util::swap(self.col_mut(3).index_mut(2), self.col_mut(2).index_mut(3)); swap(self.col_mut(3).index_mut(2), self.col_mut(2).index_mut(3));
} }
} }

View file

@ -351,6 +351,10 @@ pub impl<T:Copy Float> Quat<T> {
Mat3::from_axes(x, y, z).to_quat() Mat3::from_axes(x, y, z).to_quat()
} }
pure fn get_angle_axis<A:Angle<T>>(&self) -> (A, Vec3<T>) {
fail(~"Not yet implemented.")
}
// TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306 // TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306
#[inline(always)] #[inline(always)]
static pure fn look_at(dir: &Vec3<T>, up: &Vec3<T>) -> Quat<T> { static pure fn look_at(dir: &Vec3<T>, up: &Vec3<T>) -> Quat<T> {

View file

@ -2,16 +2,11 @@ use core::cmp::Eq;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::types::angle::Radians; use numeric::types::{Number, Radians};
use numeric::types::number::Number;
pub mod vec2; pub use vec2::Vec2;
pub mod vec3; pub use vec3::Vec3;
pub mod vec4; pub use vec4::Vec4;
pub use self::vec2::Vec2;
pub use self::vec3::Vec3;
pub use self::vec4::Vec4;
/** /**

View file

@ -1,15 +1,29 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::funs::*; use numeric::funs::*;
use numeric::types::angle::Radians; use numeric::types::{Float, Number, Radians};
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero}; use numeric::types::number::Number::{one, zero};
use vec::{
Vec3,
Vector,
MutableVector,
NumericVector,
NumericVector2,
MutableNumericVector,
ToHomogeneous,
EuclideanVector,
MutableEuclideanVector,
EquableVector,
OrdinalVector,
BooleanVector,
};
/** /**
* A 2-dimensional vector * A 2-dimensional vector
* *
@ -68,7 +82,7 @@ pub impl<T:Copy> Vec2<T>: MutableVector<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
util::swap(self.index_mut(a), swap(self.index_mut(a),
self.index_mut(b)); self.index_mut(b));
} }
} }

View file

@ -1,16 +1,29 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::funs::*; use numeric::funs::*;
use numeric::types::angle::Radians; use numeric::types::{Float, Number, Radians};
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero}; use numeric::types::number::Number::{one, zero};
use vec::Vec4; use vec::{
Vec4,
Vector,
MutableVector,
NumericVector,
NumericVector3,
MutableNumericVector,
MutableNumericVector3,
ToHomogeneous,
EuclideanVector,
MutableEuclideanVector,
EquableVector,
OrdinalVector,
BooleanVector,
};
/** /**
* A 3-dimensional vector * A 3-dimensional vector
@ -72,7 +85,7 @@ pub impl<T:Copy> Vec3<T>: MutableVector<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
util::swap(self.index_mut(a), swap(self.index_mut(a),
self.index_mut(b)); self.index_mut(b));
} }
} }

View file

@ -1,15 +1,27 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use numeric::funs::*; use numeric::funs::*;
use numeric::types::angle::Radians; use numeric::types::{Float, Number, Radians};
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero}; use numeric::types::number::Number::{one, zero};
use vec::{
Vector,
MutableVector,
NumericVector,
MutableNumericVector,
ToHomogeneous,
EuclideanVector,
MutableEuclideanVector,
EquableVector,
OrdinalVector,
BooleanVector,
};
/** /**
* A 4-dimensional vector * A 4-dimensional vector
* *
@ -72,7 +84,7 @@ pub impl<T:Copy> Vec4<T>: MutableVector<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
util::swap(self.index_mut(a), swap(self.index_mut(a),
self.index_mut(b)); self.index_mut(b));
} }
} }