簡體   English   中英

在球體表面繪制點

[英]Drawing points on a surface of a sphere

我正在嘗試制作由點組成的球體的表面。 我已經想出了如何用點制作圓形表面,但不知道如何使用它來構建球體。 有一個代碼,我用來做一個圓圈。 這里還有一個的例子。 我使用 opengl 庫來繪制。

def DrawCircle():
glBegin(GL_POINTS)
for i in range(0,300,10):
    angle = 2 * 3.14 * i / 300
    x = cos(angle)
    y = sin(angle)
    glVertex3d(x, y, 0)
glEnd()

使用 2 個嵌套循環計算水平坐標系的方位角和高度角:

def DrawSphere():
    glBegin(GL_POINTS)
    glVertex3d(0, -1, 0)          # south pole
    for i in range(-90+10,90,10): # -90 to 90 south pole to north pole
        alt = math.radians(i)
        c_alt = math.cos(alt)
        s_alt = math.sin(alt)
        for j in range(0,360,10): # 360 degree (around the sphere)
            azi = math.radians(j)
            c_azi = math.cos(azi)
            s_azi = math.sin(azi)
            glVertex3d(c_azi*c_alt, s_alt, s_azi*c_alt)
    glVertex3d(0, 1, 0)           # north pole
    glEnd()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM