Skip to content
Extraits de code Groupes Projets
earth.py 682 octets
Newer Older
  • Learn to ignore specific revisions
  • Florian Bury's avatar
    Florian Bury a validé
    ### 3D plot
    fig = plt.figure(figsize=(9,9))
    ax = fig.add_subplot(1,1,1, projection='3d')
    u, v = np.mgrid[0:2*np.pi:30j, 0:np.pi:30j]
    # u = phi (longitude)
    # v = theta (latitude)
    # R = earth radius
    x_earth = R*np.cos(u)*np.sin(v)
    y_earth = R*np.sin(u)*np.sin(v)
    z_earth = R*np.cos(v)
    # R,u,v (spherical) -> x,y,z (cartesian)
    # Plot the earth #
    ax.plot_wireframe(x_earth, y_earth, z_earth,cmap='ocean', facecolor='none')
    all_positions = np.array(all_positions)
    # Plot positions #
    ax.plot3D(all_positions[:,0],all_positions[:,1],all_positions[:,2],color='r')
    # Set axes limits
    ax.set_xlim3d(-R-5000000,R+5000000)
    ax.set_ylim3d(-R-5000000,R+5000000)
    ax.set_zlim3d(-R-5000000,R+5000000)