diff --git a/src/vec.rs b/src/vec.rs index 237e6664..b19731df 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -19,6 +19,44 @@ use traits::indexable::Indexable; mod vec_impl; +#[deriving(Ord, ToStr)] +pub struct Vec0 +{ at: [N, ..0] } + +impl Vec0 +{ + #[inline] + pub fn new_repeat(_: N) -> Vec0 + { Vec0 { at: [ ] } } +} + +clone_impl!(Vec0) +deep_clone_impl!(Vec0) +new_impl!(Vec0, 0) +indexable_impl!(Vec0) +dim_impl!(Vec0, 0) +eq_impl!(Vec0) +// (specialized) basis_impl!(Vec0, 0) +add_impl!(Vec0) +sub_impl!(Vec0) +neg_impl!(Vec0) +dot_impl!(Vec0, 0) +sub_dot_impl!(Vec0, 0) +scalar_mul_impl!(Vec0, 0) +scalar_div_impl!(Vec0, 0) +scalar_add_impl!(Vec0, 0) +scalar_sub_impl!(Vec0, 0) +translation_impl!(Vec0) +translatable_impl!(Vec0) +norm_impl!(Vec0, 0) +approx_eq_impl!(Vec0) +zero_impl!(Vec0) +one_impl!(Vec0) +bounded_impl!(Vec0) +iterable_impl!(Vec0) +iterable_mut_impl!(Vec0) +to_homogeneous_impl!(Vec0, Vec1) +from_homogeneous_impl!(Vec1, Vec0, 1) #[deriving(Ord, ToStr)] pub struct Vec1 diff --git a/src/vec_spec.rs b/src/vec_spec.rs index bfa64bdd..82a8c3f2 100644 --- a/src/vec_spec.rs +++ b/src/vec_spec.rs @@ -1,10 +1,28 @@ +use std::vec::{VecIterator, VecMutIterator}; +use std::iterator::FromIterator; use std::num::{Zero, One, abs}; use traits::basis::Basis; use traits::cross::Cross; use traits::division_ring::DivisionRing; use traits::norm::Norm; use traits::sample::UniformSphereSample; -use vec::{Vec1, Vec2, Vec3}; +use traits::iterable::FromAnyIterator; +use vec::{Vec0, Vec1, Vec2, Vec3}; + +impl FromAnyIterator for Vec0 +{ + fn from_iterator<'l>(_: &mut VecIterator<'l, N>) -> Vec0 + { Vec0 { at: [ ] } } + + fn from_mut_iterator<'l>(_: &mut VecMutIterator<'l, N>) -> Vec0 + { Vec0 { at: [ ] } } +} + +impl> FromIterator for Vec0 +{ + fn from_iterator(_: &mut Iter) -> Vec0 + { Vec0 { at: [ ] } } +} impl + Sub> Cross> for Vec2 {