Debian Codegraph @

texmf-dist/doc/lualatex/luahyperbolic/documentation-luahyperbolic.tex

raw
1 \directlua{t0 = os.clock()}
2 \documentclass{article}
3 %\usepackage{fontspec}
4 %\setmainfont{Libertinus Serif}
5 %\usepackage{mathtools,unicode-math}
6 %\setmainfont{Libertinus Math}
7 \usepackage[a4paper,margin=2cm]{geometry}
8 \usepackage{tikz}
9 %\tikzset{every picture/.style=thick}
10 \tikzset{
11 thin/.style={line width=0.8pt},
12 thick/.style={line width=1pt},
13 }
14
15 \usepackage[dvipsnames]{xcolor}
16 \usepackage{multicol}
17 \usepackage[normalem]{ulem}
18 \usepackage{tcolorbox}
19 \tcbuselibrary{listings}
20 \tcbuselibrary{skins,breakable}
21 \usepackage{fancyvrb}
22
23 \hbadness=10000
24 \hfuzz=3pt
25 \usepackage{luahyperbolic}
26 \usepackage{imakeidx}
27 \makeindex[title=Index of functions used in this documentation]
28 \makeindex[name=fields, title=Index of constants and parameters]
29 \usepackage[colorlinks]{hyperref}
30
31 \lstdefinelanguage{Lua}{
32 morekeywords={and,break,do,else,elseif,end,false,for,function,if,in,
33 local,nil,not,or,repeat,return,then,true,until,while},
34 sensitive=true,
35 morecomment=[l]{--},
36 morestring=[b]",
37 morestring=[b]'
38 }
39
40 \tcbset{
41 myluacolors/.style={
42 listing options={
43 language=Lua,
44 tabsize=2,
45 basicstyle=\ttfamily\small,
46 keywordstyle=\color{blue!60!black}\bfseries,
47 commentstyle=\color{gray}\itshape,
48 stringstyle=\color{red!50!black},
49 emph={hyper},
50 emphstyle={\color{green!40!black}\bfseries},
51 showstringspaces=false,
52 breaklines=true,
53 postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space}
54 }
55 }
56 }
57
58
59 \newtcblisting{codeandresult}{%
60 myluacolors,
61 colback=white,
62 colframe=gray!20,
63 fonttitle=\bfseries,
64 listing side text,
65 lefthand width=0.64\linewidth,
66 righthand width=0.36\linewidth
67 }
68
69
70 \newtcbinputlisting{codefromfile}[2][]{%
71 myluacolors, % shared coloring options
72 colback=white,
73 colframe=black,
74 fonttitle=\bfseries,
75 listing file=#2, % path to external file
76 title=#1,
77 breakable
78 }
79
80
81 \title{The \textbf{\textsf{luahyperbolic}} latex package}
82 \author{Damien Mégy}
83 \date{Version : \the\year/\the\month/\the\day}
84 \begin{document}
85 \maketitle
86 % - - - - - TITLE PICTURE
87 \begin{luacode*}
88 t1 = os.clock()
89 texio.write_nl(string.format("[TIMING] %.2f s: beginning title picture", t1))
90 \end{luacode*}
91 \begin{center}
92 \begin{luacode*}
93 hyper.tikzBegin("scale=5")
94 hyper.fillTilingFromAngles(math.pi/2, math.pi/4, math.pi/5, 24,"teal")
95 hyper.tikzEnd()
96 \end{luacode*}
97 \par
98 LaTeX code for above tiling : \verb+\hyperbolicTiling{2}{4}{5}[scale=5,color=teal,depth=24]+ \\
99 The latest version of this documentation is available at:
100 \href{https://github.com/dmegy/luahyperbolic}{github.com/dmegy/luahyperbolic}.
101 \end{center}
102
103 \begin{luacode*}
104 t2 = os.clock()
105 texio.write_nl(string.format("[TIMING] %.2f s: finished title picture in %.2f seconds", os.clock() - t0, t2-t1))
106 \end{luacode*}
107 \vspace{1cm}
108
109
110
111 \begin{multicols}{2}
112 \setcounter{tocdepth}{2}
113 \tableofcontents
114 \end{multicols}
115
116
117
118 \newpage
119 \section{Introduction}
120
121 \subsection{What you can do with this package}
122 \begin{enumerate}
123 \item Draw hyperbolic geometry pictures, high precision (pdf output).
124 \item Use an easy syntax. At least, easier than with \LaTeX macros and bloody pgf.
125 \item Export generated pictures to external tikz files if you want.
126 \item Read the source code and learn hyperbolic geometry.
127 \item Compile **without** installing python packages or lua packages etc.
128 \item Compile **without** "shell-escape" mode.
129 \item Compile everything in a single pass. No (Leeloo Dallas) multipass.
130 Want to illustrate Euclid's fifth postulate ?
131 Do it right there in your TeX file without having to include external files :
132
133 \begin{codeandresult}
134 \begin{luacode*}
135 hyper.tikzBegin("scale=2")
136 local P = complex(0.5,-0.2)
137 local A = complex.exp_i(math.pi/20)
138 for k=1,10 do
139 hyper.drawLine(P, A^k, "teal")
140 end
141 hyper.labelPoint(P, "$P$", "left=.2cm")
142 local style = "very thick, dashed, red"
143 hyper.drawLine(complex.J,-complex.I,style)
144 hyper.tikzEnd()
145 \end{luacode*}
146 \end{codeandresult}
147 \index[fields]{complex!I}\index[fields]{complex!J}
148 \index{complex!exp\_i}\index{tikzBegin}\index{tikzEnd}
149 \item Draw Tilings in one line, without any Lua code :
150 \begin{codeandresult}
151 \hyperbolicTiling{3}{4}{7}[scale=1.4]
152 \hyperbolicTiling{4}{4}{inf}[scale=1.4, color=violet, backgroundcolor=pink!20, depth=6]
153 \end{codeandresult}
154 \end{enumerate}
155
156
157 \subsection{What this package cannot do for you}
158
159 \begin{enumerate}
160 \item Really intensive computations, millions of geodesics etc. Source code is not optimized to keep maximum readability. All computations involve automorphisms. See other remarks below.
161 \item Coffee
162 \end{enumerate}
163
164 \subsection{Efficiency}
165
166 For heavy computations, please use a \sout{Python} C library. Nevertheless, this library is still reasonably efficient and usable:
167 \begin{itemize}
168 \item The first tiling illustration of this documentation (hyperbolic 2-4-5 tiling with 2361 geodesics) compiled in \directlua{tex.print(math.round(100*(t2-t1))/100)} seconds on a 2020 intel macbook air laptop.
169 \item This entire documentation including all pictures compiles in approx. 20 seconds on the same machine, the majority of the time spent on the tilings. The package is suitable for producing lecture notes in hyperbolic geometry, which was the reason for all of this. For an entire book with dozens of pictures, you may need to externalize some of the pictures.
170 \item Tests show that the bottleneck is TikZ, not Lua. In a future version, some future maintainer may add other fontends to the library, including drawing directly to the pdf with pdf primitives wich are several orders of magnitude faster than tikz.
171 \end{itemize}
172
173
174 \subsection{How to load the package}
175
176 \subsubsection*{Local install}
177 Simply put the \verb+luahyperbolic.sty+ file in your working directory and add the following line to your tex preamble :
178 \begin{verbatim}
179 \usepackage{luahyperbolic}
180 \end{verbatim}
181
182 The single file \texttt{luahyperbolic.sty} contains everything needed, including the necessary library for complex numbers. It can be sent to colleagues by email, etc.
183
184 It will declare two lua globals : \texttt{complex} and \texttt{hyper}, and define a \texttt{hyperbolicTiling} command for convenience.
185
186 If the sty file is not in the same directory as your tex file, you can write \verb+\usepackage{../luahyperbolic}+.
187
188
189 %\subsubsection*{CTAN}
190
191
192 \subsection{Dependencies}
193
194 The package luahyperbolic requires the following packages:
195 \begin{itemize}
196 \item tikz
197 \item luacode
198 \end{itemize}
199 It loads them if they are not loaded already.
200
201 The latex files must be compiled with the \textbf{lualatex} engine.
202
203
204 \subsection{Exporting the pictures}
205
206 \subsubsection{When finishing a picture}
207 \index{tikzExport}
208 Simply add a filename to the closing \texttt{hyper.tikzEnd()} instruction, as below:
209 \begin{center}
210 \texttt{hyper.tikzEnd("myfile.tikz")}
211 \end{center}
212
213 This will save the current picture (including \verb+\begin{tikzpicture}[options]+ and \verb+\end{tikzpicture}+).
214
215 \subsubsection{In the middle of the TikZpicture}
216
217 It is also possible to export the current picture at any point with \verb+hyper.tikzExport(optional-filename)+.
218 If no filename is provided, the package will name it \verb+hyper_picture_N+ with \texttt{N} the picture counter. Luahyperbolic keeps count of how many pictures have been produced in the document.
219 This allows exporting images in loops, or drawing several steps of the same picture.
220
221
222 \subsection{(Advanced users) Build from source}
223
224 The \texttt{luahyperbolic.sty} is pre-generated from a template sty file and four lua modules :
225 \begin{enumerate}
226 \item \texttt{complex.lua}
227 \item \texttt{luahyperbolic-core.lua}
228 \item \texttt{luahyperbolic-tikz.lua}
229 \item \texttt{luahyperbolic-tilings.lua}
230 \end{enumerate}
231
232 These files are in the \texttt{lua/} subdirectory of the package repo.
233
234 To build the \texttt{luahyperbolic.sty} from lua source files, execute \texttt{lua build.lua} in the root directory of the package.
235 This will buid and replace the existing sty file.
236
237
238
239
240 \section{Drawing and labeling elements}
241
242 % ------------------ Figure 1 : Points ------------------
243
244 \subsection{Draw and label points}
245
246 \subsubsection{Draw and label points}
247 \index{drawPoint}\index{drawPoints}\index[fields]{DRAW\_POINT\_RADIUS}
248 \index{labelPoint}\index{labelPoints}
249 \begin{codeandresult}
250 \begin{luacode*}
251 local A = complex(0.3,0.2)
252 local B = 2*A
253 local I, J = complex.I, complex.J
254 local C, D, E = I*A, I*B, J*B
255 hyper.tikzBegin()
256 hyper.drawPoint(0,"white, draw=red")
257 hyper.drawPoints(A, B, C, "teal")
258 hyper.drawPoints(D, E)
259 hyper.labelPoint(A,"$A$", "below right, blue")
260 hyper.labelPoints(B,"$B$", C, "$C$")
261 hyper.labelPoint(D,"$D$","left=.4cm, red")
262 hyper.tikzEnd()
263 \end{luacode*}
264 \end{codeandresult}
265
266
267
268 \subsection{Draw/label/mark segments/lines/rays}
269
270 \subsubsection{Segments lines and rays (through two points)}
271 \index{drawLine}\index{drawSegment}\index{drawRay}
272 \begin{codeandresult}
273 \begin{luacode*}
274 local A = -complex.I/2
275 local B = (1+complex.I)/2
276 local C = complex(-0.7,0.4)
277 local D = complex(-0.7,-0.3)
278 hyper.tikzBegin()
279 hyper.drawLine(A, B, "red")
280 hyper.drawSegment(B,C,"dashed, ForestGreen")
281 hyper.drawRay(C,D,"double,double distance=1pt")
282 hyper.drawLine(D,-D, "green!50!black")
283 hyper.drawLine(A, 1, "gray, line width=2pt")
284 hyper.drawLine(1, complex.I, "teal")
285 hyper.drawPoints(A, B, C, D)
286 hyper.labelPoints(A, "$A$", B, "$B$", C, "$C$", D, "$D$")
287 hyper.tikzEnd()
288 \end{luacode*}
289 \end{codeandresult}
290
291
292
293 \subsubsection{Triangles and polygons}
294 \index{drawTriangle}\index{drawPolygon}\index{drawPolygonFromTable}
295 \begin{codeandresult}
296 \begin{luacode*}
297 local A = complex(.9,.2)
298 local B = complex(.5,.7)
299 local C = complex(0,.9)
300 hyper.tikzBegin()
301 hyper.drawTriangle(A, B, C)
302 hyper.drawTriangle(-A, -B, -C, "red")
303 hyper.drawPolygon(-.9, -.7, complex(-.7,.4), complex(-.9,.3), "blue")
304 local points={}
305 for k=1,5 do
306 table.insert(points, complex.polar(.4,k*2*math.pi/5))
307 end
308 hyper.drawPolygonFromTable(points,"teal")
309 hyper.tikzEnd()
310 \end{luacode*}
311 \end{codeandresult}
312
313
314 \subsubsection{Triangles with prescribed angles}
315 \index{triangleWithAngles}
316 \begin{codeandresult}
317 \begin{luacode*}
318 local function myTriangle(a, b, c, color)
319 hyper.tikzBegin("scale=1.4")
320 local A, B, C = hyper.triangleWithAngles(a, b, c)
321 hyper.drawTriangle(A, B, C, color)
322 hyper.tikzEnd()
323 end
324
325 local PI = math.pi
326
327 myTriangle(PI/2, PI/6, PI/10, "red")
328 myTriangle(2*PI/5, PI/4, PI/5, "red!50!blue")
329 tex.print("\\par")
330
331 myTriangle(2*PI/3, PI/8, PI/20, "blue")
332 myTriangle(PI/3, PI/4, 0, "blue!50!green")
333 tex.print("\\par")
334
335 myTriangle(PI/3, 0, 0, "ForestGreen")
336 myTriangle(0, 0, 0, "green!50!red")
337 \end{luacode*}
338 \end{codeandresult}
339
340
341 \subsubsection{Label and mark segments}
342 \index{markSegment}\index{labelSegment}
343 \begin{codeandresult}
344 \begin{luacode*}
345 local A = -complex.I/2
346 local B = (1+complex.I)/2
347 local C = complex(-0.7,0.4)
348 local D = complex(-0.7,-0.3)
349 hyper.tikzBegin()
350 hyper.drawPolygon(A, B, C, D, "teal")
351 hyper.markSegment(A,B,"|")
352 local marking = "\\textcolor{red}{||}"
353 hyper.markSegment(B,C,marking)
354 hyper.labelSegment(C,D,"$3$", "fill=white, draw=blue")
355 hyper.labelSegment(D, A,"$\\alpha$", "below")
356 hyper.labelPoint(A, "$A$", "below")
357 hyper.tikzEnd()
358 \end{luacode*}
359 \end{codeandresult}
360
361
362 \subsubsection{Regular polygons}
363 \index{drawRegularPolygon}
364 \begin{codeandresult}
365 \begin{luacode*}
366 local O1 = complex(.5,.2)
367 local A1 = complex(.7,.3)
368 local O2 = complex(-0.1,0)
369 local A2 = complex(-.4,.3)
370 local O3 = complex(0,.7)
371 local A3 = complex(0,.9)
372 hyper.tikzBegin()
373 hyper.drawRegularPolygon(O1, A1, 3)
374 hyper.drawRegularPolygon(O2, A2, 5, "blue")
375 hyper.drawRegularPolygon(O3, A3, 8, "green!50!black")
376 hyper.drawPoints(O1,O2,O3)
377 hyper.tikzEnd()
378 \end{luacode*}
379 \end{codeandresult}
380
381
382 \subsubsection{Polygonal lines}
383 \index{drawPolyline}\index{drawPolylineFromTable}
384 \begin{codeandresult}
385 \begin{luacode*}
386 hyper.tikzBegin()
387 -- drawPolyline :
388 hyper.drawPolyline(0, 1, complex.I, -1, "red")
389 -- drawPolylineFromTable :
390 local points={}
391 local N=30
392 for k=1, N do
393 table.insert(points, complex.polar(k/N, k*math.pi/3))
394 end
395 hyper.drawPolylineFromTable(points,"teal")
396 hyper.tikzEnd()
397 \end{luacode*}
398 \end{codeandresult}
399
400
401
402
403 \subsubsection{Lines and rays (point and tangent vector)}
404 \index{drawLineFromVector}\index{drawRayFromVector}
405 \index{drawVector}
406 \begin{codeandresult}
407 \begin{luacode*}
408 local A = complex(-0.2,-0.5)
409 local B = complex(-0.5,0.5)
410 local C = complex(0,0.2)
411 local v = complex(1,0)
412 hyper.tikzBegin()
413 myVec = ">=latex, red"
414 myLine = "dashed, gray"
415 hyper.drawLineFromVector(A, v, myLine)
416 hyper.drawRayFromVector(B, v, myLine)
417 hyper.drawRayFromVector(C, v, myLine)
418 hyper.drawVector(A,v,myVec)
419 hyper.drawVector(B,v,myVec)
420 hyper.drawVector(C,v,myVec)
421 hyper.drawPoints(A, B,C)
422 hyper.tikzEnd()
423 \end{luacode*}
424 \end{codeandresult}
425
426
427
428
429
430
431 \subsubsection{Perpendicular bisector}
432 \index{drawPerpendicularBisector}
433 \begin{codeandresult}
434 \begin{luacode*}
435 local A = complex(-0.2,-0.5)
436 local B = complex(-0.7,0.3)
437 hyper.tikzBegin()
438 hyper.drawPerpendicularBisector(A,B,"red")
439 hyper.drawSegment(A, B, "teal")
440 hyper.drawPoints(A,B)
441 hyper.labelPoints(A,"$A$", B, "$B$", "above right")
442 hyper.tikzEnd()
443 \end{luacode*}
444 \end{codeandresult}
445
446
447 \subsubsection{Angle bisector}
448 \index{drawAngleBisector}
449 \begin{codeandresult}
450 \begin{luacode*}
451 local A = complex(-0.2,-0.6)
452 local O = complex(0.3,0.3)
453 local B = complex(-0.7,0.3)
454 hyper.tikzBegin()
455 hyper.drawAngleBisector(A,O,B,"red")
456 hyper.drawPolyline(A,O,B, "teal")
457 hyper.drawPoints(A,O,B)
458 hyper.labelPoints(A, "$A$", O, "$O$", B, "$B$")
459 hyper.tikzEnd()
460 \end{luacode*}
461 \end{codeandresult}
462
463 \subsection{Circles, semicircles, arcs}
464
465 \subsubsection{Center and radius}
466 \index{drawCircle}
467 \begin{codeandresult}
468 \begin{luacode*}
469 local points = {
470 complex(0,0),
471 complex(-0.5,-0.4),
472 complex(0.8,0.1),
473 complex(0,0.9)
474 }
475 hyper.tikzBegin()
476 for _,point in ipairs(points) do
477 hyper.drawCircle(point,1,"teal")
478 hyper.drawPoint(point)
479 end
480 -- NOTE : all circles have same radius=1 !
481 hyper.tikzEnd()
482 \end{luacode*}
483 \end{codeandresult}
484
485
486 \subsubsection{Circle through point}
487 \index{drawCircleThrough}
488 \begin{codeandresult}
489 \begin{luacode*}
490 local O = complex(0.3,0.2)
491 local P = complex(0.7,-0.4)
492 local Q = complex(-0.1,0.4)
493 hyper.tikzBegin()
494 hyper.drawCircleThrough(O, P, "dotted, red")
495 -- or draw by hand :
496 hyper.drawCircle(O, hyper.distance(O,Q), "blue")
497 hyper.drawPoints(O, P, Q)
498 hyper.labelPoints(O, "$O$", P, "$P$", Q, "$Q$")
499 hyper.tikzEnd()
500 \end{luacode*}
501 \end{codeandresult}
502
503 \subsubsection{Semicircles}
504 \index{drawSemicircle}
505 \begin{codeandresult}
506 \begin{luacode*}
507 local O = complex(0,0)
508 local A = complex(-0.3,0)
509 local P = complex(0.5,0.2)
510 local B = complex(0.7,-0.4)
511 hyper.tikzBegin()
512 hyper.drawSemicircle(O, A, "blue")
513 hyper.drawSemicircle(P, B, "red")
514 hyper.labelPoints(O, "$O$", A, "$A$", P, "$P$", B, "$B$")
515 hyper.drawLine(P,B, "gray, dashed")
516 hyper.drawPoints(O, A, P, B)
517 hyper.tikzEnd()
518 \end{luacode*}
519 \end{codeandresult}
520
521
522 \subsubsection{Arc (center and endpoints)}
523 \index{drawArc}
524 \begin{codeandresult}
525 \begin{luacode*}
526 local O = complex(0,0)
527 local A = complex(0.5,0)
528 local B = complex.polar(0.5,math.pi/3)
529 hyper.tikzBegin()
530 hyper.drawArc(O, A, B, "very thick, red")
531 hyper.drawArc(O, B, A, "dashed")
532 hyper.drawPoints(O,A,B)
533 hyper.tikzEnd()
534 \end{luacode*}
535 \end{codeandresult}
536
537 \subsubsection{Angles}
538 \index{drawAngle}
539 \begin{codeandresult}
540 \begin{luacode*}
541 local A = complex(-.5,-.3)
542 local B = complex(0.5,0)
543 local C = complex(0.2,.7)
544 hyper.tikzBegin()
545 hyper.drawLines(A, B, B, C, C, A, "teal")
546 hyper.drawAngle(B, A, C, "red, very thick")
547 hyper.drawAngle(A, C, B, "thick, double, double distance=2pt, blue")
548 hyper.drawAngle(A, B, C, "very thick, ->, green!50!black")
549 hyper.drawPoints(A, B, C)
550 hyper.labelPoints(A, "$A$", C, "$C$")
551 hyper.labelPoint(N, "$B$", "above right")
552 -- poor man's labelAngle:
553 hyper.labelPoint(A,"$\\alpha$", "above=.6cm, right=.7cm")
554 hyper.tikzEnd()
555 \end{luacode*}
556 \end{codeandresult}
557
558 \subsubsection{Tangent (line) at point}
559 \index{drawTangentAt}
560 \begin{codeandresult}
561 \begin{luacode*}
562 local O = complex(0.3,0.2)
563 local P = complex(-0.1,0)
564 local phi = hyper.rotation(O,math.pi/4)
565 local Q =phi(P)
566 local R = phi(Q)
567 hyper.tikzBegin()
568 hyper.drawCircleThrough(O, P, "teal")
569 hyper.drawTangentAt(O,P,"red")
570 hyper.drawTangentAt(O,Q,"red")
571 hyper.drawTangentAt(O,R,"red")
572 hyper.drawPoints(O, P, Q, R)
573 hyper.tikzEnd()
574 \end{luacode*}
575 \end{codeandresult}
576
577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 \subsection{Horocycles and hypercycles}
579
580 \subsubsection{Horocycles}
581 \index{drawHorocycle}
582 \begin{codeandresult}
583 \begin{luacode*}
584 local theta=math.pi/3
585 local idealPoint = complex.exp_i(theta)
586 local N = 10
587 hyper.tikzBegin()
588 for k=1,N-1 do
589 local point = idealPoint * (2*k/N-1)
590 hyper.drawHorocycle(idealPoint,point,"red")
591 -- and an orthogonal geodesic :
592 local endPoint = complex.exp_i(theta+2*k*math.pi/N)
593 hyper.drawLine(idealPoint,endPoint,"gray")
594 end
595 hyper.tikzEnd()
596 \end{luacode*}
597 \end{codeandresult}
598
599 \subsubsection{Hypercycles}
600 \index{drawHypercycleThrough}
601 \begin{codeandresult}
602 \begin{luacode*}
603 hyper.tikzBegin()
604 local A = 1
605 local B = complex.J
606 hyper.drawLine(A,B,"very thick, teal")
607 local N = 10
608 for k=1,N-1 do
609 local P = (2*k/N-1)*(-B^2)
610 hyper.drawHypercycleThrough(P, A, B, "red")
611 end
612 hyper.tikzEnd()
613 \end{luacode*}
614 \end{codeandresult}
615
616
617 \subsection{Printing custom strings to TikZ}
618
619 In case you want to insert custom TikZ instructions into the TikZ picture, the library provides a \texttt{tikzPintf()} function, which is essentially \texttt{tex.print} composed with \texttt{string.format()}, but also saves the printed string to the tikz buffer.
620
621 \index{tikzPrintf}\index[fields]{complex!ONE}
622 \begin{codeandresult}
623 \begin{luacode*}
624 local A = complex.ONE
625 local B = complex.I
626 local C = (-A-B)/2
627 hyper.tikzBegin()
628 hyper.tikzPrintf(
629 "\\draw[%s] (%f,%f) -- (%f,%f) ;",
630 "red, thick, dashed", A.re, A.im, B.re, B.im
631 )
632 hyper.tikzPrintf(
633 "\\draw[%s] (%f,%f) rectangle (%f,%f) ;",
634 "blue, thick", C.re, C.im, 0.8,0.7
635 )
636 hyper.tikzEnd()
637 \end{luacode*}
638 \end{codeandresult}
639
640 The package doesn't expose euclidean drawing functions.
641 Users should write TikZ directly in the picture as above with \texttt{tikzPrintf}, or use some other library, for example the amazing library \texttt{tkz-euclide}.
642
643
644 \subsection{Modifying default styles}
645
646 The drawing default styles are defined in lua constants that the user can modify. Keys and default values include:
647 \begin{lstlisting}[language=Lua]
648 hyper.LABEL_STYLE = "above left"
649 hyper.DRAW_POINT_RADIUS = 0.02
650 hyper.DRAW_POINT_STYLE = "white, draw=black"
651 hyper.BOUNDARY_CIRCLE_STYLE = "very thick, black"
652 \end{lstlisting}
653
654 For a complete list, see the source file \verb+luahyperbolic-tikz.lua+
655
656 \section{Defining points}
657
658 \subsection{Random points with uniform density}
659
660 \index{randomPoint}
661 \begin{codeandresult}
662 \begin{luacode*}
663 local rMin, rMax = .3, .8
664 hyper.tikzBegin()
665 for k=1,100 do
666 local M = hyper.randomPoint(rMin,rMax)
667 hyper.drawPoint(M)
668 end
669 hyper.tikzPrintf("\\draw[dashed] (0,0) circle (%s) ;", rMin)
670 hyper.tikzPrintf("\\draw[dashed] (0,0) circle (%s) ;", rMax)
671 hyper.tikzEnd()
672 \end{luacode*}
673 \end{codeandresult}
674
675 \subsection{Endpoints, midpoint, interpolate}
676
677
678
679 \subsubsection{Endpoints}
680 \index{endpoints}
681 \begin{codeandresult}
682 \begin{luacode*}
683 local A = complex(.4,.5)
684 local B = complex(-.5,0)
685 local AA, BB = hyper.endpoints(A,B)
686 hyper.tikzBegin()
687 hyper.drawSegment(A,B, "very thick, teal")
688 hyper.drawSegments(AA,A, B, BB, "dashed, red")
689 hyper.labelPoints(A, "$A$", B, "$B$")
690 hyper.labelPoint(AA, "$A'$", "red, below")
691 hyper.labelPoint(BB, "$B'$", "red, below right")
692 hyper.drawPoints(A, B)
693 hyper.drawPoints(AA,BB,"white, draw=red")
694 hyper.tikzEnd()
695 \end{luacode*}
696 \end{codeandresult}
697
698 \subsubsection{Midpoint}
699 \index{midpoint}
700 \begin{codeandresult}
701 \begin{luacode*}
702 local A = complex(0.4,0.6)
703 local B = complex(-0.8,-0.3)
704 local M = hyper.midpoint(A,B)
705 hyper.tikzBegin()
706 hyper.drawSegment(A,B, "very thick, teal")
707 hyper.drawPoints(A, B, M)
708 hyper.labelPoints(A, "$A$", B, "$B$")
709 hyper.labelPoint(M, "$M$", "below right, red")
710 local marking = "\\textcolor{red}{||}"
711 hyper.markSegment(A,M,marking)
712 hyper.markSegment(M,B,marking)
713 hyper.tikzEnd()
714 \end{luacode*}
715 \end{codeandresult}
716
717 \subsubsection{Interpolate and barycenter}
718 \index{interpolate}
719 \begin{codeandresult}
720 \begin{luacode*}
721 local A = complex(0.3,0.8)
722 local B = complex(-0.6,-0.3)
723 local P1 = hyper.interpolate(A, B, 1/3)
724 local P2 = hyper.interpolate(A, B, 2/3)
725 hyper.tikzBegin()
726 hyper.drawSegment(A,B, "thick, teal")
727 hyper.labelPoints(A, "$A$", B, "$B$")
728 hyper.markSegments(A, P1, P1, P2, P2, B, "||")
729 hyper.drawPoints(A, B, P1, P2)
730 hyper.tikzEnd()
731 \end{luacode*}
732 \end{codeandresult}
733
734 \subsection{Intersections}
735
736 \subsubsection{Line-Line (LL) intersection}
737 \index{interLL}
738 \begin{codeandresult}
739 \begin{luacode*}
740 local A = complex(0.4,0.3)
741 local B = complex(-0.4,-0.7)
742 local C = complex(0,0.7)
743 local D = complex(0.8,-0.4)
744 local P = hyper.interLL(A, B, C, D)
745 hyper.tikzBegin()
746 hyper.drawLines(A, B, C, D, "thick, teal")
747 hyper.drawPoints(A, B, C, D,"thick, teal")
748 hyper.drawPoint(P,"white, draw=red")
749 hyper.labelPoint(A, "$A$", "above")
750 hyper.labelPoint(B, "$B$")
751 hyper.labelPoint(C, "$C$", "left")
752 hyper.labelPoint(D, "$D$", "above")
753 hyper.labelPoint(P, "$P$", "left=.1cm, red")
754 hyper.tikzEnd()
755 \end{luacode*}
756 \end{codeandresult}
757
758
759
760 \subsubsection{Line-circle (LC) intersection}
761 \index{interLC}
762 \begin{codeandresult}
763 \begin{luacode*}
764 local A = complex(0.5,0.4)
765 local B = complex(-0.3,-0.7)
766 local O = complex(-0.4,0.2)
767 local radius = 1.5
768 local P, Q = hyper.interLC(A, B, O, radius)
769 hyper.tikzBegin()
770 hyper.drawLine(A, B, "teal")
771 hyper.drawCircle(O,radius, "teal")
772 hyper.drawSegments(O, P, O, Q, "red, dashed")
773 hyper.drawPoints(A, B, O, "teal")
774 hyper.drawPoints(P, Q, "white, draw=red")
775 hyper.labelPoints(A, "$A$", B, "$B$", O, "$O$")
776 hyper.labelPoints(P, "$P$", Q, "$Q$", "red, below right")
777 local mark = "\\textcolor{red}{||}"
778 hyper.markSegments(O, P, O, Q, mark)
779 hyper.tikzEnd()
780 \end{luacode*}
781 \end{codeandresult}
782
783 \subsubsection{Circle-circle (CC) intersection}
784 \index{interCC}
785 \begin{codeandresult}
786 \begin{luacode*}
787 local A = complex(-0.5,-.3)
788 local B = complex(0.3,0)
789 local r = hyper.distance(A, B)
790 local P, Q = hyper.interCC(A, r, B, r)
791 hyper.tikzBegin()
792 hyper.drawCircle(A, r, "teal")
793 hyper.drawCircle(B, r, "teal")
794 hyper.drawPolygon(A, B, P, "dashed, red")
795 hyper.drawPoints(P, Q, "white, draw=red")
796 hyper.drawPoints(A, B, "teal")
797 hyper.labelPoints(A, "$A$", B, "$B$", "below, teal")
798 hyper.labelPoints(P, "$P$", "above left, red")
799 hyper.labelPoint(Q, "$Q$", "red, below")
800 local mark = "\\textcolor{red}{||}"
801 hyper.markSegments(A, B, B, P, P, A, mark)
802 hyper.tikzEnd()
803 \end{luacode*}
804 \end{codeandresult}
805
806
807
808 \subsection{Reflections and projections}
809
810
811 \subsubsection{Reflection across a geodesic line}
812 \index{reflection}\index{drawRightAngle}
813 \begin{codeandresult}
814 \begin{luacode*}
815 local A = complex(0.8,0.2)
816 local B = complex(-0.3,0.5)
817 local M = complex(0.3,-0.6)
818 local Mp = (hyper.reflection(A,B))(M)
819 hyper.tikzBegin()
820 hyper.drawLine(A, B, "thick, teal")
821 hyper.drawPoints(A, B, M)
822 hyper.drawPoint(Mp,"red")
823 hyper.drawSegment(M,Mp,"dashed,red")
824 hyper.labelPoint(Mp,"$M'$", "left, red")
825 local P = hyper.interLL(A, B, M, Mp)
826 local mark="\\textcolor{red}{||}"
827 hyper.labelPoints(A, "$A$", B, "$B$", M, "$M$", "below")
828 hyper.markSegments(M, P, P, Mp, mark)
829 hyper.drawRightAngle(M, P, A, "red")
830 hyper.tikzEnd()
831 \end{luacode*}
832 \end{codeandresult}
833
834 \subsubsection{Projection onto a geodesic line}
835 \index{projection}
836 \begin{codeandresult}
837 \begin{luacode*}
838 local A = complex(0.8,0.2)
839 local B = complex(-0.3,0.5)
840 local M = complex(0.3,-0.6)
841 local P = (hyper.projection(A,B))(M)
842 hyper.tikzBegin()
843 hyper.drawLine(A, B, "thick, teal")
844 hyper.drawPoints(A, B, M)
845 hyper.drawPoint(P,"white, draw=red")
846 hyper.drawSegment(M,P,"dashed,red")
847 hyper.labelPoint(P,"$P$", "above, red")
848 hyper.labelPoints(A, "$A$", B, "$B$", M, "$M$", "below")
849 hyper.drawRightAngle(M,P,A,"red")
850 hyper.tikzEnd()
851 \end{luacode*}
852 \end{codeandresult}
853
854 \subsection{Exponential map}
855 \subsubsection{Image of a vector by exponentiel map at a point}
856
857 \index{expMap}
858 \begin{codeandresult}
859 \begin{luacode*}
860 local P = complex(-.2,-0.3)
861 local vect = complex.exp_i(math.pi/4)
862 hyper.tikzBegin()
863 hyper.drawRayFromVector(P, vect, "gray")
864 for k=1,5 do
865 local A = hyper.expMap(P,k*vect)
866 hyper.drawPoint(A, "white, draw=red")
867 end
868 hyper.drawPoint(P)
869 hyper.labelPoint(P,"$P$")
870 hyper.drawVector(P,vect, "red")
871 hyper.tikzEnd()
872 \end{luacode*}
873 \end{codeandresult}
874
875
876 \subsection{Automorphisms (direct isometries)}
877
878
879 \subsubsection{(Elliptic) Rotation by $60^\circ$}
880 \index{rotation}
881 \begin{codeandresult}
882 \begin{luacode*}
883 local O = complex(0.3,0.3)
884 local r = hyper.rotation(O,math.pi/3)
885 local points = {0, -.8, complex.J/2, -complex.I/2, complex(-.5,-.3), complex(.7,.3)}
886 hyper.tikzBegin()
887 for _,P in ipairs(points) do
888 local rP = r(P)
889 hyper.drawCircleThrough(O,P, "gray!10")
890 hyper.drawArc(O,P,rP,"->, red, thick")
891 hyper.drawPolyline(P,O,rP, "red!10")
892 hyper.drawPoint(P)
893 end
894 hyper.drawPoint(O,"black")
895 hyper.tikzEnd()
896 \end{luacode*}
897 \end{codeandresult}
898
899 \subsubsection{Symmetry around a point (rotation by $180^\circ$)}
900 \index{symmetry}
901 \begin{codeandresult}
902 \begin{luacode*}
903 local O = complex(0.2,0.2)
904 local s = hyper.symmetry(O)
905 local points={complex(-.8,.1), complex(.6,0), complex(0,-.5)}
906 hyper.tikzBegin()
907 for k, P in ipairs(points) do
908 hyper.drawCircleThrough(O, P, "gray!10")
909 local sP = s(P)
910 hyper.drawSegment(P,sP, "red, dashed")
911 hyper.drawPoints(P,sP)
912 hyper.labelPoint(P, "$P_{".. k .."}$")
913 hyper.labelPoint(sP, "$\\sigma(P_{".. k .."})$")
914 end
915 hyper.drawPoint(O)
916 hyper.tikzEnd()
917 \end{luacode*}
918 \end{codeandresult}
919
920
921 \subsubsection{Hyperbolic automorphims}
922 \index{automorphism}
923 \begin{codeandresult}
924 \begin{luacode*}
925 local A = complex(0.4,0.3)
926 local phi = hyper.automorphism(A,0)
927 local N=6
928 hyper.tikzBegin()
929 style1 = "dotted, red!50"
930 style2 = "thick, red"
931 for k=1,N do
932 local P = complex.polar(k/N, k*math.pi/N)
933 local Q = phi(P)
934 hyper.drawLine(0,P,style1)
935 hyper.drawLine(-A,Q,style2)
936 if k < N then
937 hyper.drawCircleThrough(0,P, style1)
938 hyper.drawCircleThrough(-A,Q,style2)
939 end
940 end
941 hyper.tikzEnd()
942 \end{luacode*}
943 \end{codeandresult}
944
945
946 \subsection{Orbits under automorphisms}
947
948
949 \subsubsection{Orbit under elliptic automorphism (rotation)}
950 \index{drawPointOrbit}
951 \begin{codeandresult}
952 \begin{luacode*}
953 local nbIterations = 10
954 local O = complex(0.1,0.2)
955 local points = {0, -.8, complex.J/2, -complex.I/2, complex(-.5,-.3), complex(.7,.3)}
956 local rot = hyper.rotation(O,math.pi/30) -- angle in radians
957 hyper.tikzBegin()
958 hyper.drawPoint(O,"red")
959 for _,P in ipairs(points) do
960 hyper.drawCircleThrough(O,P,"draw opacity=0.2")
961 hyper.drawPointOrbit(P, rot, nbIterations)
962 end
963 hyper.tikzEnd()
964 \end{luacode*}
965 \end{codeandresult}
966
967
968 \subsubsection{Orbit under hyperbolic automorphism}
969 \begin{codeandresult}
970 \begin{luacode*}
971 local points = {0, -.8, complex.J/2, -complex.I/2, complex(-.5,-.3), complex(.7,.3)}
972 local nbIterations = 10
973 local A = complex(0.05,0.05)
974 local phi = hyper.automorphism(A,0)
975 local X, Y = hyper.endpoints(A,0)
976 hyper.tikzBegin()
977 hyper.drawLine(A,0,"red!50")
978 for _,P in ipairs(points) do
979 hyper.drawHypercycleThrough(P,X,Y,"gray")
980 hyper.drawPointOrbit(P, phi, nbIterations)
981 end
982 hyper.drawPoint(A,"red")
983 hyper.labelPoint(A,"$A$", "above left, red")
984 hyper.drawPointOrbit(A, phi, nbIterations, "red")
985 hyper.tikzEnd()
986 \end{luacode*}
987 \end{codeandresult}
988
989
990 \subsubsection{Orbit under parabolic automorphism}
991 \index{parabolic}
992 \begin{codeandresult}
993 \begin{luacode*}
994 local nbIterations = 10
995 local limit = complex.exp_i(math.pi/3) -- on circle
996 local phi = hyper.parabolic(limit,math.pi/30)
997 local points={
998 complex(0,0), complex(0,.7),
999 complex(.4,.4), complex(.3,.7),
1000 complex(-.8,.4), complex(-.4,0),
1001 complex(.4,-.45)}
1002 hyper.tikzBegin()
1003 for _,P in ipairs(points) do
1004 hyper.drawPointOrbit(P, phi, nbIterations)
1005 hyper.drawHorocycle(limit, P, "red, draw opacity=.3")
1006 end
1007 hyper.tikzEnd()
1008 \end{luacode*}
1009 \end{codeandresult}
1010
1011
1012 \subsection{Triangle geometry (CAUTION)}
1013
1014 \subsubsection{Centroid (intersection of medians)}
1015 \index{triangleCentroid}
1016 \begin{codeandresult}
1017 \begin{luacode*}
1018 hyper.tikzBegin()
1019 local A = complex(0.1,0.8)
1020 local B = complex(-0.7,-0.3)
1021 local C = complex(0.6,-0.2)
1022 local AA = hyper.midpoint(B,C)
1023 local BB = hyper.midpoint(C,A)
1024 local CC = hyper.midpoint(A,B)
1025 local G = hyper.triangleCentroid(A,B,C)
1026 hyper.drawTriangle(A,B,C)
1027 hyper.drawSegments(A, AA, B, BB, C, CC, "teal")
1028 hyper.drawPoints(AA,BB,CC)
1029 hyper.drawPoint(G,"white, draw=teal")
1030 -- CAUTION :
1031 local wrong = hyper.interpolate(A,AA,2/3)
1032 hyper.drawPoint(wrong, "red")
1033 hyper.tikzEnd()
1034 \end{luacode*}
1035 \end{codeandresult}
1036
1037
1038 \subsubsection{Incenter and incircle}
1039 \index{triangleIncenter}\index{drawIncircle}
1040 \begin{codeandresult}
1041 \begin{luacode*}
1042 hyper.tikzBegin()
1043 local A = complex(0.1,0.8)
1044 local B = complex(-0.7,-0.3)
1045 local C = complex(0.6,-0.2)
1046 local I = hyper.triangleIncenter(A,B,C)
1047 hyper.drawTriangle(A,B,C,"teal")
1048 hyper.drawPoint(I,"white, draw=red")
1049 hyper.labelPoint(I,"$I$", "below left")
1050 hyper.drawIncircle(A,B,C,"red")
1051 -- show intersection :
1052 local mystyle = "dashed, red!50"
1053 hyper.drawAngleBisector(A,B, C, mystyle)
1054 hyper.drawAngleBisector(B,C,A, mystyle)
1055 hyper.drawAngleBisector(C,A,B, mystyle)
1056 hyper.tikzEnd()
1057 \end{luacode*}
1058 \end{codeandresult}
1059
1060 \subsubsection{Circumcenter and circumcircle (CAUTION : does not always exist)}
1061 \index{triangleCircumcenter}\index{drawCircumcircle}
1062 \begin{codeandresult}
1063 \begin{luacode*}
1064 local A = complex(0.1,0.8)
1065 local B = complex(-0.6,-0.5)
1066 local C = complex(0.6,-0.2)
1067 local O = hyper.triangleCircumcenter(A,B,C)
1068 local BC = hyper.midpoint(B,C)
1069 local CA = hyper.midpoint(C,A)
1070 local AB = hyper.midpoint(A,B)
1071 hyper.tikzBegin()
1072 local mystyle = "dashed, red!50"
1073 hyper.drawTriangle(A,B,C,"teal")
1074 hyper.drawPerpendicularBisector(A, B, mystyle)
1075 hyper.drawPerpendicularBisector(B, C, mystyle)
1076 hyper.drawPerpendicularBisector(C, A, mystyle)
1077 hyper.drawCircumcircle(A,B,C,"red")
1078 hyper.labelPoint(O,"$O$", "below left")
1079 hyper.drawRightAngle(O, CA, C,"red",1/8)
1080 hyper.drawRightAngle(O,BC,B,"red",1/8)
1081 hyper.drawPoints(O,A,B,C,AB,BC,CA)
1082 hyper.labelPoints(A, "$A$", B, "$B$", C, "$C$","above")
1083 hyper.tikzEnd()
1084 \end{luacode*}
1085 \end{codeandresult}
1086
1087
1088 \subsubsection{Orthocenter (CAUTION : does not always exist)}
1089 \index{triangleOrthocenter}\index{drawPerpendicularThrough}
1090 \begin{codeandresult}
1091 \begin{luacode*}
1092 local A = complex(0.1,0.8)
1093 local B = complex(-0.7,-0.4)
1094 local C = complex(0.6,-0.2)
1095 local H = hyper.triangleOrthocenter(A,B,C)
1096 local AA = hyper.projection(B,C)(A)
1097 local BB = hyper.projection(C,A)(B)
1098 local CC = hyper.projection(A,B)(C)
1099
1100 hyper.tikzBegin()
1101 local mystyle = "dashed, red!50"
1102 local style2 = "very thick, red"
1103 hyper.drawTriangle(A,B,C,"teal")
1104 hyper.drawPerpendicularThrough(A,B,C,mystyle)
1105 hyper.drawPerpendicularThrough(B,C,A,mystyle)
1106 hyper.drawPerpendicularThrough(C,A,B,mystyle)
1107 hyper.drawRightAngle(A,AA,B,style2,1/15)
1108 hyper.drawRightAngle(B,BB,C,style2,1/8)
1109 hyper.drawRightAngle(C,CC,A,style2,1/12)
1110 hyper.labelPoints(A, "$A$", B, "$B$", C, "$C$")
1111 hyper.drawPoints(AA,BB,CC,H,"above")
1112 hyper.tikzEnd()
1113 \end{luacode*}
1114 \end{codeandresult}
1115
1116
1117
1118 \newpage
1119
1120 \section{Tilings}
1121
1122 \subsection{Draw Tilings}
1123
1124 \subsubsection{Triangle tiling (almost) by hand}
1125 \index{propagateGeodesics}\index{drawLinesFromTable}
1126 \begin{codeandresult}
1127 \begin{luacode*}
1128 local PI = math.pi
1129 local A, B, C = hyper.triangleWithAngles(PI/2, PI/4, PI/5)
1130 local geodesics = {
1131 {hyper.endpoints(A,B)},
1132 {hyper.endpoints(B,C)},
1133 {hyper.endpoints(C,A)}
1134 }
1135 geodesics = hyper.propagateGeodesics(geodesics, 12) -- depth = 12
1136 hyper.tikzBegin()
1137 hyper.drawLinesFromTable(geodesics, "green!50!black, draw opacity=.5")
1138 hyper.drawTriangle(A,B,C,"red, very thick")
1139 hyper.tikzEnd()
1140 \end{luacode*}
1141 \end{codeandresult}
1142
1143 \subsubsection{Triangle tiling with less code}
1144 \index{drawTilingFromTriangle}
1145 \begin{codeandresult}
1146 \begin{luacode*}
1147 local PI = math.pi
1148 local DEPTH = 12
1149 local A, B, C = hyper.triangleWithAngles(PI/2,PI/3,0)
1150 hyper.tikzBegin()
1151 hyper.drawTilingFromTriangle(A, B, C, DEPTH, "teal, draw opacity=.5")
1152 hyper.drawTriangle(A,B,C,"red, very thick")
1153 hyper.tikzEnd()
1154 \end{luacode*}
1155 \end{codeandresult}
1156
1157
1158 \subsubsection{Triangle tiling with even less code}
1159 \index{drawTilingFromAngles}
1160 \begin{codeandresult}
1161 \begin{luacode*}
1162 local PI = math.pi
1163 hyper.tikzBegin()
1164 hyper.drawTilingFromAngles(PI/3,PI/5,PI/7,12)
1165 hyper.tikzEnd()
1166 \end{luacode*}
1167 \end{codeandresult}
1168
1169
1170 \subsection{Fill tilings}
1171
1172 \subsubsection{The 3--4--5 triangle tiling}
1173 \index{fillTilingFromTriangle}
1174 \begin{codeandresult}
1175 \begin{luacode*}
1176 local PI = math.pi
1177 local DEPTH = 10
1178 local A, B, C = hyper.triangleWithAngles(PI/3, PI/4, PI/5)
1179 hyper.tikzBegin()
1180 hyper.fillTilingFromTriangle(A, B, C, DEPTH)
1181 -- default color is black
1182 hyper.drawPolygon(A, B, C, "thick, red")
1183 hyper.tikzEnd()
1184 \end{luacode*}
1185 \end{codeandresult}
1186
1187 \subsubsection{Same 3--4--5 tiling centered on point $B$}
1188 \begin{codeandresult}
1189 \begin{luacode*}
1190 local PI = math.pi
1191 local DEPTH = 10
1192 local A, B, C = hyper.triangleWithAngles(PI/3, PI/4, PI/5)
1193 local phi = hyper.automorphism(B)
1194 A, B, C = phi(A), phi(B), phi(C) -- put B in the center
1195 hyper.tikzBegin()
1196 hyper.fillTilingFromTriangle(A, B, C, DEPTH, "fill opacity=.2, teal!80!black, draw=black")
1197 hyper.drawPolygon(A, B, C, "thick, red")
1198 hyper.tikzEnd()
1199 \end{luacode*}
1200 \end{codeandresult}
1201
1202 \subsubsection{Same 3--4--5 tiling centered on point $C$}
1203 \begin{codeandresult}
1204 \begin{luacode*}
1205 local PI = math.pi
1206 local DEPTH = 10
1207 local A, B, C = hyper.triangleWithAngles(PI/3, PI/4, PI/5)
1208 local phi = hyper.automorphism(C)
1209 A, B, C = phi(A), phi(B), phi(C) -- put C in the center
1210 hyper.tikzBegin()
1211 hyper.tikzPrintf("\\fill[orange!30] (0,0) circle (1);")
1212 hyper.fillTilingFromTriangle(A, B, C, DEPTH, "teal")
1213 hyper.drawPolygon(A, B, C, "thick, red")
1214 hyper.tikzEnd()
1215 \end{luacode*}
1216 \end{codeandresult}
1217
1218 \subsection{Tilings without any Lua code}
1219
1220 The package provides a TeX macro for users who want to completely avoid Lua.
1221 \bigskip
1222
1223 \noindent
1224 \hyperbolicTiling{3}{4}{5}[scale=4]\hfill
1225 \hyperbolicTiling{3}{3}{4}[scale=4,depth=12]
1226 \\
1227 \hyperbolicTiling{2}{3}{7}[scale=2.5, color=teal, depth=16]\hfill
1228 \hyperbolicTiling{2}{5}{9}[scale=2.5, depth=8, color=gray]\hfill
1229 \hyperbolicTiling{4}{4}{4}[scale=2.5, depth=6, color=purple,backgroundcolor=pink!30]
1230 \\
1231 \hyperbolicTiling{2}{5}{inf}[scale=2, depth=6, color=brown]\hfill
1232 \hyperbolicTiling{2}{inf}{inf}[scale=2, depth=6, color=olive]\hfill
1233 \hyperbolicTiling{3}{inf}{inf}[scale=2, depth=6, color=orange]\hfill
1234 \hyperbolicTiling{inf}{inf}{inf}[scale=2, depth=5, color=violet]
1235
1236 The syntax is \verb+\hyperbolicTiling{p}{q}{r}[options]+ with $p, q, r$ positive integers or \texttt{inf} satisfying $\frac1p + \frac1q+\frac1r < 1$. The associated hyperbolic triangle has angles $\frac{\pi}{p}$, $\frac{\pi}{q}$, and $\frac{\pi}{r}$.
1237
1238 The above tilings were obtained with the following commands:
1239 \begin{verbatim}
1240 \hyperbolicTiling{3}{4}{5}[scale=4]
1241 \hyperbolicTiling{3}{3}{4}[scale=4,depth=12]
1242 \hyperbolicTiling{2}{3}{7}[scale=2.5, color=teal, depth=16]
1243 \hyperbolicTiling{2}{5}{9}[scale=2.5, color=gray]
1244 \hyperbolicTiling{4}{4}{4}[scale=2.5, depth=6, color=purple,backgroundcolor=pink!30]
1245 \hyperbolicTiling{2}{5}{inf}[scale=2, depth=6, color=brown]
1246 \hyperbolicTiling{2}{inf}{inf}[scale=2, depth=6, color=olive]
1247 \hyperbolicTiling{3}{inf}{inf}[scale=2, depth=6, color=orange]
1248 \hyperbolicTiling{inf}{inf}{inf}[scale=2, depth=5, color=violet]
1249 \end{verbatim}
1250 Default values are : scale=3, depth=8, color=black, backgroundcolor=white.
1251 \newpage
1252 \section{Overview of the lua libraries}
1253
1254 The Lua files are in the \verb+lua/+ subdirectory of the repo.
1255
1256 To build the \verb+luahyperbolic.sty+ from the lua source files, run \verb+lua build.lua+ on the \verb+lua/+ directory. (Lua must be installed.)
1257
1258 The Lua source files are not needed to compile a latex document using luahyperbolic, only the sty file is necessary.
1259
1260 \begin{luacode*}
1261 -- Print all entries of a given type in a module
1262 function print_module_type(module, wanted_type, sep)
1263 sep = sep or ", "
1264 local names = {}
1265 for k, v in pairs(module) do
1266 if type(v) == wanted_type then
1267 table.insert(names, k)
1268 end
1269 end
1270 table.sort(names)
1271 for i, name in ipairs(names) do
1272 tex.sprint(-2, name)
1273 tex.sprint(sep)
1274 end
1275
1276 end
1277 \end{luacode*}
1278
1279 \subsection{complex.lua}
1280 \subsubsection*{Functions}
1281 \begin{multicols}{6}
1282 \noindent\directlua{print_module_type(complex, "function", "\\\\")}
1283 \end{multicols}
1284 \subsubsection*{Constants (numbers and complex numbers)}
1285 \directlua{print_module_type(complex, "number", ", ")}
1286 \directlua{print_module_type(complex, "table", ", ")}
1287
1288
1289
1290 \subsection{luahyperbolic}
1291
1292 The luahyperbolic library consists of three submodules : luahyperbolic-core, luahyperbolic-tikz and luahyperpolic-tilings. These three submodules are flattened in a single \texttt{hyper} global module. (The submodules are still available in three tables hyper.core, hyper.tikz and hyper.tilings if necessary.)
1293
1294 Functions beginning with underscore are available in the module but should not be needed for normal use. Don't use them, they could become private in the future and not be available to users anymore.
1295
1296 \subsubsection*{Functions}
1297 \begin{multicols}{3}
1298 \noindent\directlua{print_module_type(hyper, "function", "\\\\")}
1299 \end{multicols}
1300 \subsubsection*{Constants}
1301 \textbf{Numbers : }
1302 \directlua{print_module_type(hyper, "number", ", ")}
1303
1304 \textbf{Strings : }
1305 \directlua{print_module_type(hyper, "string", ", ")}
1306
1307 \textbf{Tables : }
1308 \directlua{print_module_type(hyper, "table", ", ")}
1309
1310 \section{Known bugs}
1311
1312 \begin{enumerate}
1313 \item Cannot use the TeX macro \verb+\hyperbolicTiling+ inside a \verb+begin{center}+ environment. Boxes and \verb+\centering+ don't work well either.
1314 \item This documentation sometimes errors during compilation with error \texttt{pgf : dimension too large} but a second compilation always succeeds.
1315 \end{enumerate}
1316
1317 \section{Index}
1318 \printindex
1319
1320 \end{document}