diff --git a/src/mat.rs b/src/mat.rs index 6c1af8d..1cb1f46 100644 --- a/src/mat.rs +++ b/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: Dimensional, Eq, DefaultEq { pure fn rows() -> uint; pure fn cols() -> uint; @@ -24,6 +26,9 @@ pub trait Matrix: Dimensional, Eq, DefaultEq { pure fn row(i: uint) -> Row; } +/// +/// A matrix with numeric elements +/// pub trait NumericMatrix: Matrix, Neg { static pure fn zero() -> self; @@ -33,6 +38,9 @@ pub trait NumericMatrix: Matrix, Neg { pure fn sub_m(other: &self) -> self; } +/// +/// A square matrix with numeric elements +/// pub trait NumericMatrix_NxN: NumericMatrix { static pure fn identity() -> self; @@ -50,15 +58,18 @@ pub trait NumericMatrix_NxN: NumericMatrix { pure fn is_invertible() -> bool; } +/// A 2 x 2 square matrix with numeric elements pub trait NumericMatrix2x2: NumericMatrix_NxN> { pure fn to_Mat3() -> Mat3; pure fn to_Mat4() -> Mat4; } +/// A 3 x 3 square matrix with numeric elements pub trait NumericMatrix3x3: NumericMatrix_NxN> { pure fn to_Mat4() -> Mat4; } +/// A 4 x 4 square matrix with numeric elements pub trait NumericMatrix4x4: NumericMatrix_NxN> { } diff --git a/src/quat.rs b/src/quat.rs index 772aa0b..1943234 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -15,9 +15,9 @@ use num::default_eq::DefaultEq; use vec::Vec3; -// -// Quaternion -// +/// +/// The base quaternion trait +/// pub trait Quaternion: Dimensional, Eq, DefaultEq, Neg { static pure fn identity() -> self; static pure fn zero() -> self; diff --git a/src/vec.rs b/src/vec.rs index 44da77b..50b5547 100644 --- a/src/vec.rs +++ b/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: Dimensional, 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: Vector { // static pure fn new(x: T, y: T) -> self; // } +// /// A 3-dimensional vector // pub trait Vector3: Vector { // static pure fn new(x: T, y: T, z: T) -> self; // } +// /// A 4-dimensional vector // pub trait Vector4: Vector { // static pure fn new(x: T, y: T, z: T, w: T) -> self; // } +/// +/// A vector with numeric components +/// pub trait NumericVector: Vector, Neg{ static pure fn identity() -> self; static pure fn zero() -> self; @@ -40,11 +49,13 @@ pub trait NumericVector: Vector, Neg{ pure fn dot(other: &self) -> T; } +// /// A 2-dimensional vector with numeric components // pub trait NumericVector2: Vector { // static pure fn unit_x() -> self; // static pure fn unit_y() -> self; // } +/// A 3-dimensional vector with numeric components pub trait NumericVector3: Vector { // static pure fn unit_x() -> self; // static pure fn unit_y() -> self; @@ -52,6 +63,7 @@ pub trait NumericVector3: Vector { pure fn cross(other: &self) -> self; } +// /// A 4-dimensional vector with numeric components // pub trait NumericVector4: Vector { // static pure fn unit_x() -> self; // static pure fn unit_y() -> self; @@ -59,6 +71,9 @@ pub trait NumericVector3: Vector { // static pure fn unit_w() -> self; // } +/// +/// A vector with geometric properties +/// pub trait GeometricVector: NumericVector { pure fn length2() -> T; pure fn length() -> T;