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

Change Box constructors to not invert points

    Details

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

      Description

      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.)

        Attachments

          Container Issues

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Planned End:

                    Summary Panel