trimesh.nsphere¶
nsphere.py¶
Functions for fitting and minimizing nspheres: circles, spheres, hyperspheres, etc.
Functions:
|
Fit an n-sphere to a set of points using least squares. |
|
Check if a list of points is an nsphere. |
|
Compute the minimum n- sphere for a mesh or a set of points. |
-
trimesh.nsphere.
fit_nsphere
(points, prior=None)¶ Fit an n-sphere to a set of points using least squares.
- Parameters
points ((n, d) float) – Points in space
prior ((d,) float) – Best guess for center of nsphere
- Returns
center ((d,) float) – Location of center
radius (float) – Mean radius across circle
error (float) – Peak to peak value of deviation from mean radius
-
trimesh.nsphere.
is_nsphere
(points)¶ Check if a list of points is an nsphere.
- Parameters
points ((n, dimension) float) – Points in space
- Returns
check – True if input points are on an nsphere
- Return type
bool
-
trimesh.nsphere.
minimum_nsphere
(obj)¶ Compute the minimum n- sphere for a mesh or a set of points.
Uses the fact that the minimum n- sphere will be centered at one of the vertices of the furthest site voronoi diagram, which is n*log(n) but should be pretty fast due to using the scipy/qhull implementations of convex hulls and voronoi diagrams.
- Parameters
obj ((n, d) float or trimesh.Trimesh) – Points or mesh to find minimum bounidng nsphere
- Returns
center ((d,) float) – Center of fitted n- sphere
radius (float) – Radius of fitted n-sphere