Bounding box points correctement labelé avec tikz, et avancées documentation
[delaunay.git] / doc / luamesh-doc.tex
1 % luamesh: compute and draw meshes with lua, luamplib and tikz
2 %
3 % Originally written by Maxime Chupin <mc@melusine.eu.org>,
4 % 2010.
5 %
6 % Distributed under the terms of the GNU free documentation licence:
7 % http://www.gnu.org/licenses/fdl.html
8 % without any invariant section or cover text.
9
10 \documentclass{lltxdoc}
11 \usepackage{tcolorbox}
12 \usepackage{xargs}
13 \usepackage{enumitem}
14
15
16 \title{\Verb+luamesh+: compute and draw meshes with \lualatex}
17 \author{Maxime Chupin \email{mc@melusine.eu.org}}
18 \date{\today}
19
20 \newcommand*\commande{\noindent\hspace{-30pt}%
21 \SaveVerb[aftersave={%
22 \UseVerb{Vitem}
23 }%
24 ]{Vitem}}
25
26 \newcommand*\textme[1]{\textcolor{black}{\rmfamily\textit{#1}}}
27 \newcommand*\meta[1]{% % meta
28 \textme{\ensuremath{\langle}#1\ensuremath{\rangle}}}
29 \newcommand*\optstar{% % optional star
30 \meta{\ensuremath{*}}\xspace}
31 \DefineShortVerb{\|}
32
33 \setlength{\fboxsep}{2pt}
34 \fvset{%
35 codes={\catcode`\«\active \catcode`\×\active },
36 defineactive={\makefancyog\makefancytimes},
37 formatcom=\color{red},
38 frame=single
39 }
40 % rendre «...» équivalent à \meta{...}
41 {\catcode`\«\active
42 \newcommandx\makefancyog[0][addprefix=\global]{%
43 \def«##1»{\meta{##1}}}}
44 % rendre × équivalent à \optstar
45 {\catcode`\×\active
46 \newcommandx\makefancytimes[0][addprefix=\global]{%
47 \def×{\optstar{}}}}
48
49
50 \tcbuselibrary{listings,breakable}
51
52 \definecolor{vert}{rgb}{0.1,0.4,0.1}
53 \definecolor{bleu}{rgb}{0.1,0.1,0.4}
54 \lstset{
55 numberstyle=\footnotesize\color{vert},
56 keywordstyle=\ttfamily\bfseries\color{blue},
57 basicstyle=\ttfamily\footnotesize,
58 commentstyle=\itshape\color{vert},
59 stringstyle=\ttfamily,
60 showstringspaces=false,
61 language=[LaTeX]TeX,
62 breaklines=true,
63 breakindent=30pt,
64 defaultdialect=[LaTeX]TeX,
65 % frame=tb
66 }
67
68 \lstdefinelanguage{lua}
69 {morekeywords={for,end,function,do,if,else,elseif,then,
70 tex.print,tex.sprint,io.read,io.open,string.find,string.explode,require},
71 morecomment=[l]{--},
72 morecomment=[s]{--[[}{]]},
73 morestring=[b]''
74 }
75
76 \newtcblisting{Exemple}{%
77 arc=0pt,outer arc=0pt,
78 colback=red!2!white,
79 colframe=red!75!black,
80 breakable,
81 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
82 3pt, toptitle=3pt,
83 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
84 0pt, bottomrule at break = 0pt,
85 listing options={breaklines},
86 }
87
88 \newtcblisting{commandshell}{colback=black,colupper=white,colframe=black,
89 arc=0pt,
90 listing only,boxsep=0pt,listing
91 options={style=tcblatex,language=sh},
92 every listing line={\textcolor{red}{\small\ttfamily\bfseries user \$> }}}
93
94 \newtcblisting{latexcode}{
95 arc=0pt,
96 listing only,boxsep=0pt,listing
97 options={style=tcblatex}}
98
99
100 \newcommand\luamesh{\Verb+luamesh+\xspace}
101
102 \newenvironment{optionsenum}[1][]
103 {\begin{description}[font=\color{red}\ttfamily]}
104 {\end{description}}
105
106 \begin{document}
107
108 \maketitle
109
110 \begin{abstract}
111 The package \Verb|luamesh| allows to compute and draw 2D triangulation
112 of Delaunay. The algorithm is written with lua, and depending of the
113 choice of the ``engine'', the draw is done by MetaPost (with
114 \Verb|luamplib|) or by \Verb|tikz|.
115
116 The Delaunay triangulation algorithm is the Bowyer and Watson
117 algorithm. Several macros are provided to draw the global mesh, the
118 set of points, a particular step of the algorithm.
119 \end{abstract}
120
121 \section{Installation}
122
123 \subsection{With Linux}
124
125 To install \luamesh with \TeX live, you have to create the local
126 \Verb+texmf+ directory in your \Verb+home+.
127
128 \begin{commandshell}
129 mkdir ~/texmf
130 \end{commandshell}
131
132 Then we have to files to place in the correct directories. First, the
133 \Verb+luamesh.sty+ file must be in the directory:
134 \begin{center}
135 \Verb+~/texmf/tex/latex/luamesh/+
136 \end{center}
137 and secondly, the \Verb+luamesh.lua+ must be in the directory:
138 \begin{center}
139 \Verb+~/texmf/scripts/luamesh/+
140 \end{center}
141
142 Once you have done this, \luamesh can be included in your document
143 with
144 \begin{latexcode}
145 \usepackage{luamesh}
146 \end{latexcode}
147
148 \subsection{Dependencies}
149
150 This package is built upon two main packages to draw the
151 triangulations :
152 \begin{enumerate}
153 \item \Verb+luamplib+ to use MetaPost via the \luatex library
154 \Verb+mplib+;
155 \item or \Verb+tikz+.
156 \end{enumerate}
157 We will see how to choose between these two \emph{drawing engines}.
158
159 Moreover, the following packages are necessary:
160 \begin{enumerate}
161 \item \Verb+xkeyval+ to manage the optional arguments;
162 \item \Verb+xcolor+ to use colors (needed by \Verb+luamplib+);
163 \item \Verb+ifthen+ to help the programming with \TeX.
164 \end{enumerate}
165
166
167 \section{The Basic Macros}
168
169 If you want to use this package, you must compile your document with
170 \Verb+lualatex+:
171
172 \begin{commandshell}
173 lualatex mylatexfile.tex
174 \end{commandshell}
175
176 Let us recall that this package provides macros to draw two
177 dimensional triangulations (or meshes).
178
179 \subsection{Draw a Complete Mesh}
180
181 \commande|\buildMeshBW[«options»]{«list of points» or «file name»}|\medskip
182
183 This macro produce the Delaunay triangulation (using the Bowyer and
184 Watson algorithm) of the given \meta{list of points}. The list of
185 points must be given in the following way :
186 \begin{center}
187 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
188 \end{center}
189
190 \begin{Exemple}
191 \buildMeshBW{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}
192 \end{Exemple}
193
194 \subsubsection{The Options}
195
196 There are several options to customize the drawing.
197 \begin{optionsenum}
198 \item[mode = int (default) or ext:] this option allows to
199 use either the previously described set of point in the argument, or
200 a file, containing, line by line (2 columns), the points. Such a
201 file looks like :
202 \begin{verbatim}
203 x1 y1
204 x2 y2
205 x3 y3
206 ...
207 xn yn
208 \end{verbatim}
209 \item[bbox = none (default) or show:] this option allows to draw the
210 added points to form a \emph{bounding box}\footnote{The bounding
211 box is defined by four points place at 15\% around the box
212 defined by $(x_{\min},y_{\min})$, $(x_{\min},y_{\max})$,
213 $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$.} and the corresponding
214 triangulation. By default, these triangles are removed at the end of
215 the algorithm.
216 \item[color = \meta{value} (default: black):] The color of the
217 drawing.
218 \item[colorBbox = \meta{value} (default: black):] The color of the
219 drawing for the elements (points and triangles) belonging to the
220 bounding box.
221 \item[print = none (default) or points:] To label the vertices of the
222 triangulations with an adding dot.
223 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
224 label the vertices of the triangulation. It is include in the math
225 mode delimiters \Verb+$...$+. The bounding box points are labeled
226 with a star exponent, and numbered from 1 to 4.
227 \item[tikz (boolean, default:false):] By default, this boolean is set
228 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
229 the picture. With this option, it is \Verb+tikz+ the \textit{drawing
230 engine}.
231 \item[scale = \meta{value} (default: 1cm):] The scale option defines
232 the scale at which the picture is draw (the same for the two
233 axis). It must contain the unit of length (cm,
234 pt, etc.).
235 \end{optionsenum}
236
237 To illustrate the options, let us show you an example. We consider a
238 file \Verb+mesh.txt+:
239 \begin{verbatim}
240 0.3 0.3
241 1.5 1
242 4 0
243 4.5 2.5
244 1.81 2.14
245 2.5 0.5
246 2.8 1.5
247 \end{verbatim}
248 \begin{Exemple}
249 \buildMeshBW[%
250 tikz,
251 mode = ext,
252 bbox = show,
253 color = red,
254 colorBbox = blue!30,
255 print = points,
256 meshpoint = x,
257 scale = 1.3cm,
258 ]{mesh.txt}
259 \end{Exemple}
260
261 \subsection{Draw the Set of Points}
262
263 \commande|\tracePointsMesh[«options»]{«list of points» or «file name»}|
264
265
266 \subsection{Draw a Step of the Bowyer and Watson Algorithm}
267
268 \commande|\meshAddPointBW[«options»]{«list of points» or «file name»}{«point» or «number of line»}|
269
270
271 \section{The \emph{inc} Macros}
272
273 \section{Gallery of Examples}
274
275 \end{document}
276
277
278
279 %%% Local Variables:
280 %%% flyspell-mode: 1
281 %%% ispell-local-dictionary: "american"
282 %%% End:

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.