locan.data.regions.region.Cuboid

class locan.data.regions.region.Cuboid(corner=(0.0, 0.0, 0.0), length=1.0, width=1.0, height=1.0, alpha=0.0, beta=0.0, gamma=0.0)[source]

Bases: Region3D

Region class to define a cuboid.

This is a 3-dimensional convex region with rectangular faces. Extension in x-, y-, z-coordinates correspond to length, width, height.

Corresponding Euler angles are defined by alpha, beta, gamma. Rotation has to be carried to in “zyx”-order. The corresponding rotation matrix can be generated from Cuboid.rotation.from_euler(“zyx”, [gamma, beta, alpha]).as_matrix().

Parameters:
  • corner (npt.ArrayLike) – A point that defines the lower left corner with shape (2,).

  • length (float) – The length of a vector describing the edge in x-direction.

  • width (float) – The length of a vector describing the edge in y-direction.

  • height (float) – The length of a vector describing the edge in z-direction.

  • alpha (float) – The first Euler angle (in degrees) by which the cuboid is rotated.

  • beta (float) – The second Euler angle (in degrees) by which the cuboid is rotated.

  • gamma (float) – The third Euler angle (in degrees) by which the cuboid is rotated.

Methods

__init__([corner, length, width, height, ...])

as_artist([origin])

Matplotlib patch object for this region (e.g. matplotlib.patches.Ellipse).

buffer(distance, **kwargs)

Extend the region perpendicular by a distance.

contains(points)

Return list of indices for all points that are inside the region of interest.

from_intervals(intervals)

Constructor for instantiating a line or axis-oriented, box-like Region from list of (min, max) bounds.

from_open3d(open3d_object)

Constructor for instantiating Region from open3d object.

intersection(other)

Returns a region representing the intersection of this region with other.

plot([ax])

Provide plot of region as matplotlib.axes.Axes object.

symmetric_difference(other)

Returns the union of the two regions minus any areas contained in the intersection of the two regions.

union(other)

Returns a region representing the union of this region with other.

Attributes

alpha

The first Euler angle (in degrees) by which the cuboid is rotated.

beta

The sescond Euler angle (in degrees) by which the cuboid is rotated.

bounding_box

A region describing the minimum axis-aligned bounding box that encloses the original region.

bounds

Region bounds min_x, min_y, ..., max_x, max_y, .

centroid

Point coordinates for region centroid.

corner

A point that defines the lower left corner.

dimension

The region dimension.

elongation

A measure between 0 and 1 for how elongated the object is.

extent

The extent (max_x - min_x), (max_y - min_y), .

gamma

The third Euler angle (in degrees) by which the cuboid is rotated.

height

The length of a vector describing the edge in z-direction.

intervals

Provide bounds in a tuple (min, max) arrangement.

isoperimetric_quotient

Ratio of the volume of a region to the volume of a ball with the same surface:

length

The length of a vector describing the edge in x-direction.

max_distance

The maximum distance between any two points within the region.

open3d_object

points

radial_distance

Average of all absolute distances between vertices and centroid.

region_measure

Region measure, i.e. area (for 2d) or volume (for 3d).

rotation

An instance of Rotation3D, an adapter class for scipy.stats.transform.Rotation.

subregion_measure

Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).

vertices

0 - dimensional elements that define the region; also called points.

width

The length of a vector describing the edge in y-direction.

property alpha: float

The first Euler angle (in degrees) by which the cuboid is rotated.

Return type:

float

as_artist(origin=(0, 0), **kwargs)[source]

Matplotlib patch object for this region (e.g. matplotlib.patches.Ellipse).

Parameters:
  • origin (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – The (x, y, z) pixel position of the origin of the displayed image. Default is (0, 0, 0).

  • kwargs (Any) – Other parameters passed to the matplotlib.patches object.

Returns:

Matplotlib patch for the specified region.

Return type:

matplotlib.patches.Patch

property beta: float

The sescond Euler angle (in degrees) by which the cuboid is rotated.

Return type:

float

property bounding_box: AxisOrientedCuboid

A region describing the minimum axis-aligned bounding box that encloses the original region.

Return type:

Region

property bounds: ndarray[tuple[int, ...], dtype[float64]]

Region bounds min_x, min_y, …, max_x, max_y, … for each dimension.

Returns:

of shape (2 * dimension,)

Return type:

npt.NDArray[np.float64] | None

buffer(distance, **kwargs)[source]

Extend the region perpendicular by a distance.

Parameters:

distance (float) – Distance by which the region is extended.

Returns:

The extended region.

Return type:

Region

property centroid: ndarray[tuple[int, ...], dtype[float64]]

Point coordinates for region centroid.

Returns:

of shape (dimension,)

Return type:

npt.NDArray[np.float64] | None

contains(points)[source]

Return list of indices for all points that are inside the region of interest.

Parameters:

points (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – Coordinates of points that are tested for being inside the specified region.

Returns:

Array with indices for all points in original point array that are within the region.

Return type:

npt.NDArray[np.int64]

property corner: ndarray[tuple[int, ...], dtype[float64]]

A point that defines the lower left corner.

Returns:

Coordinates with shape (3,)

Return type:

npt.NDArray[np.float64]

property elongation: float

A measure between 0 and 1 for how elongated the object is. It is computed as: 1 - the ratio of length of minor axis to length of major axis.

Return type:

float

property extent: ndarray[tuple[int, ...], dtype[float64]]

The extent (max_x - min_x), (max_y - min_y), … for each dimension.

Returns:

of shape (dimension,)

Return type:

npt.NDArray[np.float64] | None

static from_open3d(open3d_object)[source]

Constructor for instantiating Region from open3d object.

Parameters:

open3d_object (OrientedBoundingBox) – Geometric object to be converted into Region

Return type:

Cuboid | EmptyRegion

property gamma: float

The third Euler angle (in degrees) by which the cuboid is rotated.

Return type:

float

property height: float

The length of a vector describing the edge in z-direction.

Return type:

float

property intervals: ndarray[tuple[int, ...], dtype[float64]]

Provide bounds in a tuple (min, max) arrangement.

Returns:

((min_x, max_x), …) of shape(dimension, 2)

Return type:

npt.NDArray[np.float64]

property length: float

The length of a vector describing the edge in x-direction.

Return type:

float

property max_distance: float

The maximum distance between any two points within the region.

Return type:

float

property open3d_object: OrientedBoundingBox
property points: ndarray[tuple[int, ...], dtype[float64]]
property region_measure: float

Region measure, i.e. area (for 2d) or volume (for 3d).

Return type:

float

property rotation: Rotation3D

An instance of Rotation3D, an adapter class for scipy.stats.transform.Rotation.

Return type:

scipy.stats.transform.Rotation

property subregion_measure: float

Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).

Return type:

float

property vertices: ndarray[tuple[int, ...], dtype[float64]]

0 - dimensional elements that define the region; also called points.

Returns:

of shape (n_vertices, dimension)

Return type:

npt.NDArray[np.float64] | list[npt.NDArray[np.float64]]

property width: float

The length of a vector describing the edge in y-direction.

Return type:

float