Debian Codegraph @

texmf-dist/doc/metapost/mp-gears/mp-gears-doc-en.tex

raw
1
2 % LTeX: language=en
3
4 % gears: draw intermeshing system of gears
5 %
6 % Originally written by Maxime Chupin <[email protected]>,
7 % 2026.
8 %
9 % Distributed under the terms of the GNU free documentation licence:
10 % http://www.gnu.org/licenses/fdl.html
11 % without any invariant section or cover text.
12
13 \documentclass[english]{ltxdoc}
14
15 \input{mp-gears-preamble.tex}
16
17 \usepackage[english]{babel}
18
19 \makeindex[title=Command Index, columns=2]
20
21
22
23 %\lstset{moredelim=*[s][\color{red}\rmfamily\itshape]{<}{>}}
24 %\lstset{moredelim=*[s][\color{blue}\rmfamily\itshape]{<<}{>>}}
25
26 \begin{document}
27
28 \title{{\mpgears}: drawing systems of intermeshing gears with \MP}
29 \author{Maxime Chupin, \url{[email protected]}}
30 \date{\gearsDate}
31
32 %% === Page de garde ===================================================
33 \thispagestyle{empty}
34 \begin{tikzpicture}[remember picture, overlay]
35 \node[below right, shift={(-4pt,4pt)}] at (current page.north west) {%
36 \includegraphics{fond.pdf}%
37 };
38 \end{tikzpicture}%
39
40 \noindent
41 {\Huge \mpgears}\par\bigskip
42 \noindent
43 {\Large drawing systems of intermeshing gears \\[0.2cm]with \hologo{METAPOST}}\\[1cm]
44 \parbox{0.6\textwidth}{
45 \begin{mplibcode}[mpgears]
46 input gears;
47 input geom2d-svgnames
48
49 beginfig(1);
50 setUnit(0.3cm);
51 (G[3],G[4]) = buildExternalGearPair(40,12,0.5,20,(0,0),0,20);
52 drawGear(G3,LightBlue,"clockwork");
53 drawGear(G4,PeachPuff,"classical");
54 endfig;
55 \end{mplibcode}%
56 }\hfill
57 \parbox{0.6\textwidth}{\Large\raggedleft
58 \textbf{Contributor}\\
59 Maxime \textsc{Chupin}\\
60 \url{[email protected]}
61 }
62 \vfill
63 \begin{center}
64 Version \gearsVersion, \gearsDate \\
65 \url{https://gitlab.gutenberg-asso.fr/mchupin/mp-gears}
66 \end{center}
67 %% == Page de garde ====================================================
68 \newpage
69
70 %\maketitle
71
72 \begin{abstract}
73 This \hologo{METAPOST} package allows to draw system of intermeshing gears.
74 \end{abstract}
75
76
77 \begin{center}
78 \url{https://gitlab.gutenberg-asso.fr/mchupin/mp-gears}
79 \end{center}
80
81 \tableofcontents
82
83
84
85 \bigskip
86
87 \begin{tcolorbox}[ arc=0pt,outer arc=0pt,
88 colback=darkred!3,
89 colframe=darkred,
90 breakable,
91 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
92 3pt, toptitle=3pt,
93 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
94 0pt, bottomrule at break = 0pt,]
95 \itshape
96 This package is in beta version---do not hesitate to report bugs, as well as requests for improvement.
97 \end{tcolorbox}
98
99 \section{Introduction}
100
101 This package therefore allows users to model various gears and gear systems (and
102 even spirographs). In what follows, we will assume that the reader is familiar
103 with key concepts in gear design, such as the base radius, pitch radius, module,
104 pressure angle, pitch, etc.
105
106 For further references, please
107 see~\cite{cuisinier,chevasson,chevalier,wikipedia_gear,zpag}.
108
109 There is the excellent \package{pst-gears} package~\cite{pst-gears} by Manuel
110 Luque and Hebert Voss, which served as a major source of inspiration for me.
111 However, I believe that \hologo{METAPOST}~\cite{metapost} is a language
112 particularly well-suited to the construction of gear systems and that it may
113 offer a bit more flexibility.
114
115 Because with \hologo{METAPOST}, we do not need to declare \typeMP{numeric}
116 variable, with \mpgears, we define parameters (in table) associated to un
117 \typeMP{numeric} identifier and then we manipulate the \emph{gear} object with
118 this \typeMP{numeric} identifier.
119
120 \begin{tcolorbox}[ arc=0pt,outer arc=0pt,
121 colback=darkred!3,
122 colframe=darkred,
123 breakable,
124 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
125 3pt, toptitle=3pt,
126 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
127 0pt, bottomrule at break = 0pt,]
128 \itshape
129 This package and its documentation are developed without any use of generative
130 artificial intelligence: noGIA.
131 \end{tcolorbox}
132
133
134 \section{Installation}
135
136 \mpgears is on \ctan{} and can also be installed via the package manager of your
137 distribution.
138
139 \begin{center}
140 \url{https://www.ctan.org/pkg/mp-gears}
141 \end{center}
142
143
144 \subsection{With \TeX live under Linux or macOS}
145
146 To install \mpgears with \TeX Live, you will have to create the directory
147 \lstinline+texmf+ in your \lstinline+home+.
148
149 \begin{commandshell}
150 mkdir ~/texmf
151 \end{commandshell}
152
153 Then, you will have to place the \lstinline+gears.mp+ files in
154 \begin{center}
155 \lstinline+~/texmf/metapost/mp-gears/+
156 \end{center}
157
158
159 Once this is done, \mpgears will be loaded with the classic \MP{}
160 input code
161 \begin{mpcode}
162 input gears
163 \end{mpcode}
164
165 \subsection{With Mik\TeX{} and Windows}
166
167 These two systems are unknown to the author of \mpgears, so we
168 refer you to the Mik\TeX documentation concerning the addition of local packages:
169 \begin{center}
170 \url{http://docs.miktex.org/manual/localadditions.html}
171 \end{center}
172
173 \section{Building Gears}
174
175 In this section, we present the building macros. These macros define the
176 parameters of the gears, and return \emph{identifiers} to which the parameters
177 are attached. Hence, these functions do not produce any drawing. However, in
178 order to help the readers to understand, we will use \emph{drawing macros}
179 without presenting them. For details about them, see section~\ref{sec:drawing}.
180 \subsection{External Gears}
181
182 The first command is for building one gear. \mpgears offer three kinds of gear,
183 \emph{external}, \emph{internal} and \emph{rack}. We start with the first case,
184 more classical. For the second kind, see sectio~\ref{sec:internal}, and the
185 third case is described in section~\ref{sec:rack}.
186
187 \begin{colourband}
188 \commande|buildExternalGear(«Z1»,«m»,«a»,«c», «r»)|\return{\typeMP{numeric}}\smallskip\index{buildExternalGear@\lstinline+buildExternalGear+}
189 \begin{description}
190 \item[\meta{Z1}:] \typeMP{numeric} number of teeth of the gear.
191 \item[\meta{m}:] \typeMP{numeric} module of the gear.
192 \item[\meta{a}:] \typeMP{numeric} pressure angle.
193 \item[\meta{c}:] \typeMP{pair} center of the gear.
194 \item[\meta{r}:] \typeMP{numeric} angle of rotation of the gear.
195 \end{description}
196 \end{colourband}
197
198 Here, a simple example.
199 \begin{ExempleMP}
200 input gears
201
202 beginfig(1);
203 A = buildExternalGear(16,0.5,20,(0,0),0);
204 drawGear(A,(0.7,0.3,0.3),"classical");
205 endfig;
206 \end{ExempleMP}
207
208
209 The next command is maybe more useful because it builds two enmeshed gears.
210
211 \begin{colourband}
212 \commande|buildExternalGearPair(«Z1»,«Z2»,«m»,«a»,«c», «r», «ar»)|\return{\typeMP{pair}}\smallskip\index{buildExternalGearPair@\lstinline+buildExternalGearPair+}
213
214 This function builds two intermeshed gears and give a \typeMP{pair} of
215 identifiers.
216 \begin{description}
217 \item[\meta{Z1}:] \typeMP{numeric} number of teeth of the first gear.
218 \item[\meta{Z2}:] \typeMP{numeric} number of teeth of the second gear.
219 \item[\meta{m}:] \typeMP{numeric} module of the system.
220 \item[\meta{a}:] \typeMP{numeric} pressure angle.
221 \item[\meta{c}:] \typeMP{pair} center of the first gear.
222 \item[\meta{r}:] \typeMP{numeric} angle of rotation of the first gear.
223 The second gear will be rotated with the corresponded linked angle.
224 \item[\meta{ar}:] \typeMP{numeric} angle of rotation of the center
225 of the second gear around the center of the first gear.
226 \end{description}
227 \end{colourband}
228
229 Here, a simple example.
230 \begin{ExempleMP}
231 input gears
232
233 beginfig(1);
234 (A1,A2) = buildExternalGearPair(16,10,0.5,20,(0,0),30,45);
235 drawGear(A1,(0.7,0.3,0.3),"classical");
236 drawGear(A2,(0.3,0.7,0.3),"classical");
237 endfig;
238 \end{ExempleMP}
239
240 You can also create a gear that needs to mesh with an existing one. To do this,
241 use the following macro. This macro also works if the existing gear is an
242 internal one (see section~\ref{sec:internal}).
243
244 \begin{colourband}
245 \commande|buildExternalGearFor(«id»,«Z2»,«ar»)|\return{\typeMP{numeric}}\smallskip\index{buildExternalGearFor@\lstinline+buildExternalGearFor+}
246 \begin{description}
247 \item[\meta{id}:] \typeMP{numeric} identifier to the existing gear.
248 \item[\meta{Z2}:] \typeMP{numeric} number of teeth of the new gear.
249 \item[\meta{ar}:] \typeMP{numeric} angle of rotation of the center
250 of the new gear around the center of the existing gear.
251 \end{description}
252 \end{colourband}
253
254 Here, a simple example.
255 \begin{ExempleMP}
256 input gears
257
258 beginfig(1);
259 (A1,A2) = buildExternalGearPair(16,10,0.5,20,(0,0),30,45);
260 A3 = buildExternalGearFor(A2,16,-20);
261 drawGear(A1,(0.7,0.3,0.3),"classical");
262 drawGear(A2,(0.3,0.7,0.3),"classical");
263 drawGear(A3,(0.3,0.3,0.7),"classical");
264 endfig;
265 \end{ExempleMP}
266
267 One can build an external gear compounded to another one in the sens that they
268 only
269 share the same center (axis of rotation) and the same angle of rotation.
270 \begin{colourband}
271 \commande|buildCompoundGear(«id»,«Za»,«m»,«a»)|\return{\typeMP{pair}}\smallskip\index{buildCompoundGear@\lstinline+buildCompoundGear+}
272
273 This function builds two intermeshed gears and give a \typeMP{pair} of
274 identifiers.
275 \begin{description}
276 \item[\meta{id}:] \typeMP{numeric} identifier to the existing gear.
277 \item[\meta{Za}:] \typeMP{numeric} number of teeth of the new gear.
278 \item[\meta{m}:] \typeMP{numeric} module of the new gear.
279 \item[\meta{a}:] \typeMP{numeric} pressure angle of the new gear.
280 \end{description}
281 \end{colourband}
282
283 Here, a simple example.
284 \begin{ExempleMP}
285 input gears
286
287 beginfig(1);
288 A1 = buildExternalGear(16,0.5,20,(0,0),30);
289 A2 = buildCompoundGear(A1,22,0.2,14);
290 drawGear(A1,(0.7,0.3,0.3),"classical");
291 drawGear(A2,(0.3,0.7,0.3),"classical");
292 endfig;
293 \end{ExempleMP}
294
295
296 \subsection{Internal Gears}\label{sec:internal}
297
298 The equivalent macros exist for internal gear. Fist, the simpler one to build
299 only one internal gear.
300
301 \begin{colourband}
302 \commande|buildInternalGear(«Z1»,«m»,«a»,«c», «r»)|\return{\typeMP{numeric}}\smallskip\index{buildInternalGear@\lstinline+buildInternalGear+}
303 \begin{description}
304 \item[\meta{Z1}:] \typeMP{numeric} number of teeth of the gear.
305 \item[\meta{m}:] \typeMP{numeric} module of the gear.
306 \item[\meta{a}:] \typeMP{numeric} pressure angle.
307 \item[\meta{c}:] \typeMP{pair} center of the gear.
308 \item[\meta{r}:] \typeMP{numeric} angle of rotation of the gear.
309 \end{description}
310 \end{colourband}
311
312 Here, a simple example.
313 \begin{ExempleMP}
314 input gears
315
316 beginfig(1);
317 A = buildInternalGear(16,0.5,20,(0,0),0);
318 drawGear(A,(0.7,0.3,0.3),"classical");
319 endfig;
320 \end{ExempleMP}
321
322
323
324
325 Of course, you cannot mesh two
326 internal gears. Hence, the following macro build two gears, the first is an
327 internal one, and the second an external one.
328
329 \begin{colourband}
330 \commande|buildInternalGearPair(«Z1»,«Z2»,«m»,«a»,«c», «r», «ar»)|\return{\typeMP{pair}}\smallskip\index{buildInternalGearPair@\lstinline+buildInternalGearPair+}
331
332 This function builds two intermeshed gears and give a \typeMP{pair} of
333 identifiers.
334 \begin{description}
335 \item[\meta{Z1}:] \typeMP{numeric} number of teeth of the first gear.
336 \item[\meta{Z2}:] \typeMP{numeric} number of teeth of the second gear.
337 \item[\meta{m}:] \typeMP{numeric} module of the system.
338 \item[\meta{a}:] \typeMP{numeric} pressure angle.
339 \item[\meta{c}:] \typeMP{pair} center of the first gear.
340 \item[\meta{r}:] \typeMP{numeric} angle of rotation of the first gear.
341 The second gear will be rotated with the corresponded linked angle.
342 \item[\meta{ar}:] \typeMP{numeric} angle of rotation of the center
343 of the second gear around the center of the first gear.
344 \end{description}
345 \end{colourband}
346
347 Here, a simple example.
348 \begin{ExempleMP}
349 input gears
350
351 beginfig(1);
352 (A1,A2) = buildInternalGearPair(26,8,0.5,20,(0,0),40,45);
353 drawGear(A1,(0.7,0.3,0.3),"classical");
354 drawGear(A2,(0.3,0.7,0.3),"classical");
355 endfig;
356 \end{ExempleMP}
357
358 We can also build a internal gear meshed to an existing external one.
359
360
361 \begin{colourband}
362 \commande|buildInternalGearFor(«id»,«Z2»,«ar»)|\return{\typeMP{numeric}}\smallskip\index{buildInternalGearFor@\lstinline+buildInternalGearFor+}
363 \begin{description}
364 \item[\meta{id}:] \typeMP{numeric} identifier to the existing gear.
365 \item[\meta{Z2}:] \typeMP{numeric} number of teeth of the new gear.
366 \item[\meta{ar}:] \typeMP{numeric} angle of rotation of the center
367 of the new gear around the center of the existing gear.
368 \end{description}
369 \end{colourband}
370
371 Here, a simple example.
372 \begin{ExempleMP}
373 input gears
374
375 beginfig(1);
376 A = buildExternalGear(8,0.5,20,(0,0),0);
377 B = buildInternalGearFor(A,16,-20);
378 drawGear(A,(0.7,0.3,0.3),"classical");
379 drawGear(B,(0.3,0.7,0.3),"classical");
380 endfig;
381 \end{ExempleMP}
382
383 \subsection{Rack}\label{sec:rack}
384
385 There exist another kind of gear: rack. It can be viewed as an external gear
386 with infinite radius. Because of the singularity, we use another type of object,
387 distinct from internal and external gear. However, macros related to racks are
388 quite similar to the ones for internal and external gears.
389
390 The rack is defined by default vertically.
391
392 \begin{colourband}
393 \commande|buildRack(«Z1»,«m»,«a»,«c»,«r»,«t»)|\return{\typeMP{numeric}}\smallskip\index{buildRack@\lstinline+buildRack+}
394 \begin{description}
395 \item[\meta{Z1}:] \typeMP{numeric} number of teeth of the rack. This should be
396 odd and if the user chooses an even number, 1 is added.
397 \item[\meta{m}:] \typeMP{numeric} module of the rack.
398 \item[\meta{a}:] \typeMP{numeric} pressure angle.
399 \item[\meta{c}:] \typeMP{pair} center of the rack on the equivalent of the
400 radius of an external gear (which becomes a line). It is on the middle of the
401 middle tooth.
402 \item[\meta{r}:] \typeMP{numeric} angle of rotation of the rack around the center.
403 \item[\meta{t}:] \typeMP{numeric} translation of the rack.
404 \end{description}
405 \end{colourband}
406
407 Here, a simple example.
408 \begin{ExempleMP}
409 input gears
410
411 beginfig(1);
412 A = buildRack(5,0.5,20,(0,0),0,0);
413 drawRack(A,(0.7,0.3,0.3));
414 endfig;
415 \end{ExempleMP}
416
417 We can only mesh a rack with an external gear. This is done by the following
418 macro.
419
420 \begin{colourband}
421 \commande|buildGearRackPair(«Z1»,«Z2»,«m»,«a»,«c», «r», «ar»)|\return{\typeMP{pair}}\smallskip\index{buildGearRackPair@\lstinline+buildGearRackPair+}
422
423 \begin{description}
424 \item[\meta{Z1}:] \typeMP{numeric} number of teeth of the gear.
425 \item[\meta{Z2}:] \typeMP{numeric} number of teeth of the rack.
426 \item[\meta{m}:] \typeMP{numeric} module of the system.
427 \item[\meta{a}:] \typeMP{numeric} pressure angle.
428 \item[\meta{c}:] \typeMP{pair} center of the gear.
429 \item[\meta{r}:] \typeMP{numeric} angle of rotation of the gear.
430 The rack will be \emph{translated} with the corresponded length.
431 \item[\meta{ar}:] \typeMP{numeric} angle of rotation of the center
432 of the rack around the center of the gear.
433 \end{description}
434 \end{colourband}
435
436 Here, a simple example.
437 \begin{ExempleMP}
438 input gears
439
440 beginfig(1);
441 (A1,A2) = buildGearRackPair(16,7,0.5,20,(0,0),12,45);
442 drawGear(A1,(0.7,0.3,0.3),"classical");
443 drawRack(A2,(0.3,0.7,0.3));
444 endfig;
445 \end{ExempleMP}
446
447 Like the other kinds of gear, we can define a rack meshed with an existing
448 external gear.
449
450 \begin{colourband}
451 \commande|buildRackFor(«id»,«Z2»,«ar»)|\return{\typeMP{numeric}}\smallskip\index{buildRackFor@\lstinline+buildRackFor+}
452 \begin{description}
453 \item[\meta{id}:] \typeMP{numeric} identifier to the existing gear.
454 \item[\meta{Z2}:] \typeMP{numeric} number of teeth of the rack.
455 \item[\meta{ar}:] \typeMP{numeric} angle of rotation of the center
456 of the rack around the center of the existing gear.
457 \end{description}
458 \end{colourband}
459
460
461 Here, a simple example.
462 \begin{ExempleMP}
463 input gears
464
465 beginfig(1);
466 (A1,A2) = buildGearRackPair(16,7,0.5,20,(0,0),12,45);
467 A3 = buildRackFor(A1,9,180+45);
468 drawGear(A1,(0.7,0.3,0.3),"classical");
469 drawRack(A2,(0.3,0.7,0.3));
470 drawRack(A3,(0.3,0.3,0.7));
471 endfig;
472 \end{ExempleMP}
473
474
475
476 \section{Drawing}\label{sec:drawing}
477
478 There is only one macro to draw a gear. Depending on the type of the gear, there
479 are several styles of drawing: three for external gear and one pour internal
480 gear.
481
482 \subsection{Unit}
483
484 Drawings produced with \mpgears use an unit for $x$ and $y$ axis of
485 \hologo{METAPOST}. The default value is \SI{0.5}{cm}. To get the unit, you can
486 use the following macra.
487 \begin{colourband}
488 \commande|getUnit|\return{\typeMP{numeric}}\smallskip\index{getUnit@\lstinline+getUnit+}
489 \end{colourband}
490
491 To change the value of the \mpgears unit, you can use the following macro.
492 \begin{colourband}
493 \commande|setUnit(«u»)|\smallskip\index{setUnit@\lstinline+setUnit+}
494 \begin{description}
495 \item[\meta{u}]: \typeMP{numeric} the new value for \mpgears unit.
496 \end{description}
497 \end{colourband}
498
499
500
501
502 \subsection{Gear and Rack}
503
504 \begin{colourband}
505 \commande|drawGear(«id»,«c»,«s»)|\smallskip\index{drawGear@\lstinline+drawGear+}
506 \begin{description}
507 \item[\meta{id}:] \typeMP{numeric} identifier to the existing gear.
508 \item[\meta{c}:] \typeMP{color} the color of the gear or \typeMP{string}
509 \lstinline+"None"+. In the last case, the gear is not colored.
510 \item[\meta{s}:] \typeMP{string} type of gear. \lstinline+"classical"+ for both
511 internal and external gear, and \lstinline+"clockwork"+ and
512 \lstinline+"spirograph"+ for external gear.
513 \end{description}
514 \end{colourband}
515
516 Because this macro produce a \typeMP{picture} and a code using the
517 \lstinline+draw+ \hologo{METAPOST} macro, it is possible to add any drawing
518 compatible \hologo{METAPOST} code at this end of it. For instance, because we
519 use \package{luamplib}~\cite{luamplib} for this documentation, we can the \pdf{}
520 transparency.
521
522 \begin{ExempleMP}
523 input gears
524
525 beginfig(1);
526 A = buildExternalGear(28,0.5,20,(0,0),0);
527 B = buildExternalGearFor(A,16,-20);
528 drawGear(A,(0.7,0.3,0.3),"clockwork") withtransparency(1,0.3);
529 drawGear(B,"None","classical");
530 endfig;
531 \end{ExempleMP}
532
533 When the \lstinline+"clockwork"+ style is used, the gear will be hollow if the
534 primitive radius is greater than three times the tooth height. Otherwise, the
535 gear will be solid, much like with the \lstinline+"classical"+ style.
536
537 For internal gear and rack, there is only one style of drawing.
538
539 The \lstinline+"spirograph"+ type is illustrated in the following example.
540
541 \begin{ExempleMP}
542 input gears
543
544 beginfig(1);
545 A = buildExternalGear(12,0.5,20,(0,0),0);
546 drawGear(A,(0.7,0.3,0.3),"spirograph");
547 endfig;
548 \end{ExempleMP}
549
550 It comes with other macros to draw pictures produced by a spirograph. We refer
551 to section~\ref{sec:spirograph} for details.
552
553 For racks, we have a similar macro.
554 \begin{colourband}
555 \commande|drawRack(«id»,«c»)|\smallskip\index{drawRack@\lstinline+drawRack+}
556 \begin{description}
557 \item[\meta{id}:] \typeMP{numeric} identifier to the existing rack.
558 \item[\meta{c}:] \typeMP{color} the color of the rack or \typeMP{string}
559 \lstinline+"None"+. In the last case, the rack is not colored.
560 \end{description}
561 \end{colourband}
562
563
564 \subsection{Different Colors}
565
566 By default, lines are drawn with black color. You can change that using the
567 following command.
568
569 \begin{colourband}
570 \commande|setLineColor(«c»)|\smallskip\index{setLineColor@\lstinline+setLineColor+}
571 \begin{description}
572 \item[\meta{c}]: \typeMP{color} the new value for line color.
573 \end{description}
574 \end{colourband}
575
576 When the \lstinline+"classical"+ style is used, the axis and the key color are
577 drawn with respectively color \lstinline+(0.6,0.6,0.6)+ and
578 \lstinline+(0.4,0.4,0.4)+. You can change that using the two following macros.
579 \begin{colourband}
580 \commande|setAxisColor(«c»)|\smallskip\index{setAxisColor@\lstinline+setAxisColor+}
581 \begin{description}
582 \item[\meta{c}]: \typeMP{color} the new value for axis color.
583 \end{description}
584 \end{colourband}
585
586
587 \begin{colourband}
588 \commande|setKeyColor(«c»)|\smallskip\index{setKeyColor@\lstinline+setKeyColor+}
589 \begin{description}
590 \item[\meta{c}]: \typeMP{color} the new value for key color.
591 \end{description}
592 \end{colourband}
593
594 \section{Other Macros}
595
596 \subsection{Getting Parameters}
597
598 In this section, we list simple macros to get parameters of the gear or the
599 rack. Most of them do not need explanation. Once again, all the dimensions are
600 scaled by the \mpgears unit.
601 \begin{colourband}
602 \commande|getPrimitiveRadius(«id»)|\return{\typeMP{numeric}}\smallskip\index{getPrimitiveRadius@\lstinline+getPrimitiveRadius+}
603 \begin{description}
604 \item[\meta{id}]: \typeMP{numeric} identifier of the gear (rack does not have
605 radius parameters).
606 \end{description}
607 \end{colourband}
608
609 \begin{colourband}
610 \commande|getTopRadius(«id»)|\return{\typeMP{numeric}}\smallskip\index{getTopRadius@\lstinline+getTopRadius+}
611 \begin{description}
612 \item[\meta{id}]: \typeMP{numeric} identifier of the gear (rack does not have
613 radius parameters).
614 \end{description}
615 \end{colourband}
616
617
618 \begin{colourband}
619 \commande|getBottomRadius(«id»)|\return{\typeMP{numeric} (in degree)}\smallskip\index{getBottomRadius@\lstinline+getBottomRadius+}
620 \begin{description}
621 \item[\meta{id}]: \typeMP{numeric} identifier of the gear (rack does not have
622 radius parameters).
623 \end{description}
624 \end{colourband}
625
626
627 \begin{colourband}
628 \commande|getRadialPoint(«id»,«t»)|\return{\typeMP{pair}}\smallskip\index{getRadialPoint@\lstinline+getRadialPoint+}
629 \begin{description}
630 \item[\meta{id}]: \typeMP{numeric} identifier of the gear (not rack).
631 \item[\meta{t}:] \typeMP{numeric} between 0 and 1 to get the point
632 $c+r(\cos(\theta),\sin(\theta))$ where $c$ is the center of the gear, $r$ is
633 the primitive radius, and $\theta$ the angle of rotation.
634 \end{description}
635 \end{colourband}
636 \label{com:radialPoint}
637 \begin{ExempleMP}
638 input gears
639 beginfig(1);
640 A = buildExternalGear(26,0.2,20,(0,0),45);
641 drawGear(A,"None","classical");
642 draw getCenter(A)--getRadialPoint(A,1) dashed evenly;
643 drawdot getRadialPoint(A,0.5) withpen pencircle scaled 2pt;
644 endfig;
645 \end{ExempleMP}
646
647
648
649 \begin{colourband}
650 \commande|getPressureAngle(«id»)|\return{\typeMP{numeric} (in degree)}\smallskip\index{getPressureAngle@\lstinline+getPressureAngle+}
651 \begin{description}
652 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or rack.
653 \end{description}
654 \end{colourband}
655
656
657 \begin{colourband}
658 \commande|getModule(«id»)|\return{\typeMP{numeric}}\smallskip\index{getModule@\lstinline+getModule+}
659 \begin{description}
660 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or the rack.
661 \end{description}
662 \end{colourband}
663
664
665 \begin{colourband}
666 \commande|getTeethNbr(«id»)|\return{\typeMP{numeric}}\smallskip\index{getTeethNbr@\lstinline+getTeethNbr+}
667 \begin{description}
668 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or the rack.
669 \end{description}
670 \end{colourband}
671
672 \begin{colourband}
673 \commande|getPrimitivePitch(«id»)|\return{\typeMP{numeric}}\smallskip\index{getPrimitivePitch@\lstinline+getPrimitivePitch+}
674 \begin{description}
675 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or the rack.
676 \end{description}
677 \end{colourband}
678
679
680 \begin{colourband}
681 \commande|getCenter(«id»)|\return{\typeMP{pair}}\smallskip\index{getCenter@\lstinline+getCenter+}
682 \begin{description}
683 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or the rack. For
684 racks, the center is either in the middle tooth, or if it is meshed at the
685 point of contact with the primitive radius of the gear.
686 \end{description}
687 \end{colourband}
688
689
690 \begin{colourband}
691 \commande|getToothHeight(«id»)|\return{\typeMP{numeric}}\smallskip\index{getToothHeight@\lstinline+getToothHeight+}
692 \begin{description}
693 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or the rack.
694 \end{description}
695 \end{colourband}
696
697
698 \begin{colourband}
699 \commande|getRotation(«id»)|\return{\typeMP{numeric}}\smallskip\index{getRotation@\lstinline+getRotation+}
700 \begin{description}
701 \item[\meta{id}]: \typeMP{numeric} identifier of the gear or the rack.
702 \end{description}
703 \end{colourband}
704
705 \begin{colourband}
706 \commande|getTranslation(«id»)|\return{\typeMP{numeric}}\smallskip\index{getTranslation@\lstinline+getTranslation+}
707 \begin{description}
708 \item[\meta{id}]: \typeMP{numeric} identifier of the rack (gears do not have
709 translation parameter).
710 \end{description}
711 \end{colourband}
712
713 \subsection{Getting construction objects}
714
715 There are some macros that help to get the different construction circles and
716 lines (respectively for gears and racks).
717
718 \subsubsection{Circles}
719
720 Beware, these macros only work for gears.
721
722 \begin{colourband}
723 \commande|primitiveCircle(«id»)|\return{\typeMP{path}}\smallskip\index{primitiveCircle@\lstinline+primitiveCircle+}
724 \begin{description}
725 \item[\meta{id}]: \typeMP{numeric} identifier of the gear.
726 \end{description}
727 \end{colourband}
728
729 \begin{colourband}
730 \commande|baseCircle(«id»)|\return{\typeMP{path}}\smallskip\index{baseCircle@\lstinline+baseCircle+}
731 \begin{description}
732 \item[\meta{id}]: \typeMP{numeric} identifier of the gear.
733 \end{description}
734 \end{colourband}
735
736 \begin{colourband}
737 \commande|bottomCircle(«id»)|\return{\typeMP{path}}\smallskip\index{bottomCircle@\lstinline+bottomCircle+}
738 \begin{description}
739 \item[\meta{id}]: \typeMP{numeric} identifier of the gear.
740 \end{description}
741 \end{colourband}
742
743 \begin{colourband}
744 \commande|topCircle(«id»)|\return{\typeMP{path}}\smallskip\index{topCircle@\lstinline+topCircle+}
745 \begin{description}
746 \item[\meta{id}]: \typeMP{numeric} identifier of the gear.
747 \end{description}
748 \end{colourband}
749
750 Here, an example of use of these macros.
751
752
753 \begin{ExempleMP}
754 input gears
755
756 beginfig(1);
757 A = buildExternalGear(24,0.5,20,(0,0),0);
758 drawGear(A,(0.7,0.3,0.3),"classical");
759 draw primitiveCircle(A) withpen pencircle scaled 1.5pt withcolor red;
760 draw baseCircle(A) dashed evenly withcolor blue;
761 draw bottomCircle(A) dashed evenly withcolor green;
762 draw topCircle(A) dashed evenly withcolor green;
763 endfig;
764 \end{ExempleMP}
765
766 \subsubsection{Lines}
767
768 Beware, these macros are only for rack objects.
769
770 \begin{colourband}
771 \commande|primitiveLine(«id»)|\return{\typeMP{path}}\smallskip\index{primitiveLine@\lstinline+primitiveLine+}
772 \begin{description}
773 \item[\meta{id}]: \typeMP{numeric} identifier of the rack.
774 \end{description}
775 \end{colourband}
776
777 \begin{colourband}
778 \commande|baseLine(«id»)|\return{\typeMP{path}}\smallskip\index{baseLine@\lstinline+baseLine+}
779 \begin{description}
780 \item[\meta{id}]: \typeMP{numeric} identifier of the rack.
781 \end{description}
782 \end{colourband}
783
784 \begin{colourband}
785 \commande|bottomLine(«id»)|\return{\typeMP{path}}\smallskip\index{bottomLine@\lstinline+bottomLine+}
786 \begin{description}
787 \item[\meta{id}]: \typeMP{numeric} identifier of the rack.
788 \end{description}
789 \end{colourband}
790
791 \begin{colourband}
792 \commande|topLine(«id»)|\return{\typeMP{path}}\smallskip\index{topLine@\lstinline+topLine+}
793 \begin{description}
794 \item[\meta{id}]: \typeMP{numeric} identifier of the rack.
795 \end{description}
796 \end{colourband}
797
798 \begin{ExempleMP}
799 input gears
800
801 beginfig(1);
802 (Q,P) = buildGearRackPair(27,10,0.5,20,(0,0),-15,157);
803 drawGear(Q,"None","classical") withpen pencircle scaled 1pt;
804 drawRack(P,"None") withpen pencircle scaled 1pt;
805 drawdot getCenter(P) withpen pencircle scaled 2pt;
806 draw primitiveLine(P);
807 draw baseLine(P) dashed evenly;
808 draw bottomLine(P) dashed evenly;
809 draw topLine(P) dashed evenly;
810 draw primitiveCircle(Q);
811 draw baseCircle(Q) dashed evenly;
812 draw bottomCircle(Q) dashed evenly;
813 draw topCircle(Q) dashed evenly;
814 endfig;
815 \end{ExempleMP}
816
817 \subsection{Spirograph}\label{sec:spirograph}
818
819 \mpgears provides a number of macros for creating Spirograph illustrations. The
820 building of a \emph{spirograph} gear compute points along the Archimedes spiral.
821 We can get these points using the following macros. The number of such points
822 will depend on the radius of the external gear.
823
824 \begin{colourband}
825 \commande|getSpirographPointNbr(«id»)|\return{\typeMP{numeric}}\smallskip\index{getSpirographPointNbr@\lstinline+getSpirographPointNbr+}
826 \begin{description}
827 \item[\meta{id}]: \typeMP{numeric} identifier of the external gear.
828 \end{description}
829 \end{colourband}
830
831
832 \begin{colourband}
833 \commande|getSpirographPoint(«id»,«n»)|\return{\typeMP{numeric}}\smallskip\index{getSpirographPoint@\lstinline+getSpirographPoint+}
834 \begin{description}
835 \item[\meta{id}]: \typeMP{numeric} identifier of the external gear.
836 \item[\meta{n}:] \typeMP{numeric}, integer between 0 and \lstinline+getSpirographPointNbr(+\meta{id}\lstinline+)+.
837 \end{description}
838 \end{colourband}
839
840 Thanks to all these macros, one can build the trajectories of a
841 \emph{spirograph} point of the gear. However, \mpgears provides a dedicated
842 macro.
843
844 \begin{colourband}
845 \commande|spirographCurve(«A»,«B»,«n»,«t»)|\return{\typeMP{path}}\smallskip\index{spirographCurve@\lstinline+spirographCurve+}
846 \begin{description}
847 \item[\meta{A}:] \typeMP{numeric} identifier of the fixed gear.
848 \item[\meta{B}:] \typeMP{numeric} identifier of the rotating gear.
849 \item[\meta{n}:] \typeMP{numeric}, integer between 0 and \lstinline+getSpirographPointNbr(+\meta{id}\lstinline+)+.
850 \item[\meta{t}:] \typeMP{numeric} angle of total rotation around \meta{A}.
851 \end{description}
852 \end{colourband}
853
854 Here, are two examples. Because one revolution is 360 degrees, if we use
855 the default number system of \hologo{METAPOST}, we are limited to very few
856 revolutions.
857
858 \mplibnumbersystem{double}
859 \begin{ExempleMP}
860 input gears
861 % double number system
862 beginfig(1);
863 N:=10;
864 (Q,P) = buildExternalGearPair(27,10,0.5,20,(0,0),0,0);
865 drawGear(Q,(0.7,0.3,0.3),"classical");
866 drawGear(P,(0.3,0.7,0.3), "spirograph");
867 draw spirographCurve(Q,P,N,3600) withcolor (0.3,0.3,0.7);
868 drawdot getSpirographPoint(P,N) withpen pencircle scaled 4pt withcolor (0.9,0.6,0.3);
869 endfig;
870 \end{ExempleMP}
871
872 \begin{ExempleMP}
873 input gears
874 % double number system
875 beginfig(1);
876 N:=10;
877 (Q,P) = buildInternalGearPair(20,12,0.5,20,(0,0),0,0);
878 drawGear(Q,(0.7,0.3,0.3),"classical");
879 drawGear(P,(0.3,0.7,0.3), "spirograph");
880 draw spirographCurve(Q,P,N,3600) withcolor (0.3,0.3,0.7);
881 drawdot getSpirographPoint(P,N) withpen pencircle scaled 4pt withcolor (0.9,0.6,0.3);
882 endfig;
883 \end{ExempleMP}
884
885 You can get or modify the size of the mark of the spirograph point on the gear with the
886 following macros. In the \mpgears unit, the size is \num{0.15} by default.
887
888
889 \begin{colourband}
890 \commande|getSpirographPointSize|\return{\typeMP{numeric}}\smallskip\index{getSpirographPointSize@\lstinline+getSpirographPointSize+}
891 \end{colourband}
892
893
894 \begin{colourband}
895 \commande|setSpirographPointSize(«s»)|\smallskip\index{setSpirographPointSize@\lstinline+setSpirographPointSize+}
896 \begin{description}
897 \item[\meta{s}:] \typeMP{numeric} size of the spirograph points (\num{0.15} by default).
898 \end{description}
899 \end{colourband}
900
901 \subsection{Cycloid Curve}
902
903 Similar to \lstinline+spirographCurve+, it is possible to draw hypo or
904 epicycloids.
905
906
907 \begin{colourband}
908 \commande|cycloidCurve(«A»,«B»,«t»)|\return{\typeMP{path}}\smallskip\index{cycloidCurve@\lstinline+cycloidCurve+}
909 \begin{description}
910 \item[\meta{A}:] \typeMP{numeric} identifier of the fixed gear.
911 \item[\meta{B}:] \typeMP{numeric} identifier of the rotating gear.
912 \item[\meta{t}:] \typeMP{numeric} angle of total rotation around \meta{A}.
913 \end{description}
914 \end{colourband}
915
916 \begin{ExempleMP}
917 input gears
918 % double number system
919 beginfig(1);
920 (Q,P) = buildInternalGearPair(20,12,0.5,20,(0,0),0,0);
921 drawGear(Q,(0.7,0.3,0.3),"classical");
922 drawGear(P,(0.3,0.7,0.3), "classical");
923 draw cycloidCurve(Q,P,7200) withcolor (0.3,0.3,0.7);
924 drawdot getRadialPoint(P,1) withpen pencircle scaled 4pt withcolor (0.9,0.6,0.3);
925 endfig;
926 \end{ExempleMP}
927
928
929
930 \section{History}
931
932 \begin{description}
933 \item[2026-05-05:] Change of last parameter of \lstinline+spirographCurve+:
934 number of revolution becomes total angle of rotation. Bug correction in
935 \lstinline+spirographCurve+. New: \lstinline+cycloidCurve+. New animations for
936 cycloid and spirograph.
937 \end{description}
938
939 \pagestyle{empty}
940 \begin{landscape}
941 \section{Gallery}
942 \subsection{Clock Gear Train}
943 Inspired by the remarkable work of Tavmjong Bah on the website: \url{http:
944 //tavmjong.free.fr/INKSCAPE/DRAWINGS/clock.svg} and \package{pst-gears}.
945
946
947 \begin{center}
948 \begin{mplibcode}
949 input gears
950 color couleur[];
951 couleur1 := (0.7,0.3,0.3);
952 couleur2 := (0.3,0.7,0.3);
953 couleur3 := (0.3,0.3,0.7);
954 couleur4 := (0.6,0.6,0.6);
955
956 picture aiguille;
957
958 setUnit(1cm);
959 m := 0.08;
960 alpha := 20;
961
962 aiguille := image(
963 R := 60*m/2;
964 fill (-0.05*R,-0.3*R)--(0.05*R,-0.3*R)--(0.03*R,R)--(0,1.1*R)--
965 (-0.03*R,R)--cycle;
966 fill fullcircle scaled (0.1*2*R);
967 ) scaled getUnit;
968
969 beginfig(1);
970
971 rot := 0;
972 (G1,G2) = buildExternalGearPair(8,60,m,alpha,(0,0),rot,180);
973 G3 = buildCompoundGear(G2,8,m,alpha);
974 G4 = buildExternalGearFor(G3,64,180);
975 G5 = buildCompoundGear(G4,20,m,alpha);
976 G6 = buildExternalGearFor(G5,60,220);
977 G7 = buildCompoundGear(G6,16,m,alpha);
978 G8 = buildExternalGearFor(G7,64,140);
979
980 drawGear(G1,couleur1,"clockwork");
981 drawGear(G2,couleur1,"clockwork");
982 drawGear(G3,couleur2,"clockwork");
983 drawGear(G4,couleur2,"clockwork");
984 drawGear(G5,couleur3,"clockwork");
985 drawGear(G6,couleur3,"clockwork");
986 drawGear(G7,couleur4,"clockwork");
987 drawGear(G8,couleur4,"clockwork");
988
989 draw aiguille xscaled 0.8 rotated getRotation(G1) shifted getCenter(G1);
990 draw aiguille rotated getRotation(G5) shifted getCenter(G5);
991 draw aiguille yscaled 0.6 rotated getRotation(G8) shifted getCenter(G8);
992 endfig;
993 end.
994 \end{mplibcode}
995 \end{center}
996 \newpage
997
998 \begin{multicols}{2}
999 \begin{lstlisting}
1000 input gears
1001 color couleur[];
1002 couleur1 := (0.7,0.3,0.3);
1003 couleur2 := (0.3,0.7,0.3);
1004 couleur3 := (0.3,0.3,0.7);
1005 couleur4 := (0.6,0.6,0.6);
1006
1007 picture aiguille;
1008 setUnit(1cm);
1009 m := 0.08;
1010 alpha := 20;
1011
1012 aiguille := image(
1013 R := 60*m/2;
1014 fill (-0.05*R,-0.3*R)--(0.05*R,-0.3*R)--(0.03*R,R)--(0,1.1*R)--
1015 (-0.03*R,R)--cycle;
1016 fill fullcircle scaled (0.1*2*R);
1017 ) scaled getUnit;
1018
1019 beginfig(1);
1020
1021 rot := 0;
1022 (G1,G2) = buildExternalGearPair(8,60,m,alpha,(0,0),rot,180);
1023 G3 = buildCompoundGear(G2,8,m,alpha);
1024 G4 = buildExternalGearFor(G3,64,180);
1025 G5 = buildCompoundGear(G4,20,m,alpha);
1026 G6 = buildExternalGearFor(G5,60,220);
1027 G7 = buildCompoundGear(G6,16,m,alpha);
1028 G8 = buildExternalGearFor(G7,64,140);
1029
1030 drawGear(G1,couleur1,"clockwork");
1031 drawGear(G2,couleur1,"clockwork");
1032 drawGear(G3,couleur2,"clockwork");
1033 drawGear(G4,couleur2,"clockwork");
1034 drawGear(G5,couleur3,"clockwork");
1035 drawGear(G6,couleur3,"clockwork");
1036 drawGear(G7,couleur4,"clockwork");
1037 drawGear(G8,couleur4,"clockwork");
1038
1039 draw aiguille xscaled 0.8 rotated getRotation(G1) shifted getCenter(G1);
1040 draw aiguille rotated getRotation(G5) shifted getCenter(G5);
1041 draw aiguille yscaled 0.6 rotated getRotation(G8) shifted getCenter(G8);
1042 endfig;
1043 end.
1044 \end{lstlisting}
1045 \end{multicols}
1046 \end{landscape}
1047 \begin{landscape}
1048 \subsection{Gears Animation}
1049
1050 We can use the package \package{animate}~\cite{animate} to animate rotation of
1051 gears.
1052
1053 \begin{center}
1054 \begin{animateinline}[poster=first,loop, controls]{12}%
1055 \multiframe{360}{iAngle=0+2}{%
1056 \begin{mplibcode}
1057 input gears
1058
1059 beginfig(1);
1060 rot := \iAngle;
1061 axerot := 30;
1062 axerot3 := -30;
1063 pair gears;
1064 gears := buildExternalGearPair(16,10,0.5,20,(0,0),rot,axerot);
1065 G1 := xpart gears;
1066 G2 := ypart gears;
1067 G3 := buildExternalGearFor(G2,8,axerot3);
1068
1069 drawGear(G1, (0.7,0.3,0.3),"classical");
1070 drawGear(G2, (0.3,0.7,0.3),"classical");
1071 drawGear(G3, (0.3,0.3,0.7),"classical");
1072
1073 pair c[];
1074 c1 := getCenter(G1);
1075 c2 := getCenter(G2);
1076 c3 := getCenter(G3);
1077 draw (xpart c1-1.5*getTopRadius(G1),-1.5*getTopRadius(G1))--(xpart
1078 c3+1.5*getTopRadius(G3),-1.5*getTopRadius(G1))--(xpart
1079 c3+1.5*getTopRadius(G3),ypart c2+1.5*getTopRadius(G2))--(xpart
1080 c1-1.5*getTopRadius(G1),ypart c2+1.5*getTopRadius(G2)) --cycle withcolor background;
1081 endfig;
1082 \end{mplibcode}
1083 }
1084 \end{animateinline}
1085 \end{center}
1086 \begin{multicols}{2}
1087 \begin{lstlisting}
1088 \begin{animateinline}[poster=first,loop, controls]{12}%
1089 \multiframe{360}{iAngle=0+2}{%
1090 \begin{mplibcode}
1091 input gears
1092
1093 beginfig(1);
1094 rot := \iAngle;
1095 axerot := 30;
1096 axerot3 := -30;
1097 pair gears;
1098 gears := buildExternalGearPair(16,10,0.5,20,(0,0),rot,axerot);
1099 G1 := xpart gears;
1100 G2 := ypart gears;
1101 G3 := buildExternalGearFor(G2,8,axerot3);
1102
1103 drawGear(G1, (0.7,0.3,0.3),"classical");
1104 drawGear(G2, (0.3,0.7,0.3),"classical");
1105 drawGear(G3, (0.3,0.3,0.7),"classical");
1106
1107 endfig;
1108 \end{mplibcode}
1109 }
1110 \end{animateinline}
1111 \end{lstlisting}
1112 \end{multicols}
1113 \end{landscape}
1114
1115 \begin{landscape}
1116 \subsection{Gears Animation (2)}
1117
1118 \begin{center}
1119 \begin{animateinline}[poster=first, controls]{12}%
1120 \multiframe{360}{iAngle=0+2}{%
1121 \begin{mplibcode}
1122 input gears
1123
1124 beginfig(2);
1125 rot := \iAngle;
1126 axerot := 0;
1127 (G[7],G[8]) = buildInternalGearPair(60,24,0.2,20,(0,0),rot,axerot);
1128 G9 = buildExternalGearFor(G7,24,120);
1129 G10 = buildExternalGearFor(G7,24,240);
1130 G11 = buildExternalGearFor(G10,12,60);
1131 drawGear(G7,(0.7,0.3,0.3),"classical");
1132 drawGear(G8,(0.3,0.7,0.3),"classical");
1133 drawGear(G9,(0.3,0.7,0.3),"classical");
1134 drawGear(G10,(0.3,0.7,0.3),"classical");
1135 drawGear(G11,(0.3,0.3,0.7),"classical");
1136 endfig;
1137 \end{mplibcode}
1138 }
1139 \end{animateinline}
1140 \end{center}
1141 \begin{multicols}{2}
1142 \begin{lstlisting}
1143 \begin{animateinline}[poster=first, controls]{12}%
1144 \multiframe{360}{iAngle=0+2}{%
1145 \begin{mplibcode}
1146 input gears
1147
1148 beginfig(2);
1149 rot := \iAngle;
1150 axerot := 0;
1151 (G[7],G[8]) = buildInternalGearPair(60,24,0.2,20,(0,0),rot,axerot);
1152 G9 = buildExternalGearFor(G7,24,120);
1153 G10 = buildExternalGearFor(G7,24,240);
1154 G11 = buildExternalGearFor(G10,12,60);
1155 drawGear(G7,(0.7,0.3,0.3),"classical");
1156 drawGear(G8,(0.3,0.7,0.3),"classical");
1157 drawGear(G9,(0.3,0.7,0.3),"classical");
1158 drawGear(G10,(0.3,0.7,0.3),"classical");
1159 drawGear(G11,(0.3,0.3,0.7),"classical");
1160 endfig;
1161 \end{mplibcode}
1162 }
1163 \end{animateinline}
1164 \end{lstlisting}
1165 \end{multicols}
1166 \end{landscape}
1167
1168 \begin{landscape}
1169 \subsection{Epicycloid Animation}
1170
1171 \begin{center}
1172 \begin{animateinline}[poster=first, controls]{12}%
1173 \multiframe{217}{iAngle=0+5}{%
1174 \begin{mplibcode}
1175 input gears
1176 % double number system
1177 setUnit(0.3cm);
1178 (Q,P) = buildExternalGearPair(20,12,0.5,20,(0,0),0,0);
1179 path bb;
1180 bb := bbox image(draw cycloidCurve(Q,P,1800);) scaled 1.3;
1181 beginfig(1);
1182 (R,S) = buildExternalGearPair(20,12,0.5,20,(0,0),0,\iAngle);
1183 drawGear(R,(0.7,0.3,0.3),"classical");
1184 drawGear(S,(0.3,0.7,0.3), "classical");
1185 draw cycloidCurve(Q,P,\iAngle) withcolor (0.3,0.3,0.7) withpen pencircle scaled 2pt;
1186 drawdot getRadialPoint(S,1) withpen pencircle scaled 4pt withcolor
1187 (0.9,0.6,0.3);
1188 draw bb withcolor background;
1189 endfig;
1190 \end{mplibcode}
1191 }
1192 \end{animateinline}
1193
1194 \end{center}
1195 \begin{multicols}{2}
1196 \begin{lstlisting}
1197 \begin{animateinline}[poster=first, controls]{12}%
1198 \multiframe{217}{iAngle=0+5}{%
1199 \begin{mplibcode}
1200 input gears
1201 % double number system
1202 setUnit(0.3cm);
1203 (Q,P) = buildExternalGearPair(20,12,0.5,20,(0,0),0,0);
1204 path bb;
1205 bb := bbox image(draw cycloidCurve(Q,P,1800);) scaled 1.3;
1206 beginfig(1);
1207 (R,S) = buildExternalGearPair(20,12,0.5,20,(0,0),0,\iAngle);
1208 drawGear(R,(0.7,0.3,0.3),"classical");
1209 drawGear(S,(0.3,0.7,0.3), "classical");
1210 draw cycloidCurve(Q,P,\iAngle) withcolor (0.3,0.3,0.7) withpen pencircle scaled 2pt;
1211 drawdot getRadialPoint(S,1) withpen pencircle scaled 4pt withcolor
1212 (0.9,0.6,0.3);
1213 draw bb withcolor background;
1214 endfig;
1215 \end{mplibcode}
1216 }
1217 \end{animateinline}
1218 \end{lstlisting}
1219 \end{multicols}
1220 \end{landscape}
1221
1222 \begin{landscape}
1223 \subsection{Spirograph Animation}
1224
1225 \begin{center}
1226 \begin{animateinline}[poster=first, controls]{12}%
1227 \multiframe{217}{iAngle=0+5}{%
1228 \begin{mplibcode}
1229 input gears
1230 % double number system
1231 (Q,P) = buildInternalGearPair(20,12,0.5,20,(0,0),0,0);
1232 N:=15;%getSpirographPointNbr(P);
1233 beginfig(1);
1234 (R,S) = buildInternalGearPair(20,12,0.5,20,(0,0),0,\iAngle);
1235 drawGear(R,(0.7,0.3,0.3),"classical");
1236 drawGear(S,(0.3,0.7,0.3), "spirograph");
1237 draw spirographCurve(Q,P,N,\iAngle) withcolor (0.3,0.3,0.7) withpen pencircle scaled 2pt;
1238 drawdot getSpirographPoint(S,N) withpen pencircle scaled 4pt withcolor (0.9,0.6,0.3);
1239 endfig;
1240 \end{mplibcode}
1241 }
1242 \end{animateinline}
1243
1244 \end{center}
1245 \begin{multicols}{2}
1246 \begin{lstlisting}
1247 \begin{animateinline}[poster=first, controls]{12}%
1248 \multiframe{217}{iAngle=0+5}{%
1249 \begin{mplibcode}
1250 input gears
1251 % double number system
1252 (Q,P) = buildInternalGearPair(20,12,0.5,20,(0,0),0,0);
1253 N:=15;%getSpirographPointNbr(P);
1254 beginfig(1);
1255 (R,S) = buildInternalGearPair(20,12,0.5,20,(0,0),0,\iAngle);
1256 drawGear(R,(0.7,0.3,0.3),"classical");
1257 drawGear(S,(0.3,0.7,0.3), "spirograph");
1258 draw spirographCurve(Q,P,N,\iAngle) withcolor (0.3,0.3,0.7) withpen pencircle scaled 2pt;
1259 drawdot getSpirographPoint(S,N) withpen pencircle scaled 4pt withcolor (0.9,0.6,0.3);
1260 endfig;
1261 \end{mplibcode}
1262 }
1263 \end{animateinline}
1264 \end{lstlisting}
1265 \end{multicols}
1266 \end{landscape}
1267
1268 \printbibliography
1269 \printindex
1270 \end{document}