Remove ToQuat trait

This commit is contained in:
Brendan Zabarauskas 2012-12-14 16:22:45 +10:00
parent 6c4c2fc1c8
commit b51e66b19a
3 changed files with 10 additions and 14 deletions

View file

@ -1,9 +1,8 @@
use core::cmp::Eq; use core::cmp::Eq;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
use angle::Angle; use angle::Angle;
use quat::ToQuat; use quat::Quat;
pub mod mat2; pub mod mat2;
pub mod mat3; pub mod mat3;
@ -257,9 +256,14 @@ pub trait Matrix2<T,V>: Matrix<T,V> {
/** /**
* A 3 x 3 matrix * A 3 x 3 matrix
*/ */
pub trait Matrix3<T,V>: Matrix<T,V> ToQuat<T> { pub trait Matrix3<T,V>: Matrix<T,V> {
static pure fn from_axis_angle<A:Angle<T>>(axis: &V, theta: A) -> Mat3<T>; static pure fn from_axis_angle<A:Angle<T>>(axis: &V, theta: A) -> Mat3<T>;
pure fn to_mat4(&self) -> Mat4<T>; pure fn to_mat4(&self) -> Mat4<T>;
/**
* Convert the matrix to a quaternion
*/
pure fn to_Quat() -> Quat<T>;
} }
/** /**

View file

@ -10,7 +10,7 @@ use funs::common::*;
use funs::exponential::*; use funs::exponential::*;
use funs::triganomic::{sin, cos}; use funs::triganomic::{sin, cos};
use num::types::{Float, Number}; use num::types::{Float, Number};
use quat::{Quat, ToQuat}; use quat::Quat;
use vec::Vec3; use vec::Vec3;
/** /**
@ -393,7 +393,7 @@ pub impl<T:Copy Float Sign> Mat3<T>: MutableMatrix<T, Vec3<T>> {
} }
} }
pub impl<T:Copy Float> Mat3<T>: Matrix3<T, Vec3<T>> { pub impl<T:Copy Float Exp> Mat3<T>: Matrix3<T, Vec3<T>> {
#[inline(always)] #[inline(always)]
static pure fn from_axis_angle<A:Angle<T>>(axis: &Vec3<T>, theta: A) -> Mat3<T> { static pure fn from_axis_angle<A:Angle<T>>(axis: &Vec3<T>, theta: A) -> Mat3<T> {
let c: T = cos(&theta.to_radians()); let c: T = cos(&theta.to_radians());
@ -415,9 +415,7 @@ pub impl<T:Copy Float> Mat3<T>: Matrix3<T, Vec3<T>> {
pure fn to_mat4(&self) -> Mat4<T> { pure fn to_mat4(&self) -> Mat4<T> {
Mat4::from_Mat3(self) Mat4::from_Mat3(self)
} }
}
pub impl<T:Copy Float Exp> Mat3<T>: ToQuat<T> {
pure fn to_Quat() -> Quat<T> { pure fn to_Quat() -> Quat<T> {
// Implemented using a mix of ideas from jMonkeyEngine and Ken Shoemake's // Implemented using a mix of ideas from jMonkeyEngine and Ken Shoemake's
// paper on Quaternions: http://www.cs.ucr.edu/~vbz/resources/Quatut.pdf // paper on Quaternions: http://www.cs.ucr.edu/~vbz/resources/Quatut.pdf

View file

@ -182,12 +182,6 @@ pub trait Quaternion<T,V3>: Index<uint, T> Eq Neg<self> {
pure fn to_ptr(&self) -> *T; pure fn to_ptr(&self) -> *T;
} }
pub trait ToQuat<T> {
/**
* Convert `self` to a quaternion
*/
pure fn to_Quat() -> Quat<T>;
}