use std::ops::{Mul, MulAssign, Div, DivAssign}; use alga::general::{ClosedAdd, ClosedSub}; use core::Scalar; use core::dimension::{DimName, U1}; use core::constraint::{ShapeConstraint, SameNumberOfRows, SameNumberOfColumns}; use core::storage::{OwnedStorage, Storage}; use core::allocator::{OwnedAllocator, SameShapeAllocator}; use geometry::{PointBase, OwnedPoint, TranslationBase, OwnedTranslation}; // TranslationBase × TranslationBase add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a TranslationBase, right: &'b TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(&self.vector + &right.vector); 'a, 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a TranslationBase, right: TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(&self.vector + right.vector); 'a); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: TranslationBase, right: &'b TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(self.vector + &right.vector); 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: TranslationBase, right: TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(self.vector + right.vector); ); // TranslationBase ÷ TranslationBase // FIXME: instead of calling inverse explicitely, could we just add a `mul_tr` or `mul_inv` method? add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a TranslationBase, right: &'b TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(&self.vector - &right.vector); 'a, 'b); add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a TranslationBase, right: TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(&self.vector - right.vector); 'a); add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: TranslationBase, right: &'b TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(self.vector - &right.vector); 'b); add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: TranslationBase, right: TranslationBase, Output = OwnedTranslation; TranslationBase::from_vector(self.vector - right.vector); ); // TranslationBase × PointBase // FIXME: we don't handle properly non-zero origins here. Do we want this to be the intended // behavior? add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a TranslationBase, right: &'b PointBase, Output = OwnedPoint; right + &self.vector; 'a, 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a TranslationBase, right: PointBase, Output = OwnedPoint; right + &self.vector; 'a); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: TranslationBase, right: &'b PointBase, Output = OwnedPoint; right + self.vector; 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: TranslationBase, right: PointBase, Output = OwnedPoint; right + self.vector; ); // TranslationBase *= TranslationBase add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; (D, U1), (D, U1) for D: DimName; self: TranslationBase, right: &'b TranslationBase; self.vector += &right.vector; 'b); add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; (D, U1), (D, U1) for D: DimName; self: TranslationBase, right: TranslationBase; self.vector += right.vector; ); add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; (D, U1), (D, U1) for D: DimName; self: TranslationBase, right: &'b TranslationBase; self.vector -= &right.vector; 'b); add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; (D, U1), (D, U1) for D: DimName; self: TranslationBase, right: TranslationBase; self.vector -= right.vector; ); /* // TranslationBase × Matrix add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: &'a TranslationBase, right: &'b Matrix, Output = MatrixMul; self.vector() * right; 'a, 'b); add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: &'a TranslationBase, right: Matrix, Output = MatrixMul; self.vector() * right; 'a); add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: TranslationBase, right: &'b Matrix, Output = MatrixMul; self.unwrap() * right; 'b); add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: TranslationBase, right: Matrix, Output = MatrixMul; self.unwrap() * right; ); // Matrix × TranslationBase add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: &'a Matrix, right: &'b TranslationBase, Output = MatrixMul; self * right.vector(); 'a, 'b); add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: &'a Matrix, right: TranslationBase, Output = MatrixMul; self * right.unwrap(); 'a); add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: Matrix, right: &'b TranslationBase, Output = MatrixMul; self * right.vector(); 'b); add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: Matrix, right: TranslationBase, Output = MatrixMul; self * right.unwrap(); ); // Matrix *= TranslationBase md_assign_impl!(MulAssign, mul_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: &'b TranslationBase; self.mul_assign(right.vector()); 'b); md_assign_impl!(MulAssign, mul_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: TranslationBase; self.mul_assign(right.unwrap()); ); md_assign_impl!(DivAssign, div_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: &'b TranslationBase; self.mul_assign(right.inverse().vector()); 'b); md_assign_impl!(DivAssign, div_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: TranslationBase; self.mul_assign(right.inverse().unwrap()); ); */