2
我正在擴展Hagen Wierstorf's scripts for drawing cubes繪製任意大小的塊。Gnuplot:用正確的深度順序繪製3d塊使用splot
這裏是我的代碼:block.fct的
reset
set terminal qt size 700,524 enhanced font 'Verdana,10'
# color definitions
set cbrange [1:10]
set style fill transparent solid 1.0
set palette defined (\
1 '#ff4c4d',\
2 '#ce4c7d',\
3 '#ae559e',\
4 '#df866d',\
5 '#ffb66d',\
6 '#ffe7cf',\
7 '#cecece',\
8 '#6d6d6d',\
9 '#4c4c8e',\
10 '#4c4cef')
set style line 1 lc rgb '#ff2727' lt 1 lw 0.5
set style line 2 lc rgb '#b90046' lt 1 lw 0.5
set style line 3 lc rgb '#8b0b74' lt 1 lw 0.5
set style line 4 lc rgb '#d1512e' lt 1 lw 0.5
set style line 5 lc rgb '#ff972f' lt 1 lw 0.5
set style line 6 lc rgb '#ffddba' lt 1 lw 0.5
set style line 7 lc rgb '#b9b9b9' lt 1 lw 0.5
set style line 8 lc rgb '#2e2e2e' lt 1 lw 0.5
set style line 9 lc rgb '#00005d' lt 1 lw 0.5
set style line 10 lc rgb '#0000e8' lt 1 lw 0.5
unset key
unset border
unset tics
unset colorbox
set view equal xyz
# load block function
load 'block.fct'
set pm3d hidden3d
set pm3d implicit
unset hidden3d
set lmargin 2
set rmargin 0
set bmargin 0
set tmargin 0
# get block positions from file
add_block(x,y,z,h,l,w,c) = sprintf('block(%f,%f,%f,%f,%f,%f,%i) w l ls %i,',x,y,z,h,l,w,c,c)
CMD = ''
stats 'proofblocks3.txt' u 1:(CMD = CMD.add_block($1,$2,$3,$4,$5,$6,$7)) nooutput
set xrange [0:4]
set yrange [0:4]
set zrange [0:3]
CMD = 'splot '.CMD.'1/0 w l ls 2'
# plot block
eval(CMD)
內容:
# gnuplot function to create a cube
#
# Usage: block(x, y, z, w, l, h, c)
block(x,y,z,w,l,h,c) = sprintf('<echo "\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\n"',\
0.1+x,0.1+y,0.1+z,c,\
0.1+x,0.1+y,(h-0.1)+z,c,\
0.1+x,(l-0.1)+y,(h-0.1)+z,c,\
0.1+x,(l-0.1)+y,0.1+z,c,\
0.1+x,0.1+y,0.1+z,c,\
(w-0.1)+x,0.1+y,0.1+z,c,\
(w-0.1)+x,0.1+y,h-0.1+z,c,\
(w-0.1)+x,(l-0.1)+y,h-0.1+z,c,\
(w-0.1)+x,(l-0.1)+y,0.1+z,c,\
(w-0.1)+x,0.1+y,0.1+z,c,\
0.1+x,0.1+y,0.1+z,c,\
(w-0.1+x),0.1+y,0.1+z,c,\
(w-0.1+x),(l-0.1)+y,0.1+z,c,\
0.1+x,(l-0.1+y),0.1+z,c,\
0.1+x,0.1+y,0.1+z,c,\
0.1+x,0.1+y,(h-0.1+z),c,\
(w-0.1)+x,0.1+y,(h-0.1+z),c,\
(w-0.1)+x,(l-0.1)+y,(h-0.1+z),c,\
0.1+x,(l-0.1)+y,(h-0.1+z),c,\
0.1+x,0.1+y,(h-0.1)+z,c\
)
的問題是,當一個面(塊的一側)比另一長在前面它,我想是因爲gnuplot不能像射線跟蹤器一樣工作,它會在飛機前面靠近觀看者的大平面,因爲它有一個距離觀看者更近的點:
用於上述圖像個
座標 - proofblocks3.txt內容:
# x y z w l h color
0 0 0 1 1 1 1
1 0 0 1 3 1 2
2 0 0 1 1 1 3
0 1 0 1 1 1 4
2 1 0 1 1 1 5
0 2 0 1 1 1 6
2 2 0 1 1 1 7
有沒有辦法來解決這個問題 - 如在正確的深度順序策劃了表面?
您是否也可以提供用於測試的'proofblocks3.txt'的內容?與此同時嘗試'設置pm3d深度順序',見http://gnuplot.sourceforge.net/demo/hidden2.html第二個例子 – Christoph
嗨@Christoph,我發佈了'proofblocks3.txt'的內容。不幸的是,'深度順序'並沒有改變劇情。請注意,我更正了主腳本,將「set unhidden3d」更正爲「unset hidden3d」。謝謝! – Cescante
好的。我不知道如何讓它與gnuplot一起工作。只有'設置hidden3d'和沒有'pm3d'設置它的作品,但你沒有得到的顏色;)我讀過,'設置pm3d hidden3d'只適用於非常特殊的情況。這就是gnuplot達到極限的地方。 – Christoph