summaryrefslogtreecommitdiff
path: root/info/pstricks_calcnotes/For_Pdf_Output/AppThreePDF.tex
blob: 97a5769ece352394d949953d56ab11333ceaea1f (plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{url}
\usepackage{cmtt}
\usepackage[dvips]{geometry}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{pst-plot}
\usepackage{pst-node}
\usepackage{multido}
\usepackage{pst-xkey}
\usepackage{pst-func}
\usepackage{pstricks-add}
\usepackage[pdftex,colorlinks,linktocpage]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\hantt{\^e}\def\accentcircflx{\hskip-.3em\raisebox{0.32ex}{\'{}}}
\DeclareRobustCommand{\cs}[1]{\textmtt{\char`\\#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\Fa\newcount\Fct\newcount\tempA
\def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
\def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa \Factor\fi\global\tempA=\Fct}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\BINOM
\newcount\temp
\newcount\tmp
\def\BINOMIAL#1#2{%
\temp=#1\advance\temp by -#2
\FACTORIAL{#1}
\tmp=\tempA
\FACTORIAL{\temp}
\temp=\tempA
\divide\tmp by \temp
\FACTORIAL{#2}
\temp=\tempA
\divide\tmp by \temp\global\BINOM=\tmp}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
\xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newdimen\Xa\newdimen\Yb\newcount\kc
\newdimen\BSTemp
\def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}\else\relax\fi}
\def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa by 1pt\xmult{#2}
\BINOMIAL{5}{#1}\global\BSTemp=\BINOM\Yb}

\newdimen\Xrf
\newdimen\Yrf
\newdimen\XoneBST\newdimen\YoneBST
\newdimen\XtwoBST\newdimen\YtwoBST
\newdimen\XBST\newdimen\YBST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XoneBC#1{%
\BERNSTEIN{2}{3}{#1}
\Xrf=1.5pt
\XoneBST=\decimal\BSTemp\Xrf
\BERNSTEIN{3}{2}{#1}
\Xrf=3pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\BERNSTEIN{4}{1}{#1}
\Xrf=5pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\BERNSTEIN{5}{0}{#1}
\Xrf=5pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\global\XBST=\XoneBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XtwoBC#1{%
\BERNSTEIN{0}{5}{#1}
\Xrf=5pt
\XtwoBST=\decimal\BSTemp\Xrf
\BERNSTEIN{1}{4}{#1}
\Xrf=5pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\BERNSTEIN{2}{3}{#1}
\Xrf=3.5pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\BERNSTEIN{3}{2}{#1}
\Xrf=2pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\global\XBST=\XtwoBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\YoneBC#1#2#3{%
\BERNSTEIN{1}{4}{#1}
\Yrf=1.5pt
\YoneBST=\decimal\BSTemp\Yrf
\BERNSTEIN{2}{3}{#1}
\Yrf=1pt
\Yrf=#2\Yrf
\advance\YoneBST by \decimal\BSTemp\Yrf
\BERNSTEIN{3}{2}{#1}
\Yrf=2pt
\Yrf=#3\Yrf
\advance\YoneBST by \decimal\BSTemp\Yrf
\BERNSTEIN{4}{1}{#1}
\Yrf=1.5pt
\advance\YoneBST by \decimal\BSTemp\Yrf
\global\YBST=\YoneBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\YtwoBC#1#2#3{%
\BERNSTEIN{1}{4}{#1}
\Yrf=-1.5pt
\YtwoBST=\decimal\BSTemp\Yrf
\BERNSTEIN{2}{3}{#1}
\Yrf=-1pt
\Yrf=#2\Yrf
\advance\YtwoBST by \decimal\BSTemp\Yrf
\BERNSTEIN{3}{2}{#1}
\Yrf=-2pt
\Yrf=#3\Yrf
\advance\YtwoBST by \decimal\BSTemp\Yrf
\BERNSTEIN{4}{1}{#1}
\Yrf=-1.5pt
\advance\YtwoBST by \decimal\BSTemp\Yrf
\global\YBST=\YtwoBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XoneFive{15*t^2*(1-t)^3+30*t^3*(1-t)^2+25*t^4*(1-t)+5*t^5}
\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)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XtwoFive{5*(1-t)^5+25*t*(1-t)^4+35*t^2*(1-t)^3+20*t^3*(1-t)^2}
\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)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\NetDrawOne#1#2#3{%
\newdimen\Xsize
\newdimen\Ysize
\newdimen\tempx
\newdimen\tempy
\Xsize=7pt \divide\Xsize by #1
\Ysize=6pt \divide\Ysize by #1
\parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!85,plotpoints=200,linewidth=0.5pt]{0}{1}
{\XoneFive|\YoneFive{#2}{#3}}
\multido{\nz=0.00+0.005}{200}{\XoneBC{\nz}\YoneBC{\nz}{#2}{#3}
\multido{\nx=-1.00+\decimal\Xsize}{#1}
{\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
{\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
 \ifdim\YBST>\tempy\relax\else
 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,linecolor=black,linewidth=0.2pt]
 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\fi\fi\fi\fi}
}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\NetDrawTwo#1#2#3{%
\newdimen\Xsize
\newdimen\Ysize
\newdimen\tempx
\newdimen\tempy
\Xsize=7pt \divide\Xsize by #1
\Ysize=6pt \divide\Ysize by #1
\parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!85,plotpoints=200,linewidth=0.5pt]{0}{1}
{\XtwoFive|\YtwoFive{#2}{#3}}
\multido{\nz=0.00+0.005}{200}{\XtwoBC{\nz}\YtwoBC{\nz}{#2}{#3}
\multido{\nx=-1.00+\decimal\Xsize}{#1}
{\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
{\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
 \ifdim\YBST>\tempy\relax\else
 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,linecolor=black,linewidth=0.2pt]
 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\fi\fi\fi\fi}
}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{headings}
\topmargin=-0.6cm
\textwidth=16.7cm
\textheight=23cm
\headheight=2.5ex
\headsep=0.6cm
\oddsidemargin=.cm
\evensidemargin=-.4cm
\parskip=0.7ex plus0.5ex minus 0.5ex
\baselineskip=17pt plus2pt minus2pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=11
\gdef\@seccntformat#1{\csname the#1\endcsname.\hskip.6em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef\acknw{\section*{%
{\acknwname}\markright{\protect\textsl{\acknwname}}}%
\addcontentsline{toc}{section}{\acknwname}}
\gdef\acknwname{Acknowledgment}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\sectionmark[1]{\markright{\thesection. #1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Drawing partitions of a simply connected plane domain}
\author{Le Phuong Quan\\
\small{(Cantho University)}\\
\small{\texttt{lpquan@ctu.edu.vn}}}
\begin{document}
\maketitle

This drawing procedure takes shape from the macros \verb+\psline+, \verb+\pspolygon+, \verb+\multido+
and  \verb+\parametricplot+ in PSTricks\footnote{\footnotesize PSTricks is the original work of Timothy Van Zandt (email address: \texttt{tvz@econ.insead.fr}).
It is currently edited by Herbert Vo\ss\ (\texttt{hvoss@tug.org}).}. The \TeX\ arithmetic gives the pointwise parametrization of curves.
\section{How to make a boundary using B\'{e}zier curves}
We can make the closed boundary of a plane domain by joining B\'{e}zier curves. This can produce various boundaries. We consider here
two B\'{e}zier curves of degree $5$ whose vector functions are
$$\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,$$
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$.
Here we choose:
$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
$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
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.
\begin{figure}[htbp]
\centering\includegraphics[width=7cm]{BZ1}
\caption{A B\'{e}zier-spline boundary.}\label{BZ-1}
\end{figure}
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
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
their control points and the given couple of multipliers $\alpha_M,\beta_M$, we derive
\begin{align*}
X_a(t)&=15t^2(1-t)^3+30t^3(1-t)^2+25t^4(1-t)+5t^5,\\
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).
\end{align*}
Similarly, we have
\begin{align*}
X_b(t)&=5(1-t)^5+25t(1-t)^4+35t^2(1-t)^3+20t^3(1-t)^2,\\
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),
\end{align*}
where $\alpha_N$, $\beta_N$ are multipliers. Then, these curves will be depicted by the macro \verb+\parametricplot+
with the corresponding declarations in the \texttt{algebraic} form:
\begin{verbatim}
\def\XoneFive{15*t^2*(1-t)^3+30*t^3*(1-t)^2+25*t^4*(1-t)+5*t^5}
\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)}
\def\XtwoFive{5*(1-t)^5+25*t*(1-t)^4+35*t^2*(1-t)^3+20*t^3*(1-t)^2}
\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)}
\end{verbatim}
where \verb+#1+, \verb+#2+ stand for $\alpha_M$ and $\beta_M$ in the definition of \verb+\YoneFive+ and
for $\alpha_N$ and $\beta_N$ in that of \verb+\YtwoFive+, respectively.
In Figure \ref{BZ-2}, the boundaries are drawn by using together the commands
\begin{verbatim}
\parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
{\XoneFive|\YoneFive{alphaM}{betaM}}
\parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
{\XtwoFive|\YtwoFive{alphaN}{betaN}}
\end{verbatim}
where, \verb+alphaM+, \verb+betaM+, \verb+alphaN+ and \verb+betaN+ are chosen values of $\alpha_M$, $\beta_M$,
$\alpha_N$ and $\beta_N$, respectively.
\begin{figure}[htbp]
\centering\includegraphics[width=4.5cm]{BZ2}
\hskip0.5cm\includegraphics[width=4.5cm]{BZ3}
\hskip0.5cm\includegraphics[width=4.5cm]{BZ4}
\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$;
$\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}
\end{figure}
\section{How to draw a partition of a plane domain}
To draw a partition of a plane domain whose boundary is made by the way that has just been described, we need the two
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
the others for $\alpha_M$ and $\beta_M$ or $\alpha_N$ and $\beta_N$.
Both of \verb+\NetDrawOne+ and \verb+\NetDrawTwo+ are used here to find cells in a given grid that have points in common with
$\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
problem that we are considering here.

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
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:
\begin{itemize}
\item Coloring cells that have points in common with the boundary of $D$.
This is the result of calling \textmtt{\mtt\\NetDrawOne\{$c$\}\{$\alpha_M$\}\{$\beta_M$\}} and \textmtt{\mtt\\NetDrawTwo\{$c$\}\{$\alpha_N$\}\{$\beta_N$\}} together.
\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\}$.
\item Drawing the two curves $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$.
\end{itemize}

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}+
environment:
\begin{center}\begin{tabular}{l|l}\hline
\textbf{Commands}&\textbf{Result}\\ \hline
\textmtt{\mtt\\NetDrawOne\{$c$\}\{$\alpha_M$\}\{$\beta_M$\}}\textmtt{\mtt\\NetDrawTwo\{$c$\}\{$\alpha_N$\}\{$\beta_N$\}}&Coloring cells\\ \hline
\textmtt{\mtt\\multido\{\mtt\\nx=-1.00+\mtt\\decimal\mtt\\Xsize\}\{$c+1$\}}\\
\textmtt{\mtt\\psline[linewidth=0.2pt](\mtt\\nx,-3)(\mtt\\nx,3)}\\
\textmtt{\mtt\\multido\{\mtt\\ny=-3.00+\mtt\\decimal\mtt\\Ysize\}\{$c+1$\}}\\
\textmtt{\mtt\\psline[linewidth=0.2pt](-1,\mtt\\ny)(6,\mtt\\ny)}&Drawing the grid on $R$ \\ \hline
\textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linecolor=white,}\\
\textmtt{linewidth=0.5pt]\{0\}\{1\}\{\mtt\\XoneBFive|\mtt\\YoneBFive\{$\alpha_M$\}\{$\beta_M$\}\}}\\
\textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linecolor=white,}\\
\textmtt{linewidth=0.5pt]\{0\}\{1\}\{\mtt\\XtwoFive|\mtt\\YtwoFive\{$\alpha_N$\}\{$\beta_N$\}\}}&Drawing $\mathbf{r}_a(t)$, $\mathbf{r}_b(t)$\\ \hline
\end{tabular}
\end{center}

In the following, beside the definitions of \verb+\XoneFive+, \verb+\YoneFive+, \verb+\XtwoFive+ and \verb+\YtwoFive+,
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
a single \TeX\ file to be loaded when running the package.
\begin{itemize}
\item \verb+\def\xch+: Setting \verb+\catcode'\p=12+, \verb+\catcode'\t=12+.
\item \verb+\def\ych+: Setting \verb+\catcode'\p=11+, \verb+\catcode'\t=11+.
\item \verb+\def\decimal#1+: Getting the numeric value of \verb+#1+ without unit.
\item \verb+\def\FACTORIAL#1+: The factorial function. Ex: $\textmtt{\mtt\\FACTORIAL\{3\}}=6$.
\item \verb+\def\BINOMIAL#1#2+: Binomial coefficients. Ex: $\textmtt{\mtt\\BINOMIAL\{5\}\{2\}}=10$.
\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$.
\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)$.
\item \verb+\def\YoneBC#1#2#3+, \verb+\def\YtwoBC#1#2#3+:
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$.
Ex: $\textmtt{\mtt\\YoneBC\{0.5\}\{1.8\}\{1.2\}}=Y_a(0.5)$, with $\alpha_M=1.8$, $\beta_M=1.2$.
\end{itemize}

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
these B\'{ezier} curves by the macro \verb+\parametricplot+. But, we need to have in hand their points' coordinates to determine
cells of a grid containing points in common with these curves. Fortunately, we may use the \TeX\ arithmetic
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]$.
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,
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.
It might be possible to use this macro in other problems later.
In Appendix \ref{appendixA}, we list the replacement texts of the above macros and all the local and global variables they need.

From the listed macros, \verb+\NetDrawOne+ may now have its definition as
\begin{verbatim}
==================================================================================
\def\NetDrawOne#1#2#3{%
\newdimen\Xsize
\newdimen\Ysize
\newdimen\tempx
\newdimen\tempy
\Xsize=7pt \divide\Xsize by #1
\Ysize=6pt \divide\Ysize by #1
\parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!80,plotpoints=200,
linewidth=0.5pt]{0}{1}{\XoneFive|\YoneFive{#2}{#3}}
\multido{\nz=0.00+0.005}{200}{\XoneBC{\nz}\YoneBC{\nz}{#2}{#3}
\multido{\nx=-1.00+\decimal\Xsize}{#1}
{\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
{\tempy=\ny pt
     \ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
      \ifdim\YBST>\tempy\relax\else
       \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
        \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,
linecolor=black,linewidth=0.2pt](\nx,\ny)(\decimal\tempx,\ny)
(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\relax\fi\fi\fi\fi}}}}
==================================================================================
\end{verbatim}
To obtain the definition of \verb+\NetDrawTwo+, we just replace by \verb+\XtwoFive+,
\verb+\Ytwofive+, \verb+\XtwoBC+ and \verb+\YtwoBC+ for \verb+\XoneFive+,
\verb+\YoneFive+, \verb+\XoneBC+ and \verb+\YoneBC+ in that of \verb+\NetDrawaOne+, respectively.

Because of its inevitable shortcoming, \TeX\ often gives approximate results of calculations on dimensions.
In the following table, let us see a slight difference between results obtained from the same expression (by declaration of
operations) in Maple and in the \TeX\ arithmetic:
\begin{table}[htbp]
\centering\begin{tabular}{c||c|c|c|c|c}
$t$&$0.12$&$0.33$&$0.54$&$0.74$&$0.97$\\ \hline
\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
Maple&$0.19203$&$1.1935$&$2.6328$&$4.02479$&$4.98266$
\end{tabular}
\end{table}

Actually, calculations in determining if a point of the two curves belongs a cell almost give the desired result.
\begin{figure}[htbp]
\centering\includegraphics[width=5cm]{BZ5}
\caption{A typical cell.}\label{BZ-3}
\end{figure}

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
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
$P_i$ is

\begin{figure}[htbp]
\centering\includegraphics[width=6cm]{BZ6}\hskip1cm\includegraphics[width=6cm]{BZ7}
\caption{From left to right: $c=25$ and $c=45$.}\label{BZ-4}
\end{figure}

\begin{itemize}
\item below $d_3$, or
\item above $d_4$, or
\item on the left side of $d_1$, or
\item on the right side of $d_2$;
\end{itemize}
otherwise, color the cell. This algorithm can be expressed in the form of
\begin{center}
\begin{tabular}{llll}
\multicolumn{4}{l}{\textmtt{\mtt\\ifdim\mtt\\YBST<$y$ \mtt\\relax\mtt\\else\mtt\\advance $y$ by ysize}}\\
&\multicolumn{3}{l}{\textmtt{\mtt\\ifdim\mtt\\YBST>$y$ \mtt\\relax\mtt\\else}}\\
&&\multicolumn{2}{l}{\textmtt{\mtt\\ifdim\mtt\\XBST<$x$ \mtt\\relax\mtt\\else\mtt\\advance $x$ by xsize}}\\
&&&\textmtt{\mtt\\ifdim\mtt\\XBST>$x$ \mtt\\relax\mtt\\else\mtt\\pspolygon[fillstyle=solid,$\ldots$]}
\end{tabular}
\end{center}
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.
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
Figure \ref{BZ-3}.

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
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
same couples $\alpha_M=-0.5$, $\beta_M=2.1$, $\alpha_N=2.4$ and $\beta_N=-0.4$ for its three pictures.
\begin{figure}[htbp]
\centering\includegraphics[width=5cm]{BZ8}\hskip0.5cm\includegraphics[width=5cm]{BZ9}\hskip0.5cm\includegraphics[width=5cm]{BZ10}
\caption{From left to right: $c=25$, $c=45$ and $c=63$.}\label{BZ-5}
\end{figure}
\appendix
\section{Appendix: detailed definitions}\label{appendixA}
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+,
\verb+\NetDrawOne+ and \verb+\NetDrawTwo+.

\begin{verbatim}
----------------------------------------------------------------------------------
\def\xch{\catcode`\p=12 \catcode`\t=12}
\def\ych{\catcode`\p=11 \catcode`\t=11}\xch
\def\dec#1pt{#1}\ych
\def\decimal#1{\expandafter\dec \the#1}
\newcount\Fa\newcount\Fct\newcount\tempA

\def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
\def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa
\Factor\fi\global\tempA=\Fct}
----------------------------------------------------------------------------------
\newcount\BINOM
\newcount\temp
\newcount\tmp

\def\BINOMIAL#1#2{%
\temp=#1\advance\temp by -#2
\FACTORIAL{#1}
\tmp=\tempA
\FACTORIAL{\temp}
\temp=\tempA
\divide\tmp by \temp
\FACTORIAL{#2}
\temp=\tempA
\divide\tmp by \temp\global\BINOM=\tmp}
----------------------------------------------------------------------------------
\newdimen\Xa\newdimen\Yb\newcount\kc
\newdimen\BSTemp

\def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}
\else\relax\fi}
\def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa
by 1pt\xmult{#2}\BINOMIAL{5}{#1}\global\BSTemp=\BINOM\Yb}
----------------------------------------------------------------------------------
\newdimen\Xrf
\newdimen\Yrf
\newdimen\XoneBST\newdimen\YoneBST
\newdimen\XtwoBST\newdimen\YtwoBST
\newdimen\XBST\newdimen\YBST

\def\XoneBC#1{%
\BERNSTEIN{2}{3}{#1}
\Xrf=1.5pt
\XoneBST=\decimal\BSTemp\Xrf
\BERNSTEIN{3}{2}{#1}
\Xrf=3pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\BERNSTEIN{4}{1}{#1}
\Xrf=5pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\BERNSTEIN{5}{0}{#1}
\Xrf=5pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\global\XBST=\XoneBST}
----------------------------------------------------------------------------------
\def\XtwoBC#1{%
\BERNSTEIN{0}{5}{#1}
\Xrf=5pt
\XtwoBST=\decimal\BSTemp\Xrf
\BERNSTEIN{1}{4}{#1}
\Xrf=5pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\BERNSTEIN{2}{3}{#1}
\Xrf=3.5pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\BERNSTEIN{3}{2}{#1}
\Xrf=2pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\global\XBST=\XtwoBST}
----------------------------------------------------------------------------------
\def\YoneBC#1#2#3{%
\BERNSTEIN{1}{4}{#1}
\Yrf=1.5pt
\YoneBST=\decimal\BSTemp\Yrf
\BERNSTEIN{2}{3}{#1}
\Yrf=1pt
\Yrf=#2\Yrf
\advance\YoneBST by \decimal\BSTemp\Yrf
\BERNSTEIN{3}{2}{#1}
\Yrf=2pt
\Yrf=#3\Yrf
\advance\YoneBST by \decimal\BSTemp\Yrf
\BERNSTEIN{4}{1}{#1}
\Yrf=1.5pt
\advance\YoneBST by \decimal\BSTemp\Yrf
\global\YBST=\YoneBST}
----------------------------------------------------------------------------------
\def\YtwoBC#1#2#3{%
\BERNSTEIN{1}{4}{#1}
\Yrf=-1.5pt
\YtwoBST=\decimal\BSTemp\Yrf
\BERNSTEIN{2}{3}{#1}
\Yrf=-1pt
\Yrf=#2\Yrf
\advance\YtwoBST by \decimal\BSTemp\Yrf
\BERNSTEIN{3}{2}{#1}
\Yrf=-2pt
\Yrf=#3\Yrf
\advance\YtwoBST by \decimal\BSTemp\Yrf
\BERNSTEIN{4}{1}{#1}
\Yrf=-1.5pt
\advance\YtwoBST by \decimal\BSTemp\Yrf
\global\YBST=\YtwoBST}
----------------------------------------------------------------------------------
\end{verbatim}

\begin{thebibliography}{10}
\bibitem{one} Dominique Rodriguez, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pstricks-add}: Additional Macros for PSTricks\/}.
Version 3.60,
\url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
\bibitem{two}Eitan M. Gurari. \textsl{Writing With \TeX \/}, McGraw-Hill, Inc., 1994, ISBN 0-07-025207-6
\bibitem{three} Helmut Kopka \&\ Patrick W. Daly. \textsl{Guide to \LaTeX \/}.
Addison-Wesley, Fourth Edition, 2004, ISBN 0321173856
\bibitem{four} Timothy Van Zandt. \textsl{User's Guide\/}. Version 1.5,\\
\url{http://ctan.org/tex-archive/graphics/pstricks/base}, 2007
\end{thebibliography}
\end{document}