dodal.common.Rectangle2D#

class dodal.common.Rectangle2D[source]#

A 2D rectangle defined by two opposite corners.

This class represents a rectangle in 2D space using two points: (x1, y1) and (x2, y2). It provides methods to query rectangle properties and check point containment.

x1#

The x-coordinate of the first corner.

Type:

float

y1#

The y-coordinate of the first corner.

Type:

float

x2#

The x-coordinate of the second corner.

Type:

float

y2#

The y-coordinate of the second corner.

Type:

float

Parameters:
  • x1 (float) – The x-coordinate of the first corner.

  • y1 (float) – The y-coordinate of the first corner.

  • x2 (float) – The x-coordinate of the second corner.

  • y2 (float) – The y-coordinate of the second corner.

Methods

contains(x, y)

Check if a point is contained within the rectangle.

get_max_x()

Get the maximum x-coordinate of the rectangle.

get_max_y()

Get the maximum y-coordinate of the rectangle.

get_min_x()

Get the minimum x-coordinate of the rectangle.

get_min_y()

Get the minimum y-coordinate of the rectangle.

get_max_x() float[source]#

Get the maximum x-coordinate of the rectangle.

Returns:

The larger of the two x-coordinates (x1, x2).

Return type:

float

get_min_x() float[source]#

Get the minimum x-coordinate of the rectangle.

Returns:

The smaller of the two x-coordinates (x1, x2).

Return type:

float

get_max_y() float[source]#

Get the maximum y-coordinate of the rectangle.

Returns:

The larger of the two y-coordinates (y1, y2).

Return type:

float

get_min_y() float[source]#

Get the minimum y-coordinate of the rectangle.

Returns:

The smaller of the two y-coordinates (y1, y2).

Return type:

float

contains(x: float, y: float) bool[source]#

Check if a point is contained within the rectangle.

Parameters:
  • x (float) – The x-coordinate of the point.

  • y (float) – The y-coordinate of the point.

Returns:

True if the point is within the rectangle bounds, False otherwise.

Return type:

bool