pysdic.PointCloud.bounding_sphere#

PointCloud.bounding_sphere()[source]#

Compute the bounding sphere of the point cloud.

The bounding sphere is defined by its center and radius, which encompasses all points in the point cloud.

Note

The non-finite values (NaN, Inf) are ignored in the computation. If the point cloud is empty or contains only non-finite values, a ValueError is raised.

Returns:

  • numpy.ndarray – The center of the bounding sphere as a NumPy array of shape \((E,)\).

  • float – The radius of the bounding sphere.

Raises:

ValueError – If the point cloud is empty or contains only non-finite values.

Return type:

Tuple[ndarray, float]

Examples

Create a tetrahedron point cloud and compute its bounding sphere.

1import numpy as np
2from pysdic import PointCloud
3
4# Create a tetrahedron point cloud
5tetrahedron_points = np.array([[0, 0, 0], [1, 0, 0], [0, 2, 0], [0, 0, 3]])  # shape (4, 3)
6point_cloud = PointCloud.from_array(tetrahedron_points)

Compute the bounding sphere using the bounding_sphere method.

1# Compute the bounding sphere of the point cloud
2center, radius = point_cloud.bounding_sphere()
3print("Center of bounding sphere:", center)
4print("Radius of bounding sphere:", radius)
5# Output:
6# Center of bounding sphere: [0.25       0.5      0.75     ]
7# Radius of bounding sphere: 2.3184046