绘制方程来表示球体的线框?(大圆)

2024-06-16 09:19:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我找到了其他人的例子,展示了如何用python绘制球体,但我很好奇是否有一个方程可以表示沿球体的各个纵向线。在

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

示例:Python/matplotlib:绘制三维立方体、球体和向量?

# 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")

我想要的是一个方程,它是沿着球体运行的大圆,并且能够画出它们。在

类似于Mathematica的这篇文章。。。 https://mathematica.stackexchange.com/questions/16413/how-to-draw-a-great-circle-on-a-sphere


Tags: 示例matplotlibnppi绘制sincosax
1条回答
网友
1楼 · 发布于 2024-06-16 09:19:42

数学堆栈交换的人能帮上忙。在

椭圆方程不是解决这个问题的正确方法。大圆有他们自己的方程,其中涉及到三维表示的复数

    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

在你有(xr,yr)之后,你可以使用一个围绕z轴的旋转矩阵,在不同的轨迹上得到大的圆。在

简单绘图(xr,yr,z)

相关问题 更多 >