math::Reflection — the field plane reflected across a line through the origin, or left as it is.
This header declares 3 types (19 members).
Extracted from include/shulib/math/reflection.hpp — this page is that header's documentation, reformatted, so it cannot disagree with the code. Prose about how to think about the API lives in How it works; worked recipes live in Recipes; this page is the complete, mechanical list of what exists.
class ReflectionThe field plane reflected across a line through the origin at a multiple of 45 degrees, or the identity (the default) — the file banner's table. Exact in position, idempotent in pairs (a reflection applied twice gives positions back equal), never produces -0.0.
class, declared at include/shulib/math/reflection.hpp:58.
constexpr Reflection() noexcept = defaultThe identity.
function, declared at include/shulib/math/reflection.hpp:76.
[[nodiscard]] static constexpr Reflection identity() noexceptThe identity, by name.
function, declared at include/shulib/math/reflection.hpp:79.
[[nodiscard]] static constexpr Reflection across(Line line) noexceptThe reflection across line (Line::None is the identity).
function, declared at include/shulib/math/reflection.hpp:82.
[[nodiscard]] static Reflection acrossLineAt(Angle heading)The reflection across the line through the origin at heading (either direction along it: -45 deg and 135 deg are the same line). PRECONDITION: heading is a multiple of 45 degrees (within 1e-9 deg) — any other line would need irrational coefficients and lose exactness.
function, declared at include/shulib/math/reflection.hpp:87.
[[nodiscard]] constexpr bool isIdentity() const noexceptTrue for the identity (nothing is reflected).
function, declared at include/shulib/math/reflection.hpp:103.
[[nodiscard]] constexpr Line line() const noexceptThe line (Line::None for the identity).
function, declared at include/shulib/math/reflection.hpp:105.
[[nodiscard]] friend constexpr bool operator==(const Reflection& a, const Reflection& b) noexceptTwo reflections are equal when they are across the same line.
function, declared at include/shulib/math/reflection.hpp:108.
[[nodiscard]] constexpr Point apply(units::Length x, units::Length y) const noexceptThe point (x, y) reflected — EXACT (the coefficients are 0 / +-1), never -0.0. The identity returns it untouched.
function, declared at include/shulib/math/reflection.hpp:114.
[[nodiscard]] constexpr Point apply(const Point& p) const noexceptThe point p reflected (as apply(x, y)).
function, declared at include/shulib/math/reflection.hpp:127.
[[nodiscard]] Angle apply(Angle h) constThe heading h reflected: 2a - h for the line at heading a, wrapped into (-pi, pi] (F3), never -0.0. The identity returns it untouched.
function, declared at include/shulib/math/reflection.hpp:131.
[[nodiscard]] Pose2d apply(const Pose2d& p) constThe pose p reflected: its position and its heading. The identity returns it untouched.
function, declared at include/shulib/math/reflection.hpp:142.
[[nodiscard]] ChassisSpeeds apply(const ChassisSpeeds& s, Frame frame) const noexceptA chassis velocity in frame reflected (the file banner): FIELD — (vx, vy) as a point, the turn rate negated; BODY — (vx, -vy, -omega) for every line. Never -0.0. The identity returns it untouched.
function, declared at include/shulib/math/reflection.hpp:153.
enum class Line : std::uint8_tThe line the reflection is across (the file banner's table); None = the identity.
enum class, declared at include/shulib/math/reflection.hpp:61.
None = 0the identity: nothing is reflected
enumerator, declared at include/shulib/math/reflection.hpp:62.
XAxis = 1y = 0: (x, -y, -h) — also the robot-frame mirror ("every left a right")
enumerator, declared at include/shulib/math/reflection.hpp:63.
Diagonal = 2y = x: (y, x, 90 deg - h)
enumerator, declared at include/shulib/math/reflection.hpp:64.
YAxis = 3x = 0: (-x, y, 180 deg - h)
enumerator, declared at include/shulib/math/reflection.hpp:65.
AntiDiagonal = 4y = -x: (-y, -x, -90 deg - h) — Override's skills mirror
enumerator, declared at include/shulib/math/reflection.hpp:66.
struct PointA field point (inches) — what a reflection maps a position to.
struct, declared at include/shulib/math/reflection.hpp:70.
units::Length x{}field x, inches
field, declared at include/shulib/math/reflection.hpp:71.
units::Length y{}field y, inches
field, declared at include/shulib/math/reflection.hpp:72.
The header opens with the reasoning behind these shapes. It is reproduced here in full because a reference that only lists signatures teaches nobody why.
The header’s own reasoning — 41 lines
math::Reflection — the field plane reflected across a line through the origin, or left as it is (chunk
MIRROR1-A, 2026-11-13; the MIRROR1 brief's §1.2 and D1/D7). PURE: it includes only math/ and units/
(SHULIB_PRECONDITION reaches it through math/angle.hpp, which carries core/check.hpp for every math
header). Not in the locked math/frame.hpp, whose banner allows "new vocabulary only".
── Why only lines at a multiple of 45 degrees ───────────────────────────────────────────────────
A reflection across the line through the origin at heading a maps a point by the matrix
[ cos 2a sin 2a ]
[ sin 2a -cos 2a ]
and a heading h to 2a - h. At a multiple of 45 degrees, 2a is a multiple of 90 degrees, so every
coefficient is EXACTLY 0 or +-1: a position is reflected by swapping and negating coordinates — no
rounding at all — and a reflected reflection gives the position back EXACTLY. Those are the only
four lines a VEX field's symmetry uses (the two midlines and the two diagonals); any other line is a
precondition, refused by acrossLineAt(). The four, in the field frame (F1: +x right as seen from the
red station, +y away from it, heading 0 along +x, counterclockwise positive):
XAxis y = 0 (x, y, h) -> ( x, -y, -h) — also the ROBOT-frame mirror (D7)
Diagonal y = x (x, y, h) -> ( y, x, 90 deg - h)
YAxis x = 0 (x, y, h) -> (-x, y, 180 deg - h)
AntiDiagonal y = -x (x, y, h) -> (-y, -x, -90 deg - h) — Override's SKILLS mirror (D1)
── What it reflects ─────────────────────────────────────────────────────────────────────────────
A point, a Pose2d (position and heading), an Angle (2a - h, re-wrapped into F3's (-pi, pi]), and a
ChassisSpeeds in either math::Frame: a FIELD velocity's (vx, vy) as a point and its turn rate negated;
a BODY velocity as (vx, -vy, -omega) whatever the line — the mirror image of a robot drives the same
speed forward, the same speed to its other side, and turns the other way.
── Two rules that keep its output safe to print and to compare ─────────────────────────────────
* NEVER -0.0. Reflecting negates, and -(0.0) prints "-0.0" — robot one's x = 0 must not reach robot
two's screen as "y = -0.0". Every component a non-identity reflection produces is normalised with
`+ 0.0` (in round-to-nearest, -0.0 + 0.0 is +0.0 and every other value is unchanged): the idiom
competition/toggle_visit.hpp's towardWallRadians already uses. A reflected reflection therefore
returns positions EQUAL to the original (an input -0.0 comes back +0.0, which compares equal), not
bit-identical.
* THE IDENTITY IS NOT APPLIED. apply() on the identity hands back its input untouched — and a caller
that must stay bit-identical when nothing is mirrored (the Chassis's verbs) branches on
isIdentity() and never calls apply() at all: re-wrapping a heading through Angle::radians can move
its last bit (the MIRROR1 brief's landmine 6).
Headings follow F3 untouched: the result is wrapped into (-pi, pi], an exact -pi stored as +pi.
PROS-free, allocation-free, header-only. Nothing here has run on a robot.