From 759baea596fa25353efd78b65e0245bb2747795d Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sat, 26 Jan 2013 08:41:23 +1100 Subject: [PATCH] Fix imports --- src/lmath.rc | 6 ++++++ src/mat.rs | 10 +++------- src/mat2.rs | 20 ++++++++++++++------ src/mat3.rs | 27 +++++++++++++++++---------- src/mat4.rs | 39 +++++++++++++++++++++++---------------- src/quat.rs | 4 ++++ src/vec.rs | 13 ++++--------- src/vec2.rs | 24 +++++++++++++++++++----- src/vec3.rs | 25 +++++++++++++++++++------ src/vec4.rs | 22 +++++++++++++++++----- 10 files changed, 126 insertions(+), 64 deletions(-) diff --git a/src/lmath.rc b/src/lmath.rc index 6be693b..4c227bf 100644 --- a/src/lmath.rc +++ b/src/lmath.rc @@ -13,9 +13,15 @@ extern mod numeric; pub mod gltypes; pub mod mat; +pub mod mat2; +pub mod mat3; +pub mod mat4; pub mod quat; pub mod rot; pub mod vec; +pub mod vec2; +pub mod vec3; +pub mod vec4; #[test] mod test { diff --git a/src/mat.rs b/src/mat.rs index 6978204..861b1b5 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -4,13 +4,9 @@ use numeric::types::angle::Angle; use quat::Quat; -pub mod mat2; -pub mod mat3; -pub mod mat4; - -pub use self::mat2::Mat2; -pub use self::mat3::Mat3; -pub use self::mat4::Mat4; +pub use mat2::Mat2; +pub use mat3::Mat3; +pub use mat4::Mat4; /** * The base square matrix trait diff --git a/src/mat2.rs b/src/mat2.rs index be939f1..efa7879 100644 --- a/src/mat2.rs +++ b/src/mat2.rs @@ -1,16 +1,24 @@ use core::cast::transmute; use core::cmp::Eq; use core::ptr::to_unsafe_ptr; +use core::util::swap; use core::vec::raw::buf_as_slice; use std::cmp::FuzzyEq; use numeric::funs::*; -use numeric::types::angle::Angle; -use numeric::types::float::Float; +use numeric::types::{Angle, Float}; use numeric::types::number::Number::{one, zero}; use vec::Vec2; +use mat::{ + Mat3, + Mat4, + Matrix, + MutableMatrix, + Matrix2, +}; + /** * A 2 x 2 column major matrix * @@ -270,8 +278,8 @@ pub impl Mat2: MutableMatrix> { #[inline(always)] fn swap_cols(&mut self, a: uint, b: uint) { - util::swap(self.col_mut(a), - self.col_mut(b)); + swap(self.col_mut(a), + self.col_mut(b)); } #[inline(always)] @@ -323,8 +331,8 @@ pub impl Mat2: MutableMatrix> { #[inline(always)] fn transpose_self(&mut self) { - util::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(0).index_mut(1), self.col_mut(1).index_mut(0)); + swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); } } diff --git a/src/mat3.rs b/src/mat3.rs index 0fe4893..caed487 100644 --- a/src/mat3.rs +++ b/src/mat3.rs @@ -1,12 +1,12 @@ use core::cast::transmute; use core::cmp::Eq; use core::ptr::to_unsafe_ptr; +use core::util::swap; use core::vec::raw::buf_as_slice; use std::cmp::FuzzyEq; use numeric::funs::*; -use numeric::types::angle::Angle; -use numeric::types::float::Float; +use numeric::types::{Angle, Float}; use numeric::types::number::Number; use numeric::types::number::Number::{one, zero}; @@ -14,6 +14,13 @@ use quat::Quat; use rot::Rotation; use vec::Vec3; +use mat::{ + Mat4, + Matrix, + MutableMatrix, + Matrix3, +}; + /** * A 3 x 3 column major matrix * @@ -476,8 +483,8 @@ pub impl Mat3: MutableMatrix> { #[inline(always)] fn swap_cols(&mut self, a: uint, b: uint) { - util::swap(self.col_mut(a), - self.col_mut(b)); + swap(self.col_mut(a), + self.col_mut(b)); } #[inline(always)] @@ -533,14 +540,14 @@ pub impl Mat3: MutableMatrix> { #[inline(always)] fn transpose_self(&mut self) { - util::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(1), self.col_mut(1).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)); - util::swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); + swap(self.col_mut(1).index_mut(0), self.col_mut(0).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)); - util::swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); + swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); + swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); } } diff --git a/src/mat4.rs b/src/mat4.rs index 315e21a..670ac60 100644 --- a/src/mat4.rs +++ b/src/mat4.rs @@ -1,16 +1,23 @@ use core::cast::transmute; use core::cmp::Eq; use core::ptr::to_unsafe_ptr; +use core::util::swap; use core::vec::raw::buf_as_slice; use std::cmp::FuzzyEq; use numeric::funs::*; -use numeric::types::angle::Angle; -use numeric::types::float::Float; +use numeric::types::{Angle, Float}; use numeric::types::number::Number::{one, zero}; use vec::Vec4; +use mat::{ + Mat3, + Matrix, + MutableMatrix, + Matrix4, +}; + /** * A 4 x 4 column major matrix * @@ -402,8 +409,8 @@ pub impl Mat4: MutableMatrix> { #[inline(always)] fn swap_cols(&mut self, a: uint, b: uint) { - util::swap(self.col_mut(a), - self.col_mut(b)); + swap(self.col_mut(a), + self.col_mut(b)); } #[inline(always)] @@ -463,21 +470,21 @@ pub impl Mat4: MutableMatrix> { #[inline(always)] fn transpose_self(&mut self) { - util::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)); - util::swap(self.col_mut(0).index_mut(3), self.col_mut(3).index_mut(0)); + swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); + swap(self.col_mut(0).index_mut(2), self.col_mut(2).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)); - util::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(0), self.col_mut(0).index_mut(1)); + swap(self.col_mut(1).index_mut(2), self.col_mut(2).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)); - util::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(0), self.col_mut(0).index_mut(2)); + swap(self.col_mut(2).index_mut(1), self.col_mut(1).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)); - util::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(0), self.col_mut(0).index_mut(3)); + swap(self.col_mut(3).index_mut(1), self.col_mut(1).index_mut(3)); + swap(self.col_mut(3).index_mut(2), self.col_mut(2).index_mut(3)); } } diff --git a/src/quat.rs b/src/quat.rs index 549488d..97daf23 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -351,6 +351,10 @@ pub impl Quat { Mat3::from_axes(x, y, z).to_quat() } + pure fn get_angle_axis>(&self) -> (A, Vec3) { + fail(~"Not yet implemented.") + } + // TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306 #[inline(always)] static pure fn look_at(dir: &Vec3, up: &Vec3) -> Quat { diff --git a/src/vec.rs b/src/vec.rs index eda8157..fe64ac4 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -2,16 +2,11 @@ use core::cmp::Eq; use std::cmp::FuzzyEq; -use numeric::types::angle::Radians; -use numeric::types::number::Number; +use numeric::types::{Number, Radians}; -pub mod vec2; -pub mod vec3; -pub mod vec4; - -pub use self::vec2::Vec2; -pub use self::vec3::Vec3; -pub use self::vec4::Vec4; +pub use vec2::Vec2; +pub use vec3::Vec3; +pub use vec4::Vec4; /** diff --git a/src/vec2.rs b/src/vec2.rs index c5d0b4f..56b5111 100644 --- a/src/vec2.rs +++ b/src/vec2.rs @@ -1,15 +1,29 @@ use core::cast::transmute; use core::cmp::{Eq, Ord}; use core::ptr::to_unsafe_ptr; +use core::util::swap; use core::vec::raw::buf_as_slice; use std::cmp::FuzzyEq; use numeric::funs::*; -use numeric::types::angle::Radians; -use numeric::types::float::Float; -use numeric::types::number::Number; +use numeric::types::{Float, Number, Radians}; 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 * @@ -68,8 +82,8 @@ pub impl Vec2: MutableVector { #[inline(always)] fn swap(&mut self, a: uint, b: uint) { - util::swap(self.index_mut(a), - self.index_mut(b)); + swap(self.index_mut(a), + self.index_mut(b)); } } diff --git a/src/vec3.rs b/src/vec3.rs index 8aaad4e..e8df648 100644 --- a/src/vec3.rs +++ b/src/vec3.rs @@ -1,16 +1,29 @@ use core::cast::transmute; use core::cmp::{Eq, Ord}; use core::ptr::to_unsafe_ptr; +use core::util::swap; use core::vec::raw::buf_as_slice; use std::cmp::FuzzyEq; use numeric::funs::*; -use numeric::types::angle::Radians; -use numeric::types::float::Float; -use numeric::types::number::Number; +use numeric::types::{Float, Number, Radians}; 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 @@ -72,8 +85,8 @@ pub impl Vec3: MutableVector { #[inline(always)] fn swap(&mut self, a: uint, b: uint) { - util::swap(self.index_mut(a), - self.index_mut(b)); + swap(self.index_mut(a), + self.index_mut(b)); } } diff --git a/src/vec4.rs b/src/vec4.rs index 04941b1..09aa3a4 100644 --- a/src/vec4.rs +++ b/src/vec4.rs @@ -1,15 +1,27 @@ use core::cast::transmute; use core::cmp::{Eq, Ord}; use core::ptr::to_unsafe_ptr; +use core::util::swap; use core::vec::raw::buf_as_slice; use std::cmp::FuzzyEq; use numeric::funs::*; -use numeric::types::angle::Radians; -use numeric::types::float::Float; -use numeric::types::number::Number; +use numeric::types::{Float, Number, Radians}; use numeric::types::number::Number::{one, zero}; +use vec::{ + Vector, + MutableVector, + NumericVector, + MutableNumericVector, + ToHomogeneous, + EuclideanVector, + MutableEuclideanVector, + EquableVector, + OrdinalVector, + BooleanVector, +}; + /** * A 4-dimensional vector * @@ -72,8 +84,8 @@ pub impl Vec4: MutableVector { #[inline(always)] fn swap(&mut self, a: uint, b: uint) { - util::swap(self.index_mut(a), - self.index_mut(b)); + swap(self.index_mut(a), + self.index_mut(b)); } }