diff --git a/src/cgmath/rotation.rs b/src/cgmath/rotation.rs index 0d5e53c..2922dec 100644 --- a/src/cgmath/rotation.rs +++ b/src/cgmath/rotation.rs @@ -270,8 +270,8 @@ impl Rotation3 for Quat { /// # Notes /// /// Whilst Euler angles are more intuitive to specify than quaternions, -/// they are not reccomended for general use because they are prone to gimble -/// lock. +/// they are not recommended for general use because they are prone to gimble +/// lock, and are hard to interpolate between. #[deriving(Eq, Clone)] pub struct Euler { x: A, y: A, z: A } @@ -368,9 +368,18 @@ impl> ApproxEq for Euler { } /// A rotation about an arbitrary axis +/// +/// # Fields +/// +/// - `v`: the axis of rotation +/// - `a`: the angular rotation #[deriving(Eq, Clone)] pub struct AxisAngle { v: Vec3, a: A } +pub trait ToAxisAngle { + fn to_axis_angle(&self) -> AxisAngle; +} + impl> AxisAngle { #[inline] pub fn new(v: Vec3, a: A) -> AxisAngle { @@ -431,10 +440,14 @@ impl> Rotation3 for AxisAngle { fn concat_self(&mut self, _other: &AxisAngle) { fail!("Not yet implemented"); } #[inline] - fn invert(&self) -> AxisAngle { fail!("Not yet implemented") } + fn invert(&self) -> AxisAngle { + AxisAngle::new(self.v.clone(), (-self.a).normalize()) + } #[inline] - fn invert_self(&mut self) { fail!("Not yet implemented"); } + fn invert_self(&mut self) { + self.a = (-self.a).normalize() + } } impl> ApproxEq for AxisAngle {