2D Float Bbox
// 2D float box.
class RVAPI B2f
{
public:
// Minimum point.
S2f a;
// Maximum point.
S2f b;
// Check if box has a positive area.
bool IsValid() const { return b.x > a.x && b.y > a.y; };
// Check if box intersects [scalar].
bool IsIntersect(const S2f &scalar) const;
// Check if this box intersects [box].
bool IsIntersect(const B2f &box) const;
// Check [box] is inside this box.
bool IsInside(const B2f &box) const;
// Get box dimensions.
S2f Dims() const { return b - a; }
// Get box area.
float Area() const { return (b.x - a.x) * (b.y - a.y); }
// Check if box points are both zero.
bool operator ! () const { return !a && !b; }
// Get sum of boxes.
B2f operator + (const B2f &box) const { return B2f(a + box.a, b + box.b); }
// Get difference of boxes.
B2f operator - (const B2f &box) const { return B2f(a - box.a, b - box.b); }
// Get product of boxes.
B2f operator * (const B2f &box) const { return B2f(a * box.a, b * box.b); }
// Get division of boxes.
B2f operator / (const B2f &box) const { return B2f(a / box.a, b / box.b); }
// Add [box] to this box.
B2f &operator += (const B2f &box) { return *this = *this + box; }
// Subtract [box] from this box.
B2f &operator -= (const B2f &box) { return *this = *this - box; }
// Multiply [box] by this box.
B2f &operator *= (const B2f &box) { return *this = *this * box; }
// Divide [box] into this box.
B2f &operator /= (const B2f &box) { return *this = *this / box; }
// Get point within this box using normalized coordinates [x] and [y].
S2f Point(float x, float y) const;
// Get intersection of this box and [box].
B2f Intersect(const B2f &box) const;
// Constrain [scalar] inside this box.
S2f Constrain(const S2f &scalar) const;
// Constrain [box] inside this box.
B2f Constrain(const B2f &box) const;
// Resize this box to enclose [scalar].
void Enclose(const S2f &scalar);
// Resize this box to enclose [box].
void Enclose(const B2f &box);
// Construct box from scalars.
B2f(const S2f &scalarA, const S2f &scalarB) : a(scalarA), b(scalarB) {}
// Construct box from coordinates.
B2f(float ax, float ay, float bx, float by) : a(ax, ay), b(bx, by) {}
// Construct box from origin and dimensions. Set [dimsMode] to true.
B2f(float ax, float ay, float dx, float dy, bool/*dimsMode*/) : a(ax, ay), b(ax + dx, ay + dy) {}
// Construct box from single coordinate value.
B2f(float n = 0) : a(n), b(n) {}
// Destruct box.
~B2f() {}
};