#[macro_escape]; macro_rules! submat_impl( ($t: ident, $submat: ident) => ( impl $t { #[inline] pub fn submat<'r>(&'r self) -> &'r $submat { &'r self.submat } } ) ) macro_rules! rotate_impl( ($t: ident, $tv: ident) => ( impl Rotate<$tv> for $t { #[inline] fn rotate(&self, v: &$tv) -> $tv { self * *v } #[inline] fn inv_rotate(&self, v: &$tv) -> $tv { v * *self } } ) ) macro_rules! transform_impl( ($t: ident, $tv: ident) => ( impl Transform<$tv> for $t { #[inline] fn transform(&self, v: &$tv) -> $tv { self.rotate(v) } #[inline] fn inv_transform(&self, v: &$tv) -> $tv { self.inv_rotate(v) } } ) ) macro_rules! dim_impl( ($t: ident, $dim: expr) => ( impl Dim for $t { #[inline] fn dim(_: Option<$t>) -> uint { $dim } } ) ) macro_rules! rotation_matrix_impl( ($t: ident, $tlv: ident, $tav: ident) => ( impl + Algebraic + Trigonometric + Num + Clone> RotationMatrix<$tlv, $tav, $t> for $t { #[inline] fn to_rot_mat(&self) -> $t { self.clone() } } ) ) macro_rules! one_impl( ($t: ident) => ( impl One for $t { #[inline] fn one() -> $t { $t { submat: One::one() } } } ) ) macro_rules! rot_mul_rot_impl( ($t: ident, $mulrhs: ident) => ( impl $mulrhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t { submat: left.submat * right.submat } } } ) ) macro_rules! rot_mul_vec_impl( ($t: ident, $tv: ident, $mulrhs: ident) => ( impl $mulrhs> for $tv { #[inline] fn binop(left: &$t, right: &$tv) -> $tv { left.submat * *right } } ) ) macro_rules! vec_mul_rot_impl( ($t: ident, $tv: ident, $mulrhs: ident) => ( impl $mulrhs> for $t { #[inline] fn binop(left: &$tv, right: &$t) -> $tv { *left * right.submat } } ) ) macro_rules! inv_impl( ($t: ident) => ( impl Inv for $t { #[inline] fn invert(&mut self) -> bool { self.transpose(); // always succeed true } #[inline] fn inverted(&self) -> Option<$t> { // always succeed Some(self.transposed()) } } ) ) macro_rules! transpose_impl( ($t: ident) => ( impl Transpose for $t { #[inline] fn transposed(&self) -> $t { $t { submat: self.submat.transposed() } } #[inline] fn transpose(&mut self) { self.submat.transpose() } } ) ) macro_rules! row_impl( ($t: ident, $tv: ident) => ( impl Row<$tv> for $t { #[inline] fn nrows(&self) -> uint { self.submat.nrows() } #[inline] fn row(&self, i: uint) -> $tv { self.submat.row(i) } #[inline] fn set_row(&mut self, i: uint, row: $tv) { self.submat.set_row(i, row); } } ) ) macro_rules! col_impl( ($t: ident, $tv: ident) => ( impl Col<$tv> for $t { #[inline] fn ncols(&self) -> uint { self.submat.ncols() } #[inline] fn col(&self, i: uint) -> $tv { self.submat.col(i) } #[inline] fn set_col(&mut self, i: uint, col: $tv) { self.submat.set_col(i, col); } } ) ) macro_rules! to_homogeneous_impl( ($t: ident, $tm: ident) => ( impl ToHomogeneous<$tm> for $t { #[inline] fn to_homogeneous(&self) -> $tm { self.submat.to_homogeneous() } } ) ) macro_rules! approx_eq_impl( ($t: ident) => ( impl> ApproxEq for $t { #[inline] fn approx_epsilon() -> N { // ApproxEq::::approx_epsilon() fail!("approx_epsilon is broken since rust revision 8693943676487c01fa09f5f3daf0df6a1f71e24d.") } #[inline] fn approx_eq(&self, other: &$t) -> bool { self.submat.approx_eq(&other.submat) } #[inline] fn approx_eq_eps(&self, other: &$t, epsilon: &N) -> bool { self.submat.approx_eq_eps(&other.submat, epsilon) } } ) ) macro_rules! absolute_impl( ($t: ident, $tm: ident) => ( impl Absolute<$tm> for $t { #[inline] fn absolute(&self) -> $tm { self.submat.absolute() } } ) )