FreeformShape¶
- class FreeformShape(contains, width, center=(0, 0, 0))¶
Shape in 1 to 3 dimensions, defined by a function and a bounding box
Note that this class can describe 3D shapes, but the
plot()
method can currently only draw in 2D. Nevertheless, aModel
will accept 3D shapes without a problem.- Parameters:
- containscallable
The function which selects if a point is contained within the shape.
- widtharray_like
Width up to 3 dimensions which specifies the size of the bounding box.
- centerarray_like
The position of the center of the bounding box.
Attributes
lattice_offset
vertices
Methods
contains
(x, y, z)Return
True
if the given position is located within the shapeplot
([resolution])Plot a lightly shaded silhouette of the freeform shape
with_offset
(vector)Return a copy that's offset by the given vector
- contains(x: numpy.ndarray[numpy.float64[m, 1]], y: numpy.ndarray[numpy.float64[m, 1]], z: numpy.ndarray[numpy.float64[m, 1]])¶
Return
True
if the given position is located within the shapeGiven arrays as input the return type is a boolean array.
- Parameters:
- x, y, zarray_like
Positions to test against the shape.
- plot(resolution: Tuple[int, int] = (1000, 1000), **kwargs) AxesImage ¶
Plot a lightly shaded silhouette of the freeform shape
This method only works for 2D shapes.
- Parameters:
- resolutionTuple[int, int]
The (x, y) pixel resolution of the generated shape image.
- **kwargs
Forwarded to
matplotlib.pyplot.imshow()
.