Merge pull request #114 from andersk/neg

Remove Neg from BaseNum
This commit is contained in:
Eduard Bopp 2015-04-04 16:44:29 +02:00
commit 49abb42980
5 changed files with 13 additions and 15 deletions

View File

@ -2,7 +2,7 @@
#![allow(missing_docs)] #![allow(missing_docs)]
use std::ops::{Add, Sub, Mul}; use std::ops::{Add, Sub, Mul, Neg};
use rand::{Rand, Rng}; use rand::{Rand, Rng};
use structs::mat::{Mat3, Mat4, Mat5}; use structs::mat::{Mat3, Mat4, Mat5};

View File

@ -278,7 +278,7 @@ macro_rules! transform_impl(
macro_rules! inv_impl( macro_rules! inv_impl(
($t: ident) => ( ($t: ident) => (
impl<N: BaseNum> Inv for $t<N> { impl<N: BaseNum + Neg<Output = N>> Inv for $t<N> {
#[inline] #[inline]
fn inv_mut(&mut self) -> bool { fn inv_mut(&mut self) -> bool {
self.rotation.inv_mut(); self.rotation.inv_mut();

View File

@ -364,7 +364,7 @@ impl<N: BaseNum> Mul<Pnt3<N>> for UnitQuat<N> {
} }
} }
impl<N: BaseNum> Mul<UnitQuat<N>> for Vec3<N> { impl<N: BaseNum + Neg<Output = N>> Mul<UnitQuat<N>> for Vec3<N> {
type Output = Vec3<N>; type Output = Vec3<N>;
#[inline] #[inline]
@ -377,7 +377,7 @@ impl<N: BaseNum> Mul<UnitQuat<N>> for Vec3<N> {
} }
} }
impl<N: BaseNum> Mul<UnitQuat<N>> for Pnt3<N> { impl<N: BaseNum + Neg<Output = N>> Mul<UnitQuat<N>> for Pnt3<N> {
type Output = Pnt3<N>; type Output = Pnt3<N>;
#[inline] #[inline]
@ -432,7 +432,7 @@ impl<N: BaseFloat> Rotation<Vec3<N>> for UnitQuat<N> {
} }
} }
impl<N: BaseNum> Rotate<Vec3<N>> for UnitQuat<N> { impl<N: BaseNum + Neg<Output = N>> Rotate<Vec3<N>> for UnitQuat<N> {
#[inline] #[inline]
fn rotate(&self, v: &Vec3<N>) -> Vec3<N> { fn rotate(&self, v: &Vec3<N>) -> Vec3<N> {
*self * *v *self * *v
@ -444,7 +444,7 @@ impl<N: BaseNum> Rotate<Vec3<N>> for UnitQuat<N> {
} }
} }
impl<N: BaseNum> Rotate<Pnt3<N>> for UnitQuat<N> { impl<N: BaseNum + Neg<Output = N>> Rotate<Pnt3<N>> for UnitQuat<N> {
#[inline] #[inline]
fn rotate(&self, p: &Pnt3<N>) -> Pnt3<N> { fn rotate(&self, p: &Pnt3<N>) -> Pnt3<N> {
*self * *p *self * *p
@ -456,7 +456,7 @@ impl<N: BaseNum> Rotate<Pnt3<N>> for UnitQuat<N> {
} }
} }
impl<N: BaseNum> Transform<Vec3<N>> for UnitQuat<N> { impl<N: BaseNum + Neg<Output = N>> Transform<Vec3<N>> for UnitQuat<N> {
#[inline] #[inline]
fn transform(&self, v: &Vec3<N>) -> Vec3<N> { fn transform(&self, v: &Vec3<N>) -> Vec3<N> {
*self * *v *self * *v
@ -468,7 +468,7 @@ impl<N: BaseNum> Transform<Vec3<N>> for UnitQuat<N> {
} }
} }
impl<N: BaseNum> Transform<Pnt3<N>> for UnitQuat<N> { impl<N: BaseNum + Neg<Output = N>> Transform<Pnt3<N>> for UnitQuat<N> {
#[inline] #[inline]
fn transform(&self, p: &Pnt3<N>) -> Pnt3<N> { fn transform(&self, p: &Pnt3<N>) -> Pnt3<N> {
*self * *p *self * *p

View File

@ -1,4 +1,4 @@
use std::ops::{Add, Mul}; use std::ops::{Add, Mul, Neg};
use structs::vec::{Vec2, Vec3}; use structs::vec::{Vec2, Vec3};
use structs::pnt::{Pnt2, Pnt3}; use structs::pnt::{Pnt2, Pnt3};
use structs::mat::{Mat1, Mat2, Mat3}; use structs::mat::{Mat1, Mat2, Mat3};
@ -32,7 +32,7 @@ impl<N: BaseNum + ApproxEq<N>> Inv for Mat1<N> {
} }
} }
impl<N: BaseNum + ApproxEq<N>> Inv for Mat2<N> { impl<N: BaseNum + Neg<Output = N> + ApproxEq<N>> Inv for Mat2<N> {
#[inline] #[inline]
fn inv(&self) -> Option<Mat2<N>> { fn inv(&self) -> Option<Mat2<N>> {
let mut res = *self; let mut res = *self;
@ -61,7 +61,7 @@ impl<N: BaseNum + ApproxEq<N>> Inv for Mat2<N> {
} }
} }
impl<N: BaseNum + ApproxEq<N>> Inv for Mat3<N> { impl<N: BaseNum + Neg<Output = N> + ApproxEq<N>> Inv for Mat3<N> {
#[inline] #[inline]
fn inv(&self) -> Option<Mat3<N>> { fn inv(&self) -> Option<Mat3<N>> {
let mut res = *self; let mut res = *self;

View File

@ -3,7 +3,7 @@
use std::{f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, isize, usize}; use std::{f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, isize, usize};
use std::num::Float; use std::num::Float;
use std::slice::{Iter, IterMut}; use std::slice::{Iter, IterMut};
use std::ops::{Add, Sub, Mul, Div, Neg, Rem, Index, IndexMut}; use std::ops::{Add, Sub, Mul, Div, Rem, Index, IndexMut};
use traits::operations::{RMul, LMul, Axpy, Transpose, Inv, Absolute}; use traits::operations::{RMul, LMul, Axpy, Transpose, Inv, Absolute};
use traits::geometry::{Dot, Norm, Orig}; use traits::geometry::{Dot, Norm, Orig};
@ -11,7 +11,7 @@ use traits::geometry::{Dot, Norm, Orig};
pub trait BaseNum: Copy + Zero + One + pub trait BaseNum: Copy + Zero + One +
Add<Self, Output = Self> + Sub<Self, Output = Self> + Add<Self, Output = Self> + Sub<Self, Output = Self> +
Mul<Self, Output = Self> + Div<Self, Output = Self> + Mul<Self, Output = Self> + Div<Self, Output = Self> +
Rem<Self, Output = Self> + Neg<Output = Self> + PartialEq + Rem<Self, Output = Self> + PartialEq +
Absolute<Self> + Axpy<Self> { Absolute<Self> + Axpy<Self> {
} }
@ -239,7 +239,6 @@ pub trait VecAsPnt<P> {
pub trait NumVec<N>: Dim + pub trait NumVec<N>: Dim +
Sub<Self, Output = Self> + Add<Self, Output = Self> + Sub<Self, Output = Self> + Add<Self, Output = Self> +
Mul<N, Output = Self> + Div<N, Output = Self> + Mul<N, Output = Self> + Div<N, Output = Self> +
Neg<Output = Self> +
Index<usize, Output = N> + Index<usize, Output = N> +
Zero + PartialEq + Dot<N> + Axpy<N> { Zero + PartialEq + Dot<N> + Axpy<N> {
} }
@ -276,7 +275,6 @@ pub trait NumPnt<N, V>:
PartialEq + PartialEq +
Axpy<N> + Axpy<N> +
Sub<Self, Output = V> + Sub<Self, Output = V> +
Neg<Output = Self> +
Mul<N, Output = Self> + Mul<N, Output = Self> +
Div<N, Output = Self> + Div<N, Output = Self> +
Add<V, Output = Self> + Add<V, Output = Self> +