It is often need to draw triangular mesh using gnuplot.
Only way I currently see is to make "wireframe" using with lines option and double newlines between closed chains of lines (first and last point are the same) for each facet:
$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
This is the 4 triangles: 1 at center (p1, p2, p3) and 3 are adjacent to its legs.
There is many duplication for some ways to define a mesh. Sometimes it is more appropriate way to define the mesh as a triangle strip or triangle fan.
Another issue is to fill the interior of the 3D triangles by some color. Currently I only can draw wireframe using different colors (from palette) for different chained lines. But they overlap.
Say, I want to draw icosahedron. It is closed solid, constrained by a triangle faces.
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
Generated by blender and a python script:
https://github.com/lowlevel86/blender-to-gnuplot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With