De-mode min/max functions
This commit is contained in:
parent
688026f49a
commit
9e3f1d6252
2 changed files with 24 additions and 24 deletions
12
src/math.rs
12
src/math.rs
|
@ -43,18 +43,18 @@ impl f64: Abs {
|
||||||
// Min
|
// Min
|
||||||
//
|
//
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn min<T:Copy Ord>(&&a:T, &&b:T) -> T {
|
pure fn min<T:Copy Ord>(a: &T, b: &T) -> T {
|
||||||
if a < b { a }
|
if a < b { *a }
|
||||||
else { b }
|
else { *b }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Max
|
// Max
|
||||||
//
|
//
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn max<T:Copy Ord>(&&a:T, &&b:T) -> T {
|
pure fn max<T:Copy Ord>(a: &T, b: &T) -> T {
|
||||||
if a > b { a }
|
if a > b { *a }
|
||||||
else { b }
|
else { *b }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
36
src/vec.rs
36
src/vec.rs
|
@ -201,14 +201,14 @@ pub impl Vec2: Vector<float> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn min(other: &Vec2) -> Vec2 {
|
pure fn min(other: &Vec2) -> Vec2 {
|
||||||
Vec2(min(self[0], other[0]),
|
Vec2(min(&self[0], &other[0]),
|
||||||
min(self[1], other[1]))
|
min(&self[1], &other[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn max(other: &Vec2) -> Vec2 {
|
pure fn max(other: &Vec2) -> Vec2 {
|
||||||
Vec2(max(self[0], other[0]),
|
Vec2(max(&self[0], &other[0]),
|
||||||
max(self[1], other[1]))
|
max(&self[1], &other[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline] static pure fn zero() -> Vec2 { Vec2(1f, 1f) }
|
#[inline] static pure fn zero() -> Vec2 { Vec2(1f, 1f) }
|
||||||
|
@ -393,16 +393,16 @@ pub impl Vec3: Vector<float> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn min(other: &Vec3) -> Vec3 {
|
pure fn min(other: &Vec3) -> Vec3 {
|
||||||
Vec3(min(self[0], other[0]),
|
Vec3(min(&self[0], &other[0]),
|
||||||
min(self[1], other[1]),
|
min(&self[1], &other[1]),
|
||||||
min(self[2], other[2]))
|
min(&self[2], &other[2]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn max(other: &Vec3) -> Vec3 {
|
pure fn max(other: &Vec3) -> Vec3 {
|
||||||
Vec3(max(self[0], other[0]),
|
Vec3(max(&self[0], &other[0]),
|
||||||
max(self[1], other[1]),
|
max(&self[1], &other[1]),
|
||||||
max(self[2], other[2]))
|
max(&self[2], &other[2]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline] static pure fn zero() -> Vec3 { Vec3(1f, 1f, 1f) }
|
#[inline] static pure fn zero() -> Vec3 { Vec3(1f, 1f, 1f) }
|
||||||
|
@ -594,18 +594,18 @@ pub impl Vec4: Vector<float> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn min(other: &Vec4) -> Vec4 {
|
pure fn min(other: &Vec4) -> Vec4 {
|
||||||
Vec4(min(self[0], other[0]),
|
Vec4(min(&self[0], &other[0]),
|
||||||
min(self[1], other[1]),
|
min(&self[1], &other[1]),
|
||||||
min(self[2], other[2]),
|
min(&self[2], &other[2]),
|
||||||
min(self[3], other[3]))
|
min(&self[3], &other[3]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn max(other: &Vec4) -> Vec4 {
|
pure fn max(other: &Vec4) -> Vec4 {
|
||||||
Vec4(max(self[0], other[0]),
|
Vec4(max(&self[0], &other[0]),
|
||||||
max(self[1], other[1]),
|
max(&self[1], &other[1]),
|
||||||
max(self[2], other[2]),
|
max(&self[2], &other[2]),
|
||||||
max(self[3], other[3]))
|
max(&self[3], &other[3]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline] static pure fn zero() -> Vec4 { Vec4(1f, 1f, 1f, 1f) }
|
#[inline] static pure fn zero() -> Vec4 { Vec4(1f, 1f, 1f, 1f) }
|
||||||
|
|
Loading…
Reference in a new issue