simvx.core.math.rect2

Rect2 — 2D axis-aligned bounding rectangle.

Module Contents

Classes

Rect2

2D axis-aligned bounding rectangle.

API

class simvx.core.math.rect2.Rect2(x=0.0, y=0.0, width=0.0, height=0.0)[source]

2D axis-aligned bounding rectangle.

Initialization

__slots__

(‘x’, ‘y’, ‘width’, ‘height’)

property position: tuple[float, float]
property size: tuple[float, float]
property end: tuple[float, float]
property area: float
property center: tuple[float, float]
contains_point(x: float, y: float) bool[source]

Return True if (x, y) lies inside (or on the boundary of) this rect.

intersects(other: simvx.core.math.rect2.Rect2) bool[source]

Return True if this rect overlaps with other.

intersection(other: simvx.core.math.rect2.Rect2) simvx.core.math.rect2.Rect2[source]

Return the overlapping area, or a zero rect if none.

merge(other: simvx.core.math.rect2.Rect2) simvx.core.math.rect2.Rect2[source]

Return the smallest rect enclosing both rects (union).

expand(point) simvx.core.math.rect2.Rect2[source]

Return a rect expanded to include the given point (x, y) or Vec2.

grow(amount: float) simvx.core.math.rect2.Rect2[source]

Return a rect grown by amount on each side.

abs() simvx.core.math.rect2.Rect2[source]

Return a rect with guaranteed positive width/height.

__eq__(other)[source]
__repr__()[source]