Skip to content

box

box module contains definition of Box class used to represent 2D boxes.

Box

Bases: ModelType

Represents a box in 2D space.

from_vectors classmethod

from_vectors(*vectors: Vector) -> Self

Create a box from vectors.

from_center_width_height classmethod

from_center_width_height(
    center: tuple[float, float], width: float, height: float
) -> Self

Create a box from center, width and height.

width

width() -> float

Get width of the box.

height

height() -> float

Get height of the box.

center

center() -> Vector

Get mean center of the box.

__add__

__add__(other: object) -> Self

Add a vector to the box.

__iadd__

__iadd__(other: object) -> Self

Add a vector to the box.

__radd__

__radd__(other: object) -> Self

Add a vector to the box.

__sub__

__sub__(other: object) -> Self

Subtract a vector from the box.

__isub__

__isub__(other: object) -> Self

Subtract a vector from the box.

__rsub__

__rsub__(other: object) -> Self

Subtract a vector from the box.