Uploaded image for project: 'Request For Comments'
  1. Request For Comments
  2. RFC-324

Change Box constructors to not invert points


    • Type: RFC
    • Status: Adopted
    • Resolution: Unresolved
    • Component/s: DM
    • Labels:


      Box's two main constructors look like this:

           *  @brief Construct a box from its minimum and maximum points.
           *  @param[in] minimum   Minimum (lower left) coordinate (inclusive).
           *  @param[in] maximum   Maximum (upper right) coordinate (inclusive).
           *  @param[in] invert    If true (default), swap the minimum and maximum coordinates if
           *                       minimum > maximum instead of creating an empty box.
          Box2I(Point2I const & minimum, Point2I const & maximum, bool invert=true);
           *  @brief Construct a box from its minimum point and dimensions.
           *  @param[in] minimum    Minimum (lower left) coordinate.
           *  @param[in] dimensions Box dimensions.  If either dimension coordinate is 0, the box will be empty.
           *  @param[in] invert     If true (default), invert any negative dimensions instead of creating
           *                        an empty box.
          Box2I(Point2I const & minimum, Extent2I const & dimensions, bool invert=true);

      Because an empty Box2I is defined is one with minimum > maximum (because minimum==maximum is a one-pixel box), one cannot round-trip a Box2I through its minimum and maximum points without explicitly setting invert=False.

      This is a source of confusion and the behavior invert=True was probably too clever to be a good default, and I'd like to make the default False remove the invert option entirely.

      (The same should be done for Box2D.)


          Issue Links



              • Assignee:
                jbosch Jim Bosch
                jbosch Jim Bosch
                Jim Bosch, John Parejko, John Swinbank, Krzysztof Findeisen, Russell Owen, Tim Jenness
              • Votes:
                0 Vote for this issue
                6 Start watching this issue


                • Created:
                  Planned End:

                  Summary Panel