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, a Model will accept 3D shapes without a problem.

Parameters:
contains : callable

The function which selects if a point is contained within the shape.

width : array_like

Width up to 3 dimensions which specifies the size of the bounding box.

center : array_like

The position of the center of the bounding box.

Methods

contains(x, 1]], y, 1]], z, 1]]) Return True if the given position is located within the shape
plot([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[float32[m, 1]], y: numpy.ndarray[float32[m, 1]], z: numpy.ndarray[float32[m, 1]])

Return True if the given position is located within the shape

Given arrays as input the return type is a boolean array.

Parameters:
x, y, z : array_like

Positions to test against the shape.

plot(resolution=(1000, 1000), **kwargs)

Plot a lightly shaded silhouette of the freeform shape

This method only works for 2D shapes.

Parameters:
resolution : Tuple[int, int]

The (x, y) pixel resolution of the generated shape image.

**kwargs

Forwarded to matplotlib.pyplot.imshow().

with_offset(vector)

Return a copy that’s offset by the given vector