Cuboid

class sisl.shape.Cuboid(v, center=None)

Bases: sisl.shape.PureShape

A cuboid/rectangular prism (P4)

Parameters
  • v (float or (3,) or (3, 3)) – vectors describing the cuboid, if only 3 the cuboid will be along the Euclidean vectors.

  • center ((3,), optional) – the center of the cuboid. Defaults to the origo.

Examples

>>> shape = Cuboid([2, 2.2, 2])
>>> shape.within([0, 2.1, 0])
False
>>> shape.within([0, 1.1, 0])
True

Attributes

__doc__

__module__

__slots__

_center

_iv

_v

center

The geometric center of the shape

edge_length

The lengths of each of the vector that defines the cuboid

origo

Return the origin of the Cuboid (lower-left corner)

Methods

__add__(other)

__and__(other)

__contains__(other)

Checks whether all of other is within the shape

__delattr__

Implement delattr(self, name).

__dir__

Default dir() implementation.

__eq__

Return self==value.

__format__

Default object formatter.

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init__(v[, center])

Initialize self.

__init_subclass__

This method is called when a class is subclassed.

__le__

Return self<=value.

__lt__

Return self<value.

__ne__

Return self!=value.

__new__

Create and return a new object.

__or__(other)

__reduce__

Helper for pickle.

__reduce_ex__

Helper for pickle.

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__

Size of object in memory, in bytes.

__str__()

Return str(self).

__sub__(other)

__subclasshook__

Abstract classes can override this to customize issubclass().

__xor__(other)

copy()

expand(length)

Expand the cuboid by a constant value along side vectors

scale(scale)

Scale the cuboid box size (center is retained)

set_center(center)

Re-setting the center can sometimes be necessary

set_origo(origo)

Re-setting the origo can sometimes be necessary

toCuboid()

Return a copy of itself

toEllipsoid()

Return an ellipsoid that encompass this cuboid

toSphere()

Return a sphere that encompass this cuboid

volume()

Return volume of Cuboid

within(other, *args, **kwargs)

Return True if other is fully within self

within_index(other[, tol])

Return indices of the other object which are contained in the shape

property center

The geometric center of the shape

copy()[source]
property edge_length

The lengths of each of the vector that defines the cuboid

expand(length)[source]

Expand the cuboid by a constant value along side vectors

Parameters

length (float or (3,)) – the extension in Ang per cuboid vector.

property origo

Return the origin of the Cuboid (lower-left corner)

scale(scale)[source]

Scale the cuboid box size (center is retained)

Parameters

scale (float or (3,)) – the scale parameter for each of the vectors defining the Cuboid

set_center(center)[source]

Re-setting the center can sometimes be necessary

set_origo(origo)[source]

Re-setting the origo can sometimes be necessary

toCuboid()[source]

Return a copy of itself

toEllipsoid()[source]

Return an ellipsoid that encompass this cuboid

toSphere()[source]

Return a sphere that encompass this cuboid

volume()[source]

Return volume of Cuboid

within(other, *args, **kwargs)

Return True if other is fully within self

If other is an array, an array will be returned for each of these.

Parameters
  • other (array_like) – the array/object that is checked for containment

  • *args – passed directly to within_index

  • **kwargs – passed directly to within_index

within_index(other, tol=1e-08)[source]

Return indices of the other object which are contained in the shape

Parameters
  • other (array_like) – the object that is checked for containment

  • tol (float, optional) – absolute tolerance for boundaries