sisl.shape.Cuboid
- class sisl.shape.Cuboid(v, center=None, origin=None)
Bases:
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 origin. Not allowed as argument iforigin
is passed.origin (
(3,)
, optional) – the offset for the cuboid. The center will be equal tov.sum(0) + origin
. Not allowed as argument ifcenter
is passed.
Examples
>>> shape = Cuboid([2, 2.2, 2]) >>> shape.within([0, 2.1, 0]) False >>> shape.within([0, 1.1, 0]) True
Conversion
A dispatcher for classes, using __get__ it converts into ObjectDispatcher upon invocation from an object, or a TypeDispatcher when invoked from a class
to.Cuboid
(*args, **kwargs)to.Ellipsoid
(*args, **kwargs)to.Sphere
(*args, **kwargs)Methods
copy
()Create a new copy of this object.
expand
(length)Expand the cuboid by a constant value along side vectors
scale
(scale)Scale the cuboid box size (center is retained)
toCuboid
()Return a copy of itself
Return an ellipsoid that encompass this cuboid
toSphere
()Return a sphere that encompass this cuboid
translate
(xyz)Translate the center of the shape by xyz.
within
(other, *args, **kwargs)Return
True
if other is fully within selfwithin_index
(other[, rtol])Return indices of the other object which are contained in the shape
Attributes
The geometric center of the shape
The lengths of each of the vector that defines the cuboid
Return the origin of the Cuboid (lower-left corner)
Return volume of 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.
- to.Cuboid(*args, **kwargs)
- to.Ellipsoid(*args, **kwargs)
- to.Sphere(*args, **kwargs)
- within(other, *args, **kwargs)
Return
True
if other is fully within selfIf 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, rtol: float = 1.0e-8)[source]
Return indices of the other object which are contained in the shape
- Parameters:
other (
array_like
) – the object that is checked for containmentrtol (
float
, optional) – relative tolerance for boundaries.
- property center
The geometric center of the shape
- property edge_length
The lengths of each of the vector that defines the cuboid
- property origin
Return the origin of the Cuboid (lower-left corner)
- to
A dispatcher for classes, using __get__ it converts into ObjectDispatcher upon invocation from an object, or a TypeDispatcher when invoked from a class
This is a class-placeholder allowing a dispatcher to be a class attribute and converted into an ObjectDispatcher when invoked from an object.
If it is called on the class, it will return a TypeDispatcher.
This class should be an attribute of a class. It heavily relies on the __get__ special method.
- Parameters:
name (
str
) – name of the attribute in the classdispatchs (
dict
, optional) – dictionary of dispatch methodsobj_getattr (
callable
, optional) – method with 2 arguments, anobj
and theattr
which may be used to control how the attribute is called.instance_dispatcher (
AbstractDispatcher
, optional) – control how instance dispatchers are handled through __get__ method. This controls the dispatcher used if called from an instance.type_dispatcher (
AbstractDispatcher
, optional) – control how class dispatchers are handled through __get__ method. This controls the dispatcher used if called from a class.
Examples
>>> class A: ... new = ClassDispatcher("new", obj_getattr=lambda obj, attr: getattr(obj.sub, attr))
The above defers any attributes to the contained A.sub attribute.