1 % truncated cone diagram
\r
2 % Modified for PGF/TikZ
\r
11 def seg_rot rotate(360 / N, [J])
\r
22 % draw the cone; this is the easy part!
\r
23 sweep[cull=false,fill=blue!20,fill opacity=0.8] { N, [[seg_rot]] } line(p0)(p1)
\r
29 line[arrows=<->,linewidth=.4pt](ax)(O)(ay)
\r
30 line[arrows=->,linewidth=.4pt](O)(az)
\r
31 % repeat dotted as an overlay to hint at the hidden lines
\r
32 %line[lay=over,linestyle=dotted,linewidth=.4pt](ax)(O)(ay)
\r
33 % line[lay=over,linestyle=dotted,linewidth=.4pt](O)(az)
\r
35 special|\path #1 node[below] {$x$}
\r
36 #2 node[above] {$y$}
\r
37 #3 node[left] {$z$};|
\r
40 % height measurement mark takes too much code!
\r
41 def c0 (p0) then scale([J])
\r
42 def hdim_ref unit((p1) - (O)) then [[seg_rot]]^2
\r
43 def h00 (c0) + 1.1 * [hdim_ref]
\r
44 def h01 (c0) + 1.9 * [hdim_ref]
\r
45 def h02 (c0) + 1.8 * [hdim_ref]
\r
47 def h10 (O) + 1.6 * [hdim_ref]
\r
48 def h11 (O) + 1.9 * [hdim_ref]
\r
49 def h12 (O) + 1.8 * [hdim_ref]
\r
51 line[arrows=<->](h02)(h12)
\r
52 def hm2 ((h02)-(O)+(h12)-(O)) / 2 + (O)
\r
53 special|\node[ann] at #1 {$h$};|(hm2)
\r
55 % radius measurement marks
\r
59 def r1 ((p1) then [[seg_rot]]^-2) + [up1]
\r
60 def r1c (r1) then scale([J])
\r
61 def r1t (r1) + [gap]
\r
62 def r1b ((r1t) then scale([1,0,1])) + [gap]
\r
63 line[arrows=<->](r1c)(r1)
\r
65 def r1m ((r1) - (O) + (r1c) - (O)) / 2 + (O)
\r
66 special |\node[ann] at #1 {$r_1$};|(r1m)
\r
67 % same drill for r0, but must project down first
\r
69 def r0 ((p0) then scale([1,0,1]) then [[seg_rot]]^-2) + [up0]
\r
70 def r0c (r0) then scale([J])
\r
71 def r0t (r0) + [gap]
\r
72 def r0b ((p0) then [[seg_rot]]^-2) + [gap]
\r
73 line[arrows=<->](r0c)(r0)
\r
75 def r0m ((r0) - (O) + (r0c) - (O)) / 2 + (O)
\r
76 special |\node[ann] at #1 {$r_0$};|(r0m)
\r
81 % the "ghost" of the entire cone
\r
82 sweep[draw=lightgray,cull=false] { N-1, [[seg_rot]] }
\r
85 % for the highlighted face, we need explicit points
\r
86 def p00 (p0) then [[seg_rot]]^-1
\r
87 def p10 (p1) then [[seg_rot]]^-1
\r
90 %polygon[showpoints=true](p00)(p10)(p11)(p01)
\r
91 polygon[fillcolor=red,dotsep=semitransparent](p00)(p10)(p11)(p01)
\r
92 % TikZ does not have a showpoints option. Use dots.
\r
93 dots(p00)(p10)(p11)(p01)
\r
94 % TikZ special for labels.
\r
95 special|\fill[black,font=\footnotesize]
\r
96 #1 node [above] {$P_{00}$}
\r
97 #2 node [below] {$P_{10}$}
\r
98 #3 node [above] {$P_{01}$}
\r
99 #4 node [below] {$P_{11}$};|
\r
100 (p00)(p10)(p01)(p11)
\r
101 def mid ((p00)-(O)+(p10)-(O)+(p11)-(O)+(p01)-(O))/4+(O)
\r
102 % The TikZ arc operation starts at the current point. We therefore
\r
103 % need to shift it to get mid to be the center of the arc
\r
104 special|\draw #1+(-60:.25) [yscale=1.3,->] arc(-60:240:.25);|
\r
106 def mid_left ((p00)-(O)+(p10)-(O))/2+(O)
\r
107 def mid_right ((p11)-(O)+(p01)-(O))/2+(O)
\r
108 special|\path[font=\footnotesize]
\r
109 #1 node[left] {$j$}
\r
110 #2 node[right] {$j\hbox{$+$}1$};|
\r
111 (mid_left)(mid_right)
\r
112 def top_lbl (p01) then [[seg_rot]]^2
\r
113 def bot_lbl (p11) then [[seg_rot]]^2
\r
114 special|\path[font=\footnotesize]
\r
115 #1 node[right] {$i\hbox{$=$}0$}
\r
116 #2 node[right] {$i\hbox{$=$}1$};|
\r
124 <labeled> {labeled_cone}
\r
127 put { view((10,4,2)) } {cone}
\r
129 % Cool trick: lay = under forces this to be output first in the tikz picture block.
\r
130 special |\tikzstyle{ann} = [fill=white,font=\footnotesize,inner sep=1pt]|[lay=under]
\r