Пример #1
0
 def test_ray_hits_csg_object(self):
     s1 = Sphere()
     s2 = Sphere()
     s2.transform = Transformations.translation(0, 0, 0.5)
     c = CSG("union", s1, s2)
     r = Ray(Point(0, 0, -5), Vector(0, 0, 1))
     xs = c.local_intersect(r)
     self.assertEqual(len(xs), 2)
     self.assertEqual(xs[0].t, 4)
     self.assertEqual(xs[0].object, s1)
     self.assertEqual(xs[1].t, 6.5)
     self.assertEqual(xs[1].object, s2)
Пример #2
0
 def test_ray_misses_csg_object(self):
     c = CSG("union", Sphere(), Sphere())
     r = Ray(Point(0, 2, -5), Vector(0, 0, 1))
     xs = c.local_intersect(r)
     self.assertEqual(len(xs), 0)