libpysal.cg.get_rectangle_rectangle_intersection

libpysal.cg.get_rectangle_rectangle_intersection(r0, r1, checkOverlap=True)[source]

Returns the intersection between two rectangles.

Parameters:
r0libpysal.cg.Rectangle

A rectangle to check for an intersection.

r1libpysal.cg.Rectangle

A rectangle to check for an intersection against r0.

checkOverlapbool

Call bbcommon(r0, r1) prior to complex geometry checking. Default is True. Prior to setting as False see the Notes section.

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

The intersecting point, line, or rectangle between r0 and r1 if an intersection exists or None if r0 and r1 do not intersect.

Notes

The algorithm assumes the rectangles overlap. The keyword checkOverlap=False should be used with extreme caution.

Examples

>>> r0 = Rectangle(0,4,6,9)
>>> r1 = Rectangle(4,0,9,7)
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:]
[4.0, 4.0, 6.0, 7.0]
>>> r0 = Rectangle(0,0,4,4)
>>> r1 = Rectangle(2,1,6,3)
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:]
[2.0, 1.0, 4.0, 3.0]
>>> r0 = Rectangle(0,0,4,4)
>>> r1 = Rectangle(2,1,3,2)
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:] == r1[:]
True