You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在gnuplot中实现正二十面体所有顶点的全连接?

解决正二十面体顶点全连接的gnuplot方法

要实现所有顶点两两连接,核心问题是不能只给顶点列表——因为with lines是按数据行的顺序连接连续点,只会连相邻的条目。你需要生成所有顶点对的线段数据,每段线对应一对顶点的坐标(起点+终点),再用空行分隔不同线段(gnuplot会把空行当作线段的断点)。

具体操作步骤

  • 准备正二十面体顶点坐标:先整理好12个顶点的坐标(以单位球面为例,φ为黄金分割比≈1.618,1/φ≈0.618):

    # 正二十面体顶点坐标
    1 1 1
    1 1 -1
    1 -1 1
    1 -1 -1
    -1 1 1
    -1 1 -1
    -1 -1 1
    -1 -1 -1
    0 1.618 0.618
    0 1.618 -0.618
    0 -1.618 0.618
    0 -1.618 -0.618
    
  • 生成全连接线段数据:用脚本自动遍历所有顶点对,输出每对顶点的坐标(两行)+ 空行。比如用Python实现:

    import math
    
    phi = (1 + math.sqrt(5)) / 2
    vertices = [
        (1, 1, 1),
        (1, 1, -1),
        (1, -1, 1),
        (1, -1, -1),
        (-1, 1, 1),
        (-1, 1, -1),
        (-1, -1, 1),
        (-1, -1, -1),
        (0, phi, 1/phi),
        (0, phi, -1/phi),
        (0, -phi, 1/phi),
        (0, -phi, -1/phi),
    ]
    
    with open("icosa_full.dat", "w") as f:
        for i in range(len(vertices)):
            for j in range(i+1, len(vertices)):  # 避免重复绘制同一条线
                x1, y1, z1 = vertices[i]
                x2, y2, z2 = vertices[j]
                f.write(f"{x1} {y1} {z1}\n")
                f.write(f"{x2} {y2} {z2}\n")
                f.write("\n")
    
  • gnuplot绘制:运行脚本生成icosa_full.dat后,在gnuplot里执行:

    splot "icosa_full.dat" with lines notitle
    

    就能看到所有顶点两两连接的效果。如果要优化显示,还可以调整线条样式:

    splot "icosa_full.dat" with lines lw 1 lt 2 notitle
    

内容的提问来源于stack exchange,提问作者Данил Диков

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 10:22:07