Skip to content

Commit

Permalink
Add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Jun 29, 2023
1 parent ac89782 commit 4647742
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pytransform3d/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,32 @@


def unit_sphere_surface_grid(n_steps):
"""Create grid on the surface of a unit sphere in 3D.
Parameters
----------
n_steps : int
Number of discrete steps in each dimension of the surface.
Returns
-------
x : array, shape (n_steps, n_steps)
x-coordinates of grid points.
y : array, shape (n_steps, n_steps)
y-coordinates of grid points.
z : array, shape (n_steps, n_steps)
z-coordinates of grid points.
"""
phi, theta = np.mgrid[0.0:np.pi:n_steps * 1j,
0.0:2.0 * np.pi:n_steps * 1j]
sin_phi = np.sin(phi)

x = sin_phi * np.cos(theta)
y = sin_phi * np.sin(theta)
z = np.cos(phi)

return x, y, z


Expand Down

0 comments on commit 4647742

Please sign in to comment.