def test_nonempty_group(): g = Group() s1 = Sphere() s2 = Sphere() s2.set_transform(Translation(0, 0, -3)) s3 = Sphere() s3.set_transform(Translation(5, 0, 0)) g.add_child(s1) g.add_child(s2) g.add_child(s3) r = Ray(Point(0, 0, -5), Vector(0, 0, 1)) xs = g.local_intersect(r) assert len(xs) == 4 assert xs[0].object == s2 assert xs[1].object == s2 assert xs[2].object == s1 assert xs[3].object == s1
def test_empty_group(): g = Group() r = Ray(Point(0, 0, 0), Vector(0, 0, 1)) xs = g.local_intersect(r) assert len(xs) == 0