Fix imports
This commit is contained in:
parent
8818c9ffbf
commit
759baea596
10 changed files with 126 additions and 64 deletions
|
@ -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 {
|
||||
|
|
10
src/mat.rs
10
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
|
||||
|
|
20
src/mat2.rs
20
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<T:Copy Float> Mat2<T>: MutableMatrix<T, Vec2<T>> {
|
|||
|
||||
#[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<T:Copy Float> Mat2<T>: MutableMatrix<T, Vec2<T>> {
|
|||
|
||||
#[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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
src/mat3.rs
27
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<T:Copy Float> Mat3<T>: MutableMatrix<T, Vec3<T>> {
|
|||
|
||||
#[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<T:Copy Float> Mat3<T>: MutableMatrix<T, Vec3<T>> {
|
|||
|
||||
#[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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
39
src/mat4.rs
39
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<T:Copy Float> Mat4<T>: MutableMatrix<T, Vec4<T>> {
|
|||
|
||||
#[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<T:Copy Float> Mat4<T>: MutableMatrix<T, Vec4<T>> {
|
|||
|
||||
#[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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -351,6 +351,10 @@ pub impl<T:Copy Float> Quat<T> {
|
|||
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
|
||||
#[inline(always)]
|
||||
static pure fn look_at(dir: &Vec3<T>, up: &Vec3<T>) -> Quat<T> {
|
||||
|
|
13
src/vec.rs
13
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;
|
||||
|
||||
|
||||
/**
|
||||
|
|
24
src/vec2.rs
24
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<T:Copy> Vec2<T>: MutableVector<T> {
|
|||
|
||||
#[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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
25
src/vec3.rs
25
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<T:Copy> Vec3<T>: MutableVector<T> {
|
|||
|
||||
#[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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
22
src/vec4.rs
22
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<T:Copy> Vec4<T>: MutableVector<T> {
|
|||
|
||||
#[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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue