Debian Codegraph @

texmf-dist/doc/latex/pstricks_calcnotes/For_Ps_Output/AppThreePS.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[dvips,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 \renewcommand\sectionmark[1]{\markright{\thesection. #1}}
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 \title{Drawing partitions of a simply connected plane domain}
183 \author{Le Phuong Quan\\
184 \small{(Cantho University)}\\
185 \small{\texttt{[email protected]}}}
186 \begin{document}
187 \maketitle
188
189 This drawing procedure takes shape from the macros \verb+\psline+, \verb+\pspolygon+, \verb+\multido+
190 and \verb+\parametricplot+ in PSTricks\footnote{\footnotesize PSTricks is the original work of Timothy Van Zandt (email address: \texttt{[email protected]}).
191 It is currently edited by Herbert Vo\ss\ (\texttt{[email protected]}).}. The \TeX\ arithmetic gives the pointwise parametrization of curves.
192 \section{How to make a boundary using B\'{e}zier curves}
193 We can make the closed boundary of a plane domain by joining B\'{e}zier curves. This can produce various boundaries. We consider here
194 two B\'{e}zier curves of degree $5$ whose vector functions are
195 $$\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,$$
196 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$.
197 Here we choose:
198 $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
199 $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
200 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.
201 \begin{figure}[htbp]
202 \centering\begin{pspicture}(-1,-2)(6,2)
203 \rput[rt](0,0){$N_5=M_0\,$}\psdot(0,0)\psdot(5,0)
204 \rput[rt](0,-1.5){$N_4$}\rput[rt](2,-2){$N_3$}\rput[rt](3.5,-1){$N_2$}\rput[rt](5,-1.5){$N_1$}\rput[lt](5,0){$\,M_5=N_0$}
205 \psdots(5,0)(5,-1.5)(3.5,-1)(2,-2)(0,-1.5)(0,0)
206 \psdots(0,1.5)(1.5,1)(3,2)(5,1.5)
207 \rput[rt](0,1.5){$M_1$}\rput[rt](1.5,1){$M_2$}\rput[rt](3,2){$M_3$}\rput[rt](5,1.5){$M_4$}
208 \psline[linestyle=dotted](0,1.5)(0,-1.5)\psline[linestyle=dotted](5,1.5)(5,-1.5)
209 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
210 {\XoneFive|\YoneFive{1}{1}}
211 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
212 {\XtwoFive|\YtwoFive{1}{1}}
213 \end{pspicture}
214 \caption{A B\'{e}zier-spline boundary.}\label{BZ-1}
215 \end{figure}
216 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
217 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
218 their control points and the given couple of multipliers $\alpha_M,\beta_M$, we derive
219 \begin{align*}
220 X_a(t)&=15t^2(1-t)^3+30t^3(1-t)^2+25t^4(1-t)+5t^5,\\
221 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).
222 \end{align*}
223 Similarly, we have
224 \begin{align*}
225 X_b(t)&=5(1-t)^5+25t(1-t)^4+35t^2(1-t)^3+20t^3(1-t)^2,\\
226 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),
227 \end{align*}
228 where $\alpha_N$, $\beta_N$ are multipliers. Then, these curves will be depicted by the macro \verb+\parametricplot+
229 with the corresponding declarations in the \texttt{algebraic} form:
230 \begin{verbatim}
231 \def\XoneFive{15*t^2*(1-t)^3+30*t^3*(1-t)^2+25*t^4*(1-t)+5*t^5}
232 \def\YoneFive#1#2%
233 {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)}
234 \def\XtwoFive{5*(1-t)^5+25*t*(1-t)^4+35*t^2*(1-t)^3+20*t^3*(1-t)^2}
235 \def\YtwoFive#1#2%
236 {(-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)}
237 \end{verbatim}
238 where \verb+#1+, \verb+#2+ stand for $\alpha_M$ and $\beta_M$ in the definition of \verb+\YoneFive+ and
239 for $\alpha_N$ and $\beta_N$ in that of \verb+\YtwoFive+, respectively.
240 In Figure \ref{BZ-2}, the boundaries are drawn by using together the commands
241 \begin{verbatim}
242 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
243 {\XoneFive|\YoneFive{alphaM}{betaM}}
244 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
245 {\XtwoFive|\YtwoFive{alphaN}{betaN}}
246 \end{verbatim}
247 where, \verb+alphaM+, \verb+betaM+, \verb+alphaN+ and \verb+betaN+ are chosen values of $\alpha_M$, $\beta_M$,
248 $\alpha_N$ and $\beta_N$, respectively.
249 \begin{figure}[htbp]
250 \centering\begin{pspicture}(0,-1.5)(4.5,1.5)
251 \psset{unit=24pt}
252 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
253 {\XoneFive|\YoneFive{-0.5}{2.1}}
254 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
255 {\XtwoFive|\YtwoFive{2.4}{-0.4}}
256 \end{pspicture}
257 \begin{pspicture}(0,-1.5)(4.5,1.5)
258 \psset{unit=24pt}
259 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
260 {\XoneFive|\YoneFive{1.1}{1.4}}
261 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
262 {\XtwoFive|\YtwoFive{1.2}{1.5}}
263 \end{pspicture}
264 \begin{pspicture}(0,-1.5)(4.5,1.5)
265 \psset{unit=24pt}
266 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
267 {\XoneFive|\YoneFive{1.7}{0.2}}
268 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}
269 {\XtwoFive|\YtwoFive{0.1}{1.8}}
270 \end{pspicture}
271 \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$;
272 $\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}
273 \end{figure}
274 \section{How to draw a partition of a plane domain}
275 To draw a partition of a plane domain whose boundary is made by the way that has just been described, we need the two
276 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
277 the others for $\alpha_M$ and $\beta_M$ or $\alpha_N$ and $\beta_N$.
278 Both of \verb+\NetDrawOne+ and \verb+\NetDrawTwo+ are used here to find cells in a given grid that have points in common with
279 $\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
280 problem that we are considering here.
281
282 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
283 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:
284 \begin{itemize}
285 \item Coloring cells that have points in common with the boundary of $D$.
286 This is the result of calling \textmtt{\mtt\\NetDrawOne\{$c$\}\{$\alpha_M$\}\{$\beta_M$\}} and \textmtt{\mtt\\NetDrawTwo\{$c$\}\{$\alpha_N$\}\{$\beta_N$\}} together.
287 \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\}$.
288 \item Drawing the two curves $\mathbf{r}_a(t)$ and $\mathbf{r}_b(t)$.
289 \end{itemize}
290
291 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}+
292 environment:
293 \begin{center}\begin{tabular}{l|l}\hline
294 \textbf{Commands}&\textbf{Result}\\ \hline
295 \textmtt{\mtt\\NetDrawOne\{$c$\}\{$\alpha_M$\}\{$\beta_M$\}}\textmtt{\mtt\\NetDrawTwo\{$c$\}\{$\alpha_N$\}\{$\beta_N$\}}&Coloring cells\\ \hline
296 \textmtt{\mtt\\multido\{\mtt\\nx=-1.00+\mtt\\decimal\mtt\\Xsize\}\{$c+1$\}}\\
297 \textmtt{\mtt\\psline[linewidth=0.2pt](\mtt\\nx,-3)(\mtt\\nx,3)}\\
298 \textmtt{\mtt\\multido\{\mtt\\ny=-3.00+\mtt\\decimal\mtt\\Ysize\}\{$c+1$\}}\\
299 \textmtt{\mtt\\psline[linewidth=0.2pt](-1,\mtt\\ny)(6,\mtt\\ny)}&Drawing the grid on $R$ \\ \hline
300 \textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linecolor=white,}\\
301 \textmtt{linewidth=0.5pt]\{0\}\{1\}\{\mtt\\XoneBFive|\mtt\\YoneBFive\{$\alpha_M$\}\{$\beta_M$\}\}}\\
302 \textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linecolor=white,}\\
303 \textmtt{linewidth=0.5pt]\{0\}\{1\}\{\mtt\\XtwoFive|\mtt\\YtwoFive\{$\alpha_N$\}\{$\beta_N$\}\}}&Drawing $\mathbf{r}_a(t)$, $\mathbf{r}_b(t)$\\ \hline
304 \end{tabular}
305 \end{center}
306
307 In the following, beside the definitions of \verb+\XoneFive+, \verb+\YoneFive+, \verb+\XtwoFive+ and \verb+\YtwoFive+,
308 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
309 a single \TeX\ file to be loaded when running the package.
310 \begin{itemize}
311 \item \verb+\def\xch+: Setting \verb+\catcode'\p=12+, \verb+\catcode'\t=12+.
312 \item \verb+\def\ych+: Setting \verb+\catcode'\p=11+, \verb+\catcode'\t=11+.
313 \item \verb+\def\decimal#1+: Getting the numeric value of \verb+#1+ without unit.
314 \item \verb+\def\FACTORIAL#1+: The factorial function. Ex: $\textmtt{\mtt\\FACTORIAL\{3\}}=6$.
315 \item \verb+\def\BINOMIAL#1#2+: Binomial coefficients. Ex: $\textmtt{\mtt\\BINOMIAL\{5\}\{2\}}=10$.
316 \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$.
317 \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)$.
318 \item \verb+\def\YoneBC#1#2#3+, \verb+\def\YtwoBC#1#2#3+:
319 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$.
320 Ex: $\textmtt{\mtt\\YoneBC\{0.5\}\{1.8\}\{1.2\}}=Y_a(0.5)$, with $\alpha_M=1.8$, $\beta_M=1.2$.
321 \end{itemize}
322
323 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
324 these B\'{ezier} curves by the macro \verb+\parametricplot+. But, we need to have in hand their points' coordinates to determine
325 cells of a grid containing points in common with these curves. Fortunately, we may use the \TeX\ arithmetic
326 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]$.
327 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,
328 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.
329 It might be possible to use this macro in other problems later.
330 In Appendix \ref{appendixA}, we list the replacement texts of the above macros and all the local and global variables they need.
331
332 From the listed macros, \verb+\NetDrawOne+ may now have its definition as
333 \begin{verbatim}
334 ==================================================================================
335 \def\NetDrawOne#1#2#3{%
336 \newdimen\Xsize
337 \newdimen\Ysize
338 \newdimen\tempx
339 \newdimen\tempy
340 \Xsize=7pt \divide\Xsize by #1
341 \Ysize=6pt \divide\Ysize by #1
342 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!80,plotpoints=200,
343 linewidth=0.5pt]{0}{1}{\XoneFive|\YoneFive{#2}{#3}}
344 \multido{\nz=0.00+0.005}{200}{\XoneBC{\nz}\YoneBC{\nz}{#2}{#3}
345 \multido{\nx=-1.00+\decimal\Xsize}{#1}
346 {\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
347 {\tempy=\ny pt
348 \ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
349 \ifdim\YBST>\tempy\relax\else
350 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
351 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,
352 linecolor=black,linewidth=0.2pt](\nx,\ny)(\decimal\tempx,\ny)
353 (\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\relax\fi\fi\fi\fi}}}}
354 ==================================================================================
355 \end{verbatim}
356 To obtain the definition of \verb+\NetDrawTwo+, we just replace by \verb+\XtwoFive+,
357 \verb+\Ytwofive+, \verb+\XtwoBC+ and \verb+\YtwoBC+ for \verb+\XoneFive+,
358 \verb+\YoneFive+, \verb+\XoneBC+ and \verb+\YoneBC+ in that of \verb+\NetDrawaOne+, respectively.
359
360 Because of its inevitable shortcoming, \TeX\ often gives approximate results of calculations on dimensions.
361 In the following table, let us see a slight difference between results obtained from the same expression (by declaration of
362 operations) in Maple and in the \TeX\ arithmetic:
363 \begin{table}[htbp]
364 \centering\begin{tabular}{c||c|c|c|c|c}
365 $t$&$0.12$&$0.33$&$0.54$&$0.74$&$0.97$\\ \hline
366 \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
367 Maple&$0.19203$&$1.1935$&$2.6328$&$4.02479$&$4.98266$
368 \end{tabular}
369 \end{table}
370
371 Actually, calculations in determining if a point of the two curves belongs a cell almost give the desired result.
372 \begin{figure}[htbp]
373 \centering\begin{pspicture}(0,0)(4,4)
374 \pspolygon[linewidth=0.5pt,fillstyle=solid,fillcolor=gray!30](1,1)(4,1)(4,3)(1,3)(1,1)
375 \rput(0.8,0.8){$C$}
376 \psline[linewidth=0.5pt,linestyle=dashed](1,0)(1,1)
377 \psline[linewidth=0.5pt,linestyle=dashed](1,3)(1,4)
378 \psline[linewidth=0.5pt,linestyle=dashed](4,0)(4,1)
379 \psline[linewidth=0.5pt,linestyle=dashed](4,3)(4,4)
380 \psline[linewidth=0.5pt,linestyle=dashed](0,1)(1,1)
381 \psline[linewidth=0.5pt,linestyle=dashed](4,1)(5,1)
382 \psline[linewidth=0.5pt,linestyle=dashed](0,3)(1,3)
383 \psline[linewidth=0.5pt,linestyle=dashed](4,3)(5,3)
384 \rput[rt](1,0){$d_1$}\rput[lt](4,0){$d_2$}
385 \rput[lt](5,1){$d_3$}\rput[lb](5,3){$d_4$}
386 \pcline[offset=3pt,linewidth=0.4pt]{<->}(1,0.5)(4,0.5)
387 \ncput*{\small\textmtt{xsize}}
388 \pcline[offset=3pt,linewidth=0.4pt]{<->}(4.7,1)(4.7,3)
389 \ncput*{\small\textmtt{ysize}}
390 \end{pspicture}
391 \caption{A typical cell.}\label{BZ-3}
392 \end{figure}
393
394 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
395 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
396 $P_i$ is
397
398 \begin{figure}[htbp]
399 \centering\includegraphics[width=6cm]{BZ6}\hskip1cm\includegraphics[width=6cm]{BZ7}
400 \caption{From left to right: $c=25$ and $c=45$.}\label{BZ-4}
401 \end{figure}
402
403 \begin{itemize}
404 \item below $d_3$, or
405 \item above $d_4$, or
406 \item on the left side of $d_1$, or
407 \item on the right side of $d_2$;
408 \end{itemize}
409 otherwise, color the cell. This algorithm can be expressed in the form of
410 \begin{center}
411 \begin{tabular}{llll}
412 \multicolumn{4}{l}{\textmtt{\mtt\\ifdim\mtt\\YBST<$y$ \mtt\\relax\mtt\\else\mtt\\advance $y$ by ysize}}\\
413 &\multicolumn{3}{l}{\textmtt{\mtt\\ifdim\mtt\\YBST>$y$ \mtt\\relax\mtt\\else}}\\
414 &&\multicolumn{2}{l}{\textmtt{\mtt\\ifdim\mtt\\XBST<$x$ \mtt\\relax\mtt\\else\mtt\\advance $x$ by xsize}}\\
415 &&&\textmtt{\mtt\\ifdim\mtt\\XBST>$x$ \mtt\\relax\mtt\\else\mtt\\pspolygon[fillstyle=solid,$\ldots$]}
416 \end{tabular}
417 \end{center}
418 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.
419 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
420 Figure \ref{BZ-3}.
421
422 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
423 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
424 same couples $\alpha_M=-0.5$, $\beta_M=2.1$, $\alpha_N=2.4$ and $\beta_N=-0.4$ for its three pictures.
425 \begin{figure}[htbp]
426 \centering\includegraphics[width=5cm]{BZ8}\hskip0.5cm\includegraphics[width=5cm]{BZ9}\hskip0.5cm\includegraphics[width=5cm]{BZ10}
427 \caption{From left to right: $c=25$, $c=45$ and $c=63$.}\label{BZ-5}
428 \end{figure}
429 \appendix
430 \section{Appendix: detailed definitions}\label{appendixA}
431 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+,
432 \verb+\NetDrawOne+ and \verb+\NetDrawTwo+.
433
434 \begin{verbatim}
435 ----------------------------------------------------------------------------------
436 \def\xch{\catcode`\p=12 \catcode`\t=12}
437 \def\ych{\catcode`\p=11 \catcode`\t=11}\xch
438 \def\dec#1pt{#1}\ych
439 \def\decimal#1{\expandafter\dec \the#1}
440 \newcount\Fa\newcount\Fct\newcount\tempA
441
442 \def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
443 \def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa
444 \Factor\fi\global\tempA=\Fct}
445 ----------------------------------------------------------------------------------
446 \newcount\BINOM
447 \newcount\temp
448 \newcount\tmp
449
450 \def\BINOMIAL#1#2{%
451 \temp=#1\advance\temp by -#2
452 \FACTORIAL{#1}
453 \tmp=\tempA
454 \FACTORIAL{\temp}
455 \temp=\tempA
456 \divide\tmp by \temp
457 \FACTORIAL{#2}
458 \temp=\tempA
459 \divide\tmp by \temp\global\BINOM=\tmp}
460 ----------------------------------------------------------------------------------
461 \newdimen\Xa\newdimen\Yb\newcount\kc
462 \newdimen\BSTemp
463
464 \def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}
465 \else\relax\fi}
466 \def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa
467 by 1pt\xmult{#2}\BINOMIAL{5}{#1}\global\BSTemp=\BINOM\Yb}
468 ----------------------------------------------------------------------------------
469 \newdimen\Xrf
470 \newdimen\Yrf
471 \newdimen\XoneBST\newdimen\YoneBST
472 \newdimen\XtwoBST\newdimen\YtwoBST
473 \newdimen\XBST\newdimen\YBST
474
475 \def\XoneBC#1{%
476 \BERNSTEIN{2}{3}{#1}
477 \Xrf=1.5pt
478 \XoneBST=\decimal\BSTemp\Xrf
479 \BERNSTEIN{3}{2}{#1}
480 \Xrf=3pt
481 \advance\XoneBST by \decimal\BSTemp\Xrf
482 \BERNSTEIN{4}{1}{#1}
483 \Xrf=5pt
484 \advance\XoneBST by \decimal\BSTemp\Xrf
485 \BERNSTEIN{5}{0}{#1}
486 \Xrf=5pt
487 \advance\XoneBST by \decimal\BSTemp\Xrf
488 \global\XBST=\XoneBST}
489 ----------------------------------------------------------------------------------
490 \def\XtwoBC#1{%
491 \BERNSTEIN{0}{5}{#1}
492 \Xrf=5pt
493 \XtwoBST=\decimal\BSTemp\Xrf
494 \BERNSTEIN{1}{4}{#1}
495 \Xrf=5pt
496 \advance\XtwoBST by \decimal\BSTemp\Xrf
497 \BERNSTEIN{2}{3}{#1}
498 \Xrf=3.5pt
499 \advance\XtwoBST by \decimal\BSTemp\Xrf
500 \BERNSTEIN{3}{2}{#1}
501 \Xrf=2pt
502 \advance\XtwoBST by \decimal\BSTemp\Xrf
503 \global\XBST=\XtwoBST}
504 ----------------------------------------------------------------------------------
505 \def\YoneBC#1#2#3{%
506 \BERNSTEIN{1}{4}{#1}
507 \Yrf=1.5pt
508 \YoneBST=\decimal\BSTemp\Yrf
509 \BERNSTEIN{2}{3}{#1}
510 \Yrf=1pt
511 \Yrf=#2\Yrf
512 \advance\YoneBST by \decimal\BSTemp\Yrf
513 \BERNSTEIN{3}{2}{#1}
514 \Yrf=2pt
515 \Yrf=#3\Yrf
516 \advance\YoneBST by \decimal\BSTemp\Yrf
517 \BERNSTEIN{4}{1}{#1}
518 \Yrf=1.5pt
519 \advance\YoneBST by \decimal\BSTemp\Yrf
520 \global\YBST=\YoneBST}
521 ----------------------------------------------------------------------------------
522 \def\YtwoBC#1#2#3{%
523 \BERNSTEIN{1}{4}{#1}
524 \Yrf=-1.5pt
525 \YtwoBST=\decimal\BSTemp\Yrf
526 \BERNSTEIN{2}{3}{#1}
527 \Yrf=-1pt
528 \Yrf=#2\Yrf
529 \advance\YtwoBST by \decimal\BSTemp\Yrf
530 \BERNSTEIN{3}{2}{#1}
531 \Yrf=-2pt
532 \Yrf=#3\Yrf
533 \advance\YtwoBST by \decimal\BSTemp\Yrf
534 \BERNSTEIN{4}{1}{#1}
535 \Yrf=-1.5pt
536 \advance\YtwoBST by \decimal\BSTemp\Yrf
537 \global\YBST=\YtwoBST}
538 ----------------------------------------------------------------------------------
539 \end{verbatim}
540
541 \begin{thebibliography}{10}
542 \bibitem{one} Dominique Rodriguez, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pstricks-add}: Additional Macros for PSTricks\/}.
543 Version 3.60,
544 \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
545 \bibitem{two}Eitan M. Gurari. \textsl{Writing With \TeX \/}, McGraw-Hill, Inc., 1994, ISBN 0-07-025207-6
546 \bibitem{three} Helmut Kopka \&\ Patrick W. Daly. \textsl{Guide to \LaTeX \/}.
547 Addison-Wesley, Fourth Edition, 2004, ISBN 0321173856
548 \bibitem{four} Timothy Van Zandt. \textsl{User's Guide\/}. Version 1.5,\\
549 \url{http://ctan.org/tex-archive/graphics/pstricks/base}, 2007
550 \end{thebibliography}
551 \end{document}