Add DeltaTransformVector tait and fix transformation.
This commit is contained in:
parent
fb20ffdf8b
commit
4cc5b178c8
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ nalgebra_lib_path=lib
|
||||||
nalgebra_doc_path=doc
|
nalgebra_doc_path=doc
|
||||||
all:
|
all:
|
||||||
mkdir -p $(nalgebra_lib_path)
|
mkdir -p $(nalgebra_lib_path)
|
||||||
rust build src/nalgebra.rc --out-dir $(nalgebra_lib_path)
|
rust build src/nalgebra.rc --out-dir $(nalgebra_lib_path) --opt-level 3
|
||||||
|
|
||||||
test:
|
test:
|
||||||
mkdir -p $(nalgebra_lib_path)
|
mkdir -p $(nalgebra_lib_path)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use traits::dim::Dim;
|
||||||
use traits::inv::Inv;
|
use traits::inv::Inv;
|
||||||
use traits::transpose::Transpose;
|
use traits::transpose::Transpose;
|
||||||
use traits::rotation::Rotation;
|
use traits::rotation::Rotation;
|
||||||
use traits::delta_transform::DeltaTransform;
|
use traits::delta_transform::{DeltaTransform, DeltaTransformVector};
|
||||||
use dim1::vec1::Vec1;
|
use dim1::vec1::Vec1;
|
||||||
use dim2::mat2::Mat2;
|
use dim2::mat2::Mat2;
|
||||||
use dim3::mat3::Mat3;
|
use dim3::mat3::Mat3;
|
||||||
|
@ -141,6 +141,12 @@ impl<M: Copy> DeltaTransform<M> for Rotmat<M>
|
||||||
{ self.submat }
|
{ self.submat }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<M: RMul<V> + Copy, V: Copy> DeltaTransformVector<V> for Rotmat<M>
|
||||||
|
{
|
||||||
|
fn delta_transform_vector(&self, v: &V) -> V
|
||||||
|
{ self.submat.rmul(v) }
|
||||||
|
}
|
||||||
|
|
||||||
impl<M: Copy + Transpose> Inv for Rotmat<M>
|
impl<M: Copy + Transpose> Inv for Rotmat<M>
|
||||||
{
|
{
|
||||||
fn invert(&mut self)
|
fn invert(&mut self)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use traits::inv::Inv;
|
||||||
use traits::rotation::Rotation;
|
use traits::rotation::Rotation;
|
||||||
use traits::translation::Translation;
|
use traits::translation::Translation;
|
||||||
use traits::transpose::Transpose;
|
use traits::transpose::Transpose;
|
||||||
use traits::delta_transform::DeltaTransform;
|
use traits::delta_transform::{DeltaTransform, DeltaTransformVector};
|
||||||
use traits::workarounds::rlmul::{RMul, LMul};
|
use traits::workarounds::rlmul::{RMul, LMul};
|
||||||
|
|
||||||
#[deriving(Eq, ToStr)]
|
#[deriving(Eq, ToStr)]
|
||||||
|
@ -51,16 +51,16 @@ Mul<Transform<M, V>, Transform<M, V>> for Transform<M, V>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RMul<V>, V> RMul<V> for Transform<M, V>
|
impl<M: RMul<V>, V: Add<V, V>> RMul<V> for Transform<M, V>
|
||||||
{
|
{
|
||||||
fn rmul(&self, other: &V) -> V
|
fn rmul(&self, other: &V) -> V
|
||||||
{ self.submat.rmul(other) }
|
{ self.submat.rmul(other) + self.subtrans }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: LMul<V>, V> LMul<V> for Transform<M, V>
|
impl<M: LMul<V>, V: Add<V, V>> LMul<V> for Transform<M, V>
|
||||||
{
|
{
|
||||||
fn lmul(&self, other: &V) -> V
|
fn lmul(&self, other: &V) -> V
|
||||||
{ self.submat.lmul(other) }
|
{ self.submat.lmul(other) + self.subtrans }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: Copy, V: Copy + Translation<V>> Translation<V> for Transform<M, V>
|
impl<M: Copy, V: Copy + Translation<V>> Translation<V> for Transform<M, V>
|
||||||
|
@ -104,6 +104,12 @@ impl<M: Copy, V> DeltaTransform<M> for Transform<M, V>
|
||||||
{ self.submat }
|
{ self.submat }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<M: RMul<V> + Copy, V> DeltaTransformVector<V> for Transform<M, V>
|
||||||
|
{
|
||||||
|
fn delta_transform_vector(&self, v: &V) -> V
|
||||||
|
{ self.submat.rmul(v) }
|
||||||
|
}
|
||||||
|
|
||||||
impl<M:Copy + Transpose + Inv + RMul<V>, V:Copy + Neg<V>>
|
impl<M:Copy + Transpose + Inv + RMul<V>, V:Copy + Neg<V>>
|
||||||
Inv for Transform<M, V>
|
Inv for Transform<M, V>
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,13 @@ pub trait DeltaTransform<DT>
|
||||||
{
|
{
|
||||||
/// Extracts the delta transformation associated with this transformation.
|
/// Extracts the delta transformation associated with this transformation.
|
||||||
fn delta_transform(&self) -> DT;
|
fn delta_transform(&self) -> DT;
|
||||||
// FIXME: add functions to apply the delta-transform to a vector without
|
}
|
||||||
// explicit computation of the transform (does this avoid some matrix copy?)
|
|
||||||
|
/**
|
||||||
|
* Trait of delta-transformations on vectors.
|
||||||
|
*/
|
||||||
|
pub trait DeltaTransformVector<V>
|
||||||
|
{
|
||||||
|
/// Applies a delta-transform to a vector.
|
||||||
|
fn delta_transform_vector(&self, &V) -> V;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue