**Last modified**: September 16, 2022

This is a reference chapter for the various classes that manage coordinates, dimensions and bounding boxes.

__init__(Int *x*, Int *y*)

Point stores an (*x*, *y*) coordinate point. On the C++ side, the
coordinates are unsigned integers, so that you cannot use negative
*x* or *y* values.

Most functions that take a Point as an argument can also take a 2-element sequence. For example, the following are all equivalent:

```
px = image.get(Point(5, 2))
px = image.get((5, 2))
px = image.get([5, 2])
```

From the numeric operators, only *+* and *+=* are implemented, because
subtraction would cause problems when the result is negative.
On the C++ side, the comparison operator *<* is also implemented, which does
not make real sense, but allows Points to be used as keys in maps and sets.

Size stores a size (*width*, *height*). This is almost the same as `Dim`, but stores the number of columns/rows minus one:

*width* == *ncols* - 1

*height* == *nrows* - 1

**Size** (Int *width*, Int *height*)

(int property)

The width of an object is the right boundary minus the left. This is the same as the number of columns *minus one.*

(int property)

The height of an object is the lower boundary minus the upper boundary (remember that *y* is counted in the negative direction). This is the same as the number of rows *minus one*.

There are a number of ways to initialize a `Rect` object:

Rect(Pointupper_left, Pointlower_right)Rect(Pointupper_left, Sizesize)Rect(Pointupper_left, Dimdim)Rect(Rectrectangle)

The `Rect` class manages bounding boxes, and has a number of methods to modify and analyse those bounding boxes.

(Point property)

The coordinate at the exact center of the rectangle in the logical coordinate space.

(int property)

The x-location at the exact center of the rectangle in the logical coordinate space.

(int property)

The y-location at the exact center of the rectangle in the logical coordinate space.

bool **contains_x** (Int *x*)

`True` if the rectangle contains the given x-value in logical coordinate space.

bool **contains_y** (Int *y*)

`True` if the rectangle contains the given y-value in logical coordinate space.

bool **contains_point** (Point *point*)

`True` if the rectangle contains the given `Point` in logical coordinate space

bool **contains_rect** (Rect *other*)

`True` if rectangle completely contains the given rectangle in logical coordinate space.

bool **intersects_x** (Rect *other*)

`True` if rectangle intersects the given rectangle in the *x* direction (completely ignoring the *y* direction). (`True` if the two rectangles are merely "vertically aligned".)

bool **intersects_y** (Rect *other*)

`True` if rectangle intersects the given rectangle in the *y* direction (completely ignoring the *x* direction). (`True` if the two rectangles are merely "horizontally aligned".)

bool **intersection** (Rect *other*)

Returns a new Rect that is the intersection of `self` and the given Rect object.

Rect **union_rects** (RectList *rects*)

Returns a new rectangle that encloses all of the given rectangles in a list.

float **distance_euclid** (Rect *other*)

Returns the Euclidean distance between the center points of this rectangle and the given rectangle.

float **distance_bb** (Rect *other*)

Returns the closest (Euclidean) distance between the edges of this rectangle and the edges of the given rectangle.

int **distance_cx** (Rect *other*)

Returns the distance of the center points of this rectangle and the given rectangle in the horizontal direction.

int **distance_cy** (Rect *other*)

Returns the distance of the center points of this rectangle and the given rectangle in the vertical direction.