Axis-aligned rectangle in the XY plane, stored as an origin corner and a signed size.
More...
#include <meshkit/geometry.hpp>
|
| constexpr | Box2 ()=default |
| | Null box at the origin: width and height 0, so isNull() and isEmpty() hold.
|
| |
| constexpr | Box2 (Point2 a, Point2 b) |
| | Box spanning from corner a to corner b.
|
| |
| constexpr double | left () const |
| | X of the origin corner; the minimum x when width() >= 0.
|
| |
| constexpr double | right () const |
| | left() + width(); the maximum x when width() >= 0.
|
| |
| constexpr double | top () const |
| | Y of the origin corner; the minimum y when height() >= 0.
|
| |
| constexpr double | bottom () const |
| | top() + height(); the maximum y when height() >= 0.
|
| |
| constexpr double | width () const |
| | Signed extent along x in XY plane units; negative when not normalized.
|
| |
| constexpr double | height () const |
| | Signed extent along y in XY plane units; negative when not normalized.
|
| |
| | Box2 (double x, double y, double w, double h) |
| | Box from an origin corner and a size, all stored as given.
|
| |
| Box2 | normalized () const |
| | Copy with non-negative width and height covering the same two corners.
|
| |
| bool | isValid () const |
| | True when width and height are both > 0.
|
| |
| bool | isEmpty () const |
| | True when width <= 0 or height <= 0.
|
| |
| bool | isNull () const |
| | True when width and height are both exactly 0 (one zero side is empty, not null).
|
| |
| Point2 | bottomRight () const |
| | Corner (right(), bottom()).
|
| |
| Point2 | topLeft () const |
| | Corner (left(), top()), the origin corner.
|
| |
| bool | contains (double x, double y) const |
| | Inclusive point-in-box test on coordinates; same as contains(Point2(x, y)).
|
| |
| bool | contains (Point2 p) const |
| | Inclusive point-in-box test.
|
| |
| bool | intersects (Box2 b) const |
| | Strict overlap test.
|
| |
| Box2 | intersected (Box2 b) const |
| | Overlap of this box and b.
|
| |
| Box2 | adjusted (double l, double t, double r, double b) const |
| | Copy with each edge moved by an offset, in XY plane units.
|
| |
| constexpr Point2 | center () const |
| | Midpoint (left() + width() / 2, top() + height() / 2).
|
| |
| Box2 | united (Box2 b) const |
| | Bounding box of this box and b.
|
| |
Axis-aligned rectangle in the XY plane, stored as an origin corner and a signed size.
Stand-in for QRectF in detail::StandardStorage, with QRectF's naming: left() and top() are the origin corner, right() is left() + width() and bottom() is top() + height(). With a non-negative height, top() is the minimum-y edge, which is not the visually upper edge of a y-up map. Coordinates, width and height are in XY plane units; there are no finiteness checks. Width and height may be negative (see normalized()). contains(), intersects(), intersected() and united() assume normalized boxes (width and height >= 0) and do not normalize their inputs.
◆ Box2() [1/3]
◆ Box2() [2/3]
Box spanning from corner a to corner b.
The size is stored as b - a and the corners are not reordered, so a b left of or below a gives a negative width or height.
- Parameters
-
◆ Box2() [3/3]
| meshkit::Box2::Box2 |
( |
double | x, |
|
|
double | y, |
|
|
double | w, |
|
|
double | h ) |
|
inline |
Box from an origin corner and a size, all stored as given.
- Parameters
-
| [in] | x | Left (origin) x in XY plane units. |
| [in] | y | Top (origin) y in XY plane units. |
| [in] | w | Width; may be negative. |
| [in] | h | Height; may be negative. |
◆ adjusted()
| Box2 meshkit::Box2::adjusted |
( |
double | l, |
|
|
double | t, |
|
|
double | r, |
|
|
double | b ) const |
|
inline |
Copy with each edge moved by an offset, in XY plane units.
adjusted(-d, -d, d, d) grows a normalized box by d on every side.
- Parameters
-
- Returns
- Box from
(left() + l, top() + t) to (right() + r, bottom() + b).
◆ bottom()
| double meshkit::Box2::bottom |
( |
| ) |
const |
|
inlineconstexpr |
◆ bottomRight()
| Point2 meshkit::Box2::bottomRight |
( |
| ) |
const |
|
inline |
◆ center()
| Point2 meshkit::Box2::center |
( |
| ) |
const |
|
inlineconstexpr |
◆ contains() [1/2]
| bool meshkit::Box2::contains |
( |
double | x, |
|
|
double | y ) const |
|
inline |
Inclusive point-in-box test on coordinates; same as contains(Point2(x, y)).
- Parameters
-
| [in] | x | Query x in XY plane units. |
| [in] | y | Query y in XY plane units. |
- Returns
- True when the point lies inside or on the boundary.
◆ contains() [2/2]
| bool meshkit::Box2::contains |
( |
Point2 | p | ) |
const |
|
inline |
Inclusive point-in-box test.
- Parameters
-
| [in] | p | Query point in XY plane units. |
- Returns
- True when
left() <= p.x <= right() and top() <= p.y <= bottom(), so points on an edge or corner are inside. Always false for a box with a negative width or height, or for a NaN coordinate.
◆ height()
| double meshkit::Box2::height |
( |
| ) |
const |
|
inlineconstexpr |
Signed extent along y in XY plane units; negative when not normalized.
◆ intersected()
| Box2 meshkit::Box2::intersected |
( |
Box2 | b | ) |
const |
|
inline |
Overlap of this box and b.
- Parameters
-
| [in] | b | Other box, assumed normalized like this one. |
- Returns
- Box from
(max(left), max(top)) to (min(right), min(bottom)) of the two boxes. Boxes that touch along an edge give a zero-width or zero-height box there; disjoint boxes give the null box Box2() at the origin.
◆ intersects()
| bool meshkit::Box2::intersects |
( |
Box2 | b | ) |
const |
|
inline |
Strict overlap test.
- Parameters
-
| [in] | b | Other box, assumed normalized. |
- Returns
- True when
left() < b.right(), right() > b.left(), top() < b.bottom() and bottom() > b.top(). Boxes that only share an edge or a corner do not intersect.
◆ isEmpty()
| bool meshkit::Box2::isEmpty |
( |
| ) |
const |
|
inline |
True when width <= 0 or height <= 0.
A NaN width or height makes both isValid() and isEmpty() false.
◆ isNull()
| bool meshkit::Box2::isNull |
( |
| ) |
const |
|
inline |
True when width and height are both exactly 0 (one zero side is empty, not null).
◆ isValid()
| bool meshkit::Box2::isValid |
( |
| ) |
const |
|
inline |
True when width and height are both > 0.
◆ left()
| double meshkit::Box2::left |
( |
| ) |
const |
|
inlineconstexpr |
X of the origin corner; the minimum x when width() >= 0.
◆ normalized()
| Box2 meshkit::Box2::normalized |
( |
| ) |
const |
|
inline |
Copy with non-negative width and height covering the same two corners.
- Returns
- Box from
(min(left, right), min(top, bottom)) to (max(left, right), max(top, bottom)).
◆ right()
| double meshkit::Box2::right |
( |
| ) |
const |
|
inlineconstexpr |
◆ top()
| double meshkit::Box2::top |
( |
| ) |
const |
|
inlineconstexpr |
Y of the origin corner; the minimum y when height() >= 0.
◆ topLeft()
| Point2 meshkit::Box2::topLeft |
( |
| ) |
const |
|
inline |
◆ united()
| Box2 meshkit::Box2::united |
( |
Box2 | b | ) |
const |
|
inline |
Bounding box of this box and b.
- Parameters
-
- Returns
- Box from
(min(left), min(top)) to (max(right), max(bottom)) of the two boxes. Each box's left() and top() are taken as its minimum corner, so both must be normalized. A null or empty box is not skipped: uniting with Box2() extends the result to include the origin.
◆ width()
| double meshkit::Box2::width |
( |
| ) |
const |
|
inlineconstexpr |
Signed extent along x in XY plane units; negative when not normalized.
The documentation for this class was generated from the following file: