libpysal.cg.get_segments_intersect

libpysal.cg.get_segments_intersect(seg1, seg2)[source]

Returns the intersection of two segments if one exists.

Parameters:
seg1libpysal.cg.LineSegment

A segment to check for an intersection.

seg2libpysal.cg.LineSegment

The segment to check against seg1 for an intersection.

Returns:
intersection{libpysal.cg.Point, libpysal.cg.LineSegment, None}

The intersecting point or line between seg1 and seg2 if an intersection exists or None if seg1 and seg2 do not intersect.

Examples

>>> seg1 = LineSegment(Point((0, 0)), Point((0, 10)))
>>> seg2 = LineSegment(Point((-5, 5)), Point((5, 5)))
>>> i = get_segments_intersect(seg1, seg2)
>>> isinstance(i, Point)
True
>>> str(i)
'(0.0, 5.0)'
>>> seg3 = LineSegment(Point((100, 100)), Point((100, 101)))
>>> i = get_segments_intersect(seg2, seg3)