4.6.3 pde.tools.cuboid module

An n-dimensional, axes-aligned cuboid.

This module defines the Cuboid class, which represents an n-dimensional cuboid that is aligned with the axes of a Cartesian coordinate system.

class Cuboid(pos, size, mutable=True)[source]

Bases: object

Class that represents a cuboid in \(n\) dimensions.

Defines a cuboid from a position and a size vector.

Parameters:
  • pos (list) – The position of the lower left corner. The length of this list determines the dimensionality of space

  • size (list) – The size of the cuboid along each dimension.

  • mutable (bool) – Flag determining whether the cuboid parameters can be changed

property bounds: tuple[tuple[float, float], ...]
buffer(amount=0, inplace=False)[source]

Dilate the cuboid by a certain amount in all directions.

Parameters:

amount (float | ndarray)

Return type:

Cuboid

property centroid
contains_point(points)[source]

Returns a True when points are within the Cuboid.

Parameters:

points (ndarray) – List of point coordinates

Returns:

list of booleans indicating which points are inside

Return type:

ndarray

copy()[source]
Return type:

Cuboid

property corners: tuple[ndarray, ndarray]

Return coordinates of two extreme corners defining the cuboid.

property diagonal: float

Returns the length of the diagonal.

property dim: int
classmethod from_bounds(bounds, **kwargs)[source]

Create cuboid from bounds.

Parameters:

bounds (list) – Two dimensional array of axes bounds

Returns:

cuboid with positive size

Return type:

Cuboid

classmethod from_centerpoint(centerpoint, size, **kwargs)[source]

Create cuboid from two points.

Parameters:
  • centerpoint (list) – Coordinates of the center

  • size (list) – Size of the cuboid

Returns:

cuboid with positive size

Return type:

Cuboid

classmethod from_points(p1, p2, **kwargs)[source]

Create cuboid from two points.

Parameters:
  • p1 (list) – Coordinates of first corner point

  • p2 (list) – Coordinates of second corner point

Returns:

cuboid with positive size

Return type:

Cuboid

property mutable: bool
property size: ndarray
property surface_area: float

Surface area of a cuboid in \(n\) dimensions.

The surface area is the volume of the (\(n-1\))-dimensional hypercubes that bound the current cuboid:

  • \(n=1\): the number of end points (2)

  • \(n=2\): the perimeter of the rectangle

  • \(n=3\): the surface area of the cuboid

property vertices: list[list[float]]

Return the coordinates of all the corners.

property volume: float
asanyarray_flags(data, dtype=None, writeable=True)[source]

Turns data into an array and sets the respective flags.

A copy is only made if necessary

Parameters:
Returns:

array with same data as data but with flags adjusted.

Return type:

ndarray