0

I have the following code :

def sphere():
    #helper function to compute the coordinates of a unit sphere centered at 0,0,0
    # Create a sphere
    r = 1
    pi = np.pi
    cos = np.cos
    sin = np.sin
    phi, theta = np.mgrid[0.0:pi:20j, 0.0:2.0 * pi:20j]
    x = r * sin(phi) * cos(theta)
    y = r * sin(phi) * sin(theta)
    z = r * cos(phi)
    return (x,y,z)

The code works fine but I don't understand the part where 0.0:2.0 * pi:20j obviously, it makes 20 subdivisions between 0 and 2pi but why?

what's the connection between the complex number and the generated list?

itzik Ben Shabat
  • 927
  • 11
  • 24

0 Answers0