Skip to content

RectangleF

Generated from engine/math/rectanglef.h at f525bc6. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the math module

Audience: game code.

#include "engine/math/rectanglef.h" · namespace labrador

struct RectangleF : public Shape
float x = 0.0f;
float y = 0.0f;
float width = 0.0f;
float height = 0.0f;
RectangleF() = default;
RectangleF(const RectangleF&) = default;
RectangleF& operator=(const RectangleF&) = default;
constexpr RectangleF(float x, float y, float width, float height);
RectangleF(const Vector2F& position,
const Vector2F& size);
RectangleF(const Vector2F& center, float half_width,
float half_height);

constexpr and defined here so zero is constant-initialised. See Vector2F's constants for what the dynamic alternative risks.

RectangleF bounding_box() const override;
ShapeType shape_type() const override;

center · position · size · left · right · top · bottom · top_left · bottom_right · top_right · bottom_left · top_edge · bottom_edge · left_edge · right_edge · edges

Section titled “center · position · size · left · right · top · bottom · top_left · bottom_right · top_right · bottom_left · top_edge · bottom_edge · left_edge · right_edge · edges”
Vector2F center() const override;
Vector2F position() const;
Vector2F size() const;
float left() const;
float right() const;
float top() const;
float bottom() const;
Vector2F top_left() const;
Vector2F bottom_right() const;
Vector2F top_right() const;
Vector2F bottom_left() const;
Segment top_edge() const;
Segment bottom_edge() const;
Segment left_edge() const;
Segment right_edge() const;
std::array<Segment, 4> edges() const;
bool operator==(const RectangleF& other) const;
bool operator!=(const RectangleF& other) const;
bool contains(const RectangleF& other) const;
bool intersects(const RectangleF& other) const;

The one member predicate, because box against box is what the broad phase and the scene's view cull ask. Every other pair is a free predicate in intersects.h (shape.h says why there is no virtual table over them).

inflate · offset · scale · set_position · set_position_at_center · set_size · set_width · set_height

Section titled “inflate · offset · scale · set_position · set_position_at_center · set_size · set_width · set_height”
void inflate(float horizontal_amount, float vertical_amount);
void inflate(const Vector2F& amount);
void inflate(float amount) override;
void offset(float horizontal_amount, float vertical_amount);
void offset(const Vector2F& amount) override;
void scale(float horizontal_amount, float vertical_amount);
void scale(const Vector2F& amount);
void set_position(const Vector2F& position);
void set_position(float x, float y);
void set_position_at_center(const Vector2F& position);
void set_position_at_center(float x, float y);
void set_size(const Vector2F& size);
void set_size(float width, float height);
void set_width(float width);
void set_height(float height);
static RectangleF union_of(const RectangleF& a, const RectangleF& b);
static RectangleF bounding_box_of(std::span<const Point2F> points);

The smallest axis-aligned box containing every point.

Triangle, Quad and RectangleRotated all take their bounding_box() from this. Empty in, zero out - a box around nothing.

A non-finite coordinate is NOT rejected. std::min(a, NaN) returns a, so a poisoned vertex is silently dropped rather than poisoning the box, and checking per coordinate would put an isnan on a path every broad-phase candidate walks. The predicates downstream are the ones written to survive a NaN (see test_AABB_AABB); this stays cheap.

static const RectangleF zero;
typedef RectangleF AABB;

Named in the public declarations above: Segment, Shape, ShapeType, Vector2F.

The files that include this header directly. A file can also reach it through another header.

Documentation for Labrador v0.4.0. Built from Labrador f525bc6 of 2026-11-17.

All documentation versions