Issue in Rectangle

EDIT : Be careful, this issue is valid only when point at negative position is used.

Hi, I am back with a fresh new issue.
But in fact, this seems to be there from a while now…

The function Rectangle::findAreaContainingPoints() returns a rectangle whose position is at bottom-left ! There is the code which is in this function:

    /** Returns the smallest Rectangle that can contain a set of points. */
    static Rectangle findAreaContainingPoints (const Point<ValueType>* const points, const int numPoints) noexcept
    {
        if (numPoints == 0)
            return Rectangle();

        ValueType minX (points[0].x);
        ValueType maxX (minX);
        ValueType minY (points[0].y);
        ValueType maxY (minY);

        for (int i = 1; i < numPoints; ++i)
        {
            minX = jmin (minX, points[i].x);
            maxX = jmax (maxX, points[i].x);
            minY = jmin (minY, points[i].y);
            maxY = jmax (maxY, points[i].y);
        }

        return Rectangle (minX, minY, maxX - minX, maxY - minY);
    }

As you see, minY is set to jmin() of Y-coordinates… So, position will be at bottom-left !

There are two solutions to solve this issue:

  • first, modify function to get jmax() of Y-coordinates.
  • second, use the static Rectangle::leftTopRightBottom function with leftTopRightBottom(minX, maxY, maxX, minY).

Let me know what do you think about this issue, and what do you want to do with it.

Are you holding your computer upside-down?

Maybe I’m being stupid, but I can’t see anything wrong with that code (!?!?)

Rectangle::getTopLeft() returns the pos member. So, Rectangle are defined like this

pos---width
|
height

So, using Rectangle::findAreaContainingPoints() which create Rectangle from (minX, minY) and (maxX - minX, maxY - minY), you get

height
|
pos---width

As you can see, the one created from ::findAreaContainingPoints() returns a reverted Rectangle along OY axis.

No, I really can’t see.

This isn’t openGL or CoreGraphics - the origin is at the top-left, not the bottom left, and y values increase downwards.

Yeah, it was late and I was a bit burned.
I was mixing coordinate systems in geometry, graphics, and OpenGL texture.
I am sorry ^^’