skspatial.objects.Sphere.to_mesh

Sphere.to_mesh(n_angles: int = 30) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Return coordinate matrices for the 3D surface of the sphere.

Parameters
n_angles: int

Number of angles used to generate the coordinate matrices.

Returns
X, Y, Z: (n_angles, n_angles) ndarray

Coordinate matrices.

Examples

>>> from skspatial.objects import Sphere
>>> X, Y, Z = Sphere([0, 0, 0], 1).to_mesh(5)
>>> X.round(3)
array([[ 0.   ,  0.   ,  0.   ,  0.   ,  0.   ],
       [ 0.   ,  0.707,  0.   , -0.707, -0.   ],
       [ 0.   ,  1.   ,  0.   , -1.   , -0.   ],
       [ 0.   ,  0.707,  0.   , -0.707, -0.   ],
       [ 0.   ,  0.   ,  0.   , -0.   , -0.   ]])
>>> Y.round(3)
array([[ 0.   ,  0.   ,  0.   ,  0.   ,  0.   ],
       [ 0.707,  0.   , -0.707, -0.   ,  0.707],
       [ 1.   ,  0.   , -1.   , -0.   ,  1.   ],
       [ 0.707,  0.   , -0.707, -0.   ,  0.707],
       [ 0.   ,  0.   , -0.   , -0.   ,  0.   ]])
>>> Z.round(3)
array([[ 1.   ,  1.   ,  1.   ,  1.   ,  1.   ],
       [ 0.707,  0.707,  0.707,  0.707,  0.707],
       [ 0.   ,  0.   ,  0.   ,  0.   ,  0.   ],
       [-0.707, -0.707, -0.707, -0.707, -0.707],
       [-1.   , -1.   , -1.   , -1.   , -1.   ]])