3D Float Box

// 3D float box.
class RVAPI B3f
{
public:
    // Minimum point.
    S3f a;

    // Maximum point.
    S3f b;

    // Check if box has a positive area.
    bool IsValid() const { return b.x > a.x && b.y > a.y && b.z > a.z; };

    // Check if box intersects [scalar].
    bool IsIntersect(const S3f &scalar) const;

    // Check if this box intersects [box].
    bool IsIntersect(const B3f &box) const;

    // Check [box] is inside this box.
    bool IsInside(const B3f &box) const;

    // Get box dimensions.
    S3f Dims() const { return b - a; }

    // Get box volume.
    float Volume() const { return (b.x - a.x) * (b.y - a.y) * (b.z - a.z); }

    // Check if box points are both zero.
    bool operator ! () const { return !a && !b; }

    // Get sum of boxes.
    B3f operator + (const B3f &box) const { return B3f(a + box.a, b + box.b); }

    // Get difference of boxes.
    B3f operator - (const B3f &box) const { return B3f(a - box.a, b - box.b); }

    // Get product of boxes.
    B3f operator * (const B3f &box) const { return B3f(a * box.a, b * box.b); }

    // Get division of boxes.
    B3f operator / (const B3f &box) const { return B3f(a / box.a, b / box.b); }

    // Add [box] to this box.
    B3f &operator += (const B3f &box) { return *this = *this + box; }

    // Subtract [box] from this box.
    B3f &operator -= (const B3f &box) { return *this = *this - box; }

    // Multiply [box] by this box.
    B3f &operator *= (const B3f &box) { return *this = *this * box; }

    // Divide [box] into this box.
    B3f &operator /= (const B3f &box) { return *this = *this / box; }

    // Get point within this box using normalized coordinates [x], [y] and [z].
    S3f Point(float x, float y, float z) const;

    // Get intersection of this box and [box].
    B3f Intersect(const B3f &box) const;

    // Get [scalar] constrained to this box.
    S3f Constrain(const S3f &scalar) const;

    // Get [box] constrained to this box.
    B3f Constrain(const B3f &box) const;

    // Resize this box to enclose [scalar].
    void Enclose(const S3f &scalar);

    // Resize this box to enclose [box].
    void Enclose(const B3f &box);

    // Construct box from scalars.
    B3f(const S3f &scalarA, const S3f &scalarB) : a(scalarA), b(scalarB) {}

    // Construct box from coordinates.
    B3f(float ax, float ay, float az, float bx, float by, float bz) : a(ax, ay, az), b(bx, by, bz) {}

    // Construct box from origin and dimensions. Set [dimsMode] to true.
    B3f(float ax, float ay, float az, float dx, float dy, float dz, bool/*dimsMode*/) : a(ax, ay, az), b(ax + dx, ay + dy, az + dz) {}

    // Construct box from single coordinate value.
    B3f(float n = 0) : a(n), b(n) {}

    // Destruct box.
    ~B3f() {}
};