Change fovy parameter to accept a generic angle

This commit is contained in:
Brendan Zabarauskas 2012-11-29 15:59:45 +10:00
parent 93d228f2f9
commit eeaf6cb3c1

View file

@ -1,5 +1,5 @@
use funs::triganomic::tan;
use angle::Radians;
use angle::Angle;
use mat::Mat4;
use num::cast::cast;
use num::consts::pi;
@ -12,8 +12,8 @@ use num::ext::FloatExt;
* can be found [here](http://www.opengl.org/wiki/GluPerspective_code).
*/
#[inline(always)]
pure fn perspective<T:Copy FloatExt>(fovy: Radians<T>, aspectRatio: T, near: T, far: T) -> Mat4<T> {
let ymax = near * tan(&fovy);
pure fn perspective<T:Copy FloatExt, A:Angle<T>>(fovy: A, aspectRatio: T, near: T, far: T) -> Mat4<T> {
let ymax = near * tan(&fovy.to_radians());
let xmax = ymax * aspectRatio;
frustum(-xmax, xmax, -ymax, ymax, near, far)