Add delta-transformation implementations.
This commit is contained in:
parent
f3ed302874
commit
b2d17300d9
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
*.swp
|
||||
doc
|
||||
lib
|
||||
|
@ -7,18 +7,24 @@ use traits::dim::Dim;
|
||||
use traits::inv::Inv;
|
||||
use traits::transpose::Transpose;
|
||||
use traits::rotation::Rotation;
|
||||
use traits::delta_transform::DeltaTransform;
|
||||
use dim1::vec1::{Vec1, vec1};
|
||||
use dim2::mat2::{Mat2, mat2};
|
||||
use dim3::mat3::{Mat3, mat3};
|
||||
use dim3::vec3::{Vec3};
|
||||
|
||||
// FIXME: use a newtype here?
|
||||
#[deriving(Eq)]
|
||||
pub struct Rotmat<M>
|
||||
{
|
||||
priv submat: M
|
||||
}
|
||||
|
||||
impl<M: Copy> Rotmat<M>
|
||||
{
|
||||
fn submat(&self) -> M
|
||||
{ self.submat }
|
||||
}
|
||||
|
||||
pub fn rotmat2<T: Copy + Trigonometric + Neg<T>>(angle: T) -> Rotmat<Mat2<T>>
|
||||
{
|
||||
let coa = Trigonometric::cos(angle);
|
||||
@ -130,8 +136,13 @@ impl<V, M: LMul<V>> LMul<V> for Rotmat<M>
|
||||
{ self.submat.lmul(other) }
|
||||
}
|
||||
|
||||
impl<M: Copy + Transpose>
|
||||
Inv for Rotmat<M>
|
||||
impl<M: Copy> DeltaTransform<M> for Rotmat<M>
|
||||
{
|
||||
fn delta_transform(&self) -> M
|
||||
{ self.submat }
|
||||
}
|
||||
|
||||
impl<M: Copy + Transpose> Inv for Rotmat<M>
|
||||
{
|
||||
fn invert(&mut self)
|
||||
{ self.transpose() }
|
||||
|
@ -6,15 +6,17 @@ use traits::inv::Inv;
|
||||
use traits::rotation::Rotation;
|
||||
use traits::translation::Translation;
|
||||
use traits::transpose::Transpose;
|
||||
use traits::delta_transform::DeltaTransform;
|
||||
use traits::workarounds::rlmul::{RMul, LMul};
|
||||
|
||||
pub struct Transform<M, V>
|
||||
{
|
||||
submat : M,
|
||||
subtrans : V
|
||||
priv submat : M,
|
||||
priv subtrans : V
|
||||
}
|
||||
|
||||
pub fn transform<M: Copy, V: Copy>(mat: &M, trans: &V) -> Transform<M, V>
|
||||
pub fn transform<M: Copy, V: Copy>(mat: &M, trans: &V)
|
||||
-> Transform<M, V>
|
||||
{ Transform { submat: *mat, subtrans: *trans } }
|
||||
|
||||
impl<M:Dim, V> Dim for Transform<M, V>
|
||||
@ -95,6 +97,12 @@ Rotation<V> for Transform<M, V>
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Copy, V> DeltaTransform<M> for Transform<M, V>
|
||||
{
|
||||
fn delta_transform(&self) -> M
|
||||
{ self.submat }
|
||||
}
|
||||
|
||||
impl<M:Copy + Transpose + Inv + RMul<V>, V:Copy + Neg<V>>
|
||||
Inv for Transform<M, V>
|
||||
{
|
||||
|
@ -48,6 +48,10 @@ mod traits
|
||||
mod norm;
|
||||
mod rotation;
|
||||
mod translation;
|
||||
mod delta_transform;
|
||||
mod vector_space;
|
||||
mod ring;
|
||||
mod division_ring;
|
||||
|
||||
mod workarounds
|
||||
{
|
||||
|
@ -4,8 +4,6 @@ use core::num::{One, abs};
|
||||
use core::rand::{random};
|
||||
#[test]
|
||||
use std::cmp::FuzzyEq;
|
||||
// #[test]
|
||||
// use ndim::nmat::NMat;
|
||||
#[test]
|
||||
use traits::inv::Inv;
|
||||
#[test]
|
||||
@ -20,8 +18,6 @@ use dim2::mat2::Mat2;
|
||||
use dim3::mat3::Mat3;
|
||||
#[test]
|
||||
use adaptors::rotmat::Rotmat;
|
||||
// #[test]
|
||||
// use traits::dim::d7;
|
||||
|
||||
// FIXME: this one fails with an ICE: node_id_to_type: no type for node [...]
|
||||
// #[test]
|
||||
|
Loading…
Reference in New Issue
Block a user