2013-09-22 16:58:21 +08:00
|
|
|
//! Vectors with dimensions known at compile-time.
|
|
|
|
|
2013-09-26 23:18:14 +08:00
|
|
|
#[allow(missing_doc)]; // we allow missing to avoid having to document the vector components.
|
2013-09-15 03:11:43 +08:00
|
|
|
|
2013-07-22 16:26:20 +08:00
|
|
|
use std::cast;
|
|
|
|
use std::num::{Zero, One, Algebraic, Bounded};
|
|
|
|
use std::rand::Rng;
|
|
|
|
use std::vec::{VecIterator, VecMutIterator};
|
2013-09-09 17:19:54 +08:00
|
|
|
use std::iter::{Iterator, FromIterator};
|
2013-07-22 16:26:20 +08:00
|
|
|
use std::cmp::ApproxEq;
|
2013-08-31 17:41:32 +08:00
|
|
|
|
2013-09-22 16:58:21 +08:00
|
|
|
use traits::geometry::{Transform, Rotate};
|
|
|
|
|
|
|
|
pub use traits::geometry::{FromHomogeneous, ToHomogeneous, Dot, Norm, Cross, CrossMatrix,
|
|
|
|
Translation, Translate, UniformSphereSample};
|
|
|
|
pub use traits::structure::{VecCast, Vec, VecExt, AlgebraicVec, AlgebraicVecExt, Basis, Dim,
|
|
|
|
Indexable, Iterable, IterableMut};
|
|
|
|
pub use traits::operations::{Outer, ScalarAdd, ScalarSub};
|
2013-07-22 17:35:36 +08:00
|
|
|
|
2013-09-07 14:23:09 +08:00
|
|
|
// structs
|
|
|
|
pub use dvec::DVec;
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
mod metal;
|
2013-07-22 16:26:20 +08:00
|
|
|
mod vec_macros;
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector of dimension 0.
|
2013-08-04 16:36:35 +08:00
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Zero, ToStr)]
|
2013-07-22 16:26:20 +08:00
|
|
|
pub struct Vec0<N>;
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector 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 Vec1<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
/// First component of the vector.
|
|
|
|
x: N
|
2013-07-24 22:50:40 +08:00
|
|
|
}
|
2013-07-22 16:26:20 +08:00
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(Vec1, Vec1MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec1, Vec1DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec1, Vec1AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec1, Vec1SubRhs)
|
|
|
|
mul_redispatch_impl!(Vec1, Vec1MulRhs)
|
|
|
|
div_redispatch_impl!(Vec1, Vec1DivRhs)
|
|
|
|
add_redispatch_impl!(Vec1, Vec1AddRhs)
|
|
|
|
sub_redispatch_impl!(Vec1, Vec1SubRhs)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_impl!(Vec1, x)
|
2013-08-04 16:36:35 +08:00
|
|
|
ord_impl!(Vec1, x)
|
2013-08-04 17:06:23 +08:00
|
|
|
orderable_impl!(Vec1, x)
|
2013-07-25 05:54:54 +08:00
|
|
|
vec_axis_impl!(Vec1, x)
|
2013-07-23 05:42:35 +08:00
|
|
|
vec_cast_impl!(Vec1, x)
|
2013-07-22 16:26:20 +08:00
|
|
|
indexable_impl!(Vec1, 1)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(Vec1, 1)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_repeat_impl!(Vec1, val, x)
|
|
|
|
dim_impl!(Vec1, 1)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(Vec1)
|
2013-07-22 16:26:20 +08:00
|
|
|
// (specialized) basis_impl!(Vec1, 1)
|
2013-09-15 03:11:43 +08:00
|
|
|
add_impl!(Vec1, Vec1AddRhs, x)
|
|
|
|
sub_impl!(Vec1, Vec1SubRhs, x)
|
2013-07-22 16:26:20 +08:00
|
|
|
neg_impl!(Vec1, x)
|
|
|
|
dot_impl!(Vec1, x)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(Vec1, f64, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, f32, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, u64, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, u32, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, u16, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, u8, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, i64, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, i32, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, i16, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, i8, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, uint, Vec1MulRhs, x)
|
|
|
|
scalar_mul_impl!(Vec1, int, Vec1MulRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, f64, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, f32, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, u64, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, u32, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, u16, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, u8, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, i64, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, i32, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, i16, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, i8, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, uint, Vec1DivRhs, x)
|
|
|
|
scalar_div_impl!(Vec1, int, Vec1DivRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, f64, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, f32, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, u64, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, u32, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, u16, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, u8, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, i64, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, i32, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, i16, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, i8, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, uint, Vec1AddRhs, x)
|
|
|
|
scalar_add_impl!(Vec1, int, Vec1AddRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, f64, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, f32, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, u64, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, u32, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, u16, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, u8, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, i64, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, i32, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, i16, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, i8, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, uint, Vec1SubRhs, x)
|
|
|
|
scalar_sub_impl!(Vec1, int, Vec1SubRhs, x)
|
2013-07-22 16:26:20 +08:00
|
|
|
translation_impl!(Vec1)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(Vec1, x)
|
2013-07-22 16:26:20 +08:00
|
|
|
approx_eq_impl!(Vec1, x)
|
2013-08-15 16:41:47 +08:00
|
|
|
round_impl!(Vec1, x)
|
2013-07-22 16:26:20 +08:00
|
|
|
one_impl!(Vec1)
|
|
|
|
from_iterator_impl!(Vec1, iterator)
|
|
|
|
bounded_impl!(Vec1)
|
|
|
|
iterable_impl!(Vec1, 1)
|
|
|
|
iterable_mut_impl!(Vec1, 1)
|
|
|
|
to_homogeneous_impl!(Vec1, Vec2, y, x)
|
|
|
|
from_homogeneous_impl!(Vec1, Vec2, y, x)
|
2013-08-23 22:29:08 +08:00
|
|
|
translate_impl!(Vec1)
|
|
|
|
rotate_impl!(Vec1)
|
|
|
|
transform_impl!(Vec1)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector 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 Vec2<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
/// First component of the vector.
|
|
|
|
x: N,
|
|
|
|
/// Second component of the vector.
|
|
|
|
y: N
|
2013-07-22 16:26:20 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(Vec2, Vec2MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec2, Vec2DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec2, Vec2AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec2, Vec2SubRhs)
|
|
|
|
mul_redispatch_impl!(Vec2, Vec2MulRhs)
|
|
|
|
div_redispatch_impl!(Vec2, Vec2DivRhs)
|
|
|
|
add_redispatch_impl!(Vec2, Vec2AddRhs)
|
|
|
|
sub_redispatch_impl!(Vec2, Vec2SubRhs)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_impl!(Vec2, x, y)
|
2013-08-04 16:36:35 +08:00
|
|
|
ord_impl!(Vec2, x, y)
|
2013-08-04 17:06:23 +08:00
|
|
|
orderable_impl!(Vec2, x, y)
|
2013-07-25 05:54:54 +08:00
|
|
|
vec_axis_impl!(Vec2, x, y)
|
2013-07-23 05:42:35 +08:00
|
|
|
vec_cast_impl!(Vec2, x, y)
|
2013-07-22 16:26:20 +08:00
|
|
|
indexable_impl!(Vec2, 2)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(Vec2, 2)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_repeat_impl!(Vec2, val, x, y)
|
|
|
|
dim_impl!(Vec2, 2)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(Vec2)
|
2013-07-22 16:26:20 +08:00
|
|
|
// (specialized) basis_impl!(Vec2, 1)
|
2013-09-15 03:11:43 +08:00
|
|
|
add_impl!(Vec2, Vec2AddRhs, x, y)
|
|
|
|
sub_impl!(Vec2, Vec2SubRhs, x, y)
|
2013-07-22 16:26:20 +08:00
|
|
|
neg_impl!(Vec2, x, y)
|
|
|
|
dot_impl!(Vec2, x, y)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(Vec2, f64, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, f32, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, u64, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, u32, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, u16, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, u8, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, i64, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, i32, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, i16, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, i8, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, uint, Vec2MulRhs, x, y)
|
|
|
|
scalar_mul_impl!(Vec2, int, Vec2MulRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, f64, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, f32, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, u64, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, u32, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, u16, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, u8, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, i64, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, i32, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, i16, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, i8, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, uint, Vec2DivRhs, x, y)
|
|
|
|
scalar_div_impl!(Vec2, int, Vec2DivRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, f64, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, f32, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, u64, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, u32, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, u16, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, u8, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, i64, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, i32, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, i16, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, i8, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, uint, Vec2AddRhs, x, y)
|
|
|
|
scalar_add_impl!(Vec2, int, Vec2AddRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, f64, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, f32, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, u64, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, u32, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, u16, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, u8, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, i64, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, i32, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, i16, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, i8, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, uint, Vec2SubRhs, x, y)
|
|
|
|
scalar_sub_impl!(Vec2, int, Vec2SubRhs, x, y)
|
2013-07-22 16:26:20 +08:00
|
|
|
translation_impl!(Vec2)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(Vec2, x, y)
|
2013-07-22 16:26:20 +08:00
|
|
|
approx_eq_impl!(Vec2, x, y)
|
2013-08-15 16:41:47 +08:00
|
|
|
round_impl!(Vec2, x, y)
|
2013-07-22 16:26:20 +08:00
|
|
|
one_impl!(Vec2)
|
|
|
|
from_iterator_impl!(Vec2, iterator, iterator)
|
|
|
|
bounded_impl!(Vec2)
|
|
|
|
iterable_impl!(Vec2, 2)
|
|
|
|
iterable_mut_impl!(Vec2, 2)
|
|
|
|
to_homogeneous_impl!(Vec2, Vec3, z, x, y)
|
|
|
|
from_homogeneous_impl!(Vec2, Vec3, z, x, y)
|
2013-08-23 22:29:08 +08:00
|
|
|
translate_impl!(Vec2)
|
|
|
|
rotate_impl!(Vec2)
|
|
|
|
transform_impl!(Vec2)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector 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 Vec3<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
/// First component of the vector.
|
|
|
|
x: N,
|
|
|
|
/// Second component of the vector.
|
|
|
|
y: N,
|
|
|
|
/// Third component of the vector.
|
|
|
|
z: N
|
2013-07-22 16:26:20 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(Vec3, Vec3MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec3, Vec3DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec3, Vec3AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec3, Vec3SubRhs)
|
|
|
|
mul_redispatch_impl!(Vec3, Vec3MulRhs)
|
|
|
|
div_redispatch_impl!(Vec3, Vec3DivRhs)
|
|
|
|
add_redispatch_impl!(Vec3, Vec3AddRhs)
|
|
|
|
sub_redispatch_impl!(Vec3, Vec3SubRhs)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_impl!(Vec3, x, y, z)
|
2013-08-04 16:36:35 +08:00
|
|
|
ord_impl!(Vec3, x, y, z)
|
2013-08-04 17:06:23 +08:00
|
|
|
orderable_impl!(Vec3, x, y, z)
|
2013-07-25 05:54:54 +08:00
|
|
|
vec_axis_impl!(Vec3, x, y, z)
|
2013-07-23 05:42:35 +08:00
|
|
|
vec_cast_impl!(Vec3, x, y, z)
|
2013-07-22 16:26:20 +08:00
|
|
|
indexable_impl!(Vec3, 3)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(Vec3, 3)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_repeat_impl!(Vec3, val, x, y, z)
|
|
|
|
dim_impl!(Vec3, 3)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(Vec3)
|
2013-07-22 16:26:20 +08:00
|
|
|
// (specialized) basis_impl!(Vec3, 1)
|
2013-09-15 03:11:43 +08:00
|
|
|
add_impl!(Vec3, Vec3AddRhs, x, y, z)
|
|
|
|
sub_impl!(Vec3, Vec3SubRhs, x, y, z)
|
2013-07-22 16:26:20 +08:00
|
|
|
neg_impl!(Vec3, x, y, z)
|
|
|
|
dot_impl!(Vec3, x, y, z)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(Vec3, f64, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, f32, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, u64, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, u32, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, u16, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, u8, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, i64, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, i32, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, i16, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, i8, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, uint, Vec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(Vec3, int, Vec3MulRhs, x, y, z)
|
|
|
|
|
|
|
|
scalar_div_impl!(Vec3, f64, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, f32, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, u64, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, u32, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, u16, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, u8, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, i64, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, i32, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, i16, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, i8, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, uint, Vec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(Vec3, int, Vec3DivRhs, x, y, z)
|
|
|
|
|
|
|
|
scalar_add_impl!(Vec3, f64, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, f32, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, u64, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, u32, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, u16, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, u8, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, i64, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, i32, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, i16, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, i8, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, uint, Vec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(Vec3, int, Vec3AddRhs, x, y, z)
|
|
|
|
|
|
|
|
scalar_sub_impl!(Vec3, f64, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, f32, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, u64, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, u32, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, u16, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, u8, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, i64, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, i32, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, i16, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, i8, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, uint, Vec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(Vec3, int, Vec3SubRhs, x, y, z)
|
2013-07-22 16:26:20 +08:00
|
|
|
translation_impl!(Vec3)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(Vec3, x, y ,z)
|
2013-07-22 16:26:20 +08:00
|
|
|
approx_eq_impl!(Vec3, x, y, z)
|
2013-08-15 16:41:47 +08:00
|
|
|
round_impl!(Vec3, x, y, z)
|
2013-07-22 16:26:20 +08:00
|
|
|
one_impl!(Vec3)
|
|
|
|
from_iterator_impl!(Vec3, iterator, iterator, iterator)
|
|
|
|
bounded_impl!(Vec3)
|
|
|
|
iterable_impl!(Vec3, 3)
|
|
|
|
iterable_mut_impl!(Vec3, 3)
|
|
|
|
to_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
|
|
|
|
from_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
|
2013-08-23 22:29:08 +08:00
|
|
|
translate_impl!(Vec3)
|
|
|
|
rotate_impl!(Vec3)
|
|
|
|
transform_impl!(Vec3)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
2013-08-31 17:11:46 +08:00
|
|
|
|
|
|
|
/// Vector of dimension 3 with an extra component for padding.
|
|
|
|
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
|
|
|
pub struct PVec3<N> {
|
|
|
|
/// First component of the vector.
|
|
|
|
x: N,
|
|
|
|
/// Second component of the vector.
|
|
|
|
y: N,
|
|
|
|
/// Third component of the vector.
|
|
|
|
z: N,
|
|
|
|
// Unused component, for padding
|
|
|
|
priv _unused: N
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Clone> PVec3<N> {
|
|
|
|
/// Creates a new 3d vector.
|
|
|
|
pub fn new(x: N, y: N, z: N) -> PVec3<N> {
|
|
|
|
PVec3 { x: x.clone(), y: y, z: z, _unused: x }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(PVec3, PVec3MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(PVec3, PVec3DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(PVec3, PVec3AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(PVec3, PVec3SubRhs)
|
|
|
|
mul_redispatch_impl!(PVec3, PVec3MulRhs)
|
|
|
|
div_redispatch_impl!(PVec3, PVec3DivRhs)
|
|
|
|
add_redispatch_impl!(PVec3, PVec3AddRhs)
|
|
|
|
sub_redispatch_impl!(PVec3, PVec3SubRhs)
|
2013-08-31 17:11:46 +08:00
|
|
|
ord_impl!(PVec3, x, y, z)
|
|
|
|
orderable_impl!(PVec3, x, y, z)
|
|
|
|
vec_axis_impl!(PVec3, x, y, z)
|
|
|
|
vec_cast_impl!(PVec3, x, y, z)
|
|
|
|
indexable_impl!(PVec3, 3)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(PVec3, 3)
|
2013-08-31 17:11:46 +08:00
|
|
|
new_repeat_impl!(PVec3, val, x, y, z, _unused)
|
|
|
|
dim_impl!(PVec3, 3)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(PVec3)
|
2013-08-31 17:11:46 +08:00
|
|
|
// (specialized) basis_impl!(PVec3, 1)
|
2013-09-15 03:11:43 +08:00
|
|
|
add_impl!(PVec3, PVec3AddRhs, x, y, z)
|
|
|
|
sub_impl!(PVec3, PVec3SubRhs, x, y, z)
|
2013-08-31 17:11:46 +08:00
|
|
|
neg_impl!(PVec3, x, y, z)
|
|
|
|
dot_impl!(PVec3, x, y, z)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(PVec3, f64, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, f32, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, u64, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, u32, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, u16, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, u8, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, i64, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, i32, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, i16, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, i8, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, uint, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_mul_impl!(PVec3, int, PVec3MulRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, f64, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, f32, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, u64, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, u32, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, u16, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, u8, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, i64, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, i32, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, i16, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, i8, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, uint, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_div_impl!(PVec3, int, PVec3DivRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, f64, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, f32, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, u64, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, u32, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, u16, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, u8, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, i64, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, i32, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, i16, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, i8, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, uint, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_add_impl!(PVec3, int, PVec3AddRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, f64, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, f32, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, u64, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, u32, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, u16, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, u8, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, i64, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, i32, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, i16, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, i8, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, uint, PVec3SubRhs, x, y, z)
|
|
|
|
scalar_sub_impl!(PVec3, int, PVec3SubRhs, x, y, z)
|
2013-08-31 17:11:46 +08:00
|
|
|
translation_impl!(PVec3)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(PVec3, x, y, z)
|
2013-08-31 17:11:46 +08:00
|
|
|
approx_eq_impl!(PVec3, x, y, z)
|
|
|
|
round_impl!(PVec3, x, y, z)
|
|
|
|
one_impl!(PVec3)
|
|
|
|
from_iterator_impl!(PVec3, iterator, iterator, iterator)
|
|
|
|
bounded_impl!(PVec3)
|
|
|
|
iterable_impl!(PVec3, 3)
|
|
|
|
iterable_mut_impl!(PVec3, 3)
|
|
|
|
to_homogeneous_impl!(PVec3, Vec4, w, x, y, z)
|
|
|
|
from_homogeneous_impl!(PVec3, Vec4, w, x, y, z)
|
|
|
|
translate_impl!(PVec3)
|
|
|
|
rotate_impl!(PVec3)
|
|
|
|
transform_impl!(PVec3)
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector 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 Vec4<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
/// First component of the vector.
|
|
|
|
x: N,
|
|
|
|
/// Second component of the vector.
|
|
|
|
y: N,
|
|
|
|
/// Third component of the vector.
|
|
|
|
z: N,
|
|
|
|
/// Fourth component of the vector.
|
|
|
|
w: N
|
2013-07-22 16:26:20 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(Vec4, Vec4MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec4, Vec4DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec4, Vec4AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec4, Vec4SubRhs)
|
|
|
|
mul_redispatch_impl!(Vec4, Vec4MulRhs)
|
|
|
|
div_redispatch_impl!(Vec4, Vec4DivRhs)
|
|
|
|
add_redispatch_impl!(Vec4, Vec4AddRhs)
|
|
|
|
sub_redispatch_impl!(Vec4, Vec4SubRhs)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_impl!(Vec4, x, y, z, w)
|
2013-08-04 16:36:35 +08:00
|
|
|
ord_impl!(Vec4, x, y, z, w)
|
2013-08-04 17:06:23 +08:00
|
|
|
orderable_impl!(Vec4, x, y, z, w)
|
2013-07-25 05:54:54 +08:00
|
|
|
vec_axis_impl!(Vec4, x, y, z, w)
|
2013-07-23 05:42:35 +08:00
|
|
|
vec_cast_impl!(Vec4, x, y, z, w)
|
2013-07-22 16:26:20 +08:00
|
|
|
indexable_impl!(Vec4, 4)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(Vec4, 4)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_repeat_impl!(Vec4, val, x, y, z, w)
|
|
|
|
dim_impl!(Vec4, 4)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(Vec4)
|
2013-09-15 03:11:43 +08:00
|
|
|
basis_impl!(Vec4, Vec4MulRhs, 4)
|
|
|
|
add_impl!(Vec4, Vec4AddRhs, x, y, z, w)
|
|
|
|
sub_impl!(Vec4, Vec4SubRhs, x, y, z, w)
|
2013-07-22 16:26:20 +08:00
|
|
|
neg_impl!(Vec4, x, y, z, w)
|
|
|
|
dot_impl!(Vec4, x, y, z, w)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(Vec4, f64, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, f32, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, u64, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, u32, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, u16, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, u8, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, i64, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, i32, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, i16, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, i8, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, uint, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_mul_impl!(Vec4, int, Vec4MulRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, f64, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, f32, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, u64, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, u32, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, u16, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, u8, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, i64, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, i32, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, i16, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, i8, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, uint, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_div_impl!(Vec4, int, Vec4DivRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, f64, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, f32, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, u64, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, u32, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, u16, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, u8, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, i64, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, i32, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, i16, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, i8, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, uint, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_add_impl!(Vec4, int, Vec4AddRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, f64, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, f32, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, u64, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, u32, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, u16, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, u8, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, i64, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, i32, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, i16, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, i8, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, uint, Vec4SubRhs, x, y, z, w)
|
|
|
|
scalar_sub_impl!(Vec4, int, Vec4SubRhs, x, y, z, w)
|
2013-07-22 16:26:20 +08:00
|
|
|
translation_impl!(Vec4)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(Vec4, x, y, z, w)
|
2013-07-22 16:26:20 +08:00
|
|
|
approx_eq_impl!(Vec4, x, y, z, w)
|
2013-08-15 16:41:47 +08:00
|
|
|
round_impl!(Vec4, x, y, z, w)
|
2013-07-22 16:26:20 +08:00
|
|
|
one_impl!(Vec4)
|
|
|
|
from_iterator_impl!(Vec4, iterator, iterator, iterator, iterator)
|
|
|
|
bounded_impl!(Vec4)
|
|
|
|
iterable_impl!(Vec4, 4)
|
|
|
|
iterable_mut_impl!(Vec4, 4)
|
|
|
|
to_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
|
|
|
|
from_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
|
2013-08-23 22:29:08 +08:00
|
|
|
translate_impl!(Vec4)
|
|
|
|
rotate_impl!(Vec4)
|
|
|
|
transform_impl!(Vec4)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector 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 Vec5<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
/// First component of the vector.
|
|
|
|
x: N,
|
|
|
|
/// Second component of the vector.
|
|
|
|
y: N,
|
|
|
|
/// Third component of the vector.
|
|
|
|
z: N,
|
|
|
|
/// Fourth component of the vector.
|
|
|
|
w: N,
|
|
|
|
/// Fifth of the vector.
|
|
|
|
a: N
|
2013-07-22 16:26:20 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(Vec5, Vec5MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec5, Vec5DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec5, Vec5AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec5, Vec5SubRhs)
|
|
|
|
mul_redispatch_impl!(Vec5, Vec5MulRhs)
|
|
|
|
div_redispatch_impl!(Vec5, Vec5DivRhs)
|
|
|
|
add_redispatch_impl!(Vec5, Vec5AddRhs)
|
|
|
|
sub_redispatch_impl!(Vec5, Vec5SubRhs)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_impl!(Vec5, x, y, z, w, a)
|
2013-08-04 16:36:35 +08:00
|
|
|
ord_impl!(Vec5, x, y, z, w, a)
|
2013-08-04 17:06:23 +08:00
|
|
|
orderable_impl!(Vec5, x, y, z, w, a)
|
2013-07-25 05:54:54 +08:00
|
|
|
vec_axis_impl!(Vec5, x, y, z, w, a)
|
2013-07-23 05:42:35 +08:00
|
|
|
vec_cast_impl!(Vec5, x, y, z, w, a)
|
2013-07-22 16:26:20 +08:00
|
|
|
indexable_impl!(Vec5, 5)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(Vec5, 5)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_repeat_impl!(Vec5, val, x, y, z, w, a)
|
|
|
|
dim_impl!(Vec5, 5)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(Vec5)
|
2013-09-15 03:11:43 +08:00
|
|
|
basis_impl!(Vec5, Vec5MulRhs, 5)
|
|
|
|
add_impl!(Vec5, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
sub_impl!(Vec5, Vec5SubRhs, x, y, z, w, a)
|
2013-07-22 16:26:20 +08:00
|
|
|
neg_impl!(Vec5, x, y, z, w, a)
|
|
|
|
dot_impl!(Vec5, x, y, z, w, a)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(Vec5, f64, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, f32, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, u64, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, u32, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, u16, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, u8, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, i64, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, i32, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, i16, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, i8, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, uint, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_mul_impl!(Vec5, int, Vec5MulRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, f64, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, f32, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, u64, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, u32, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, u16, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, u8, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, i64, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, i32, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, i16, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, i8, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, uint, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_div_impl!(Vec5, int, Vec5DivRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, f64, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, f32, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, u64, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, u32, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, u16, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, u8, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, i64, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, i32, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, i16, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, i8, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, uint, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_add_impl!(Vec5, int, Vec5AddRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, f64, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, f32, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, u64, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, u32, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, u16, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, u8, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, i64, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, i32, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, i16, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, i8, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, uint, Vec5SubRhs, x, y, z, w, a)
|
|
|
|
scalar_sub_impl!(Vec5, int, Vec5SubRhs, x, y, z, w, a)
|
2013-07-22 16:26:20 +08:00
|
|
|
translation_impl!(Vec5)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(Vec5, x, y, z, w, a)
|
2013-07-22 16:26:20 +08:00
|
|
|
approx_eq_impl!(Vec5, x, y, z, w, a)
|
2013-08-15 16:41:47 +08:00
|
|
|
round_impl!(Vec5, x, y, z, w, a)
|
2013-07-22 16:26:20 +08:00
|
|
|
one_impl!(Vec5)
|
|
|
|
from_iterator_impl!(Vec5, iterator, iterator, iterator, iterator, iterator)
|
|
|
|
bounded_impl!(Vec5)
|
|
|
|
iterable_impl!(Vec5, 5)
|
|
|
|
iterable_mut_impl!(Vec5, 5)
|
|
|
|
to_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
|
|
|
|
from_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
|
2013-08-23 22:29:08 +08:00
|
|
|
translate_impl!(Vec5)
|
|
|
|
rotate_impl!(Vec5)
|
|
|
|
transform_impl!(Vec5)
|
2013-07-22 16:26:20 +08:00
|
|
|
|
2013-07-24 22:50:40 +08:00
|
|
|
/// Vector 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 Vec6<N> {
|
2013-08-05 15:44:56 +08:00
|
|
|
/// First component of the vector.
|
|
|
|
x: N,
|
|
|
|
/// Second component of the vector.
|
|
|
|
y: N,
|
|
|
|
/// Third component of the vector.
|
|
|
|
z: N,
|
|
|
|
/// Fourth component of the vector.
|
|
|
|
w: N,
|
|
|
|
/// Fifth of the vector.
|
|
|
|
a: N,
|
|
|
|
/// Sixth component of the vector.
|
|
|
|
b: N
|
2013-07-22 16:26:20 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:11:43 +08:00
|
|
|
double_dispatch_binop_decl_trait!(Vec6, Vec6MulRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec6, Vec6DivRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec6, Vec6AddRhs)
|
|
|
|
double_dispatch_binop_decl_trait!(Vec6, Vec6SubRhs)
|
|
|
|
mul_redispatch_impl!(Vec6, Vec6MulRhs)
|
|
|
|
div_redispatch_impl!(Vec6, Vec6DivRhs)
|
|
|
|
add_redispatch_impl!(Vec6, Vec6AddRhs)
|
|
|
|
sub_redispatch_impl!(Vec6, Vec6SubRhs)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_impl!(Vec6, x, y, z, w, a, b)
|
2013-08-04 16:36:35 +08:00
|
|
|
ord_impl!(Vec6, x, y, z, w, a, b)
|
2013-08-04 17:06:23 +08:00
|
|
|
orderable_impl!(Vec6, x, y, z, w, a, b)
|
2013-07-25 05:54:54 +08:00
|
|
|
vec_axis_impl!(Vec6, x, y, z, w, a, b)
|
2013-07-23 05:42:35 +08:00
|
|
|
vec_cast_impl!(Vec6, x, y, z, w, a, b)
|
2013-07-22 16:26:20 +08:00
|
|
|
indexable_impl!(Vec6, 6)
|
2013-09-13 19:21:42 +08:00
|
|
|
at_fast_impl!(Vec6, 6)
|
2013-07-22 16:26:20 +08:00
|
|
|
new_repeat_impl!(Vec6, val, x, y, z, w, a, b)
|
|
|
|
dim_impl!(Vec6, 6)
|
2013-09-08 23:26:31 +08:00
|
|
|
container_impl!(Vec6)
|
2013-09-15 03:11:43 +08:00
|
|
|
basis_impl!(Vec6, Vec6MulRhs, 6)
|
|
|
|
add_impl!(Vec6, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
sub_impl!(Vec6, Vec6SubRhs, x, y, z, w, a, b)
|
2013-07-22 16:26:20 +08:00
|
|
|
neg_impl!(Vec6, x, y, z, w, a, b)
|
|
|
|
dot_impl!(Vec6, x, y, z, w, a, b)
|
2013-09-15 03:11:43 +08:00
|
|
|
scalar_mul_impl!(Vec6, f64, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, f32, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, u64, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, u32, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, u16, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, u8, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, i64, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, i32, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, i16, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, i8, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, uint, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_mul_impl!(Vec6, int, Vec6MulRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, f64, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, f32, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, u64, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, u32, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, u16, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, u8, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, i64, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, i32, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, i16, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, i8, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, uint, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_div_impl!(Vec6, int, Vec6DivRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, f64, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, f32, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, u64, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, u32, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, u16, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, u8, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, i64, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, i32, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, i16, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, i8, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, uint, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_add_impl!(Vec6, int, Vec6AddRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, f64, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, f32, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, u64, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, u32, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, u16, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, u8, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, i64, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, i32, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, i16, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, i8, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, uint, Vec6SubRhs, x, y, z, w, a, b)
|
|
|
|
scalar_sub_impl!(Vec6, int, Vec6SubRhs, x, y, z, w, a, b)
|
2013-07-22 16:26:20 +08:00
|
|
|
translation_impl!(Vec6)
|
2013-09-15 03:11:43 +08:00
|
|
|
norm_impl!(Vec6, x, y, z, w, a, b)
|
2013-07-22 16:26:20 +08:00
|
|
|
approx_eq_impl!(Vec6, x, y, z, w, a, b)
|
2013-08-15 16:41:47 +08:00
|
|
|
round_impl!(Vec6, x, y, z, w, a, b)
|
2013-07-22 16:26:20 +08:00
|
|
|
one_impl!(Vec6)
|
|
|
|
from_iterator_impl!(Vec6, iterator, iterator, iterator, iterator, iterator, iterator)
|
|
|
|
bounded_impl!(Vec6)
|
|
|
|
iterable_impl!(Vec6, 6)
|
|
|
|
iterable_mut_impl!(Vec6, 6)
|
2013-08-23 22:29:08 +08:00
|
|
|
translate_impl!(Vec6)
|
|
|
|
rotate_impl!(Vec6)
|
|
|
|
transform_impl!(Vec6)
|