2013-08-23 21:59:26 +08:00
|
|
|
use std::num::{One, Zero};
|
2013-10-06 22:54:09 +08:00
|
|
|
use structs::mat;
|
2013-09-22 16:58:21 +08:00
|
|
|
use traits::operations::{Inv, Transpose};
|
|
|
|
use traits::geometry::{Translation, Translate, Rotation, Rotate, Transformation, Transform};
|
2013-08-23 21:59:26 +08:00
|
|
|
|
|
|
|
impl One for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn one() -> mat::Identity {
|
2013-08-23 22:29:08 +08:00
|
|
|
mat::Identity::new()
|
2013-08-23 21:59:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Inv for mat::Identity {
|
2013-10-06 22:54:09 +08:00
|
|
|
fn inverted(&self) -> Option<mat::Identity> {
|
2013-08-23 22:29:08 +08:00
|
|
|
Some(mat::Identity::new())
|
2013-08-23 21:59:26 +08:00
|
|
|
}
|
|
|
|
|
2013-10-06 22:54:09 +08:00
|
|
|
fn invert(&mut self) -> bool {
|
2013-08-23 21:59:26 +08:00
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-15 16:48:18 +08:00
|
|
|
impl<T: Clone> Mul<T, T> for mat::Identity {
|
2013-08-23 21:59:26 +08:00
|
|
|
#[inline]
|
2013-09-15 16:48:18 +08:00
|
|
|
fn mul(&self, other: &T) -> T {
|
2013-08-23 21:59:26 +08:00
|
|
|
other.clone()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Transpose for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn transposed(&self) -> mat::Identity {
|
2013-08-23 22:29:08 +08:00
|
|
|
mat::Identity::new()
|
2013-08-23 21:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn transpose(&mut self) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<V: Zero> Translation<V> for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn translation(&self) -> V {
|
|
|
|
Zero::zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn inv_translation(&self) -> V {
|
|
|
|
Zero::zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn translate_by(&mut self, _: &V) {
|
|
|
|
fail!("Attempted to translate the identity matrix.")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn translated(&self, _: &V) -> mat::Identity {
|
|
|
|
fail!("Attempted to translate the identity matrix.")
|
|
|
|
}
|
2013-09-06 14:48:08 +08:00
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn set_translation(&mut self, _: V) {
|
|
|
|
fail!("Attempted to translate the identity matrix.")
|
|
|
|
}
|
2013-08-23 21:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<V: Clone> Translate<V> for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn translate(&self, v: &V) -> V {
|
|
|
|
v.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn inv_translate(&self, v: &V) -> V {
|
|
|
|
v.clone()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<V: Zero> Rotation<V> for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn rotation(&self) -> V {
|
|
|
|
Zero::zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn inv_rotation(&self) -> V {
|
|
|
|
Zero::zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn rotate_by(&mut self, _: &V) {
|
|
|
|
fail!("Attempted to rotate the identity matrix.")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn rotated(&self, _: &V) -> mat::Identity {
|
|
|
|
fail!("Attempted to rotate the identity matrix.")
|
|
|
|
}
|
2013-09-06 14:48:08 +08:00
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn set_rotation(&mut self, _: V) {
|
|
|
|
fail!("Attempted to rotate the identity matrix.")
|
|
|
|
}
|
2013-08-23 21:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<V: Clone> Rotate<V> for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn rotate(&self, v: &V) -> V {
|
|
|
|
v.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn inv_rotate(&self, v: &V) -> V {
|
|
|
|
v.clone()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<M: One> Transformation<M> for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn transformation(&self) -> M {
|
|
|
|
One::one()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn inv_transformation(&self) -> M {
|
|
|
|
One::one()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn transform_by(&mut self, _: &M) {
|
|
|
|
fail!("Attempted to transform the identity matrix.")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn transformed(&self, _: &M) -> mat::Identity {
|
|
|
|
fail!("Attempted to transform the identity matrix.")
|
|
|
|
}
|
2013-09-06 14:48:08 +08:00
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn set_transformation(&mut self, _: M) {
|
|
|
|
fail!("Attempted to transform the identity matrix.")
|
|
|
|
}
|
2013-08-23 21:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<V: Clone> Transform<V> for mat::Identity {
|
|
|
|
#[inline]
|
|
|
|
fn transform(&self, v: &V) -> V {
|
|
|
|
v.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn inv_transform(&self, v: &V) -> V {
|
|
|
|
v.clone()
|
|
|
|
}
|
|
|
|
}
|