Improve mathematical terminology

This commit is contained in:
Brendan Zabarauskas 2012-12-05 12:10:05 +10:00
parent b15c20c7fc
commit 8acc8f6943
2 changed files with 34 additions and 15 deletions

View file

@ -76,7 +76,7 @@ fn test_Vec2() {
}
#[test]
fn test_Vec2_geometric() {
fn test_Vec2_euclidean() {
let a = Vec2::new(5f, 12f); // (5, 12, 13) Pythagorean triple
let b0 = Vec2::new(3f, 4f); // (3, 4, 5) Pythagorean triple
let b = a.add_v(&b0);
@ -190,7 +190,7 @@ fn test_Vec3() {
}
#[test]
fn test_Vec3_geometric() {
fn test_Vec3_euclidean() {
let a = Vec3::new(2f, 3f, 6f); // (2, 3, 6, 7) Pythagorean quadruple
let b0 = Vec3::new(1f, 4f, 8f); // (1, 4, 8, 9) Pythagorean quadruple
let b = a.add_v(&b0);
@ -304,7 +304,7 @@ fn test_Vec4() {
}
#[test]
fn test_Vec4_geometric() {
fn test_Vec4_euclidean() {
let a = Vec4::new(1f, 2f, 4f, 10f); // (1, 2, 4, 10, 11) Pythagorean quintuple
let b0 = Vec4::new(1f, 2f, 8f, 10f); // (1, 2, 8, 10, 13) Pythagorean quintuple
let b = a.add_v(&b0);

View file

@ -64,12 +64,20 @@ pub trait Vector4<T>: Vector<T> {
*/
pub trait NumericVector<T>: Vector<T>, Neg<self> {
/**
* Returns a vector with each component set to one
* The standard basis vector
*
* # Returns
*
* A vector with each component set to one
*/
static pure fn identity() -> self;
/**
* Returns a vector with each component set to zero
* The null vector
*
* # Returns
*
* A vector with each component set to zero
*/
static pure fn zero() -> self;
@ -172,9 +180,13 @@ pub trait NumericVector4<T>: NumericVector<T> {
}
/**
* A vector with geometric properties
* A Euclidean (or Affine) vector
*
* # Type parameters
*
* * `T` - The type of the components. This should be a floating point type.
*/
pub trait GeometricVector<T>: NumericVector<T> {
pub trait EuclideanVector<T>: NumericVector<T> {
/**
* Returns the squared length of the vector
*/
@ -206,8 +218,15 @@ pub trait GeometricVector<T>: NumericVector<T> {
pure fn lerp(&self, other: &self, amount: T) -> self;
}
pub trait MutableGeometricVector<T>: MutableNumericVector<&self/T>,
GeometricVector<T> {
/**
* A mutable Euclidean (or Affine) vector
*
* # Type parameters
*
* * `T` - The type of the components. This should be a floating point type.
*/
pub trait MutableEuclideanVector<T>: MutableNumericVector<&self/T>,
EuclideanVector<T> {
/**
* Normalize the vector
*/
@ -368,7 +387,7 @@ pub impl<T:Copy Number> Vec2<T>: MutableNumericVector<&self/T> {
}
}
pub impl<T:Copy Number Exp> Vec2<T>: GeometricVector<T> {
pub impl<T:Copy Number Exp> Vec2<T>: EuclideanVector<T> {
#[inline(always)]
pure fn length2(&self) -> T {
self.dot(self)
@ -402,7 +421,7 @@ pub impl<T:Copy Number Exp> Vec2<T>: GeometricVector<T> {
}
}
pub impl<T:Copy Number Exp> Vec2<T>: MutableGeometricVector<&self/T> {
pub impl<T:Copy Number Exp> Vec2<T>: MutableEuclideanVector<&self/T> {
#[inline(always)]
fn normalize_self(&mut self) {
let mut n: T = Number::from(1);
@ -622,7 +641,7 @@ pub impl<T:Copy Number> Vec3<T>: MutableNumericVector3<&self/T> {
}
}
pub impl<T:Copy Number Exp> Vec3<T>: GeometricVector<T> {
pub impl<T:Copy Number Exp> Vec3<T>: EuclideanVector<T> {
#[inline(always)]
pure fn length2(&self) -> T {
self.dot(self)
@ -656,7 +675,7 @@ pub impl<T:Copy Number Exp> Vec3<T>: GeometricVector<T> {
}
}
pub impl<T:Copy Number Exp> Vec3<T>: MutableGeometricVector<&self/T> {
pub impl<T:Copy Number Exp> Vec3<T>: MutableEuclideanVector<&self/T> {
#[inline(always)]
fn normalize_self(&mut self) {
let mut n: T = Number::from(1);
@ -875,7 +894,7 @@ pub impl<T:Copy Number> Vec4<T>: MutableNumericVector<&self/T> {
}
}
pub impl<T:Copy Number Exp> Vec4<T>: GeometricVector<T> {
pub impl<T:Copy Number Exp> Vec4<T>: EuclideanVector<T> {
#[inline(always)]
pure fn length2(&self) -> T {
self.dot(self)
@ -909,7 +928,7 @@ pub impl<T:Copy Number Exp> Vec4<T>: GeometricVector<T> {
}
}
pub impl<T:Copy Number Exp> Vec4<T>: MutableGeometricVector<&self/T> {
pub impl<T:Copy Number Exp> Vec4<T>: MutableEuclideanVector<&self/T> {
#[inline(always)]
fn normalize_self(&mut self) {
let mut n: T = Number::from(1);