Update documentation, add vector type parameter to quaternion

This commit is contained in:
Brendan Zabarauskas 2012-12-05 11:51:18 +10:00
parent 63f9cd38b7
commit b15c20c7fc
3 changed files with 42 additions and 6 deletions

View file

@ -16,6 +16,13 @@ use vec::{NumericVector, Vec2, Vec3, Vec4};
/**
* The base square matrix trait
*
* # Type parameters
*
* * `T` - The type of the elements of the matrix. Should be a floating point type.
* * `V` - The type of the row and column vectors. Should have components of a
* floating point type and have the same number of dimensions as the
* number of rows and columns in the matrix.
*/
pub trait Matrix<T,V>: Dimensional<V>, ToPtr<T>, Eq, Neg<self> {
/**
@ -182,6 +189,10 @@ pub trait Matrix4<T,V>: Matrix<T,V> {
/**
* A 2 x 2 column major matrix
*
* # Type parameters
*
* * `T` - The type of the elements of the matrix. Should be a floating point type.
*
* # Fields
*
* * `x` - the first column vector of the matrix
@ -535,6 +546,10 @@ pub impl<T:Copy Float> Mat2<T>: FuzzyEq {
/**
* A 3 x 3 column major matrix
*
* # Type parameters
*
* * `T` - The type of the elements of the matrix. Should be a floating point type.
*
* # Fields
*
* * `x` - the first column vector of the matrix
@ -984,6 +999,10 @@ pub impl<T:Copy Float> Mat3<T>: FuzzyEq {
/**
* A 4 x 4 column major matrix
*
* # Type parameters
*
* * `T` - The type of the elements of the matrix. Should be a floating point type.
*
* # Fields
*
* * `x` - the first column vector of the matrix

View file

@ -17,8 +17,14 @@ use vec::Vec3;
/**
* The base quaternion trait
*
* # Type parameters
*
* * `T` - The type of the components. Should be a floating point type.
* * `V3` - The 3-dimensional vector containing the three imaginary components
* of the quaternion.
*/
pub trait Quaternion<T>: Dimensional<T>, ToPtr<T>, Eq, Neg<self> {
pub trait Quaternion<T,V3>: Dimensional<T>, ToPtr<T>, Eq, Neg<self> {
/**
* Returns the multiplicative identity, ie: `q = 1 + 0i + 0j + 0i`
*/
@ -42,7 +48,7 @@ pub trait Quaternion<T>: Dimensional<T>, ToPtr<T>, Eq, Neg<self> {
/**
* Returns the result of multiplying the quaternion by a vector
*/
pure fn mul_v(&self, vec: &Vec3<T>) -> Vec3<T>;
pure fn mul_v(&self, vec: &V3) -> V3;
/**
* Returns the sum of this quaternion and `other`
@ -138,6 +144,10 @@ pub trait ToQuat<T> {
/**
* A quaternion in scalar/vector form
*
* # Type parameters
*
* * `T` - The type of the components. Should be a floating point type.
*
* # Fields
*
* * `s` - the scalar component
@ -202,7 +212,7 @@ pub impl<T:Copy> Quat<T>: ToPtr<T> {
}
}
pub impl<T:Copy Float Exp Extent InvTrig> Quat<T>: Quaternion<T> {
pub impl<T:Copy Float Exp Extent InvTrig> Quat<T>: Quaternion<T, Vec3<T>> {
#[inline(always)]
static pure fn identity() -> Quat<T> {
Quat::new(Number::from(1),

View file

@ -12,10 +12,17 @@ use num::default_eq::DefaultEq;
use num::kinds::Number;
/**
* The base generic vector trait
* The base generic vector trait.
*
* # Type parameters
*
* * `T` - The type of the components. This is intended to support boolean,
* integer, unsigned integer, and floating point types.
*/
pub trait Vector<T>: Dimensional<T>, ToPtr<T>, Eq, DefaultEq {
/// Construct the vector from a single value, copying it to each component
/**
* Construct the vector from a single value, copying it to each component
*/
static pure fn from_value(value: T) -> self;
}
@ -49,7 +56,7 @@ pub trait Vector3<T>: Vector<T> {
* A generic 4-dimensional vector
*/
pub trait Vector4<T>: Vector<T> {
// static pure fn new(x: T, y: T, z: T, w: T) -> self;
// static pure fn new(x: T, y: T, z: T, w: T) -> self;
}
/**