RectD



This union represents four double precision floating point values or a double precision float point rectangle.

You can find more information in comments below.

union RectD
{
    struct
    {
        double Left;
        double Top;
        double Right;
        double Bottom;
    };
    struct
    {
        PointD LeftTop;
        PointD RightBottom;
    };
    double Data[4];

    double operator[](const int index) const; // Return element
    double &operator[](const int index); // Return element

    bool is_valid(const double tolerance = dTolerance) const; // Return whether right border isn't less than left and bottom isn't less than top
    bool is_empty(const double tolerance = dTolerance) const; // Return whether right border is same as left and bottom is same as top
    bool is_zero(const double tolerance = dTolerance) const; // Return whether either right border is same to left or bottom is same to top
    bool has_negative(const double tolerance = dTolerance) const; // Whether there is a negative element
    bool has_positive(const double tolerance = dTolerance) const; // Whether there is a positive element
    double width() const; // Rectangle width
    double height() const; // Rectangle height
    void validate(const double tolerance = dTolerance); // Make width and height not negative
};

Following operators are also available.

RectD operator+(const RectD &a, const double value); // Add rect and value
RectD operator-(const RectD &a, const double value); // Subtract rect and value
RectD operator/(const RectD &a, const double value); // Divide rect and value
RectD operator*(const RectD &a, const double value); // Multiply rect and value
RectD operator+(const double value, const RectD &a); // Add value and rect
RectD operator-(const double value, const RectD &a); // Subtract value and rect
RectD operator/(const double value, const RectD &a); // Divide value and rect
RectD operator*(const double value, const RectD &a); // Multiply value and rect
RectD &operator+=(RectD &a, const double value); // Add value to rect
RectD &operator-=(RectD &a, const double value); // Subtract value from rect
RectD &operator/=(RectD &a, const double value); // Divide rect on value
RectD &operator*=(RectD &a, const double value); // Multiply rect on value
RectD operator+(const RectD &a, const RectD &b); // Find bounding rect for both rects
RectD operator*(const RectD &a, const RectD &b); // Calculate intersection
RectD &operator+=(RectD &a, const RectD &b); // Find bounding rect for both rects and store it in first one
RectD &operator*=(RectD &a, const RectD &b); // Calculate intersection and store it in first one
RectD operator+(const RectD &a, const PointD &shift); // Return moved in shift direction rect
RectD operator-(const RectD &a, const PointD &shift); // Return moved in opposite to shift direction rect
RectD operator*(const RectD &a, const PointD &shift); // Return scaled in shift direction rect
RectD &operator+=(RectD &a, const PointD &shift); // Move rect in shift direction
RectD &operator-=(RectD &a, const PointD &shift); // Move rect in direction opposite to shift
RectD &operator*=(RectD &a, const PointD &shift); // Scale rect in shift direction
std::wostream &operator<<(std::wostream &stream, const RectF &a); // Output as source code
Namespace: nitisa
Include: Nitisa/Core/Math/RectD.h (For union declaration)
Nitisa/Core/Math/RectDUtils.h (For standalone operators)