From 3c24a084b955983b73a9623c979dab6518705ab9 Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Wed, 13 Nov 2019 17:28:43 -0500 Subject: [PATCH] Add another ray-sphere intersection unit test --- src/raycasting.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/raycasting.rs b/src/raycasting.rs index 79905c3..d7be361 100644 --- a/src/raycasting.rs +++ b/src/raycasting.rs @@ -175,12 +175,19 @@ mod tests { } #[test] - fn ray_does_not_intersect_sphere() { + fn ray_does_not_intersect_sphere_when_sphere_is_in_front() { let r = Ray::new(Vector3::new(1.0, 2.0, 3.0), Vector3::new(0.0, 0.0, 1.0)); let s = Sphere::new(Vector3::new(-5.0, 1.5, 15.0), 5.0); assert_matches!(s.intersect(&r), None); } + #[test] + fn ray_does_not_intersect_sphere_when_sphere_is_behind() { + let r = Ray::new(Vector3::new(1.0, 2.0, 3.0), Vector3::new(0.0, 0.0, 1.0)); + let s = Sphere::new(Vector3::new(1.5, 1.5, -15.0), 5.0); + assert_matches!(s.intersect(&r), None); + } + #[test] fn ray_intersects_plane() { let r = Ray::new(Vector3::new(1.0, 2.0, 3.0), Vector3::new(-1.0, 0.0, 1.0));