def test_make_perpendicular(): line = Line(Point(0, 0), 0) perp_point = Point(0, 10) perp = line.create_line_perpendicular(perp_point) assert perp.slope == math.inf assert perp.p == perp_point line.slope = math.inf perp_point = Point(10, 0) perp = line.create_line_perpendicular(perp_point) assert perp.slope == 0 assert perp.p == perp_point line.slope = 1 perp_point = Point(-10, 10) perp = line.create_line_perpendicular(perp_point) assert perp.slope == -1 assert perp.p == perp_point
def test_cant_make_perpendicular_if_co_linear(): line = Line(Point(0, 0), 0) assert line.create_line_perpendicular(Point(10, 0)) is None