pygfx.geometries.Geometry

class pygfx.geometries.Geometry(**kwargs)

Bases: Trackable

Generic container for Geometry data.

Parameters:

kwargs (dict) – A dict of attributes to define on the geometry object. Keys must match the naming convention described in the implementation details section of the Geometries module. If they don’t they will become optional attributes. Values must either be Resources or ArrayLike.

Example

g = Geometry(positions=[[1, 2], [2, 4], [3, 5], [4, 1]])
g.positions.data  # numpy array
get_bounding_box()

Compute the axis-aligned bounding box.

Computes the aabb based on either positions or the shape of the grid buffer. If both are present, the bounding box will be computed based on the positions buffer.

Returns:

aabb – The axis-aligned bounding box given by the “smallest” (lowest value) and “largest” (highest value) corners. Is None when the geometry has no finite positions.

Return type:

ndarray, [2, 3] or None

get_bounding_sphere()

Compute a bounding sphere.

Uses the geometry’s axis-aligned bounding box, to estimate a sphere which contains the geometry.

Returns:

sphere – A sphere given by it’s center and radius. Format: (x, y, z, radius). Is None when the geometry has no finite positions.

Return type:

ndarray, [4] or None

Notes

Since the sphere wraps the geometry’s bounding box, it typically won’t be the minimally binding sphere.