Zum Hauptinhalt springen

raygeo.geo.shape.rect

Rectangle intersection and containment tests.

Provides functions to test whether two axis-aligned rectangles intersect, whether one rectangle fully contains another, and utilities for computing the union bounding rectangle of multiple geometries.

Functions

do_rects_intersect()

do_rects_intersect(r1: types.Rect, r2: types.Rect) -> bool

Check if two rectangles intersect.

ParameterTypeDescription
r1types.RectFirst rectangle (x_min, y_min, x_max, y_max).
r2types.RectSecond rectangle (x_min, y_min, x_max, y_max).
ReturnsboolTrue if the rectangles intersect.
ComplexityO(1) time, O(1) space

does_rect_contain_rect()

does_rect_contain_rect(outer: types.Rect, inner: types.Rect) -> bool

Check if one rectangle contains another.

ParameterTypeDescription
outertypes.RectOuter rectangle (x_min, y_min, x_max, y_max).
innertypes.RectInner rectangle (x_min, y_min, x_max, y_max).
ReturnsboolTrue if outer fully contains inner.
ComplexityO(1) time, O(1) space

get_combined_rect()

get_combined_rect(geometries: list[geo.Geometry]) -> types.Rect

Compute the union bounding box of multiple geometries.

ParameterTypeDescription
geometrieslist[geo.Geometry]List of Geometry objects.
Returnstypes.RectUnion bounding rectangle (x_min, y_min, x_max, y_max).
ComplexityO(n) time, O(1) space where n is the number of geometries

is_point_inside_rect()

is_point_inside_rect(point: types.Point, rect: types.Rect) -> bool

Check if a point is inside a rectangle.

ParameterTypeDescription
pointtypes.PointPoint (x, y) to test.
recttypes.RectRectangle (x_min, y_min, x_max, y_max).
ReturnsboolTrue if the point is inside the rectangle.
ComplexityO(1) time, O(1) space