3d - 使用 gnuplot 绘制三角形网格

标签 3d gnuplot mesh

经常需要使用gnuplot绘制三角形网格。 .

我目前看到的唯一方法是使用 with lines 制作“线框”每个方面的闭合线链(第一个和最后一个点相同)之间的选项和双换行符:

$wireframe <<EOD
 0  1 1 p1
 1 -1 1 p2
-1 -1 1 p3
 0  1 1 


 2  1 0 p4
 0  1 1 
 1 -1 1 
 2  1 0 


 0 -2 0 p5
 1 -1 1 
-1 -1 1 
 0 -2 0 


-2  1 0 p6
-1 -1 1 
 0  1 1 
-2  1 0 
EOD
splot '$wireframe' with lines notitle, '' with labels offset character 0, character 1 notitle

这是 4 个三角形:1 个在中心 (p1, p2, p3) 和 3 个与它的腿相邻。

定义网格的某些方法有很多重复。有时将网格定义为三角形 strip 或三角形扇形更合适。

另一个问题是用某种颜色填充 3D 三角形的内部。目前我只能为不同的链线使用不同的颜色(来自调色板)绘制线框。但它们重叠。

说,我想画二十面体。它是封闭的实体,受三角形面的约束。

最佳答案

set terminal wxt size 800,600

#set title "Graph Title"
#set xlabel "X"
#set ylabel "Y"
#set zlabel "Z"

# sets background color
set object 1 rectangle from screen -0.1,-0.1 to screen 1.1,1.1 fillcolor rgb "#ffffff" behind

# allows rendering of polygons with hidden line removal
set hidden3d back offset 0 trianglepattern 3 undefined 1 altdiagonal bentover

# displays borders 0x7F = 0b1111111
set border 0x7F linecolor rgb "#555555"

# displays the x, y and z axis
set xzeroaxis linewidth 0.5 linetype 1
set yzeroaxis linewidth 0.5 linetype 2
set zzeroaxis linewidth 0.5 linetype 3

# displays the x, y and z grid
set grid xtics linecolor rgb "#888888" linewidth 0.2 linetype 9
set grid ytics linecolor rgb "#888888" linewidth 0.2 linetype 9
set grid ztics linecolor rgb "#888888" linewidth 0.2 linetype 9

# moves the x, y grid to 0
set xyplane at 0

# makes the x, y, and z axis proportional
set view equal xyz

# sets the axis range
set xrange [-10:10]
set yrange [-10:10]
set zrange [-10:10]

# moves the key out of the graph
set key outside vertical bottom right

# hides the key
set key off

splot\
"ico.dat" title "ico" with lines linewidth 2.1 linecolor rgb "#88FF88"

ico.dat:
-1.381925 -4.253200 -2.236075
0.000000 0.000000 -5.000000

3.618000 -2.628600 -2.236075
3.618000 -2.628600 -2.236075


3.618000 -2.628600 -2.236075
0.000000 0.000000 -5.000000

3.618000 2.628600 -2.236075
3.618000 2.628600 -2.236075


-4.472125 0.000000 -2.236075
0.000000 0.000000 -5.000000

-1.381925 -4.253200 -2.236075
-1.381925 -4.253200 -2.236075


-1.381925 4.253200 -2.236075
0.000000 0.000000 -5.000000

-4.472125 0.000000 -2.236075
-4.472125 0.000000 -2.236075


3.618000 2.628600 -2.236075
0.000000 0.000000 -5.000000

-1.381925 4.253200 -2.236075
-1.381925 4.253200 -2.236075


3.618000 -2.628600 -2.236075
3.618000 2.628600 -2.236075

4.472125 0.000000 2.236075
4.472125 0.000000 2.236075


-1.381925 -4.253200 -2.236075
3.618000 -2.628600 -2.236075

1.381925 -4.253200 2.236075
1.381925 -4.253200 2.236075


-4.472125 0.000000 -2.236075
-1.381925 -4.253200 -2.236075

-3.618000 -2.628600 2.236075
-3.618000 -2.628600 2.236075


-1.381925 4.253200 -2.236075
-4.472125 0.000000 -2.236075

-3.618000 2.628600 2.236075
-3.618000 2.628600 2.236075


3.618000 2.628600 -2.236075
-1.381925 4.253200 -2.236075

1.381925 4.253200 2.236075
1.381925 4.253200 2.236075


4.472125 0.000000 2.236075
1.381925 -4.253200 2.236075

3.618000 -2.628600 -2.236075
3.618000 -2.628600 -2.236075


1.381925 -4.253200 2.236075
-3.618000 -2.628600 2.236075

-1.381925 -4.253200 -2.236075
-1.381925 -4.253200 -2.236075


-3.618000 -2.628600 2.236075
-3.618000 2.628600 2.236075

-4.472125 0.000000 -2.236075
-4.472125 0.000000 -2.236075


-3.618000 2.628600 2.236075
1.381925 4.253200 2.236075

-1.381925 4.253200 -2.236075
-1.381925 4.253200 -2.236075


1.381925 4.253200 2.236075
4.472125 0.000000 2.236075

3.618000 2.628600 -2.236075
3.618000 2.628600 -2.236075


1.381925 -4.253200 2.236075
4.472125 0.000000 2.236075

0.000000 0.000000 5.000000
0.000000 0.000000 5.000000


-3.618000 -2.628600 2.236075
1.381925 -4.253200 2.236075

0.000000 0.000000 5.000000
0.000000 0.000000 5.000000


-3.618000 2.628600 2.236075
-3.618000 -2.628600 2.236075

0.000000 0.000000 5.000000
0.000000 0.000000 5.000000


1.381925 4.253200 2.236075
-3.618000 2.628600 2.236075

0.000000 0.000000 5.000000
0.000000 0.000000 5.000000


4.472125 0.000000 2.236075
1.381925 4.253200 2.236075

0.000000 0.000000 5.000000
0.000000 0.000000 5.000000

由 blender 和 python 脚本生成:
https://github.com/lowlevel86/blender-to-gnuplot

关于3d - 使用 gnuplot 绘制三角形网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42784369/

相关文章:

algorithm - 寻找边缘,算法优化

javascript - 获取 A 框架中实体的方向向量

java - 对三角形进行排序时快速排序太慢

c# - 获得形成三角形的最近点

opengl - 计算法线并将其应用到三角形网格

linux - 通过对列进行分组,使用 gnuplot 绘制多个图

fonts - 带有 Times-Roman 字体的 gnuplot 埃标签

gnuplot - gnuplot 中的抖动点。数据输入文件格式

graphics - 使用 Meshlab 进行纹理映射

three.js - 在 Three.js 中绘制网格的边缘