def test_intersection(self): s = Sphere(Point(0, 0, 2), 2) l = Line(Point(-1, 0, 2), Point(1, 0, 2)) assert s.contains(Point(0, 0, 0)) assert s.intersect(l) == [Point(-2, 0, 2), Point(2, 0, 2)] assert s.intersect(l-Point(0, 0, 2)) == [Point(0, 0, 0)] s = Sphere(Point(0, 0, 0, 2), 2) l = Line(Point(-1, 0, 0, 2), Point(1, 0, 0, 2)) assert s.contains(Point(0, 0, 0, 0)) assert s.intersect(l) == [Point(2, 0, 0, 2), Point(-2, 0, 0, 2)]
def test_intersect(self): s = Sphere(Point(0, 0, 2), 2) l = Line(Point(-1, 0, 2), Point(1, 0, 2)) assert s.contains(Point(0, 0, 0)) assert s.intersect(l) == [Point(-2, 0, 2), Point(2, 0, 2)] assert s.intersect(l - Point(0, 0, 2)) == [Point(0, 0, 0)] l = LineCollection([Line(Point(-1, 0, 2), Point(1, 0, 2)), Line(Point(0, 0, 0), Point(0, 0, 2))]) assert s.intersect(l) == [PointCollection([Point(-2, 0, 2), Point(0, 0, 0)]), PointCollection([Point(2, 0, 2), Point(0, 0, 4)])] s = Sphere(Point(0, 0, 0, 2), 2) l = Line(Point(-1, 0, 0, 2), Point(1, 0, 0, 2)) assert s.contains(Point(0, 0, 0, 0)) assert s.intersect(l) == [Point(2, 0, 0, 2), Point(-2, 0, 0, 2)]