From 8c458d073e21b444c0f7f4a70be9e92ac9ce9bdc Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Fri, 28 Mar 2025 22:11:07 -0300 Subject: [PATCH] Fix unit test in camera --- src/camera.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index e66a6cd..455524c 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -173,12 +173,12 @@ mod tests { }) => location, None => panic!(), }; - let expected_x: f64 = - ImageSampler::scale(200, 800, target.film_width) - target.film_width * 0.5; - assert!((point_on_film_plane.x() - expected_x).abs() < 0.5 / 800.0); - let expected_y = - -ImageSampler::scale(100, 600, target.film_height) + target.film_height * 0.5; - assert!((point_on_film_plane.y() - expected_y).abs() < 0.5 / 600.0); + let expected_x = target.film_width * (200.0/800.0 - 0.5); + assert!(point_on_film_plane.x() - expected_x < target.film_width / 800.0); + assert!(point_on_film_plane.x() - expected_x >= 0.0); + let expected_y = -target.film_height * (100.0/600.0 - 0.5); + assert!(expected_y - point_on_film_plane.y() < target.film_height / 600.0); + assert!(expected_y - point_on_film_plane.y() >= 0.0); } } }