Skip to main content

BoundRect

The BoundRect type defines an axis-aligned bounding rectangle for 2D space, providing efficient spatial containment, expansion, and intersection logic. It supports initialization from points, circles, and other bounding rectangles, and offers utilities for validation, distance computation, ray intersection, and spatial queries. The implementation prioritizes performance, precision, and flexibility with support for custom vector types.

#include <geometry/TellusimBounds.h>

BoundRectf

Represents a BoundRect using 32-bit floating-point precision.

BoundRectd

Represents a BoundRect using 64-bit floating-point precision.

Variables

TypeNameDescription
Vector2minMinimum extent.
Vector2maxMaximum extent.
Vector2points[2]Array access.

Constructors

BoundRect()
BoundRect(const BoundRect &br)
BoundRect(const Vector2 &br_min, const Vector2 &br_max)
BoundRect(const Vector2 &bc_center, Type bc_radius)
BoundRect(const BoundRect &br, const BoundCircle &bc)
explicit BoundRect(const BoundCircle &bc)
explicit BoundRect(const BoundRect<CType, CVector> &br)
explicit BoundRect(const BoundCircle<CType, CVector> &bc)
BoundRect(const Vector2 *points, uint32_t num_points)

Methods

Clear bound rect.

void clear()

Check bound rect.

bool isValid() const
operator bool() const

Set bound rect.

void set(const Vector2 &br_min, const Vector2 &br_max)
void set(const BoundRect &br)

Set bound circle.

void set(const Vector2 &bc_center, Type bc_radius)
void set(const BoundCircle &bc)

Set minimal bound rect.

void set(const Vector2 &br_min, const Vector2 &br_max, const Vector2 &bc_center, const Type &bc_radius)
void set(const BoundRect &br, const BoundCircle &bc)

Set bound rect.

void set(const Vector2 *points, uint32_t num_points)

Expand by point.

void expand(const Vector2 &point)

Expand by bound rect.

void expand(const Vector2 &br_min, const Vector2 &br_max)
void expand(const BoundRect &br)

Expand by bound circle.

void expand(const Vector2 &bc_center, Type bc_radius)
void expand(const BoundCircle &bc)

Inside point.

bool inside(const Vector2 &point) const

Inside bound rect.

bool inside(const Vector2 &br_min, const Vector2 &br_max) const
bool inside(const BoundRect &br) const

Inside bound circle.

bool inside(const Vector2 &bc_center, Type bc_radius) const
bool inside(const BoundCircle &bc) const

Signed distance to the bound rect.

Type distance(const Vector2 &point) const

Bound rect ray intersection.

Vector2 trace(const Vector2 &point, const Vector2 &idirection) const

To bound circle.

Vector2 getCenter() const
Type getRadius() const

Bound rect parameters.

Vector2 getSize() const
const Vector2 &getMin() const
const Vector2 &getMax() const
const Vector2 *getPoints() const
Type getArea(Type threshold = 1e-8f) const

Operators

Matrix to bound rect multiplication.

BoundRect operator*(const Matrix4x3 &m, const BoundRect &br)
BoundRect operator*(const Matrix4x4 &m, const BoundRect &br)

Comparison operators.

bool operator==(const BoundRect &br0, const BoundRect &br1)
bool operator!=(const BoundRect &br0, const BoundRect &br1)