首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用gnuplot图绘制三角形网格

用gnuplot图绘制三角形网格
EN

Stack Overflow用户
提问于 2017-03-14 11:09:31
回答 2查看 1.9K关注 0票数 4

通常需要用gnuplot绘制三角形网格。

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

代码语言:javascript
运行
复制
$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

这是四个三角形:一个在中心(p1,p2,p3)和3个在它的腿附近。

在某些定义网格的方法中有许多重复。有时将网格定义为三角形条形或三角形扇形是比较合适的方法。

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

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-15 03:57:51

代码语言:javascript
运行
复制
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:

代码语言:javascript
运行
复制
-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

由搅拌器和python脚本生成:

https://github.com/lowlevel86/blender-to-gnuplot

票数 4
EN

Stack Overflow用户

发布于 2017-03-14 16:00:25

解决方法可以是编写gawk/Python脚本,该脚本将解析面的定义,并生成Gnuplot脚本,其中面将手动绘制为多边形:

代码语言:javascript
运行
复制
set xr [0:1]
set yr [0:1]
set zr [0:1]

#generate the polygons
set object polygon from 0,0,0 to 1,0,0 to 1,1,0 to 0,1,0 to 0,0,0 fc rgb "cyan" fillstyle solid 1.0 border lt -1
set object polygon from 1,0,0 to 1,1,0 to 1,1,1 to 1,0,1 to 1,0,0 fc rgb "cyan" fillstyle solid 1.0 border lt -1

#do not plot anything
splot 1/0
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42784369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档