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: bool = 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: Union[float, ndarray] = 0, inplace=False) Cuboid[source]

dilate the cuboid by a certain amount in all directions

property centroid
contains_point(points: ndarray) ndarray[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() Cuboid[source]
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: ndarray, **kwargs) Cuboid[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: ndarray, size: ndarray, **kwargs) Cuboid[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: ndarray, p2: ndarray, **kwargs) Cuboid[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: ndarray, dtype=None, writeable: bool = True)[source]

turns data into an array and sets the respective flags.

A copy is only made if necessary

Parameters
  • data (ndarray) – numpy array that whose flags are adjusted

  • dtype – the resulant dtype

  • writeable (bool) – Flag determining whether the results is writable

Returns

array with same data as data but with flags adjusted.

Return type

ndarray