Implement inversions for AngleAxis rotations
This commit is contained in:
parent
7eb8bc50c9
commit
eade6cc18f
1 changed files with 17 additions and 4 deletions
|
@ -270,8 +270,8 @@ impl<S: Float> Rotation3<S> for Quat<S> {
|
||||||
/// # Notes
|
/// # Notes
|
||||||
///
|
///
|
||||||
/// Whilst Euler angles are more intuitive to specify than quaternions,
|
/// Whilst Euler angles are more intuitive to specify than quaternions,
|
||||||
/// they are not reccomended for general use because they are prone to gimble
|
/// they are not recommended for general use because they are prone to gimble
|
||||||
/// lock.
|
/// lock, and are hard to interpolate between.
|
||||||
#[deriving(Eq, Clone)]
|
#[deriving(Eq, Clone)]
|
||||||
pub struct Euler<A> { x: A, y: A, z: A }
|
pub struct Euler<A> { x: A, y: A, z: A }
|
||||||
|
|
||||||
|
@ -368,9 +368,18 @@ impl<S: Float, A: Angle<S>> ApproxEq<S> for Euler<A> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A rotation about an arbitrary axis
|
/// A rotation about an arbitrary axis
|
||||||
|
///
|
||||||
|
/// # Fields
|
||||||
|
///
|
||||||
|
/// - `v`: the axis of rotation
|
||||||
|
/// - `a`: the angular rotation
|
||||||
#[deriving(Eq, Clone)]
|
#[deriving(Eq, Clone)]
|
||||||
pub struct AxisAngle<S, A> { v: Vec3<S>, a: A }
|
pub struct AxisAngle<S, A> { v: Vec3<S>, a: A }
|
||||||
|
|
||||||
|
pub trait ToAxisAngle<S, A> {
|
||||||
|
fn to_axis_angle(&self) -> AxisAngle<S, A>;
|
||||||
|
}
|
||||||
|
|
||||||
impl<S: Float, A: Angle<S>> AxisAngle<S, A> {
|
impl<S: Float, A: Angle<S>> AxisAngle<S, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(v: Vec3<S>, a: A) -> AxisAngle<S, A> {
|
pub fn new(v: Vec3<S>, a: A) -> AxisAngle<S, A> {
|
||||||
|
@ -431,10 +440,14 @@ impl<S: Float, A: Angle<S>> Rotation3<S> for AxisAngle<S, A> {
|
||||||
fn concat_self(&mut self, _other: &AxisAngle<S, A>) { fail!("Not yet implemented"); }
|
fn concat_self(&mut self, _other: &AxisAngle<S, A>) { fail!("Not yet implemented"); }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn invert(&self) -> AxisAngle<S, A> { fail!("Not yet implemented") }
|
fn invert(&self) -> AxisAngle<S, A> {
|
||||||
|
AxisAngle::new(self.v.clone(), (-self.a).normalize())
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn invert_self(&mut self) { fail!("Not yet implemented"); }
|
fn invert_self(&mut self) {
|
||||||
|
self.a = (-self.a).normalize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Float, A: Angle<S>> ApproxEq<S> for AxisAngle<S, A> {
|
impl<S: Float, A: Angle<S>> ApproxEq<S> for AxisAngle<S, A> {
|
||||||
|
|
Loading…
Reference in a new issue