Function CE::Math::overlaps

Function Documentation

constexpr bool CE::Math::overlaps(const glm::vec2 p1, const glm::vec2 p2, const glm::vec2 d1, const glm::vec2 d2, const ::CE::Rendering::Geometry::Pivot a1 = ::CE::Rendering::Geometry::Pivot{}, const ::CE::Rendering::Geometry::Pivot a2 = ::CE::Rendering::Geometry::Pivot{}) noexcept

Declaration: [[nodiscard]]

Test whether two axis-aligned rectangles share positive area in Y-up coordinates.

Parameters:
  • p1 – Position of the first rectangle’s anchor, in caller-defined units.

  • p2 – Position of the second rectangle’s anchor, in the same coordinates and units.

  • d1 – Full width and height of the first rectangle; nonpositive dimensions return false.

  • d2 – Full width and height of the second rectangle; nonpositive dimensions return false.

  • a1 – Normalized top-left-origin anchor of the first rectangle; defaults to {0.5,0.5} (center).

  • a2 – Normalized top-left-origin anchor of the second rectangle; defaults to {0.5,0.5} (center).

Returns:

True for overlap or containment; false for separation, touching edges/corners or empty rectangles.

Pre:

Positions and dimensions are finite, anchors are finite and in [0,1], and calculated edges are representable. Rotation, scaling and coordinate conversion are the caller’s responsibility. No allocation or renderer is required.