2016-12-05 05:44:42 +08:00
|
|
|
use std::mem;
|
2017-02-13 01:17:09 +08:00
|
|
|
use std::ops::{Deref, DerefMut};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
use alga::general::Real;
|
|
|
|
|
|
|
|
use core::coordinates::IJKW;
|
|
|
|
use core::storage::OwnedStorage;
|
|
|
|
use core::allocator::OwnedAllocator;
|
|
|
|
use core::dimension::{U1, U4};
|
|
|
|
|
|
|
|
use geometry::QuaternionBase;
|
|
|
|
|
|
|
|
|
|
|
|
impl<N, S> Deref for QuaternionBase<N, S>
|
|
|
|
where N: Real,
|
|
|
|
S: OwnedStorage<N, U4, U1>,
|
|
|
|
S::Alloc: OwnedAllocator<N, U4, U1, S> {
|
|
|
|
type Target = IJKW<N>;
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
unsafe { mem::transmute(self) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N, S> DerefMut for QuaternionBase<N, S>
|
|
|
|
where N: Real,
|
|
|
|
S: OwnedStorage<N, U4, U1>,
|
|
|
|
S::Alloc: OwnedAllocator<N, U4, U1, S> {
|
|
|
|
#[inline]
|
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
|
|
unsafe { mem::transmute(self) }
|
|
|
|
}
|
|
|
|
}
|