def test_bounded_cone_bounding_box(self): shape = Cone() shape.minimum = -5 shape.maximum = 3 box = shape.bounds_of() self.assertEqual(box.min, Point(-5, -5, -5)) self.assertEqual(box.max, Point(5, 3, 5))
def test_intersect_cone_end_cap(self): shape = Cone() shape.minimum = -0.5 shape.maximum = 0.5 shape.closed = True RayIntersection = namedtuple("RayIntersection", ["origin", "direction", "count"]) ray_intersections = [ RayIntersection(Point(0, 0, -5), Vector(0, 1, 0), 0), RayIntersection(Point(0, 0, -0.25), Vector(0, 1, 1), 2), RayIntersection(Point(0, 0, -0.25), Vector(0, 1, 0), 4) ] for ray_intersection in ray_intersections: direction = Vector.normalize(ray_intersection.direction) r = Ray(ray_intersection.origin, direction) xs = shape.local_intersect(r) self.assertEqual(len(xs), ray_intersection.count)