Add comments
This commit is contained in:
parent
16e687c25e
commit
a030f4cf19
3 changed files with 31 additions and 5 deletions
13
src/mat.rs
13
src/mat.rs
|
@ -13,7 +13,9 @@ use num::default_eq::DefaultEq;
|
|||
use quat::{Quat, ToQuat};
|
||||
use vec::{NumericVector, Vec2, Vec3, Vec4};
|
||||
|
||||
|
||||
///
|
||||
/// The base Matrix trait
|
||||
///
|
||||
pub trait Matrix<T, Col, Row>: Dimensional<T>, Eq, DefaultEq {
|
||||
pure fn rows() -> uint;
|
||||
pure fn cols() -> uint;
|
||||
|
@ -24,6 +26,9 @@ pub trait Matrix<T, Col, Row>: Dimensional<T>, Eq, DefaultEq {
|
|||
pure fn row(i: uint) -> Row;
|
||||
}
|
||||
|
||||
///
|
||||
/// A matrix with numeric elements
|
||||
///
|
||||
pub trait NumericMatrix<T, Col, Row>: Matrix<T, Col, Row>, Neg<self> {
|
||||
static pure fn zero() -> self;
|
||||
|
||||
|
@ -33,6 +38,9 @@ pub trait NumericMatrix<T, Col, Row>: Matrix<T, Col, Row>, Neg<self> {
|
|||
pure fn sub_m(other: &self) -> self;
|
||||
}
|
||||
|
||||
///
|
||||
/// A square matrix with numeric elements
|
||||
///
|
||||
pub trait NumericMatrix_NxN<T, ColRow>: NumericMatrix<T, ColRow, ColRow> {
|
||||
static pure fn identity() -> self;
|
||||
|
||||
|
@ -50,15 +58,18 @@ pub trait NumericMatrix_NxN<T, ColRow>: NumericMatrix<T, ColRow, ColRow> {
|
|||
pure fn is_invertible() -> bool;
|
||||
}
|
||||
|
||||
/// A 2 x 2 square matrix with numeric elements
|
||||
pub trait NumericMatrix2x2<T>: NumericMatrix_NxN<T, Mat2<T>> {
|
||||
pure fn to_Mat3() -> Mat3<T>;
|
||||
pure fn to_Mat4() -> Mat4<T>;
|
||||
}
|
||||
|
||||
/// A 3 x 3 square matrix with numeric elements
|
||||
pub trait NumericMatrix3x3<T>: NumericMatrix_NxN<T, Mat3<T>> {
|
||||
pure fn to_Mat4() -> Mat4<T>;
|
||||
}
|
||||
|
||||
/// A 4 x 4 square matrix with numeric elements
|
||||
pub trait NumericMatrix4x4<T>: NumericMatrix_NxN<T, Mat4<T>> {
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ use num::default_eq::DefaultEq;
|
|||
use vec::Vec3;
|
||||
|
||||
|
||||
//
|
||||
// Quaternion
|
||||
//
|
||||
///
|
||||
/// The base quaternion trait
|
||||
///
|
||||
pub trait Quaternion<T>: Dimensional<T>, Eq, DefaultEq, Neg<self> {
|
||||
static pure fn identity() -> self;
|
||||
static pure fn zero() -> self;
|
||||
|
|
17
src/vec.rs
17
src/vec.rs
|
@ -10,23 +10,32 @@ use funs::exp::Exp;
|
|||
use num::cast::*;
|
||||
use num::default_eq::DefaultEq;
|
||||
|
||||
|
||||
///
|
||||
/// The base vector trait
|
||||
///
|
||||
pub trait Vector<T>: Dimensional<T>, Eq, DefaultEq {
|
||||
/// Construct the vector from a single value, copying it to each component
|
||||
static pure fn from_value(value: T) -> self;
|
||||
}
|
||||
|
||||
// /// A 2-dimensional vector
|
||||
// pub trait Vector2<T>: Vector<T> {
|
||||
// static pure fn new(x: T, y: T) -> self;
|
||||
// }
|
||||
|
||||
// /// A 3-dimensional vector
|
||||
// pub trait Vector3<T>: Vector<T> {
|
||||
// static pure fn new(x: T, y: T, z: T) -> self;
|
||||
// }
|
||||
|
||||
// /// A 4-dimensional vector
|
||||
// pub trait Vector4<T>: Vector<T> {
|
||||
// static pure fn new(x: T, y: T, z: T, w: T) -> self;
|
||||
// }
|
||||
|
||||
///
|
||||
/// A vector with numeric components
|
||||
///
|
||||
pub trait NumericVector<T>: Vector<T>, Neg<self>{
|
||||
static pure fn identity() -> self;
|
||||
static pure fn zero() -> self;
|
||||
|
@ -40,11 +49,13 @@ pub trait NumericVector<T>: Vector<T>, Neg<self>{
|
|||
pure fn dot(other: &self) -> T;
|
||||
}
|
||||
|
||||
// /// A 2-dimensional vector with numeric components
|
||||
// pub trait NumericVector2<T>: Vector<T> {
|
||||
// static pure fn unit_x() -> self;
|
||||
// static pure fn unit_y() -> self;
|
||||
// }
|
||||
|
||||
/// A 3-dimensional vector with numeric components
|
||||
pub trait NumericVector3<T>: Vector<T> {
|
||||
// static pure fn unit_x() -> self;
|
||||
// static pure fn unit_y() -> self;
|
||||
|
@ -52,6 +63,7 @@ pub trait NumericVector3<T>: Vector<T> {
|
|||
pure fn cross(other: &self) -> self;
|
||||
}
|
||||
|
||||
// /// A 4-dimensional vector with numeric components
|
||||
// pub trait NumericVector4<T>: Vector<T> {
|
||||
// static pure fn unit_x() -> self;
|
||||
// static pure fn unit_y() -> self;
|
||||
|
@ -59,6 +71,9 @@ pub trait NumericVector3<T>: Vector<T> {
|
|||
// static pure fn unit_w() -> self;
|
||||
// }
|
||||
|
||||
///
|
||||
/// A vector with geometric properties
|
||||
///
|
||||
pub trait GeometricVector<T>: NumericVector<T> {
|
||||
pure fn length2() -> T;
|
||||
pure fn length() -> T;
|
||||
|
|
Loading…
Reference in a new issue