1 % luamesh: compute and draw meshes with lua, luamplib and tikz
3 % Originally written by Maxime Chupin <mc@melusine.eu.org>,
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.
10 \documentclass{lltxdoc
}
11 \usepackage{tcolorbox
}
12 \title{\Verb+luamesh+: compute and draw meshes with
\lualatex}
13 \author{Maxime Chupin
\email{mc@melusine.eu.org
}}
16 \newcommand*
\commande{\noindent\hspace{-
30pt
}%
17 \SaveVerb[aftersave=
{%
23 \newcommand*
\textme[1]{\color{black
}{\rmfamily\textit{#1}}}
24 \newcommand*
\meta[1]{% % meta
25 \textme{\ensuremath{\langle}#1\ensuremath{\rangle}}}
26 \newcommand*
\optstar{% % optional star
27 \meta{\ensuremath{*
}}\xspace}
30 \setlength{\fboxsep}{2pt
}
32 codes=
{\catcode`\«
\active \catcode`\×
\active },
33 defineactive=
{\makefancyog\makefancytimes},
34 formatcom=
\color{red
},
37 % rendre «...» équivalent à \meta{...}
39 \newcommandx\makefancyog[0][addprefix=
\global]{%
40 \def«#
#1»
{\meta{#
#1}}}}
41 % rendre × équivalent à \optstar
43 \newcommandx\makefancytimes[0][addprefix=
\global]{%
47 \tcbuselibrary{listings,breakable
}
49 \definecolor{vert
}{rgb
}{0.1,
0.4,
0.1}
50 \definecolor{bleu
}{rgb
}{0.1,
0.1,
0.4}
52 numberstyle=
\footnotesize\color{vert
},
53 keywordstyle=
\ttfamily\bfseries\color{blue
},
54 basicstyle=
\ttfamily\footnotesize,
55 commentstyle=
\itshape\color{vert
},
56 stringstyle=
\ttfamily,
57 showstringspaces=false,
61 defaultdialect=
[LaTeX
]TeX,
65 \lstdefinelanguage{lua
}
66 {morekeywords=
{for,end,function,do,if,else,elseif,then,
67 tex.print,tex.sprint,io.read,io.open,string.find,string.explode,require
},
69 morecomment=
[s
]{--
[[}{]]},
73 \newtcblisting{Exemple
}{%
74 arc=
0pt,outer arc=
0pt,
76 colframe=red!
75!black,
78 boxsep=
0pt,left=
5pt,right=
5pt,top=
5pt,bottom=
5pt, bottomtitle =
80 boxrule=
0pt,bottomrule=
0.5pt,toprule=
0.5pt, toprule at break =
81 0pt, bottomrule at break =
0pt,
82 listing options=
{breaklines
},
85 \newtcblisting{commandshell
}{colback=black,colupper=white,colframe=black,
87 listing only,boxsep=
0pt,listing
88 options=
{style=tcblatex,language=sh
},
89 every listing line=
{\textcolor{red
}{\small\ttfamily\bfseries user \$>
}}}
91 \newtcblisting{latexcode
}{
93 listing only,boxsep=
0pt,listing
94 options=
{style=tcblatex
}}
97 \newcommand\luamesh{\Verb+luamesh+
\xspace}
104 The package
\Verb|luamesh| allows to compute and draw
2D triangulation
105 of Delaunay. The algorithm is written with lua, and depending of the
106 choice of the ``engine'', the draw is done by MetaPost (with
107 \Verb|luamplib|) or by
\Verb|tikz|.
109 The Delaunay triangulation algorithm is the Bowyer and Watson
110 algorithm. Several macros are provided to draw the global mesh, the
111 set of points, a particular step of the algorithm.
114 \section{Installation
}
116 \subsection{With Linux
}
118 To install
\luamesh with
\TeX live, you have to create the local
119 \Verb+texmf+ directory in your
\Verb+home+.
125 Then we have to files to place in the correct directories. First, the
126 \Verb+luamesh.sty+ file must be in the directory:
128 \Verb+~/texmf/tex/latex/luamesh/+
130 and secondly, the
\Verb+luamesh.lua+ must be in the directory:
132 \Verb+~/texmf/scripts/luamesh/+
135 Once you have done this,
\luamesh can be included in your
document
141 \subsection{Dependencies
}
143 This package is built upon two main packages to draw the
146 \item \Verb+luamplib+ to use MetaPost via the
\luatex library
148 \item or
\Verb+tikz+.
150 We will see how to choose between these two
\emph{drawing engines
}.
152 Moreover, the following packages are necessary:
154 \item \Verb+xkeyval+ to manage the optional arguments;
155 \item \Verb+xcolor+ to use colors (needed by
\Verb+luamplib+);
156 \item \Verb+ifthen+ to help the programming with
\TeX.
160 \section{The Basic Macros
}
162 If you want to use this package, you must compile your
document with
166 lualatex mylatexfile.tex
169 Let us recall that this package provides macros to draw two
170 dimensional triangulations (or meshes).
172 \subsection{Draw a Complete Mesh
}
174 \commande|
\buildMeshBW[«options»
]{«list of points» or «file name»
}|
\medskip
176 This macro produce the Delaunay triangulation (using the Bowyer and
177 Watson algorithm) of the given
\meta{list of points
}. The list of
178 points must be given in the following way :
180 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
184 \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)
}
187 \subsubsection{The Options
}
189 There are several options to customize the drawing.
191 \item[\color{red
}\texttt{mode = int (default) or ext
}:
] the mode option allow to
192 use either the previously described set of point in the argument, or
193 a file, containing, line by line (
2 columns), the points. Such a
204 \subsection{Draw the Set of Points
}
206 \commande|
\tracePointsMesh[«options»
]{«list of points» or «file name»
}|
209 \subsection{Draw a Step of the Bowyer and Watson Algorithm
}
211 \commande|
\meshAddPointBW[«options»
]{«list of points» or «file name»
}{«point» or «number of line»
}|
214 \section{The
\emph{inc
} Macros
}
216 \section{Gallery of Examples
}
224 %%% ispell-local-dictionary: "american"