1

I found someone else's example that showed how to plot a sphere in python, but I was curious if there was an equation that represents individual longitudinal lines along a sphere.

Example: Python/matplotlib : plotting a 3d cube, a sphere and a vector?

Example: Python/matplotlib : plotting a 3d cube, a sphere and a vector?

# draw sphere
u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j]
x = np.cos(u)*np.sin(v)
y = np.sin(u)*np.sin(v)
z = np.cos(v)
ax.plot_wireframe(x, y, z, color="r")

What I want is an equation for Great Circles that run along a sphere and be able to plot them.

Similar to this post in Mathematica... https://mathematica.stackexchange.com/questions/16413/how-to-draw-a-great-circle-on-a-sphere

NoviceCoder
  • 424
  • 1
  • 4
  • 20

1 Answers1

0

Someone on the math stack exchange was able to help.

The ellipse equations aren't the right way to approach this problem. Great Circles have their own equations that involve complex numbers to represent in 3D.

    theta = np.linspace(0, np.pi * 2, 80)

    # equations for great cricles (longitduinal great circles)
    x = R * np.sin(theta[i]) * np.cos((1j / len(theta)) * np.pi * 2)
    y = R * np.sin(theta[i]) * np.sin((1j / len(theta)) * np.pi * 2)
    z = R * np.cos(theta[i])

    # takes the real components of the great circle equation to get the position coords in 3D space
    xr = x.real
    yr = y.real

After you have (xr,yr) you can use a rotation matrices around the z-axis to get great circles at different trajectories.

Simply plot(xr,yr,z)

NoviceCoder
  • 424
  • 1
  • 4
  • 20