def test_intersect5(self): r = Ray(point(0, 0, 5), vector(0, 0, 1)) s = Sphere() i = s.intersect(r) self.assertEqual(2, len(i)) self.assertEqual(-6.0, i[0].t) self.assertEqual(-4.0, i[1].t)
def test_intersect_sphere1(self): s = Sphere() r = Ray(point(0, 0, -5), vector(0, 0, 1)) s.set_transform(xf_scale(2, 2, 2)) i = s.intersect(r) self.assertEqual(2, len(i)) self.assertEqual(i[0].t, 3.0) self.assertEqual(i[1].t, 7.0)
def test_get_hit3(self): s = Sphere() ii = Intersections() i1 = Intersection(s, -2) ii.add(i1) i2 = Intersection(s, -1) ii.add(i2) self.assertEqual(ii.get_hit(), None)
def test_get_hit4(self): s = Sphere() ii = Intersections() i1 = Intersection(s, 5) ii.add(i1) i2 = Intersection(s, 7) ii.add(i2) i3 = Intersection(s, -3) ii.add(i3) i4 = Intersection(s, 2) ii.add(i4) self.assertEqual(ii.get_hit(), i4)
def test_intersect3(self): r = Ray(point(0, 2, -5), vector(0, 0, 1)) s = Sphere() i = s.intersect(r) self.assertEqual(0, len(i))