A rectangle is defined by origin (O), two unit-length axis vectors
(U, V), and two non-negative extents (e1, e2). More...
#include <Nimble/Rectangle.hpp>
Public Member Functions | |
| Nimble::Vector2f | axis0 () const |
| Returns the first axis of the rectangle. | |
| Nimble::Vector2f | axis1 () const |
| Returns the second axis of the rectangle. | |
| Nimble::Rect | boundingBox () const |
| Get the axis-aligned bounding box of this rectangle. More... | |
| Nimble::Vector2f | center () const |
| Return the center point of the rectangle. | |
| void | computeCorners (std::array< Nimble::Vector2f, 4 > &corners) const |
| Computes the corner vertices of the rectangle and appends the to the given array. More... | |
| float | extent0 () const |
| Returns the extent along axis0. | |
| float | extent1 () const |
| Returns the extent along axis1. | |
| bool | intersects (const Rectangle &r) const |
| Test if two rectangles intersect. More... | |
| bool | isInside (Nimble::Vector2f p) const |
| Test if a point is inside the rectangle. More... | |
| bool | isInside (const Nimble::Rectangle &r) const |
| Test if an another rectangle is fully inside this rectangle. More... | |
| Rectangle () | |
| Constructs a new rectangle. Does not initialize values. | |
| Rectangle (Nimble::Vector2f origin, Nimble::Vector2f a0, float e0, Nimble::Vector2f a1, float e1) | |
| Constructs a new rectangle. More... | |
| Rectangle (Nimble::SizeF size, const Nimble::Matrix3 &m) | |
| Constructs a new rectangle. More... | |
| Rectangle (const Nimble::Rectf &rect) | |
| Construct a copy of the given rectangle. More... | |
| Nimble::SizeF | size () const |
| Return the size of the rectangle. | |
| void | transform (const Nimble::Matrix3 &m) |
| Transforms the rectangle with the given matrix. More... | |
Static Public Member Functions | |
| static Nimble::Rectangle | merge (const Nimble::Rectangle &a, const Nimble::Rectangle &b) |
| Returns a rectangle that contains the two given rectangles. More... | |
A rectangle is defined by origin (O), two unit-length axis vectors
(U, V), and two non-negative extents (e1, e2).
Point P=O+x*U+y*V is inside or on the rectangle whenever |x|<=e1 and |y|<=e2.
| Nimble::Rectangle::Rectangle | ( | Nimble::Vector2f | origin, |
| Nimble::Vector2f | a0, | ||
| float | e0, | ||
| Nimble::Vector2f | a1, | ||
| float | e1 | ||
| ) |
Constructs a new rectangle.
| origin | center of the box |
| a0 | unit-length axis vector |
| e0 | non-negative extent along a0 |
| a1 | unit-length axis vector |
| e1 | non-negative extent along a1 |
| Nimble::Rectangle::Rectangle | ( | Nimble::SizeF | size, |
| const Nimble::Matrix3 & | m | ||
| ) |
Constructs a new rectangle.
| size | size (width & height) of the rectangle |
| m | transformation matrix defining the center of the rectangle |
| Nimble::Rectangle::Rectangle | ( | const Nimble::Rectf & | rect | ) |
Construct a copy of the given rectangle.
| rect | rectangle to copy |
| Nimble::Rect Nimble::Rectangle::boundingBox | ( | ) | const |
Get the axis-aligned bounding box of this rectangle.
| void Nimble::Rectangle::computeCorners | ( | std::array< Nimble::Vector2f, 4 > & | corners | ) | const |
Computes the corner vertices of the rectangle and appends the to the given array.
| corners | vector of points where the four corners are appended |
| bool Nimble::Rectangle::intersects | ( | const Rectangle & | r | ) | const |
Test if two rectangles intersect.
| r | rectangle to test |
| bool Nimble::Rectangle::isInside | ( | Nimble::Vector2f | p | ) | const |
Test if a point is inside the rectangle.
| p | point to test |
| bool Nimble::Rectangle::isInside | ( | const Nimble::Rectangle & | r | ) | const |
Test if an another rectangle is fully inside this rectangle.
| r | rectangle to test |
|
static |
Returns a rectangle that contains the two given rectangles.
The result is not guaranteed to be the smallest rectangle containing the input rectangles.
| a | rectangle to merge |
| b | rectangle to merge |
| void Nimble::Rectangle::transform | ( | const Nimble::Matrix3 & | m | ) |
Transforms the rectangle with the given matrix.
If the matrix is not orthogonal, the results are undefined.
| m | transformation matrix |