pysdic.PointCloud.bounding_sphere#
- PointCloud.bounding_sphere()[source]#
Compute a bounding sphere of the point cloud.
The center is the centroid \(\bar{x}\) of the points and the radius is the largest distance to the centroid:
\[r = \max_i \| x_i - \bar{x} \|\]Note
This sphere contains all the points but is not the smallest one.
The non-finite points (NaN, Inf) are ignored.
- Returns:
numpy.ndarray – The center of the sphere, an array of shape \((E,)\).
float – The radius of the sphere.
- Raises:
ValueError – If the point cloud is empty or contains only non-finite points.
- Return type:
Examples
1import numpy 2from pysdic import PointCloud 3 4point_cloud = PointCloud([[0, 0, 0], [1, 0, 0], [0, 2, 0], [0, 0, 3]]) 5center, radius = point_cloud.bounding_sphere() 6print(center, radius) # [0.25 0.5 0.75] 2.318...