# Change Box constructors to not invert points

XMLWordPrintable

## Details

• Type: RFC
• Resolution: Unresolved
• Component/s:
• 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.)

## People

• Assignee:
Jim Bosch
Reporter:
Jim Bosch
Watchers:
Jim Bosch, John Parejko, John Swinbank, Krzysztof Findeisen, Russell Owen, Tim Jenness