pub fn perspective(width: u32, height: u32, fov: f32, near: f32, far: f32) -> Mat4f {
    let fov: f32 = fov * std::f32::consts::PI / 180.;
    let focal_length = 1. / (fov / 2.).tan();
    let aspect_ratio = (width as f32) / (height as f32);

    let mut mat = Mat4f::zeros();
    mat[(0, 0)] = focal_length / aspect_ratio;
    mat[(1, 1)] = -focal_length;
    mat[(2, 2)] = -far / (far - near);
    mat[(2, 3)] = -far * near / (far - near);
    mat[(3, 2)] = -1.;

    mat
}
/// Create a right handed perpective projection matrix.
Create a right handed perpective projection matrix.
Create a right handed perpective projection matrix .
pub fn perspective(width: u32, height: u32, fov: f32, near: f32, far: f32) -> Mat4f {
    let fov: f32 = fov * std::f32::consts::PI / 180.;
    let focal_length = 1. / (fov / 2.).tan();
    let aspect_ratio = (width as f32) / (height as f32);
    let mut mat = Mat4f::zeros();
    mat[(0, 0)] = focal_length / aspect_ratio;
    mat[(1, 1)] = -focal_length;
    mat[(2, 2)] = -far / (far - near);
    mat[(2, 3)] = -far * near / (far - near);
    mat[(3, 2)] = -1.;
    mat
}
pub fn perspective ( width : u32 , height : u32 , fov : f32 , near : f32 , far : f32 ) -> Mat4f { let fov : f32 = fov * std :: f32 :: consts :: PI / 180. ; let focal_length = 1. / ( fov / 2. ) . tan ( ) ; let aspect_ratio = ( width as f32 ) / ( height as f32 ) ; let mut mat = Mat4f :: zeros ( ) ; mat [ ( 0 , 0 ) ] = focal_length / aspect_ratio ; mat [ ( 1 , 1 ) ] = - focal_length ; mat [ ( 2 , 2 ) ] = - far / ( far - near ) ; mat [ ( 2 , 3 ) ] = - far * near / ( far - near ) ; mat [ ( 3 , 2 ) ] = - 1. ; mat }
Create a right handed perpective projection matrix.
Create a right handed perpective projection matrix .
width
u32
height
u32
fov
f32
near
f32
far
f32
width
u32
height
u32
fov
f32
near
f32
far
f32