diff --git a/src/quaternion.rs b/src/quaternion.rs index 8ab4b17..46c0025 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -28,7 +28,7 @@ use array::Array1; use matrix::{Matrix3, Matrix4}; use num::BaseFloat; use point::Point3; -use rotation::{Rotation, Rotation3, Basis3, ToBasis3}; +use rotation::{Rotation, Rotation3, Basis3}; use vector::{Vector3, Vector, EuclideanVector}; @@ -382,9 +382,9 @@ impl fmt::Debug for Quaternion { // Quaternion Rotation impls -impl ToBasis3 for Quaternion { +impl From> for Basis3 { #[inline] - fn to_rot3(&self) -> Basis3 { Basis3::from_quaternion(self) } + fn from(quat: Quaternion) -> Basis3 { Basis3::from_quaternion(&quat) } } impl ToQuaternion for Quaternion { diff --git a/src/rotation.rs b/src/rotation.rs index 1e65e03..f9ad20f 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -76,7 +76,7 @@ pub trait Rotation, P: Point>: PartialEq + Approx /// A two-dimensional rotation. pub trait Rotation2: Rotation, Point2> + Into> - + ToBasis2 { + + Into> { /// Create a rotation by a given angle. Thus is a redundant case of both /// from_axis_angle() and from_euler() for 2D space. fn from_angle(theta: Rad) -> Self; @@ -85,7 +85,7 @@ pub trait Rotation2: Rotation, Point2> /// A three-dimensional rotation. pub trait Rotation3: Rotation, Point3> + Into> - + ToBasis3 + + Into> + ToQuaternion{ /// Create a rotation using an angle around a given axis. fn from_axis_angle(axis: &Vector3, angle: Rad) -> Self; @@ -174,17 +174,6 @@ impl AsRef> for Basis2 { } } -/// Represents types which can be converted to a rotation matrix. -pub trait ToBasis2 { - /// Convert this type to a rotation matrix. - fn to_rot2(&self) -> Basis2; -} - -impl ToBasis2 for Basis2 { - #[inline] - fn to_rot2(&self) -> Basis2 { self.clone() } -} - impl From> for Matrix2 { #[inline] fn from(b: Basis2) -> Matrix2 { b.mat } @@ -261,17 +250,6 @@ impl AsRef> for Basis3 { } } -/// Represents types which can be converted to a rotation matrix. -pub trait ToBasis3 { - /// Convert this type to a rotation matrix. - fn to_rot3(&self) -> Basis3; -} - -impl ToBasis3 for Basis3 { - #[inline] - fn to_rot3(&self) -> Basis3 { self.clone() } -} - impl From> for Matrix3 { #[inline] fn from(b: Basis3) -> Matrix3 { b.mat } @@ -294,7 +272,7 @@ impl Rotation, Point3> for Basis3 { #[inline] fn between_vectors(a: &Vector3, b: &Vector3) -> Basis3 { let q: Quaternion = Rotation::between_vectors(a, b); - q.to_rot3() + q.into() } #[inline]