let eye = Point3::new(s * camera_radius, camera_height, c * camera_radius);
let center = Point3::ZERO;
let camera_from_model = Mat4::look_at(eye, center, Vec3::Y);
- let clip_from_camera =
- Mat4::perspective_rev_inf_zo(Deg::new(45.0).into(), width as f32 / height as f32, 0.01);
+ let clip_from_camera = Mat4::perspective_rev_inf_zo(
+ HalfTurn::new(1.0 / 3.0),
+ width as f32 / height as f32,
+ 0.01,
+ );
let clip_from_model = clip_from_camera * camera_from_model;
basic_uniform_buffer.write(BasicUniforms { clip_from_model });
-use crate::{sin_cos_pi_f32, HalfTurn, Point2, Point3, Rad, Vec2, Vec3, Vec4};
+use crate::{sin_cos_pi_f32, tan_pi_f32, HalfTurn, Point2, Point3, Vec2, Vec3, Vec4};
/// 4x4 matrix.
///
///
/// Src coordinate space: right-handed, +y up.
/// Dst coordinate space: right-handed, -y up, depth range \[0,1\].
- pub fn perspective_rev_inf_zo(vertical_fov: Rad, aspect_ratio: f32, z_near: f32) -> Mat4 {
- let tan = (vertical_fov.as_f32() / 2.0).tan();
+ pub fn perspective_rev_inf_zo(vertical_fov: HalfTurn, aspect_ratio: f32, z_near: f32) -> Mat4 {
+ let tan = tan_pi_f32(vertical_fov.as_f32() / 2.0);
let sy = 1.0 / tan;
let sx = sy / aspect_ratio;
Mat4::from_rows([