1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use std::ops::Mul;
use num::One;
use structs::matrix::Identity;
use traits::operations::{Inverse, Transpose};
use traits::geometry::{Translate, Rotate, Transform, AbsoluteRotate};

impl One for Identity {
    #[inline]
    fn one() -> Identity {
        Identity::new()
    }
}

impl Inverse for Identity {
    fn inverse(&self) -> Option<Identity> {
        Some(Identity::new())
    }

    fn inverse_mut(&mut self) -> bool {
        true
    }
}

impl<T: Clone> Mul<T> for Identity {
    type Output = T;

    #[inline]
    fn mul(self, other: T) -> T {
        other
    }
}

impl Transpose for Identity {
    #[inline]
    fn transpose(&self) -> Identity {
        Identity::new()
    }

    #[inline]
    fn transpose_mut(&mut self) {
    }
}

impl<V: Clone> Translate<V> for Identity {
    #[inline]
    fn translate(&self, v: &V) -> V {
        v.clone()
    }

    #[inline]
    fn inverse_translate(&self, v: &V) -> V {
        v.clone()
    }
}

impl<V: Clone> Rotate<V> for Identity {
    #[inline]
    fn rotate(&self, v: &V) -> V {
        v.clone()
    }

    #[inline]
    fn inverse_rotate(&self, v: &V) -> V {
        v.clone()
    }
}

impl<V: Clone> AbsoluteRotate<V> for Identity {
    #[inline]
    fn absolute_rotate(&self, v: &V) -> V {
        v.clone()
    }
}

impl<V: Clone> Transform<V> for Identity {
    #[inline]
    fn transform(&self, v: &V) -> V {
        v.clone()
    }

    #[inline]
    fn inverse_transform(&self, v: &V) -> V {
        v.clone()
    }
}