Debian Codegraph @

texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/AppThreePDF.tex

raw
1 \documentclass[11pt,a4paper,oneside]{article}
2 \usepackage{multirow}
3 \usepackage{longtable}
4 \usepackage{amsthm}
5 \usepackage{amsmath}
6 \usepackage{url}
7 \usepackage{cmtt}
8 \usepackage[dvips]{geometry}
9 \usepackage{pstricks}
10 \usepackage{graphicx}
11 \usepackage{graphics}
12 \usepackage{pst-plot}
13 \usepackage{pst-node}
14 \usepackage{multido}
15 \usepackage{pst-xkey}
16 \usepackage{pst-func}
17 \usepackage{pstricks-add}
18 \usepackage[pdftex,colorlinks,linktocpage]{hyperref}
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 \def\hantt{\^e}\def\accentcircflx{\hskip-.3em\raisebox{0.32ex}{\'{}}}
21 \DeclareRobustCommand{\cs}[1]{\textmtt{\char`\\#1}}
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 \newcount\Fa\newcount\Fct\newcount\tempA
24 \def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
25 \def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa \Factor\fi\global\tempA=\Fct}
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 \newcount\BINOM
28 \newcount\temp
29 \newcount\tmp
30 \def\BINOMIAL#1#2{%
31 \temp=#1\advance\temp by -#2
32 \FACTORIAL{#1}
33 \tmp=\tempA
34 \FACTORIAL{\temp}
35 \temp=\tempA
36 \divide\tmp by \temp
37 \FACTORIAL{#2}
38 \temp=\tempA
39 \divide\tmp by \temp\global\BINOM=\tmp}
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 \def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
42 \xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 \newdimen\Xa\newdimen\Yb\newcount\kc
45 \newdimen\BSTemp
46 \def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}\else\relax\fi}
47 \def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa by 1pt\xmult{#2}
48 \BINOMIAL{5}{#1}\global\BSTemp=\BINOM\Yb}
49
50 \newdimen\Xrf
51 \newdimen\Yrf
52 \newdimen\XoneBST\newdimen\YoneBST
53 \newdimen\XtwoBST\newdimen\YtwoBST
54 \newdimen\XBST\newdimen\YBST
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 \def\XoneBC#1{%
57 \BERNSTEIN{2}{3}{#1}
58 \Xrf=1.5pt
59 \XoneBST=\decimal\BSTemp\Xrf
60 \BERNSTEIN{3}{2}{#1}
61 \Xrf=3pt
62 \advance\XoneBST by \decimal\BSTemp\Xrf
63 \BERNSTEIN{4}{1}{#1}
64 \Xrf=5pt
65 \advance\XoneBST by \decimal\BSTemp\Xrf
66 \BERNSTEIN{5}{0}{#1}
67 \Xrf=5pt
68 \advance\XoneBST by \decimal\BSTemp\Xrf
69 \global\XBST=\XoneBST}
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 \def\XtwoBC#1{%
72 \BERNSTEIN{0}{5}{#1}
73 \Xrf=5pt
74 \XtwoBST=\decimal\BSTemp\Xrf
75 \BERNSTEIN{1}{4}{#1}
76 \Xrf=5pt
77 \advance\XtwoBST by \decimal\BSTemp\Xrf
78 \BERNSTEIN{2}{3}{#1}
79 \Xrf=3.5pt
80 \advance\XtwoBST by \decimal\BSTemp\Xrf
81 \BERNSTEIN{3}{2}{#1}
82 \Xrf=2pt
83 \advance\XtwoBST by \decimal\BSTemp\Xrf
84 \global\XBST=\XtwoBST}
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 \def\YoneBC#1#2#3{%
87 \BERNSTEIN{1}{4}{#1}
88 \Yrf=1.5pt
89 \YoneBST=\decimal\BSTemp\Yrf
90 \BERNSTEIN{2}{3}{#1}
91 \Yrf=1pt
92 \Yrf=#2\Yrf
93 \advance\YoneBST by \decimal\BSTemp\Yrf
94 \BERNSTEIN{3}{2}{#1}
95 \Yrf=2pt
96 \Yrf=#3\Yrf
97 \advance\YoneBST by \decimal\BSTemp\Yrf
98 \BERNSTEIN{4}{1}{#1}
99 \Yrf=1.5pt
100 \advance\YoneBST by \decimal\BSTemp\Yrf
101 \global\YBST=\YoneBST}
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 \def\YtwoBC#1#2#3{%
104 \BERNSTEIN{1}{4}{#1}
105 \Yrf=-1.5pt
106 \YtwoBST=\decimal\BSTemp\Yrf
107 \BERNSTEIN{2}{3}{#1}
108 \Yrf=-1pt
109 \Yrf=#2\Yrf
110 \advance\YtwoBST by \decimal\BSTemp\Yrf
111 \BERNSTEIN{3}{2}{#1}
112 \Yrf=-2pt
113 \Yrf=#3\Yrf
114 \advance\YtwoBST by \decimal\BSTemp\Yrf
115 \BERNSTEIN{4}{1}{#1}
116 \Yrf=-1.5pt
117 \advance\YtwoBST by \decimal\BSTemp\Yrf
118 \global\YBST=\YtwoBST}
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 \def\XoneFive{15*t^2*(1-t)^3+30*t^3*(1-t)^2+25*t^4*(1-t)+5*t^5}
121 \def\YoneFive#1#2{7.5*t*(1-t)^4+(#1)*10*t^2*(1-t)^3+(#2)*20*t^3*(1-t)^2+7.5*t^4*(1-t)}
122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123 \def\XtwoFive{5*(1-t)^5+25*t*(1-t)^4+35*t^2*(1-t)^3+20*t^3*(1-t)^2}
124 \def\YtwoFive#1#2{(-7.5)*t*(1-t)^4+(#1)*(-10)*t^2*(1-t)^3+(#2)*(-20)*t^3*(1-t)^2+(-7.5)*t^4*(1-t)}
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126 \def\NetDrawOne#1#2#3{%
127 \newdimen\Xsize
128 \newdimen\Ysize
129 \newdimen\tempx
130 \newdimen\tempy
131 \Xsize=7pt \divide\Xsize by #1
132 \Ysize=6pt \divide\Ysize by #1
133 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!85,plotpoints=200,linewidth=0.5pt]{0}{1}
134 {\XoneFive|\YoneFive{#2}{#3}}
135 \multido{\nz=0.00+0.005}{200}{\XoneBC{\nz}\YoneBC{\nz}{#2}{#3}
136 \multido{\nx=-1.00+\decimal\Xsize}{#1}
137 {\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
138 {\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
139 \ifdim\YBST>\tempy\relax\else
140 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
141 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,linecolor=black,linewidth=0.2pt]
142 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\fi\fi\fi\fi}
143 }}
144 }
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 \def\NetDrawTwo#1#2#3{%
147 \newdimen\Xsize
148 \newdimen\Ysize
149 \newdimen\tempx
150 \newdimen\tempy
151 \Xsize=7pt \divide\Xsize by #1
152 \Ysize=6pt \divide\Ysize by #1
153 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!85,plotpoints=200,linewidth=0.5pt]{0}{1}
154 {\XtwoFive|\YtwoFive{#2}{#3}}
155 \multido{\nz=0.00+0.005}{200}{\XtwoBC{\nz}\YtwoBC{\nz}{#2}{#3}
156 \multido{\nx=-1.00+\decimal\Xsize}{#1}
157 {\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
158 {\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
159 \ifdim\YBST>\tempy\relax\else
160 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
161 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,linecolor=black,linewidth=0.2pt]
162 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\fi\fi\fi\fi}
163 }}
164 }
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 \pagestyle{headings}
167 \topmargin=-0.6cm
168 \textwidth=16.7cm
169 \textheight=23cm
170 \headheight=2.5ex
171 \headsep=0.6cm
172 \oddsidemargin=.cm
173 \evensidemargin=-.4cm
174 \parskip=0.7ex plus0.5ex minus 0.5ex
175 \baselineskip=17pt plus2pt minus2pt
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 \catcode`\@=11
178 \gdef\@seccntformat#1{\csname the#1\endcsname.\hskip.6em}
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 \gdef\acknw{\section*{%
181 {\acknwname}\markright{\protect\textsl{\acknwname}}}%
182 \addcontentsline{toc}{section}{\acknwname}}
183 \gdef\acknwname{Acknowledgment}
184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185 \renewcommand\sectionmark[1]{\markright{\thesection. #1}}
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 \title{Drawing partitions of a simply connected plane domain}
188 \author{Le Phuong Quan\\
189 \small{(Cantho University)}\\
190 \small{\texttt{[email protected]}}}
191 \begin{document}
192 \maketitle
193
194 This drawing procedure takes shape from the macros \verb+\psline+, \verb+\pspolygon+, \verb+\multido+
195 and \verb+\parametricplot+ in PSTricks\footnote{\footnotesize PSTricks is the original work of Timothy Van Zandt (email address: \texttt{[email protected]}).
196 It is currently edited by Herbert Vo\ss\ (\texttt{[email protected]}).}. The \TeX\ arithmetic gives the pointwise parametrization of curves.
197 \section{How to make a boundary using B\'{e}zier curves}
198 We can make the closed boundary of a plane domain by joining B\'{e}zier curves. This can produce various boundaries. We consider here
199 two B\'{e}zier curves of degree $5$ whose vector functions are
200 $$\mathbf{r}_a(t)=\sum_{i=0}^5\binom{5}{i}t^i(1-t)^{5-i}\mathbf{a}_i,\quad \mathbf{r}_b(t)=\sum_{i=0}^5\binom{5}{i}t^i(1-t)^{5-i}\mathbf{b}_i,$$
201 where $\mathbf{a}_i$ and $\mathbf{b}_i$ are the position vectors of control points $M_i$, $N_i$ of the two curves, respectively, $i=0,\ldots,5$.
202 Here we choose:
203 $M_0=(0,0)$, $M_1=(0,1.5)$, $M_2=(1.5,1)$, $M_3=(3,2)$, $M_4=(5,1.5)$, $M_5=(5,0)$, and
204 $N_0=(5,0)$, $N_1=(5,-1.5)$, $N_2=(3.5,-1)$, $N_3=(2,-2)$, $N_4=(0,-1.5)$, $N_5=(0,0)$. The two curves and
205 their control points are shown in Figure \ref{BZ-1} and the picture in it gives us an obvious explanation of how to combine two B\'{e}zier curves to make a closed and smooth boundary.
206 \begin{figure}[htbp]
207 \centering\includegraphics[width=7cm]{BZ1}
208 \caption{A B\'{e}zier-spline boundary.}\label{BZ-1}
209 \end{figure}
210 To change the shape of the boundary, we take one couple of multipliers for the second coordinates of $M_2$, $M_3$ and another one for those of $N_2$, $N_3$. To
211 draw the curves $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$ we need their parametrization $(X_a(t),Y_a(t))$ and $(X_b(t),Y_b(t))$, $t\in[0,1]$. From
212 their control points and the given couple of multipliers $\alpha_M,\beta_M$, we derive
213 \begin{align*}
214 X_a(t)&=15t^2(1-t)^3+30t^3(1-t)^2+25t^4(1-t)+5t^5,\\
215 Y_a(t)&=7.5t(1-t)^4+10\alpha_M t^2(1-t)^3+20\beta_M t^3(1-t)^2+7.5t^4(1-t).
216 \end{align*}
217 Similarly, we have
218 \begin{align*}
219 X_b(t)&=5(1-t)^5+25t(1-t)^4+35t^2(1-t)^3+20t^3(1-t)^2,\\
220 Y_b(t)&=-7.5t(1-t)^4-10\alpha_N t^2(1-t)^3-20\beta_N t^3(1-t)^2-7.5t^4(1-t),
221 \end{align*}
222 where $\alpha_N$, $\beta_N$ are multipliers. Then, these curves will be depicted by the macro \verb+\parametricplot+
223 with the corresponding declarations in the \texttt{algebraic} form:
224 \begin{verbatim}
225 \def\XoneFive{15*t^2*(1-t)^3+30*t^3*(1-t)^2+25*t^4*(1-t)+5*t^5}
226 \def\YoneFive#1#2%
227 {7.5*t*(1-t)^4+(#1)*10*t^2*(1-t)^3+(#2)*20*t^3*(1-t)^2+7.5*t^4*(1-t)}
228 \def\XtwoFive{5*(1-t)^5+25*t*(1-t)^4+35*t^2*(1-t)^3+20*t^3*(1-t)^2}
229 \def\YtwoFive#1#2%
230 {(-7.5)*t*(1-t)^4+(#1)*(-10)*t^2*(1-t)^3+(#2)*(-20)*t^3*(1-t)^2+(-7.5)*t^4*(1-t)}
231 \end{verbatim}
232 where \verb+#1+, \verb+#2+ stand for $\alpha_M$ and $\beta_M$ in the definition of \verb+\YoneFive+ and
233 for $\alpha_N$ and $\beta_N$ in that of \verb+\YtwoFive+, respectively.
234 In Figure \ref{BZ-2}, the boundaries are drawn by using together the commands
235 \begin{verbatim}
236 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
237 {\XoneFive|\YoneFive{alphaM}{betaM}}
238 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
239 {\XtwoFive|\YtwoFive{alphaN}{betaN}}
240 \end{verbatim}
241 where, \verb+alphaM+, \verb+betaM+, \verb+alphaN+ and \verb+betaN+ are chosen values of $\alpha_M$, $\beta_M$,
242 $\alpha_N$ and $\beta_N$, respectively.
243 \begin{figure}[htbp]
244 \centering\includegraphics[width=4.5cm]{BZ2}
245 \hskip0.5cm\includegraphics[width=4.5cm]{BZ3}
246 \hskip0.5cm\includegraphics[width=4.5cm]{BZ4}
247 \caption{From left to right, corresponding to the couple of values: $\alpha_M=-0.5$, $\beta_M=2.1$, $\alpha_N=2.4$, $\beta_N=-0.4$;
248 $\alpha_M=1.1$, $\beta_M=1.4$, $\alpha_N=1.2$, $\beta_N=1.5$; $\alpha_M=1.7$, $\beta_M=0.2$, $\alpha_N=0.1$, $\beta_N=1.8$}\label{BZ-2}
249 \end{figure}
250 \section{How to draw a partition of a plane domain}
251 To draw a partition of a plane domain whose boundary is made by the way that has just been described, we need the two
252 procedures \verb+\NetDrawOne+ and \verb+\NetDrawTwo+, corresponding to $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$. Their calling sequences take three arguments in order: one for $c$ (the number of cells) and
253 the others for $\alpha_M$ and $\beta_M$ or $\alpha_N$ and $\beta_N$.
254 Both of \verb+\NetDrawOne+ and \verb+\NetDrawTwo+ are used here to find cells in a given grid that have points in common with
255 $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$, and to color those cells. To obtain the definition of these procedures, we first state the
256 problem that we are considering here.
257
258 A grid of rectangular cells will be put on a rectangle $R$ containing a domain $D$ whose boundary consist of $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$, including
259 the given values of $c$, $\alpha_M$, $\beta_M$, $\alpha_N$ and $\beta_N$. Then, the steps for drawing a partition of $D$ can be listed as follows:
260 \begin{itemize}
261 \item Coloring cells that have points in common with the boundary of $D$.
262 This is the result of calling \textmtt{\mtt\\NetDrawOne\{$c$\}\{$\alpha_M$\}\{$\beta_M$\}} and \textmtt{\mtt\\NetDrawTwo\{$c$\}\{$\alpha_N$\}\{$\beta_N$\}} together.
263 \item Drawing the grid on $R$, which has been chosen as $R=\{(x,y)\colon -1\le x\le 6,\,-3\le y\le 3\}$.
264 \item Drawing the two curves $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$.
265 \end{itemize}
266
267 In practice, a partition of $D$ can be given by a calling sequence that has the following structure inside the \verb+\begin{pspicture}+ \ldots \verb+\end{pspicture}+
268 environment:
269 \begin{center}\begin{tabular}{l|l}\hline
270 \textbf{Commands}&\textbf{Result}\\ \hline
271 \textmtt{\mtt\\NetDrawOne\{$c$\}\{$\alpha_M$\}\{$\beta_M$\}}\textmtt{\mtt\\NetDrawTwo\{$c$\}\{$\alpha_N$\}\{$\beta_N$\}}&Coloring cells\\ \hline
272 \textmtt{\mtt\\multido\{\mtt\\nx=-1.00+\mtt\\decimal\mtt\\Xsize\}\{$c+1$\}}\\
273 \textmtt{\mtt\\psline[linewidth=0.2pt](\mtt\\nx,-3)(\mtt\\nx,3)}\\
274 \textmtt{\mtt\\multido\{\mtt\\ny=-3.00+\mtt\\decimal\mtt\\Ysize\}\{$c+1$\}}\\
275 \textmtt{\mtt\\psline[linewidth=0.2pt](-1,\mtt\\ny)(6,\mtt\\ny)}&Drawing the grid on $R$ \\ \hline
276 \textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linecolor=white,}\\
277 \textmtt{linewidth=0.5pt]\{0\}\{1\}\{\mtt\\XoneBFive|\mtt\\YoneBFive\{$\alpha_M$\}\{$\beta_M$\}\}}\\
278 \textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linecolor=white,}\\
279 \textmtt{linewidth=0.5pt]\{0\}\{1\}\{\mtt\\XtwoFive|\mtt\\YtwoFive\{$\alpha_N$\}\{$\beta_N$\}\}}&Drawing $\mathbf{r}_a(t)$, $\mathbf{r}_b(t)$\\ \hline
280 \end{tabular}
281 \end{center}
282
283 In the following, beside the definitions of \verb+\XoneFive+, \verb+\YoneFive+, \verb+\XtwoFive+ and \verb+\YtwoFive+,
284 we list all the remaining macros by their control sequences only and the results derived from running them. They form the whole drawing package, and of course they are also put in the preamble or in
285 a single \TeX\ file to be loaded when running the package.
286 \begin{itemize}
287 \item \verb+\def\xch+: Setting \verb+\catcode'\p=12+, \verb+\catcode'\t=12+.
288 \item \verb+\def\ych+: Setting \verb+\catcode'\p=11+, \verb+\catcode'\t=11+.
289 \item \verb+\def\decimal#1+: Getting the numeric value of \verb+#1+ without unit.
290 \item \verb+\def\FACTORIAL#1+: The factorial function. Ex: $\textmtt{\mtt\\FACTORIAL\{3\}}=6$.
291 \item \verb+\def\BINOMIAL#1#2+: Binomial coefficients. Ex: $\textmtt{\mtt\\BINOMIAL\{5\}\{2\}}=10$.
292 \item \verb+\def\BERNSTEIN#1#2#3+: Bernstein's functions. Ex: $\textmtt{\mtt\\BERNSTEIN\{3\}\{2\}\{t\}}=\displaystyle\binom{5}{3}t^3(1-t)^2$.
293 \item \verb+\def\XoneBC#1+, \verb+\def\XtwoBC#1+: The values of $X_a(t)$, $X_b(t)$. Ex: $\textmtt{\mtt\\XoneBC\{0.5\}}=X_a(0.5)$.
294 \item \verb+\def\YoneBC#1#2#3+, \verb+\def\YtwoBC#1#2#3+:
295 The value of $Y_a(t)$ with given values of $\alpha_M$, $\beta_M$, and the value of $Y_b(t)$ with given values of $\alpha_N$, $\beta_N$.
296 Ex: $\textmtt{\mtt\\YoneBC\{0.5\}\{1.8\}\{1.2\}}=Y_a(0.5)$, with $\alpha_M=1.8$, $\beta_M=1.2$.
297 \end{itemize}
298
299 We recall here the main idea for this drawing procedure. We have already the expressions of $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$ to draw
300 these B\'{ezier} curves by the macro \verb+\parametricplot+. But, we need to have in hand their points' coordinates to determine
301 cells of a grid containing points in common with these curves. Fortunately, we may use the \TeX\ arithmetic
302 to design expressions of $X_a(t)$, $Y_a(t)$, $X_b(t)$ and $Y_b(t)$, hence we can evaluate their values at each given $t\in[0,1]$.
303 For instance, the macro \verb+\def\XoneBC#1+ is destined for evaluating the value of $X_a(t)$, and since it is a linear combination of Bernstein's functions,
304 we need binomial coefficients. We do not take directly numeric values of those coefficients, and we have had the macro \verb+\def\BINOMIAL#1#2+ do that instead.
305 It might be possible to use this macro in other problems later.
306 In Appendix \ref{appendixA}, we list the replacement texts of the above macros and all the local and global variables they need.
307
308 From the listed macros, \verb+\NetDrawOne+ may now have its definition as
309 \begin{verbatim}
310 ==================================================================================
311 \def\NetDrawOne#1#2#3{%
312 \newdimen\Xsize
313 \newdimen\Ysize
314 \newdimen\tempx
315 \newdimen\tempy
316 \Xsize=7pt \divide\Xsize by #1
317 \Ysize=6pt \divide\Ysize by #1
318 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!80,plotpoints=200,
319 linewidth=0.5pt]{0}{1}{\XoneFive|\YoneFive{#2}{#3}}
320 \multido{\nz=0.00+0.005}{200}{\XoneBC{\nz}\YoneBC{\nz}{#2}{#3}
321 \multido{\nx=-1.00+\decimal\Xsize}{#1}
322 {\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
323 {\tempy=\ny pt
324 \ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
325 \ifdim\YBST>\tempy\relax\else
326 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
327 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,
328 linecolor=black,linewidth=0.2pt](\nx,\ny)(\decimal\tempx,\ny)
329 (\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\relax\fi\fi\fi\fi}}}}
330 ==================================================================================
331 \end{verbatim}
332 To obtain the definition of \verb+\NetDrawTwo+, we just replace by \verb+\XtwoFive+,
333 \verb+\Ytwofive+, \verb+\XtwoBC+ and \verb+\YtwoBC+ for \verb+\XoneFive+,
334 \verb+\YoneFive+, \verb+\XoneBC+ and \verb+\YoneBC+ in that of \verb+\NetDrawaOne+, respectively.
335
336 Because of its inevitable shortcoming, \TeX\ often gives approximate results of calculations on dimensions.
337 In the following table, let us see a slight difference between results obtained from the same expression (by declaration of
338 operations) in Maple and in the \TeX\ arithmetic:
339 \begin{table}[htbp]
340 \centering\begin{tabular}{c||c|c|c|c|c}
341 $t$&$0.12$&$0.33$&$0.54$&$0.74$&$0.97$\\ \hline
342 \textmtt{\mtt\\XoneBC\{$t$\}}&$\XoneBC{0.12}\decimal\XBST$&$\XoneBC{0.33}\decimal\XBST$&$\XoneBC{0.54}\decimal\XBST$&$\XoneBC{0.74}\decimal\XBST$&$\XoneBC{0.97}\decimal\XBST$\\ \hline
343 Maple&$0.19203$&$1.1935$&$2.6328$&$4.02479$&$4.98266$
344 \end{tabular}
345 \end{table}
346
347 Actually, calculations in determining if a point of the two curves belongs a cell almost give the desired result.
348 \begin{figure}[htbp]
349 \centering\includegraphics[width=5cm]{BZ5}
350 \caption{A typical cell.}\label{BZ-3}
351 \end{figure}
352
353 Before taking some examples, we give an explanation about what the main algorithm in the procedure \verb+\NetDrawOne+ (or \verb+\NetDrawTwo+) is. Let us take an approximate sequence of points
354 for the curve $\mathbf{r}_a(t)$, say $P_i(\textmtt{\mtt\\XoneBC\{$t_i$\}},\textmtt{\mtt\\YoneBC\{$t_i$\}\{$\alpha_M$\}\{$\beta_M$\}})$, $i=1,\ldots,200$. Then, each $P_i$ is examined whether to be in a cell that has the reference point $C=(x,y)$ by the instruction that: do nothing if
355 $P_i$ is
356
357 \begin{figure}[htbp]
358 \centering\includegraphics[width=6cm]{BZ6}\hskip1cm\includegraphics[width=6cm]{BZ7}
359 \caption{From left to right: $c=25$ and $c=45$.}\label{BZ-4}
360 \end{figure}
361
362 \begin{itemize}
363 \item below $d_3$, or
364 \item above $d_4$, or
365 \item on the left side of $d_1$, or
366 \item on the right side of $d_2$;
367 \end{itemize}
368 otherwise, color the cell. This algorithm can be expressed in the form of
369 \begin{center}
370 \begin{tabular}{llll}
371 \multicolumn{4}{l}{\textmtt{\mtt\\ifdim\mtt\\YBST<$y$ \mtt\\relax\mtt\\else\mtt\\advance $y$ by ysize}}\\
372 &\multicolumn{3}{l}{\textmtt{\mtt\\ifdim\mtt\\YBST>$y$ \mtt\\relax\mtt\\else}}\\
373 &&\multicolumn{2}{l}{\textmtt{\mtt\\ifdim\mtt\\XBST<$x$ \mtt\\relax\mtt\\else\mtt\\advance $x$ by xsize}}\\
374 &&&\textmtt{\mtt\\ifdim\mtt\\XBST>$x$ \mtt\\relax\mtt\\else\mtt\\pspolygon[fillstyle=solid,$\ldots$]}
375 \end{tabular}
376 \end{center}
377 where \verb+\XBST+ and \verb+\YBST+ hold the values of \textmtt{\mtt\\XoneBC\{$t_i$\}} and \textmtt{\mtt\\YoneBC\{$t_i$\}\{$\alpha_M$\}\{$\beta_M$\}}, respectively.
378 This structure is almost the same as that in the procedure \verb+\NetDrawOne+ (or \verb+\NetDrawTwo+), but the variables here are declared according to the gloss in
379 Figure \ref{BZ-3}.
380
381 Finally, let us take two examples where we just give values of $c$ for the caption of figures. In Figure \ref{BZ-4}, we take the
382 same couples $\alpha_M=1.7$, $\beta_M=0.2$, $\alpha_N=0.1$ and $\beta_N=1.8$ for its two pictures. In Figure \ref{BZ-5}, we take the
383 same couples $\alpha_M=-0.5$, $\beta_M=2.1$, $\alpha_N=2.4$ and $\beta_N=-0.4$ for its three pictures.
384 \begin{figure}[htbp]
385 \centering\includegraphics[width=5cm]{BZ8}\hskip0.5cm\includegraphics[width=5cm]{BZ9}\hskip0.5cm\includegraphics[width=5cm]{BZ10}
386 \caption{From left to right: $c=25$, $c=45$ and $c=63$.}\label{BZ-5}
387 \end{figure}
388 \appendix
389 \section{Appendix: detailed definitions}\label{appendixA}
390 The following is the list of all the detailed definitions needed for the procedure, except those of \verb+\XoneFive+, \verb+\YoneFive+, \verb+\XtwoFive+, \verb+\YtwoFive+,
391 \verb+\NetDrawOne+ and \verb+\NetDrawTwo+.
392
393 \begin{verbatim}
394 ----------------------------------------------------------------------------------
395 \def\xch{\catcode`\p=12 \catcode`\t=12}
396 \def\ych{\catcode`\p=11 \catcode`\t=11}\xch
397 \def\dec#1pt{#1}\ych
398 \def\decimal#1{\expandafter\dec \the#1}
399 \newcount\Fa\newcount\Fct\newcount\tempA
400
401 \def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
402 \def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa
403 \Factor\fi\global\tempA=\Fct}
404 ----------------------------------------------------------------------------------
405 \newcount\BINOM
406 \newcount\temp
407 \newcount\tmp
408
409 \def\BINOMIAL#1#2{%
410 \temp=#1\advance\temp by -#2
411 \FACTORIAL{#1}
412 \tmp=\tempA
413 \FACTORIAL{\temp}
414 \temp=\tempA
415 \divide\tmp by \temp
416 \FACTORIAL{#2}
417 \temp=\tempA
418 \divide\tmp by \temp\global\BINOM=\tmp}
419 ----------------------------------------------------------------------------------
420 \newdimen\Xa\newdimen\Yb\newcount\kc
421 \newdimen\BSTemp
422
423 \def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}
424 \else\relax\fi}
425 \def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa
426 by 1pt\xmult{#2}\BINOMIAL{5}{#1}\global\BSTemp=\BINOM\Yb}
427 ----------------------------------------------------------------------------------
428 \newdimen\Xrf
429 \newdimen\Yrf
430 \newdimen\XoneBST\newdimen\YoneBST
431 \newdimen\XtwoBST\newdimen\YtwoBST
432 \newdimen\XBST\newdimen\YBST
433
434 \def\XoneBC#1{%
435 \BERNSTEIN{2}{3}{#1}
436 \Xrf=1.5pt
437 \XoneBST=\decimal\BSTemp\Xrf
438 \BERNSTEIN{3}{2}{#1}
439 \Xrf=3pt
440 \advance\XoneBST by \decimal\BSTemp\Xrf
441 \BERNSTEIN{4}{1}{#1}
442 \Xrf=5pt
443 \advance\XoneBST by \decimal\BSTemp\Xrf
444 \BERNSTEIN{5}{0}{#1}
445 \Xrf=5pt
446 \advance\XoneBST by \decimal\BSTemp\Xrf
447 \global\XBST=\XoneBST}
448 ----------------------------------------------------------------------------------
449 \def\XtwoBC#1{%
450 \BERNSTEIN{0}{5}{#1}
451 \Xrf=5pt
452 \XtwoBST=\decimal\BSTemp\Xrf
453 \BERNSTEIN{1}{4}{#1}
454 \Xrf=5pt
455 \advance\XtwoBST by \decimal\BSTemp\Xrf
456 \BERNSTEIN{2}{3}{#1}
457 \Xrf=3.5pt
458 \advance\XtwoBST by \decimal\BSTemp\Xrf
459 \BERNSTEIN{3}{2}{#1}
460 \Xrf=2pt
461 \advance\XtwoBST by \decimal\BSTemp\Xrf
462 \global\XBST=\XtwoBST}
463 ----------------------------------------------------------------------------------
464 \def\YoneBC#1#2#3{%
465 \BERNSTEIN{1}{4}{#1}
466 \Yrf=1.5pt
467 \YoneBST=\decimal\BSTemp\Yrf
468 \BERNSTEIN{2}{3}{#1}
469 \Yrf=1pt
470 \Yrf=#2\Yrf
471 \advance\YoneBST by \decimal\BSTemp\Yrf
472 \BERNSTEIN{3}{2}{#1}
473 \Yrf=2pt
474 \Yrf=#3\Yrf
475 \advance\YoneBST by \decimal\BSTemp\Yrf
476 \BERNSTEIN{4}{1}{#1}
477 \Yrf=1.5pt
478 \advance\YoneBST by \decimal\BSTemp\Yrf
479 \global\YBST=\YoneBST}
480 ----------------------------------------------------------------------------------
481 \def\YtwoBC#1#2#3{%
482 \BERNSTEIN{1}{4}{#1}
483 \Yrf=-1.5pt
484 \YtwoBST=\decimal\BSTemp\Yrf
485 \BERNSTEIN{2}{3}{#1}
486 \Yrf=-1pt
487 \Yrf=#2\Yrf
488 \advance\YtwoBST by \decimal\BSTemp\Yrf
489 \BERNSTEIN{3}{2}{#1}
490 \Yrf=-2pt
491 \Yrf=#3\Yrf
492 \advance\YtwoBST by \decimal\BSTemp\Yrf
493 \BERNSTEIN{4}{1}{#1}
494 \Yrf=-1.5pt
495 \advance\YtwoBST by \decimal\BSTemp\Yrf
496 \global\YBST=\YtwoBST}
497 ----------------------------------------------------------------------------------
498 \end{verbatim}
499
500 \begin{thebibliography}{10}
501 \bibitem{one} Dominique Rodriguez, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pstricks-add}: Additional Macros for PSTricks\/}.
502 Version 3.60,
503 \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
504 \bibitem{two}Eitan M. Gurari. \textsl{Writing With \TeX \/}, McGraw-Hill, Inc., 1994, ISBN 0-07-025207-6
505 \bibitem{three} Helmut Kopka \&\ Patrick W. Daly. \textsl{Guide to \LaTeX \/}.
506 Addison-Wesley, Fourth Edition, 2004, ISBN 0321173856
507 \bibitem{four} Timothy Van Zandt. \textsl{User's Guide\/}. Version 1.5,\\
508 \url{http://ctan.org/tex-archive/graphics/pstricks/base}, 2007
509 \end{thebibliography}
510 \end{document}