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