def crossing(p1: Point, p2: Point, p3: Point, p4: Point): line1, seg1 = Line(p1, p2), Segment(p1, p2) line2, seg2 = Line(p3, p4), Segment(p3, p4) intersect = line1.intersection(line2) if intersect: seg1 = Segment(p1, p2) seg2 = Segment(p3, p4) pi = intersect[0] return seg1.contains(pi) and seg2.contains(pi)
def is_projection_between_two_points(p, p1, p2) : #return (p1.x - p.x)*(p2.x - p.x) <= 0 and (p1.y - p.y) * (p2.y - p.y) <= 0 seg = Segment(p1, p2) return seg.contains(p)