From 948341685efe929b86c8656bf2927afaba2547ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 15 Nov 2015 21:38:23 +0100 Subject: [PATCH] Add implementation of `RotationMatrix` for `UnitQuat`. --- src/structs/quat.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/structs/quat.rs b/src/structs/quat.rs index 604a1e20..a8664ef5 100644 --- a/src/structs/quat.rs +++ b/src/structs/quat.rs @@ -12,7 +12,7 @@ use structs::{Vec3, Pnt3, Rot3, Mat3}; use traits::operations::{ApproxEq, Inv, POrd, POrdering, Axpy}; use traits::structure::{Cast, Indexable, Iterable, IterableMut, Dim, Shape, BaseFloat, BaseNum, Bounded, Repeat}; -use traits::geometry::{Norm, Rotation, Rotate, RotationTo, Transform}; +use traits::geometry::{Norm, Rotation, RotationMatrix, Rotate, RotationTo, Transform}; #[cfg(feature="arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -156,6 +156,8 @@ impl + BaseFloat> Div> for Quat { } } +rand_impl!(Quat, w, i, j, k); + /// A unit quaternion that can represent a 3D rotation. #[repr(C)] @@ -246,8 +248,6 @@ impl UnitQuat { } } -rand_impl!(Quat, w, i, j, k); - impl UnitQuat { /// Creates a new unit quaternion from a quaternion. @@ -432,6 +432,15 @@ impl Rotation> for UnitQuat { } } +impl RotationMatrix, Vec3> for UnitQuat { + type Output = Rot3; + + #[inline] + fn to_rot_mat(&self) -> Rot3 { + self.to_rot() + } +} + impl> Rotate> for UnitQuat { #[inline] fn rotate(&self, v: &Vec3) -> Vec3 {