1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#
# Polygons as individual objects first,
# then "splot with polygons"
#
# The vertices of an icosahedron are circular permutations of (0, ±1, ±ϕ)
# where ϕ = (1 + √5) / 2 is the golden ratio.
phi = (1.0 + sqrt(5.)) / 2.
array v1 = [0., 1., phi]
array v2 = [0., 1., -phi]
array v3 = [0., -1., phi]
array v4 = [0., -1., -phi]
array v5 = [ 1., phi, 0.]
array v6 = [ 1., -phi, 0.]
array v7 = [ -1., phi, 0.]
array v8 = [ -1., -phi, 0.]
array v9 = [ phi, 0., 1.]
array v10 = [ -phi, 0., 1.]
array v11 = [ phi, 0., -1.]
array v12 = [ -phi, 0., -1.]
# define one point per vertex
do for [i=1:12] {
eval( sprintf("set label %d 'v%d' at v%d[1], v%d[2], v%d[3]", i,i,i,i,i ))
}
seq1 = "v5 v7 v10 v3 v9 v5"
n = 1
do for [i=1:5] {
vert1 = word(seq1,i)
vert2 = word(seq1,i+1)
eval( sprintf("set obj %d polygon from v1[1], v1[2], v1[3] to %s[1],%s[2],%s[3] to %s[1],%s[2],%s[3]", n, vert1, vert1, vert1, vert2, vert2, vert2) )
n = n+1
}
seq2 = "v5 v11 v4 v12 v7 v5"
do for [i=1:5] {
vert1 = word(seq2,i)
vert2 = word(seq2,i+1)
eval( sprintf("set obj %d polygon from v2[1], v2[2], v2[3] to %s[1],%s[2],%s[3] to %s[1],%s[2],%s[3]", n, vert1, vert1, vert1, vert2, vert2, vert2) )
n = n+1
}
seq3 = "v3 v10 v12 v4 v6 v3"
do for [i=1:5] {
vert1 = word(seq3,i)
vert2 = word(seq3,i+1)
eval( sprintf("set obj %d polygon from v8[1], v8[2], v8[3] to %s[1],%s[2],%s[3] to %s[1],%s[2],%s[3]", n, vert1, vert1, vert1, vert2, vert2, vert2) )
n = n+1
}
eval( sprintf("set obj %d polygon from v7[1], v7[2], v7[3] to v12[1],v12[2],v12[3] to v10[1],v10[2],v10[3]", n) )
n = n+1
eval( sprintf("set obj %d polygon from v6[1], v6[2], v6[3] to v4[1],v4[2],v4[3] to v11[1],v11[2],v11[3]", n) )
n = n+1
eval( sprintf("set obj %d polygon from v5[1], v5[2], v5[3] to v9[1],v9[2],v9[3] to v11[1],v11[2],v11[3]", n) )
n = n+1
eval( sprintf("set obj %d polygon from v9[1], v9[2], v9[3] to v6[1],v6[2],v6[3] to v11[1],v11[2],v11[3]", n) )
n = n+1
eval( sprintf("set obj %d polygon from v9[1], v9[2], v9[3] to v3[1],v3[2],v3[3] to v6[1],v6[2],v6[3]", n) )
n = n+1
set for [o=1:n] obj o polygon depthorder fs transparent solid 0.8 fc "gray75"
set pm3d depthorder border lc "black" lw 2
set xrange [-2:2]; set yrange [-2:2]; set zrange [-2:2]
set view equal xyz
set view 30,30,1.5
unset border
unset tics
unset key
unset label
undefine v*
undefine seq*
set title "Faces of an icosahedron drawn as 20 individual objects"
splot -10
pause -1 "Hit return to continue"
set title "2-sided coloring\ngreen outside, yellow inside"
set style line 101 lc "forest-green"
set style line 102 lc "goldenrod"
set for [o=1:n] obj o polygon depthorder fs transparent pattern o fc ls 101
replot
pause -1 "Hit return to continue"
unset object
set pm3d lighting spec2 0.6
set title "splot icosahedron.dat with polygons"
splot 'icosahedron.dat' with polygons fc "gray75"
pause -1 "Hit return to continue"
set title "splot dodecahedron.dat with polygons"
set view 148, 55, 2.7
set pm3d lighting spec2 0.3
splot 'dodecahedron.dat' with polygons fc "gold"
pause -1 "Hit return to continue"
set title "splot truncated_cube with polygons" noenhanced
set view 36, 60, 4.2
set style fill transparent solid 0.75
set pm3d nolighting border lt -1 lw 2
splot 'truncated_cube.dat' using ($1-0.5):($2-0.5):($3-0.5) with polygons fc bgnd
pause -1 "Hit return to continue"
set title "A whale rendered as a fan of large polygons"
set view 59, 314, 3.0, 1.0
set view equal xyz
set pm3d depthorder
set pm3d border linecolor rgb "blue" linewidth 0.25
set autoscale
splot 'whale.dat' using 1:2:3 with polygons fc "slategray", \
'whale.dat' with lines lw .2 lt 6
pause -1 "Hit return to continue"
reset
|