public void CanFailToInsersectWithRayFacingAwayFromSphere() { // Arrange var sphere = new Sphere() { Center = new Vector(0, 0, 0), Radius = 1 }; var ray = new Ray() { Start = new Vector(0, 0, -2), Direction = new Vector(0, 0, -1) }; // Act var isect = sphere.Intersect(ray); // Assert Assert.IsNull(isect); }
public void CanIntersectEdgeOfSphere() { // Arrange var sphere = new Sphere() { Center = new Vector(0, 0, 0), Radius = 1 }; var ray = new Ray() { Start = new Vector(1, 0, -2), Direction = new Vector(0, 0, 1) }; // Act var isect = sphere.Intersect(ray); // Assert Assert.NotNull(isect); Assert.AreEqual(2, isect.Distance); Assert.AreEqual(sphere, isect.Element); }