【问题标题】:How to get Coordinates of a Sphere?如何获得球体的坐标?
【发布时间】:2014-09-02 22:07:39
【问题描述】:

我想知道这个地块的所有坐标:

来源:http://matplotlib.org/examples/mplot3d/surface3d_demo2.html

来源:https://stackoverflow.com/a/11156353/3755171

并将其绘制为一个圆点(只考虑其中一个,我找不到那种):

或者即使是矩阵也可以。

当我尝试绘制上面提到的那些时,我得到了:

我的密码

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
#ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)

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

#ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')
ax.plot(x,y,z,"o")

plt.show()

【问题讨论】:

    标签: python matplotlib 3d geometry


    【解决方案1】:

    如果您将plot 的调用替换为scatter,如下所示,您将重新创建一个完全由点组成的球体。请参阅文档here

    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    #ax = fig.add_subplot(111, projection='3d')
    ax = Axes3D(fig)
    
    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")
    
    #ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')
    ax.scatter(x,y,z,"o")
    
    plt.show()
    

    【讨论】:

    • 谢谢,有什么办法可以得到坐标矩阵??还是 [x[], y[], z[]] ??
    • 据我所知,第 i 个坐标是 (x[i], y[i], z[i])。
    • 编辑:我不确定我所说的关于第 i 个坐标的内容是否确实正确。如果查看 x 数组,您会发现每个元素都是多个值,而不是单个 x 坐标。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    相关资源
    最近更新 更多