Sphere#

class Sphere(radius, center)[source]#

Bases: Parametrization

Parametrize a point cloud as sphere.

Parameters:
radiusnp.ndarray

Radius of the sphere

centernp.ndarray

Center of the sphere along each axis.

Methods

Sphere.compute_distance(points, **kwargs)

Computes the distance between points and the parameterization.

Sphere.compute_normal(points)

Compute the normal vector at a given point on the surface.

Sphere.fit(positions, **kwargs)

Fit a sphere to a point cloud using least-squares.

Sphere.points_per_sampling(sampling_density)

Computes the approximate number of random samples required to achieve a given spatial sampling_density.

Sphere.sample(n_samples[, normal_offset])

Samples points from the surface of a sphere.

compute_distance(points, **kwargs)[source]#

Computes the distance between points and the parameterization.

Parameters:
pointsnp.ndarray

Array of coordinates (n, d).

Returns:
np.ndarray

Distances between points and the parametrization.

compute_normal(points)[source]#

Compute the normal vector at a given point on the surface.

Parameters:
pointsnp.ndarray

Points on the surface with shape n x d

Returns:
np.ndarray

Normal vectors at the given points

classmethod fit(positions, **kwargs)[source]#

Fit a sphere to a point cloud using least-squares.

Parameters:
positionsnp.ndarray

Point coordinates with shape (n, 3).

Returns:
Sphere

Fitted sphere with estimated radius and center.

points_per_sampling(sampling_density, normal_offset=None)[source]#

Computes the approximate number of random samples required to achieve a given spatial sampling_density.

Parameters:
sampling_densityfloat

Average distance between points.

normal_offsetfloat, optional

Compute number of samples on offset parametrization, instead of current.

Returns:
int

Number of required random samples.

sample(n_samples, normal_offset=0.0, **kwargs)[source]#

Samples points from the surface of a sphere.

Parameters:
n_samplesint

Number of samples to draw

normal_offsetfloat, optional

Offset points by normal_offset times their normal vector.

Returns:
np.ndarray

Point coordinates (n, 3).