Have ToHomogeneous use &self in method signature

I find makes the syntax a bit lighter.
This commit is contained in:
Eduard Bopp 2014-11-21 17:00:39 +01:00
parent cb720dc86c
commit 733219d728
6 changed files with 14 additions and 14 deletions

View File

@ -318,13 +318,13 @@ macro_rules! inv_impl(
macro_rules! to_homogeneous_impl(
($t: ident, $th: ident) => (
impl<N: BaseNum + Clone> ToHomogeneous<$th<N>> for $t<N> {
fn to_homogeneous(m: &$t<N>) -> $th<N> {
let mut res = ToHomogeneous::to_homogeneous(&m.rotation);
fn to_homogeneous(&self) -> $th<N> {
let mut res = self.rotation.to_homogeneous();
// copy the translation
let dim = Dim::dim(None::<$th<N>>);
res.set_col(dim - 1, ToHomogeneous::to_homogeneous(m.translation.as_pnt()).to_vec());
res.set_col(dim - 1, self.translation.as_pnt().to_homogeneous().to_vec());
res
}

View File

@ -645,12 +645,12 @@ macro_rules! to_homogeneous_impl(
($t: ident, $t2: ident, $dim: expr, $dim2: expr) => (
impl<N: BaseNum + Clone> ToHomogeneous<$t2<N>> for $t<N> {
#[inline]
fn to_homogeneous(m: &$t<N>) -> $t2<N> {
fn to_homogeneous(&self) -> $t2<N> {
let mut res: $t2<N> = ::one();
for i in range(0u, $dim) {
for j in range(0u, $dim) {
res.set((i, j), m.at((i, j)))
res.set((i, j), self.at((i, j)))
}
}

View File

@ -101,11 +101,11 @@ macro_rules! pnt_as_vec_impl(
macro_rules! pnt_to_homogeneous_impl(
($t: ident, $t2: ident, $extra: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + One + Zero> ToHomogeneous<$t2<N>> for $t<N> {
fn to_homogeneous(v: &$t<N>) -> $t2<N> {
fn to_homogeneous(&self) -> $t2<N> {
let mut res: $t2<N> = Orig::orig();
res.$comp0 = v.$comp0.clone();
$( res.$compN = v.$compN.clone(); )*
res.$comp0 = self.$comp0.clone();
$( res.$compN = self.$compN.clone(); )*
res.$extra = ::one();
res

View File

@ -283,8 +283,8 @@ macro_rules! to_homogeneous_impl(
($t: ident, $tm: ident) => (
impl<N: BaseNum + Clone> ToHomogeneous<$tm<N>> for $t<N> {
#[inline]
fn to_homogeneous(m: &$t<N>) -> $tm<N> {
ToHomogeneous::to_homogeneous(&m.submat)
fn to_homogeneous(&self) -> $tm<N> {
self.submat.to_homogeneous()
}
}
)

View File

@ -696,11 +696,11 @@ macro_rules! bounded_impl(
macro_rules! vec_to_homogeneous_impl(
($t: ident, $t2: ident, $extra: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + One + Zero> ToHomogeneous<$t2<N>> for $t<N> {
fn to_homogeneous(v: &$t<N>) -> $t2<N> {
fn to_homogeneous(&self) -> $t2<N> {
let mut res: $t2<N> = ::zero();
res.$comp0 = v.$comp0.clone();
$( res.$compN = v.$compN.clone(); )*
res.$comp0 = self.$comp0.clone();
$( res.$compN = self.$compN.clone(); )*
res
}

View File

@ -244,7 +244,7 @@ pub trait CrossMatrix<M> {
/// Traits of objects which can be put in homogeneous coordinates form.
pub trait ToHomogeneous<U> {
/// Gets the homogeneous coordinates form of this object.
fn to_homogeneous(&Self) -> U;
fn to_homogeneous(&self) -> U;
}
/// Traits of objects which can be build from an homogeneous coordinate form.