Skip to content

RectangleRotated

Generated from engine/math/rectangle_rotated.h at 862e08b. 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

#include "engine/math/rectangle_rotated.h" · namespace mattmath

struct RectangleRotated : public Shape
RectangleRotated() = default;
RectangleRotated(const RectangleRotated&) = default;
RectangleRotated(const mattmath::Point2F& center,
const mattmath::Vector2F& x_axis, const mattmath::Vector2F& y_axis,
const mattmath::Vector2F& hw_extents);
RectangleRotated(const mattmath::Segment& center_line, float thickness);

bounding_box · shape_type · offset · center · edges · inflate

Section titled “bounding_box · shape_type · offset · center · edges · inflate”
RectangleF bounding_box() const override;
ShapeType shape_type() const override;
void offset(const Vector2F& amount) override;
Point2F center() const override;
std::array<Segment, 4> edges() const;
void inflate(float amount) override;

x_axis · y_axis · axis · half_extents · half_x_width · half_y_width · half_width

Section titled “x_axis · y_axis · axis · half_extents · half_x_width · half_y_width · half_width”
Point2F x_axis() const;
Point2F y_axis() const;
Point2F axis(int axis) const;
Point2F half_extents() const;
float half_x_width() const;
float half_y_width() const;
float half_width(int axis) const;
void set_center(const Point2F& center);

set_axes · set_x_axis · set_y_axis · set_half_extents · set_half_x_width · set_half_y_width

Section titled “set_axes · set_x_axis · set_y_axis · set_half_extents · set_half_x_width · set_half_y_width”
void set_axes(const Point2F& x_axis, const Point2F& y_axis);
void set_x_axis(const Point2F& x_axis);
void set_y_axis(const Point2F& y_axis);
void set_half_extents(const Point2F& hw_extents);
void set_half_x_width(float half_x_width);
void set_half_y_width(float half_y_width);

Rotating a rectangle means writing BOTH axes, and this is the only way to do it.

set_x_axis and set_y_axis each validate the candidate against the partner axis as it currently stands, which is correct and which makes them useless for turning anything: the new x axis has to be perpendicular to the OLD y axis, so every genuine rotation is rejected whichever of the two is called first. They remain for the one thing they can express - reversing an axis - and this exists for the thing they cannot.

Throws std::invalid_argument unless the pair is orthonormal, and commits nothing when it does.

Point2F point_0() const;
Point2F point_1() const;
Point2F point_2() const;
Point2F point_3() const;
const std::array<Point2F, 4>& points() const;

The four corners, in the order point_0..point_3 name them. A reference to storage the rectangle already holds, recomputed only when something that defines it changes.

Segment edge_0() const;
Segment edge_1() const;
Segment edge_2() const;
Segment edge_3() const;
Quad quad() const;
RectangleF rectangle_rotated_to_axis() const;
float angle() const;
bool is_valid() const;
bool operator==(const RectangleRotated& other) const;
bool operator!=(const RectangleRotated& other) const;
typedef RectangleRotated OBB;

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

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

Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.