2013-07-24 22:50:40 +08:00
|
|
|
|
#[allow(missing_doc)]; // we allow missing to avoid having to document the mij components.
|
|
|
|
|
|
2013-07-22 16:26:20 +08:00
|
|
|
|
use std::cast;
|
|
|
|
|
use std::num::{One, Zero};
|
|
|
|
|
use std::cmp::ApproxEq;
|
|
|
|
|
use std::vec::{VecIterator, VecMutIterator};
|
2013-08-31 18:23:26 +08:00
|
|
|
|
use vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6, Outer};
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-08-31 23:17:18 +08:00
|
|
|
|
// traits
|
2013-09-13 16:26:19 +08:00
|
|
|
|
pub use traits::mat::Mat;
|
|
|
|
|
pub use traits::absolute::Absolute;
|
2013-08-31 23:14:41 +08:00
|
|
|
|
pub use traits::dim::Dim;
|
|
|
|
|
pub use traits::indexable::Indexable;
|
|
|
|
|
pub use traits::iterable::{Iterable, IterableMut};
|
|
|
|
|
pub use traits::scalar_op::{ScalarSub, ScalarAdd};
|
|
|
|
|
pub use traits::mat_cast::MatCast;
|
|
|
|
|
pub use traits::column::Column;
|
|
|
|
|
pub use traits::inv::Inv;
|
|
|
|
|
pub use traits::rlmul::{RMul, LMul};
|
2013-09-13 16:26:19 +08:00
|
|
|
|
pub use traits::rotation::{Rotation, RotationMatrix, Rotate};
|
2013-08-31 23:14:41 +08:00
|
|
|
|
pub use traits::transformation::{Transformation, Transform};
|
|
|
|
|
pub use traits::translation::{Translation, Translate};
|
|
|
|
|
pub use traits::transpose::{Transpose};
|
|
|
|
|
pub use traits::homogeneous::{ToHomogeneous, FromHomogeneous};
|
|
|
|
|
pub use traits::row::Row;
|
2013-09-13 16:26:19 +08:00
|
|
|
|
pub use traits::col::Col;
|
|
|
|
|
pub use traits::comp::rotation_with_translation::RotationWithTranslation;
|
|
|
|
|
pub use traits::comp::absolute_rotate::AbsoluteRotate;
|
2013-07-22 17:35:36 +08:00
|
|
|
|
|
2013-09-07 14:23:09 +08:00
|
|
|
|
// structs
|
|
|
|
|
pub use dmat::DMat;
|
|
|
|
|
|
2013-07-22 16:26:20 +08:00
|
|
|
|
mod mat_macros;
|
|
|
|
|
|
2013-08-23 21:59:26 +08:00
|
|
|
|
/// Special identity matrix. All its operation are no-ops.
|
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Zero, ToStr)]
|
2013-08-23 22:29:08 +08:00
|
|
|
|
pub struct Identity {
|
|
|
|
|
unused: uint // XXX: zero-sized structures ICE when used cross-crate.
|
|
|
|
|
}
|
2013-08-23 21:59:26 +08:00
|
|
|
|
|
|
|
|
|
impl Identity {
|
|
|
|
|
/// Creates a new identity matrix.
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn new() -> Identity {
|
2013-08-23 22:29:08 +08:00
|
|
|
|
Identity {
|
|
|
|
|
unused: 0
|
|
|
|
|
}
|
2013-08-23 21:59:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
|
/// Square matrix of dimension 1.
|
2013-08-04 16:36:35 +08:00
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
2013-08-05 16:13:44 +08:00
|
|
|
|
pub struct Mat1<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
|
m11: N
|
2013-07-24 22:50:40 +08:00
|
|
|
|
}
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-09-14 23:08:48 +08:00
|
|
|
|
double_dispatch_binop_decl_trait!(Mat1, Mat1MulRhs)
|
2013-07-23 05:42:35 +08:00
|
|
|
|
mat_impl!(Mat1, m11)
|
|
|
|
|
mat_cast_impl!(Mat1, m11)
|
2013-08-12 22:50:50 +08:00
|
|
|
|
add_impl!(Mat1, m11)
|
|
|
|
|
sub_impl!(Mat1, m11)
|
2013-08-12 23:04:53 +08:00
|
|
|
|
scalar_mul_impl!(Mat1, m11)
|
|
|
|
|
scalar_div_impl!(Mat1, m11)
|
|
|
|
|
scalar_add_impl!(Mat1, m11)
|
|
|
|
|
scalar_sub_impl!(Mat1, m11)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
absolute_impl!(Mat1, m11)
|
2013-09-07 23:26:05 +08:00
|
|
|
|
one_impl!(Mat1, One::one)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
iterable_impl!(Mat1, 1)
|
|
|
|
|
iterable_mut_impl!(Mat1, 1)
|
2013-09-13 19:21:42 +08:00
|
|
|
|
at_fast_impl!(Mat1, 1)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
dim_impl!(Mat1, 1)
|
|
|
|
|
indexable_impl!(Mat1, 1)
|
2013-09-14 23:08:48 +08:00
|
|
|
|
mul_redispatch_impl!(Mat1, Mat1MulRhs)
|
|
|
|
|
mat_mul_mat_impl!(Mat1, Mat1MulRhs, 1)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
rmul_impl!(Mat1, Vec1, 1)
|
|
|
|
|
lmul_impl!(Mat1, Vec1, 1)
|
|
|
|
|
transform_impl!(Mat1, Vec1)
|
|
|
|
|
// (specialized) inv_impl!(Mat1, 1)
|
|
|
|
|
transpose_impl!(Mat1, 1)
|
|
|
|
|
approx_eq_impl!(Mat1)
|
2013-08-26 05:01:44 +08:00
|
|
|
|
column_impl!(Mat1, Vec1, 1)
|
|
|
|
|
row_impl!(Mat1, Vec1, 1)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
col_impl!(Mat1, Vec1, 1)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
to_homogeneous_impl!(Mat1, Mat2, 1, 2)
|
|
|
|
|
from_homogeneous_impl!(Mat1, Mat2, 1, 2)
|
2013-08-12 22:45:31 +08:00
|
|
|
|
outer_impl!(Vec1, Mat1)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
|
/// Square matrix of dimension 2.
|
2013-08-04 16:36:35 +08:00
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
2013-08-05 16:13:44 +08:00
|
|
|
|
pub struct Mat2<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
|
m11: N, m12: N,
|
|
|
|
|
m21: N, m22: N
|
2013-07-22 16:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-23 05:42:35 +08:00
|
|
|
|
mat_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
|
|
|
|
mat_cast_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
2013-08-12 22:50:50 +08:00
|
|
|
|
add_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
|
|
|
|
sub_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
2013-08-12 23:04:53 +08:00
|
|
|
|
scalar_mul_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
|
|
|
|
scalar_div_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
|
|
|
|
scalar_add_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
|
|
|
|
scalar_sub_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
absolute_impl!(Mat2, m11, m12,
|
|
|
|
|
m21, m22)
|
2013-09-07 23:26:05 +08:00
|
|
|
|
one_impl!(Mat2, One::one, Zero::zero,
|
|
|
|
|
Zero::zero, One::one)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
iterable_impl!(Mat2, 2)
|
|
|
|
|
iterable_mut_impl!(Mat2, 2)
|
|
|
|
|
dim_impl!(Mat2, 2)
|
|
|
|
|
indexable_impl!(Mat2, 2)
|
2013-09-13 19:21:42 +08:00
|
|
|
|
at_fast_impl!(Mat2, 2)
|
2013-09-14 17:06:41 +08:00
|
|
|
|
// (specialized) mul_impl!(Mat2, 2)
|
|
|
|
|
// (specialized) rmul_impl!(Mat2, Vec2, 2)
|
|
|
|
|
// (specialized) lmul_impl!(Mat2, Vec2, 2)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
transform_impl!(Mat2, Vec2)
|
|
|
|
|
// (specialized) inv_impl!(Mat2, 2)
|
|
|
|
|
transpose_impl!(Mat2, 2)
|
|
|
|
|
approx_eq_impl!(Mat2)
|
2013-08-26 05:01:44 +08:00
|
|
|
|
column_impl!(Mat2, Vec2, 2)
|
|
|
|
|
row_impl!(Mat2, Vec2, 2)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
col_impl!(Mat2, Vec2, 2)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
to_homogeneous_impl!(Mat2, Mat3, 2, 3)
|
|
|
|
|
from_homogeneous_impl!(Mat2, Mat3, 2, 3)
|
2013-08-12 22:45:31 +08:00
|
|
|
|
outer_impl!(Vec2, Mat2)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
|
/// Square matrix of dimension 3.
|
2013-08-04 16:36:35 +08:00
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
2013-08-05 16:13:44 +08:00
|
|
|
|
pub struct Mat3<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
|
m11: N, m12: N, m13: N,
|
|
|
|
|
m21: N, m22: N, m23: N,
|
|
|
|
|
m31: N, m32: N, m33: N
|
2013-07-22 16:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-23 05:42:35 +08:00
|
|
|
|
mat_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
|
|
|
|
mat_cast_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
2013-08-12 22:50:50 +08:00
|
|
|
|
add_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
|
|
|
|
sub_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
2013-08-12 23:04:53 +08:00
|
|
|
|
scalar_mul_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
|
|
|
|
scalar_div_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
|
|
|
|
scalar_add_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
|
|
|
|
scalar_sub_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
absolute_impl!(Mat3, m11, m12, m13,
|
|
|
|
|
m21, m22, m23,
|
|
|
|
|
m31, m32, m33)
|
2013-09-07 23:26:05 +08:00
|
|
|
|
one_impl!(Mat3, One::one , Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, One::one , Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, One::one)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
iterable_impl!(Mat3, 3)
|
|
|
|
|
iterable_mut_impl!(Mat3, 3)
|
|
|
|
|
dim_impl!(Mat3, 3)
|
|
|
|
|
indexable_impl!(Mat3, 3)
|
2013-09-13 19:21:42 +08:00
|
|
|
|
at_fast_impl!(Mat3, 3)
|
2013-09-14 17:06:41 +08:00
|
|
|
|
// (specialized) mul_impl!(Mat3, 3)
|
|
|
|
|
// (specialized) rmul_impl!(Mat3, Vec3, 3)
|
|
|
|
|
// (specialized) lmul_impl!(Mat3, Vec3, 3)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
transform_impl!(Mat3, Vec3)
|
|
|
|
|
// (specialized) inv_impl!(Mat3, 3)
|
|
|
|
|
transpose_impl!(Mat3, 3)
|
|
|
|
|
approx_eq_impl!(Mat3)
|
2013-08-26 05:01:44 +08:00
|
|
|
|
column_impl!(Mat3, Vec3, 3)
|
|
|
|
|
// (specialized) row_impl!(Mat3, Vec3, 3)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
// (specialized) col_impl!(Mat3, Vec3, 3)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
to_homogeneous_impl!(Mat3, Mat4, 3, 4)
|
|
|
|
|
from_homogeneous_impl!(Mat3, Mat4, 3, 4)
|
2013-08-12 22:45:31 +08:00
|
|
|
|
outer_impl!(Vec3, Mat3)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
|
/// Square matrix of dimension 4.
|
2013-08-04 16:36:35 +08:00
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
2013-08-05 16:13:44 +08:00
|
|
|
|
pub struct Mat4<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
|
m11: N, m12: N, m13: N, m14: N,
|
|
|
|
|
m21: N, m22: N, m23: N, m24: N,
|
|
|
|
|
m31: N, m32: N, m33: N, m34: N,
|
|
|
|
|
m41: N, m42: N, m43: N, m44: N
|
2013-07-22 16:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-14 23:08:48 +08:00
|
|
|
|
double_dispatch_binop_decl_trait!(Mat4, Mat4MulRhs)
|
2013-07-23 05:42:35 +08:00
|
|
|
|
mat_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
|
|
|
|
mat_cast_impl!(Mat4,
|
2013-07-22 16:26:20 +08:00
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
2013-08-12 22:50:50 +08:00
|
|
|
|
add_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
|
|
|
|
sub_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
2013-08-12 23:04:53 +08:00
|
|
|
|
scalar_mul_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
|
|
|
|
scalar_div_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
|
|
|
|
scalar_add_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
|
|
|
|
scalar_sub_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
absolute_impl!(Mat4,
|
|
|
|
|
m11, m12, m13, m14,
|
|
|
|
|
m21, m22, m23, m24,
|
|
|
|
|
m31, m32, m33, m34,
|
|
|
|
|
m41, m42, m43, m44
|
|
|
|
|
)
|
2013-09-07 23:26:05 +08:00
|
|
|
|
one_impl!(Mat4, One::one , Zero::zero, Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, One::one , Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, One::one , Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, Zero::zero, One::one)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
iterable_impl!(Mat4, 4)
|
|
|
|
|
iterable_mut_impl!(Mat4, 4)
|
|
|
|
|
dim_impl!(Mat4, 4)
|
|
|
|
|
indexable_impl!(Mat4, 4)
|
2013-09-13 19:21:42 +08:00
|
|
|
|
at_fast_impl!(Mat4, 4)
|
2013-09-14 23:08:48 +08:00
|
|
|
|
mul_redispatch_impl!(Mat4, Mat4MulRhs)
|
|
|
|
|
mat_mul_mat_impl!(Mat4, Mat4MulRhs, 4)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
rmul_impl!(Mat4, Vec4, 4)
|
|
|
|
|
lmul_impl!(Mat4, Vec4, 4)
|
|
|
|
|
transform_impl!(Mat4, Vec4)
|
|
|
|
|
inv_impl!(Mat4, 4)
|
|
|
|
|
transpose_impl!(Mat4, 4)
|
|
|
|
|
approx_eq_impl!(Mat4)
|
2013-08-26 05:01:44 +08:00
|
|
|
|
column_impl!(Mat4, Vec4, 4)
|
|
|
|
|
row_impl!(Mat4, Vec4, 4)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
col_impl!(Mat4, Vec4, 4)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
to_homogeneous_impl!(Mat4, Mat5, 4, 5)
|
|
|
|
|
from_homogeneous_impl!(Mat4, Mat5, 4, 5)
|
2013-08-12 22:45:31 +08:00
|
|
|
|
outer_impl!(Vec4, Mat4)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
|
/// Square matrix of dimension 5.
|
2013-08-04 16:36:35 +08:00
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
2013-08-05 16:13:44 +08:00
|
|
|
|
pub struct Mat5<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
|
m11: N, m12: N, m13: N, m14: N, m15: N,
|
|
|
|
|
m21: N, m22: N, m23: N, m24: N, m25: N,
|
|
|
|
|
m31: N, m32: N, m33: N, m34: N, m35: N,
|
|
|
|
|
m41: N, m42: N, m43: N, m44: N, m45: N,
|
|
|
|
|
m51: N, m52: N, m53: N, m54: N, m55: N
|
2013-07-22 16:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-14 23:08:48 +08:00
|
|
|
|
double_dispatch_binop_decl_trait!(Mat5, Mat5MulRhs)
|
2013-07-23 05:42:35 +08:00
|
|
|
|
mat_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
|
|
|
|
mat_cast_impl!(Mat5,
|
2013-07-22 16:26:20 +08:00
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
absolute_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
one_impl!(Mat5,
|
2013-09-07 23:26:05 +08:00
|
|
|
|
One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, One::one , Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one
|
2013-07-22 16:26:20 +08:00
|
|
|
|
)
|
2013-08-12 22:50:50 +08:00
|
|
|
|
add_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
|
|
|
|
sub_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
2013-08-12 23:04:53 +08:00
|
|
|
|
scalar_mul_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
|
|
|
|
scalar_div_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
|
|
|
|
scalar_add_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
|
|
|
|
scalar_sub_impl!(Mat5,
|
|
|
|
|
m11, m12, m13, m14, m15,
|
|
|
|
|
m21, m22, m23, m24, m25,
|
|
|
|
|
m31, m32, m33, m34, m35,
|
|
|
|
|
m41, m42, m43, m44, m45,
|
|
|
|
|
m51, m52, m53, m54, m55
|
|
|
|
|
)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
iterable_impl!(Mat5, 5)
|
|
|
|
|
iterable_mut_impl!(Mat5, 5)
|
|
|
|
|
dim_impl!(Mat5, 5)
|
|
|
|
|
indexable_impl!(Mat5, 5)
|
2013-09-13 19:21:42 +08:00
|
|
|
|
at_fast_impl!(Mat5, 5)
|
2013-09-14 23:08:48 +08:00
|
|
|
|
mul_redispatch_impl!(Mat5, Mat5MulRhs)
|
|
|
|
|
mat_mul_mat_impl!(Mat5, Mat5MulRhs, 5)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
rmul_impl!(Mat5, Vec5, 5)
|
|
|
|
|
lmul_impl!(Mat5, Vec5, 5)
|
|
|
|
|
transform_impl!(Mat5, Vec5)
|
|
|
|
|
inv_impl!(Mat5, 5)
|
|
|
|
|
transpose_impl!(Mat5, 5)
|
|
|
|
|
approx_eq_impl!(Mat5)
|
2013-08-26 05:01:44 +08:00
|
|
|
|
column_impl!(Mat5, Vec5, 5)
|
|
|
|
|
row_impl!(Mat5, Vec5, 5)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
col_impl!(Mat5, Vec5, 5)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
to_homogeneous_impl!(Mat5, Mat6, 5, 6)
|
|
|
|
|
from_homogeneous_impl!(Mat5, Mat6, 5, 6)
|
2013-08-12 22:45:31 +08:00
|
|
|
|
outer_impl!(Vec5, Mat5)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
|
/// Square matrix of dimension 6.
|
2013-08-04 16:36:35 +08:00
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
2013-08-05 16:13:44 +08:00
|
|
|
|
pub struct Mat6<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
|
m11: N, m12: N, m13: N, m14: N, m15: N, m16: N,
|
|
|
|
|
m21: N, m22: N, m23: N, m24: N, m25: N, m26: N,
|
|
|
|
|
m31: N, m32: N, m33: N, m34: N, m35: N, m36: N,
|
|
|
|
|
m41: N, m42: N, m43: N, m44: N, m45: N, m46: N,
|
|
|
|
|
m51: N, m52: N, m53: N, m54: N, m55: N, m56: N,
|
|
|
|
|
m61: N, m62: N, m63: N, m64: N, m65: N, m66: N
|
2013-07-22 16:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-14 23:08:48 +08:00
|
|
|
|
double_dispatch_binop_decl_trait!(Mat6, Mat6MulRhs)
|
2013-07-23 05:42:35 +08:00
|
|
|
|
mat_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
|
|
|
|
mat_cast_impl!(Mat6,
|
2013-07-22 16:26:20 +08:00
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
2013-08-12 22:50:50 +08:00
|
|
|
|
add_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
|
|
|
|
sub_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
2013-08-12 23:04:53 +08:00
|
|
|
|
scalar_mul_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
|
|
|
|
scalar_div_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
|
|
|
|
scalar_add_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
|
|
|
|
scalar_sub_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
absolute_impl!(Mat6,
|
|
|
|
|
m11, m12, m13, m14, m15, m16,
|
|
|
|
|
m21, m22, m23, m24, m25, m26,
|
|
|
|
|
m31, m32, m33, m34, m35, m36,
|
|
|
|
|
m41, m42, m43, m44, m45, m46,
|
|
|
|
|
m51, m52, m53, m54, m55, m56,
|
|
|
|
|
m61, m62, m63, m64, m65, m66
|
|
|
|
|
)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
one_impl!(Mat6,
|
2013-09-07 23:26:05 +08:00
|
|
|
|
One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero, Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero,
|
|
|
|
|
Zero::zero, Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one
|
2013-07-22 16:26:20 +08:00
|
|
|
|
)
|
|
|
|
|
iterable_impl!(Mat6, 6)
|
|
|
|
|
iterable_mut_impl!(Mat6, 6)
|
|
|
|
|
dim_impl!(Mat6, 6)
|
|
|
|
|
indexable_impl!(Mat6, 6)
|
2013-09-13 19:21:42 +08:00
|
|
|
|
at_fast_impl!(Mat6, 6)
|
2013-09-14 23:08:48 +08:00
|
|
|
|
mul_redispatch_impl!(Mat6, Mat6MulRhs)
|
|
|
|
|
mat_mul_mat_impl!(Mat6, Mat6MulRhs, 6)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
rmul_impl!(Mat6, Vec6, 6)
|
|
|
|
|
lmul_impl!(Mat6, Vec6, 6)
|
|
|
|
|
transform_impl!(Mat6, Vec6)
|
|
|
|
|
inv_impl!(Mat6, 6)
|
|
|
|
|
transpose_impl!(Mat6, 6)
|
|
|
|
|
approx_eq_impl!(Mat6)
|
2013-08-26 05:01:44 +08:00
|
|
|
|
column_impl!(Mat6, Vec6, 6)
|
|
|
|
|
row_impl!(Mat6, Vec6, 6)
|
2013-09-13 16:26:19 +08:00
|
|
|
|
col_impl!(Mat6, Vec6, 6)
|
2013-08-12 22:45:31 +08:00
|
|
|
|
outer_impl!(Vec6, Mat6)
|