Clean up 'orthographic' function and rename to 'ortho'

This commit is contained in:
Brendan Zabarauskas 2013-04-07 23:04:54 +10:00
parent 98d2ed5fc7
commit a57935ccea

View file

@ -68,14 +68,33 @@ pub fn frustum<T:Copy + Float + Zero + One + FuzzyEq<T> + Add<T,T> + Sub<T,T> +
* (http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml) function. * (http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml) function.
*/ */
#[inline(always)] #[inline(always)]
pub fn orthographic<T:Copy + Float + Zero + One + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4<T> { pub fn ortho<T:Copy + Float + Zero + One + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4<T> {
let _0: T = num::cast(0); let _0: T = num::cast(0);
let _1: T = num::cast(1); let _1: T = num::cast(1);
let _2: T = num::cast(2); let _2: T = num::cast(2);
BaseMat4::new(_2 / (right - left), _0, _0, _0, let c0r0 = _2 / (right - left);
_0, _2 / (top - bottom), _0, _0, let c0r1 = _0;
_0, _0, -_2 / (far - near), _0, let c0r2 = _0;
-(right + left) / (right - left), -(top + bottom) / (top - bottom), let c0r3 = -(right + left) / (right - left);
-(far + near) / (far - near), _1)
let c1r0 = _0;
let c1r1 = _2 / (top - bottom);
let c1r2 = _0;
let c1r3 = -(top + bottom) / (top - bottom);
let c2r0 = _0;
let c2r1 = _0;
let c2r2 = -_2 / (far - near);
let c2r3 = -(far + near) / (far - near);
let c3r0 = _0;
let c3r1 = _0;
let c3r2 = _0;
let c3r3 = _1;
BaseMat4::new(c0r0, c0r1, c0r2, c0r3,
c1r0, c1r1, c1r2, c1r3,
c2r0, c2r1, c2r2, c2r3,
c3r0, c3r1, c3r2, c3r3)
} }