use std::ops::{Mul, MulAssign, Div, DivAssign}; use alga::general::{ClosedAdd, ClosedSub}; use core::{DefaultAllocator, Scalar}; use core::dimension::{DimName, U1}; use core::constraint::{ShapeConstraint, SameNumberOfRows, SameNumberOfColumns}; use core::allocator::{Allocator, SameShapeAllocator}; use geometry::{Point, Translation}; // Translation × Translation add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a Translation, right: &'b Translation, Output = Translation; Translation::from_vector(&self.vector + &right.vector); 'a, 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a Translation, right: Translation, Output = Translation; Translation::from_vector(&self.vector + right.vector); 'a); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: Translation, right: &'b Translation, Output = Translation; Translation::from_vector(self.vector + &right.vector); 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: Translation, right: Translation, Output = Translation; Translation::from_vector(self.vector + right.vector); ); // Translation ÷ Translation // 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 Translation, right: &'b Translation, Output = Translation; Translation::from_vector(&self.vector - &right.vector); 'a, 'b); add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a Translation, right: Translation, Output = Translation; Translation::from_vector(&self.vector - right.vector); 'a); add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: Translation, right: &'b Translation, Output = Translation; Translation::from_vector(self.vector - &right.vector); 'b); add_sub_impl!(Div, div, ClosedSub; (D, U1), (D, U1) -> (D) for D: DimName; self: Translation, right: Translation, Output = Translation; Translation::from_vector(self.vector - right.vector); ); // Translation × Point // 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 Translation, right: &'b Point, Output = Point; right + &self.vector; 'a, 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: &'a Translation, right: Point, Output = Point; right + &self.vector; 'a); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: Translation, right: &'b Point, Output = Point; right + self.vector; 'b); add_sub_impl!(Mul, mul, ClosedAdd; (D, U1), (D, U1) -> (D) for D: DimName; self: Translation, right: Point, Output = Point; right + self.vector; ); // Translation *= Translation add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; (D, U1), (D, U1) for D: DimName; self: Translation, right: &'b Translation; self.vector += &right.vector; 'b); add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; (D, U1), (D, U1) for D: DimName; self: Translation, right: Translation; self.vector += right.vector; ); add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; (D, U1), (D, U1) for D: DimName; self: Translation, right: &'b Translation; self.vector -= &right.vector; 'b); add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; (D, U1), (D, U1) for D: DimName; self: Translation, right: Translation; self.vector -= right.vector; ); /* // Translation × Matrix add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: &'a Translation, right: &'b Matrix, Output = MatrixMN; self.vector() * right; 'a, 'b); add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: &'a Translation, right: Matrix, Output = MatrixMN; self.vector() * right; 'a); add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: Translation, right: &'b Matrix, Output = MatrixMN; self.unwrap() * right; 'b); add_sub_impl!(Mul, mul; (D1, D1), (R2, C2) for D1, R2, C2; self: Translation, right: Matrix, Output = MatrixMN; self.unwrap() * right; ); // Matrix × Translation add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: &'a Matrix, right: &'b Translation, Output = MatrixMN; self * right.vector(); 'a, 'b); add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: &'a Matrix, right: Translation, Output = MatrixMN; self * right.unwrap(); 'a); add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: Matrix, right: &'b Translation, Output = MatrixMN; self * right.vector(); 'b); add_sub_impl!(Mul, mul; (R1, C1), (D2, D2) for R1, C1, D2; self: Matrix, right: Translation, Output = MatrixMN; self * right.unwrap(); ); // Matrix *= Translation md_assign_impl!(MulAssign, mul_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: &'b Translation; self.mul_assign(right.vector()); 'b); md_assign_impl!(MulAssign, mul_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: Translation; self.mul_assign(right.unwrap()); ); md_assign_impl!(DivAssign, div_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: &'b Translation; self.mul_assign(right.inverse().vector()); 'b); md_assign_impl!(DivAssign, div_assign; (R1, C1), (C1, C1) for R1, C1; self: Matrix, right: Translation; self.mul_assign(right.inverse().unwrap()); ); */