Update documentation, add vector type parameter to quaternion
This commit is contained in:
parent
63f9cd38b7
commit
b15c20c7fc
3 changed files with 42 additions and 6 deletions
19
src/mat.rs
19
src/mat.rs
|
@ -16,6 +16,13 @@ use vec::{NumericVector, Vec2, Vec3, Vec4};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base square matrix trait
|
* 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> {
|
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
|
* 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
|
* # Fields
|
||||||
*
|
*
|
||||||
* * `x` - the first column vector of the matrix
|
* * `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
|
* 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
|
* # Fields
|
||||||
*
|
*
|
||||||
* * `x` - the first column vector of the matrix
|
* * `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
|
* 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
|
* # Fields
|
||||||
*
|
*
|
||||||
* * `x` - the first column vector of the matrix
|
* * `x` - the first column vector of the matrix
|
||||||
|
|
16
src/quat.rs
16
src/quat.rs
|
@ -17,8 +17,14 @@ use vec::Vec3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base quaternion trait
|
* 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`
|
* 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
|
* 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`
|
* Returns the sum of this quaternion and `other`
|
||||||
|
@ -138,6 +144,10 @@ pub trait ToQuat<T> {
|
||||||
/**
|
/**
|
||||||
* A quaternion in scalar/vector form
|
* A quaternion in scalar/vector form
|
||||||
*
|
*
|
||||||
|
* # Type parameters
|
||||||
|
*
|
||||||
|
* * `T` - The type of the components. Should be a floating point type.
|
||||||
|
*
|
||||||
* # Fields
|
* # Fields
|
||||||
*
|
*
|
||||||
* * `s` - the scalar component
|
* * `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)]
|
#[inline(always)]
|
||||||
static pure fn identity() -> Quat<T> {
|
static pure fn identity() -> Quat<T> {
|
||||||
Quat::new(Number::from(1),
|
Quat::new(Number::from(1),
|
||||||
|
|
11
src/vec.rs
11
src/vec.rs
|
@ -12,10 +12,17 @@ use num::default_eq::DefaultEq;
|
||||||
use num::kinds::Number;
|
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 {
|
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;
|
static pure fn from_value(value: T) -> self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue