Debian Codegraph @

texmf-dist/doc/latex/euclideangeometry/euclideangeometry-man.tex

raw
1 % !TEX encoding = UTF-8 Unicode
2 % !TEX TS-program = pdflatex
3
4 \documentclass[11pt,titlepage,a4paper]{article}\errorcontextlines=100
5 \usepackage[T1]{fontenc}
6 \usepackage[utf8]{inputenc}
7 \usepackage[english]{babel}
8 \usepackage{lmodern,textcomp,mflogo}
9 \usepackage{amsmath,fancyvrb,graphicx,afterpage,etoolbox,trace}
10 \usepackage{enumitem,xspace,xcolor,euclideangeometry,pm-isomath}
11 \usepackage{url}
12 \providecommand\file{}
13 \renewcommand*\file[1]{{\normalfont\texttt{#1}}}
14 \providecommand\prog{}
15 \renewcommand*\prog[1]{{\normalfont\texttt{#1}}}
16 \newcommand*\conta[1]{\texttt{\slshape#1}}
17 \providecommand\cs{}
18 \renewcommand\cs[1]{{\normalfont\texttt{\char92#1}}}
19 \providecommand\meta{}
20 \renewcommand*\meta[1]{{\normalfont$\langle$\textit{#1}$\rangle$}}
21 \providecommand\marg{}
22 \renewcommand*\marg[1]{{\ttfamily \char123\meta{#1}\char125}}
23 \newcommand*\Marg[1]{{\normalfont\ttfamily\{#1\}}}\let\Arg\Marg
24 \providecommand\oarg{}
25 \renewcommand*\oarg[1]{{\ttfamily[\meta{#1}]}}
26 \newcommand*\Oarg[1]{{\ttfamily[#1]}}
27 \newcommand*\aarg[1]{{\ttfamily{<\meta{#1}>}}}
28 \newcommand*\Aarg[1]{{\ttfamily<#1>}}
29 \newcommand*\Bambiente[1]{\texttt{\char92begin\{#1\}}}
30 \newcommand*\Eambiente[1]{\texttt{\char92end\{#1\}}}
31 \newcommand*\garg[1]{\texttt{(\splitgarg#1,!)}}\let\parg\garg
32 \newcommand*\Garg[1]{\texttt{(#1)}}\let\Parg\Garg
33 \def\secgarg#1,{#1}
34 \def\splitgarg#1,#2!{%
35 \ifstrequal{#2}{}{\meta{#1}}{\meta{#1},\meta{\secgarg#2}}}
36 \providecommand\pack{}
37 \renewcommand*\pack[1]{{\normalfont\textsf{#1}}}
38 \providecommand\opt{}
39 \renewcommand*\opt[1]{{\normalfont\textsl{#1}}}\let\opz\opt
40 \providecommand\env{}
41 \renewcommand*\env[1]{{\normalfont\textit{\bfseries#1}}}\let\amb\env
42
43 \providecommand*\ped[1]{\ensuremath{_{\mathrm{#1}}}}
44 \providecommand*\ap[1]{\ensuremath{^{\mathrm{#1}}}}
45 \providecommand*\unit[1]{\ensuremath{\,\mathrm{#1}}}
46 \providecommand*\sigla[1]{\textsc{\lowercase{#1}}}
47 \providecommand*\iu{\ensuremath{\mathrm{i}}}\let\gei\iu
48 \providecommand*\eu{\ensuremath{\mathop{\mathrm{e}}\nolimits}}
49
50 \providecommand\GetFileInfo{}
51 \makeatletter
52 \renewcommand*\GetFileInfo[1]{%
53 \def\filename{#1}%
54 \def\@tempb##1 v.##2 ##3\relax##4\relax{%
55 \def\filedate{##1}\def\fileversion{##2}\def\fileinfo{##3}}%
56 \edef\@tempa{\csname ver@#1\endcsname}%
57 \expandafter\@tempb\@tempa\relax? ? \relax\relax}
58 \makeatother
59
60 \DeclareRobustCommand*{\Ars}{% for the bibliography
61 \textsf{\lower -.48ex\hbox{\rotatebox{-20}{A}}\kern -.3em{rs}}%
62 \kern -.05em\TeX\unskip\kern -.17em\lower -.357ex\hbox{nica}\xspace}
63
64
65 \definecolor{verdeguit}{rgb}{0, 0.40, 0}
66 \providecommand\GuIT{\mbox{\color{verdeguit}\def\I{\textcolor{black}{I}}%
67 \fontfamily{lmr}\fontseries{m}\fontshape{sc}\selectfont
68 g\raisebox{-0.715ex}{\kern-0.26em u}\kern-0.13em\I\kern-0.14em t}\xspace}
69
70
71 \makeatletter
72 \AfterEndPreamble{%
73 \DeclareRobustCommand{\TeX}{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@\xspace}
74 \DeclareRobustCommand{\LaTeX}{L\kern-.36em%
75 {\sbox\z@ T%
76 \vbox to\ht\z@{\hbox{\check@mathfonts
77 \fontsize\sf@size\z@
78 \math@fontsfalse\selectfont
79 A}%
80 \vss}%
81 }%
82 \kern-.15em%
83 \TeX}}%
84 \makeatother
85
86 \DeclareRobustCommand*\TeXLive{\TeX\ Live\xspace}
87 \DeclareRobustCommand*\MiKTeX{MiK\TeX}
88 \DeclareRobustCommand*\MacTeX{Mac\TeX}
89 \DeclareRobustCommand*\pdfLaTeX{pdf\/\LaTeX}
90 \DeclareRobustCommand*\LuaLaTeX{Lua\LaTeX}
91 \DeclareRobustCommand*\XeLaTeX{X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
92 \lower.5ex\hbox{\rotatebox[origin=c]{180}{E}}%
93 \ifdim\fontdimen1\font=0pt\kern-0.15em\else\kern-0.275em\fi
94 \LaTeX}
95 \DeclareRobustCommand*\LaTeXe{\LaTeX\kern-0,25em\relax2\raisebox{-0.5ex}{$\epsilon$}\xspace}
96 \DeclareRobustCommand*\TikZ{Ti\emph{k}Z\xspace}
97 \DeclareRobustCommand*\TUGboat{\textsl{TUG\-boat}\xspace}
98
99 \def\hz{\hskip0pt}
100
101 \makeatletter
102 \newlength\Wboxu \newlength\Wboxd
103
104 % Caution!
105 %
106 % This is the latest version of the Esempio (Example) environment
107 % It differs from the previous ones because it accepts an optional
108 % first argument asterisk; if the asterisk is not specified, the
109 % environment produces the code and the typeset result side by side.
110 % If the asterisk is specified, the code is typeset first, and its typeset
111 % result is shown below the code.
112 % Very handy when the typeset result cannot be shrunk too much and/or
113 % when the code is really lengthy possibly with lines that are quite long.
114 % With reasonably short codes and lines that can be folded, the code font
115 % size can be specified even with a fractional size; obviously, the
116 % default value is \normalsize, but, if necessary, it can be specified
117 % with something such as [\setfontsize{8,25}] (if the unit of measure is
118 % not specified, pt is assumed; otherwise it is possible to specify
119 % something such as 2.33mm).
120 % When the asterisk is NOT specified, the \textwidth fraction for the
121 % code may be specified: default is (0.40); the remaining fraction minus
122 % \columnsep is used for the code typeset result.
123 % For some reasons the optional code is not so optional, although the
124 % argument descriptor is D()(0.40); it is not a burden to specify it
125 % every time:
126 %
127 % Warning!
128 % The \begin and \end statements must be on a line by themselves:
129 %
130 % Correct:
131 % \begin{Esempio}*[...](...)
132 % code
133 % \end{Esempio}
134 %
135 % Wrong:
136 % \begin{Esempio}*[...](...)
137 % code\end{Esempio}
138 %
139 % The code end-of-line characters are part of the code to be saved
140 % and reused
141
142 \DeclareDocumentEnvironment{Esempio}{ s O{\normalsize} D(){0.40} }%
143 {%
144 \par%\addvspace{3.0ex plus 0.8ex minus 0.5ex}\vskip -\parskip
145 \Wboxu=#3\textwidth
146 \Wboxd=\dimexpr\linewidth-\columnsep-\Wboxu\relax
147 \VerbatimOut{\jobname-temp.tex}%
148 }{%
149 \endVerbatimOut
150 \begin{minipage}{\linewidth}%
151 \IfBooleanTF{#1}{\begin{minipage}{\linewidth}}{\begin{minipage}{\Wboxu}}%
152 #2\relax
153 \VerbatimInput{\jobname-temp.tex}
154 \end{minipage}%
155 \IfBooleanTF{#1}{\par\bigskip}{\hfill}%
156 \IfBooleanTF{#1}{\begin{minipage}{\linewidth}}{\begin{minipage}{\Wboxd}}%
157 \raggedleft
158 \input{\jobname-temp}
159 \end{minipage}
160 \end{minipage}\par
161 }
162
163 \makeatother
164
165 \providecommand\setfontsize{}
166 \RenewDocumentCommand\setfontsize{m O{1.2}}{%
167 \fontsize{#1}{\fpeval{#2*#1}}\selectfont}
168
169 \NewDocumentEnvironment{ttsintassi}{O{}}{\begin{lrbox}{0}
170 \minipage{\dimexpr\linewidth-2\fboxrule-2\fboxsep}\ttfamily#1\obeylines}%
171 {\endminipage\end{lrbox}\center\fbox{\box0}\endcenter}
172 \let\ttsyntax\ttsintassi \let\endttsyntax\endttsintassi
173
174 \newcommand\heart[3]{%
175 \edef\X{\fpeval{#1*16*(sind(#2)^3)}}
176 \edef\Y{\fpeval{#1*(13*cosd(#2) - 5*cosd(2*#2)
177 - 2*cosd(3*#2) -cosd(4*#2)+2.4)}}
178 \CopyVect\X,\Y to#3}
179 \let\cuore\heart
180
181 \begin{document}\errorcontextlines=100
182
183 \begin{titlepage}
184 \thispagestyle{empty}
185 \centering
186 \textsc{\large Claudio Beccari}\\[2ex]
187 \texttt{claudio dot beccari at gmail dot com}
188
189 \vspace{\stretch{2}}
190
191 {\LARGE\scshape The \pack{euclideangeometry} package\\
192 {\large user manual}\par}
193
194 \vspace{\baselineskip}
195
196
197 \GetFileInfo{euclideangeometry.sty}
198 Version \fileversion\ of \filedate
199
200 \vspace*{\stretch{5}}
201 \end{titlepage}
202
203 \begin{abstract}
204 The \pack{euclideangeometry} package further extends the functionalities
205 of the \pack{curve2e} package, which, on turn, is an extension of the
206 \pack{pict2e} package for the standard \env{picture} environment as
207 defined in the \LaTeX\ kernel source file.
208
209 The \pack{curve2e} package was upgraded in 2020 and again in 2023; some
210 material of this package, might have been included in the former pict2e
211 one, but it is so specific, that we preferred defining a standalone one;
212 this package takes care of requesting the packages it depends from.
213
214 The purpose is to provide the tools to draw most of the geometrical
215 constructions that a high school teacher or bachelor degree professor
216 might need in order to teach (plane) geometry. The connection to Euclide
217 depends on the fact that in its times calculations were made with ruler,
218 compass, and, apparently, also with the ellipsograph.
219
220 The user of this package has available all the machinery provided by
221 the \pack{pict2e} and \pack{curve2e} packages, in order to define new
222 functionalities and build macros that draw the necessary lines, circles,
223 and other such objects, as they would have done in the old times.
224 Actually just one macro is defined in this package to solve a linear
225 system of equations
226 \end{abstract}
227
228 \tableofcontents
229
230
231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 \section*{Warning}
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234 The \pack{euclideangeometry} package requires the advanced functionalities of the \LaTeX\!3 (L3) language; if such functionalities are not available for any reason (incomplete/basic installation of the \TeX system; legacy installation of the \TeX system; the \TeX system has not been updated; \dots) input of this package is stopped, the whole job is aborted, and a visible message is issued.
235
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 \section{Introduction}
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 The \pack{picture} environment has been available since the very
240 beginning
241 of \LaTeX in 1985. At that time it was really a simple environment
242 that allowed to draw very simple line graphics with many limitations.
243 When \LaTeX was upgraded from \LaTeX\!2.09 to \LaTeXe in 1994, Leslie
244 Lamport announced an upgrade that eventually became available in 2003
245 with package \pack{pict2e}; in 2006 I wrote the first version of the
246 \pack{curve2e} package that added many more functionalities; both
247 packages were upgraded during these years; and now line graphics with
248 the \env{picture} environment can perform pretty well. The package
249 \pack{euclideangeometry} adds even more specific functionalities in order
250 to produce geometric drawings as they were possible in the old times,
251 when calculus and analytic geometry were not available.
252
253 In these years other drawing programs were made available to the \TeX
254 community; \pack{PSTricks} and \pack{TikZ} are the most known ones, but
255 there are other less known packages, that perform very well; among the
256 latter I would like to mention \pack{xpicture}, that relies on
257 \pack{pict2e} and \pack{curve2e}, but extends the functionalities with a
258 very smart handling of coordinate systems, that allow to draw many line
259 drawings suitable for teaching geometry in high schools and introductory
260 courses in the university bachelor degree programs. It is worth
261 mentioning that an extension of \pack{TikZ}, called \pack{tkz-euclide},
262 is also available in a complete and updated \TeX system installation; at
263 the moment its documentation needs some refinements, at least to
264 consistently use a single language, without switching from English
265 to French and viceversa. It aims at the same readership, but it allows
266 to do many more geometrical constructions, than \pack{euclideangeometry}.
267 The real difference is that \pack{euclideangemetry} may be easily
268 expanded without the need of knowing the complex machinery and coding
269 of the \pack{tkz-euclide} underlaying \pack{TikZ} package.
270
271 This package \pack{euclideangeomery} apparently follows the same
272 path of \pack{xpicture}, but it avoids defining a new user language
273 interface; rather it builds new macros by using the same philosophy of
274 the recent \pack{curve2e} package.
275
276 It is worth mentioning that now \pack{curve2e} accepts coordinates in
277 both cartesian and polar form; it allows to identify specific points of
278 the drawing with macros, so the same macro can be used over and over
279 again to address the same point. The package can draw lines, vectors,
280 arcs with no arrow tips, or with one arrow tip, or with arrow tips at
281 both ends, arcs included. The macros for drawing polylines, polygons,
282 circles, generic curves (by means of Bézier cubic or quadratic splines)
283 are already available; such facilities are documented and exemplified
284 in the user manual of the \pack{curve2e} package.
285
286 In what follows there will be several figures drawn with this package;
287 in the background there is a red grid where the meshes are
288 10\,\cs{unitlenth} apart in both directions; they should help to
289 understand the position of the various drawings on the picture canvas.
290 This grid is useful also to the end user, while s/he is working on a
291 particular drawing, but when the drawing is finished, the user can
292 delete the grid command or comment out that line of code.
293 For what regards the commands used to render the images, their
294 \emph{codes} can be found in the documented code file
295 \pack{euclideangeometry.pdf}.
296
297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298 \section{Installing \pack{euclideangeometry}}
299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
300 You are not supposed to manually install package \pack{euclideangeometry}.
301 In facts you have to work with a complete and updated/upgraded \TeX
302 installation, otherwise this package won't work; this means that
303 you have done your updating after 2020-01-18. And this package is already
304 present in any modern updated complete installation of the \TeX system.
305 If \pack{curve2e} has a date earlier then 2020-01-018, the \pack{curve2e}
306 itself will load \pack{curve2ev161}, an older version, and this package
307 \pack{euclideangeomentry} will abort its own loading, besides
308 aborting the whole job.
309
310 We remember the package dependencies; the primary dependence is package
311 \pack{curve2e} with a version date more recent or equal to 2020-01-18.
312 On turn \pack{curve2e} requires packages \pack{xparse} and
313 \pack{xfp}\footnote{Most functionalities of \pack{xfp} are already
314 included into the \LaTeXe kernel, but this package uses also some
315 functionalities that have not made their way to the kernel.};
316 missing these two package, it loads its own previous version, that does
317 not use such packages, but their absence forbids it working, so that,
318 after a very visible error message, it directly aborts.
319 It also depends on \pack{etoolbox}. The chain of dependencies of the
320 above first level packages may be controlled directly on those packages
321 documentation
322
323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
324 \section{Loading \pack{euclideangeometry}}
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 If you want to use the \pack{euclideangeometry} package, we suggest you
327 load it with the following command:
328 \begin{flushleft}\obeylines
329 \cs{usepackage}\oarg{options}\Marg{euclideangeomery}
330 \end{flushleft}
331 The package will take care of managing the possible \meta{options}
332 and to call \pack{curve2e} with such specified options; on turn
333 \pack{curve2e} calls \pack{pict2e} passing on the \meta{options}; such
334 \meta{options} are only those usable by \pack{pict2e} because neither
335 \pack{curve2e} nor \pack{euclideangeometry} use any option. If the
336 user is invoking \pack{euclideangeometry}, it is certain s/he does
337 not want to use the modern extended picture environment, not the native
338 one; therefore the only meaningful possible options are
339 \opt{latex} and \opt{pstricks}; such options influence only the shape
340 of the arrow tips; with option \opt{latex} they are triangular,
341 while with \opt{pstricks} they have the shape of a stealth
342 aircraft. The difference is very small; therefore we imagine that
343 even if these options are available, they might never be used.
344
345 Nothing happens if the user forgets this mechanism; therefore if s/he
346 loads \pack{curve2e} and/or \pack{pict2e}, before
347 \pack{euclideangeomentry} the only problem that might arise is an
348 “Option clash” error message; if two of these packages are selected
349 with different arrow tips; not impossible, of course, by we deem
350 it very unlikely.
351
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353 \section{Available commands}
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355
356 The commands available with the first extension \pack{pict2e} to the
357 native \amb{picture} environment, maintain their names but do not
358 maintain the same restrictions; in particular there are the following
359 improvements.
360 \begin{enumerate}[noitemsep]
361 \item Lines and vectors are drawn as usual by \cs{put}ting in place
362 their forms, but their inclinations are not limited to a small set of
363 slope parameters, originally specified with reciprocally
364 prime single digit values not exceeding~6 for lines, and~4 for vectors;
365 the length of these sloped objects is still their horizontal component;
366 now, the slopes may be described with any signed fractional number not
367 exceeding $2^{30}-1$ in absolute value; it still is a limited number of
368 slopes, but their combinations are practically countless.
369 %
370 \item There is no restriction on the minimum length of lines and vectors.
371 %
372 \item Circles and dots can be drawn at any size, not at that dozen
373 or so finite sizes that were accepted with the original environment.
374 %
375 \item Ovals may be specified the corner curvature; the default
376 size of the quarter circles that make up the oval corners may be
377 specified; if no specification is given the radius of such corners
378 is the maximum that can fit into the oval; in practice it is
379 half the shortest value between the oval height and width.
380
381 \item The quadratic Bézier splines do not require the specification
382 of the number of dots that were used by the native environment to
383 draw “arbitrary” curves; now they are drawn with continuous curved
384 lines.
385 \end{enumerate}
386 Some new commands were added by \pack{pict2e}
387 \begin{enumerate}[noitemsep]
388
389 \item The third degree (cubic) Bézier splines are sort of new; certainly
390 now they are traced with continuous lines; if it is desired, it is
391 possible to replace the continuous line with a number of dots so as
392 to have a (unevenly) dotted curve. It suffices to specify the number
393 of dots the curve should be made with.
394
395 \item\cs{arc} and \cs{arc*} draw an arc or a filled circular sector,
396 with their centers at the axes origin; therefore they need to be put
397 in place somewhere else by means of the usual \cs{put} command.
398
399 \item The new command \cs{Line} traces a segment from one given point
400 to another point; it is very convenient to specify the end points
401 instead of the slope the line must have to go from the starting
402 to the ending point. The command does not require the \cs{put}
403 command to put the segment in place; nevertheless it can be shifted
404 somewhere else with \cs{put} if it becomes necessary.
405
406 \item The new command \cs{polyline} draws a sequence of connected
407 segments that form a piecewise linear “curve”; the way segments are
408 joined to one another depend from the “join” specifiers that
409 \pack{pict2e} has introduced; they will be described further on.
410
411 \item \cs{polygon} and \cs{polygon*} produce closed paths as it would
412 be possible when using \cs{polyline} and specifying its last point
413 coincident with its first one of that curve. If the asterisk is used
414 the closed path is filled with the default color.
415 \end{enumerate}
416
417 There were also the low level commands user interfaces to the various
418 drivers; these drivers really exist, but \pack{pict2e}
419 knows how to detect the correct language of the necessary driver;
420 the user is therefore allowed to pretend to ignore the existence
421 of such drivers, and s/he can simply use these low level commands; their
422 names are almost self explanatory.
423 \begin{enumerate}[noitemsep]
424 \item \cs{moveto} Sets the start of a line to an initial point.
425
426 \item \cs{lineto} traces a segment up to a specified point.
427
428 \item \cs{curveto} traces a third degree Bézier spline up to the third
429 specified point, while using the other two ones as control
430 points.\footnote{If these terms are unfamiliar, please, read the \pack{pict2e} documentation.}
431
432 \item \cs{circlearc} traces a circumference arc from the last line
433 point to a specified destination; its center, its angle amplitude, its
434 initial point are among the specified arguments, but the reader should
435 check on the \pack{pict2e} documentation for the details.
436
437 \item[]\mbox{\bfseries Warning!} Notice that these commands produce
438 just information to trace lines, but by themselves they do not trace
439 anything; in order to actually trace the curve or do other operations
440 with what has been done after the user finished describing the line to be
441 traced, the following low level commands must be used.
442
443 \item A \cs{closepath} is necessary if it is desired to
444 join the last position to the initial one. But if the last point
445 specified coincides with the very first one, a closed loop is
446 effectively already completed.
447
448 \item If a \cs{strokepath} command is used the line is drawn.
449
450 \item If a \cs{fillpath} command is used, the line loop is filled with
451 the current color. Notice, if the described line is not a closed loop,
452 this filling command acts as if the line first and last points were
453 joined by a straight line.
454
455 \end{enumerate}
456
457 While describing a line with the above low level commands, or with
458 the previous high level commands, lines and segments join and finish
459 as described hereafter; the following commands must be used before
460 actually tracing a specific line made up with several joined lines or
461 curves. Notice that their effect is just visible with lines as thin as
462 1\,pt, and very visible with thicker lines.
463 \begin{enumerate}[noitemsep]
464 \item \cs{buttcap} truncates each line with a sharp cut perpendicular
465 to the line axis exactly through the line end point (default).
466
467 \item \cs{roundcap} adds a semicircle to the very end of each line.
468
469 \item \cs{squarecap} adds a half square to the very end of each line.
470
471 \item \cs{miterjoin} joins two (generally straight) lines with a miter
472 (or mitre) joint; this means that the borders of the line are prolonged
473 until they meet; it is very nice when the junction angle is not far away
474 from, or is larger than $90^\circ$. Apparently for \pack{pict2e} this
475 type of joint is the default.
476
477 \item \cs{roundjoin} joins each (generally straight) line with
478 an arc on the external part of the bend; it is good in most
479 circumstances.
480
481 \item \cs{beveljoin} joins two (generally straight) lines with a miter
482 joint truncated with a sharp cut perpendicular to the bisector of the
483 lines axes; with acute angles it is better than the miter joint, but
484 when angles are very small, even this joint is not adequate.
485 \end{enumerate}
486
487 Notice that \cs{buttcap} is the default, but in general it might be
488 better to declare the \cs{roundcap} for the whole document.
489
490 We do not go further in the description of the new \pack{pict2e}
491 modified and new commands; the reader unfamiliar with programmable
492 drawing and the \pack{pic2e} extensions can consult that package
493 documentation. Actually all commands have been redefined or modified
494 by \pack{curve2e} in order to render them at least compatible with
495 both the cartesian and polar coordinates. In oder to have a better
496 understanding of these details, see figure~\ref{fig:joins}\footnote{The \cs{polyline} macro has the default join of type bevel; remember to specify a different join type if you want a different one.}.
497
498 \begin{figure}[!htb] \centering
499 \makebox[\textwidth]{\unitlength=0.009\textwidth
500 \begin{picture}(130,50)
501 \AutoGrid
502 \linethickness{4mm}
503 \buttcap\miterjoin
504 \put(10,10){\polyline[\miterjoin](0,0)(30,0)(30,30)
505 \put(0,-10){\makebox(30,10)[b]{\cs{buttcap},\cs{miterjoin}}}}
506 \roundcap\roundjoin
507 \put(50,10){\polyline[\roundjoin](0,0)(30,0)(30,30)
508 \put(0,-10){\makebox(30,10)[b]{\cs{roundcap},\cs{roundjoin}}}}
509 \squarecap\beveljoin
510 \put(90,10){\polyline(0,0)(30,0)(30,30)
511 \put(0,-10){\makebox(30,10)[b]{\cs{squarecap},\cs{beveljoin}}}}
512 \end{picture}}
513 \caption{Different caps and joins}\label{fig:joins}
514 \end{figure}
515
516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>>>
517 \section{\pack{curve2e} extensions}
518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
519 Again we do not enter into the details, because the user can read the
520 new user manual \file{curve2e-manual.pdf} simply by entering and
521 executing the \verb|texdoc curve2e-manual| command into a terminal or
522 command prompt window; this new manual is available with version~2.2.0
523 (or higher) of \pack{curve2e} and it contains the extensions and sample
524 codes for (simple) sample drawings; some examples are not so simple, but
525 show the power of this package upgrade.
526
527 The most important two changes are $(a)$ the choice of different
528 coordinates for addressing points on the drawing canvas, and $(b)$
529 the possibility of using macros to identify specific points.
530 As already mentioned, such changes have been applied also to most,
531 if not all\footnote{I assume I have upgraded all such commands; if not,
532 please, send me a bug notice; I will acknowledge your contribution.}
533 commands defined by \pack{pict2e}.
534
535 \pack{curve2e} defines a lot of operations the user can do with
536 the point coordinates; this is done by assuming they are complex
537 numbers, or vectors, or roto\-amplification operators, and making
538 with such entities a lot of actions compatible with their “incarnation".
539 For example multiplying a vector by a roto\`amplification operator,
540 in spite the fact that internally they are both represented by ordered
541 pairs of (generally) fractional numbers, means simply obtaining a new
542 vector rotated and scaled with respect to the original one; the point
543 addressed by the first vector, becomes another point in a different
544 precise position.
545
546 Below you see several examples of usage of such commands; but here space
547 will be saved if a short list is made concerning these “complex number”
548 operations.
549
550 Remember the double nature of such complex numbers:
551 \[
552 z = x + \iu y = m\eu^{\iu \phi}
553 \]
554 therefore addition and subtraction are simply done with
555 \[
556 z_1 \pm z_2 = x_1 \pm x_2 +\iu (y_1 \pm y_2)
557 \]
558 Multiplications and divisions are simply done with
559 \begin{align*}
560 z_1 z_2 &=( m_1 m_2) \eu^{\iu(\phi_1 + \phi_2)} \\
561 z_1/z_2 &=( m_1/m_2) \eu^{\iu(\phi_1 - \phi_2)}
562 \end{align*}
563 Squares and square roots\footnote{The square root of a complex number
564 has two complex values; here we do not go into the details on how
565 \pack{curve2e} choses which value. In practice, the
566 \pack{curve2e} macros that use square roots, work mostly on scalars to
567 find magnitudes that are always positive.} are simply done with:
568 \begin{align*}
569 z^2 &= m^2\eu^{\iu 2\phi}\\
570 \sqrt{z} &= \sqrt{m}\eu^{\iu\phi/2}
571 \end{align*}
572 The complex conjugate of a complex number is shown with a superscript
573 asterisk:
574 \[\text{if } z= x+\iu y \text{ then } z^\star = x- \iu y\]
575 and from these simple formal rules many results can be obtained;
576 and therefore several macros have been defined.
577
578 But let us summarise. Here is a short list with a minimum of
579 explanation of the commands functionalities introduced by
580 \pack{curve2e}. The user notices that many commands rely on
581 a delimited argument command syntax; the first arguments can
582 generally be introduced with point macros, as well as numerical
583 coordinates (no matter if cartesian or polar ones) while
584 the output(s) should always be in form of point macro(s). Parentheses
585 for delimiting the ordered pairs or the point macros are seldom
586 required. On the other side, the variety of multiple optional
587 arguments, sometimes requires the use of different delimiters,
588 most often than not the signs~\texttt{<~>}, in addition to the
589 usual brackets. These syntax functionalities are available with the
590 \pack{xparse} and \pack{xfp} packages, that render the language~L3
591 very useful and effective.
592
593 Handling of complex numbers is done with the following commands.
594 New commands to draw special objects, are also described.
595 \begin{enumerate}[noitemsep]
596 %
597 \item Cartesian and polar coordinates; they are distinguished by
598 their separator; cartesian coordinates are the usual comma separated
599 pair \meta{$x,y$}; polar coordinates are specified with a colon
600 separated pair \meta{$\theta{:}\,\rho$}. In general they are
601 specified within parentheses, but some commands require them without
602 any parenthesis. In what follows a generic math symbol, such as for
603 example $P_1$, is used to indicate a complex number that addresses
604 a particular point, irrespective of the chosen coordinate type,
605 or a macro defined to contain those coordinates.
606
607 \item The complex number/vector operations already available with
608 \pack{curve2e} are the following; we specify “macro” because in general
609 macros are used, instead of explicit numerical values, but for input
610 vector macros it is possible to use the comma or colon separated ordered
611 pair; “versor” means “unit vector”; angles are always expressed in
612 degrees; output quantities are everything that follows the key word
613 \texttt{to}; output quantities are always supposed to be in the form
614 of control sequences.
615 \begin{itemize}\setfontsize{9.5}
616 \item \cs{MakeVectorFrom}\meta{number,number}\texttt{to}\meta{vector macro}
617 \item \cs{CopyVect}\meta{vector macro} \texttt{to}\meta{vector macro}
618 \item \cs{ModOfVect}\meta{vector macro} \texttt{to}\meta{modulus macro}
619 \item \cs{DirOfVect}\meta{vector macro} \texttt{to}\meta{versor macro}
620 \item \cs{ModAndDirOfVect}\meta{vector macro} \texttt{to}\meta{modulus macro} \texttt{and}\meta{versor macro}
621 \item \cs{ModAndAngleOfVect}\meta{vector macro} \texttt{to}\meta{modulus macro} \texttt{and}\meta{angle macro}
622 \item {\setfontsize{8.75}\cs{DistanceAndDirOfVect}\meta{$P_1$}
623 \texttt{minus}\meta{$P_2$} \texttt{to}\meta{distance macro}
624 \texttt{and}\meta{versor macro}}
625 \item \cs{XpartOfVect}\meta{vector macro} \texttt{to}\meta{numerical macro}
626 \item \cs{YpartOfVect}\meta{vector macro} \texttt{to}\meta{numerical macro}
627 \item \cs{DirFromAngle}\meta{angle macro} \texttt{to}\meta{versor macro}
628 \item \cs{ArgOfVect}\meta{vector macro} \texttt{to}\meta{angle macro}
629 \item \cs{ScaleVect}\meta{vector macro} \texttt{by}\meta{scale factor}
630 \texttt{to}\meta{vector macro}
631 \item \cs{ConjVect}\meta{vector macro} \texttt{to}\meta{conjugate vector macro}
632 \item \cs{SubVect}\meta{subtrahend vector} \texttt{from}\meta{minuend vector} \texttt{to}\meta{vector macro}
633 \item \cs{AddVect}\meta{1st vector} \texttt{and}\meta{2nd vector} \texttt{to}\meta{vector macro}
634 \item \cs{Multvect}\marg{1st vector}\meta{$\star$}\marg{2nd vector}\meta{$
635 \star$}\meta{output vector macro}\newline the asterisks are optional;
636 either one changes the \meta{2nd vector} into its complex conjugate
637 \item \cs{MultVect}\meta{1st vector}\meta{$\star$}\meta{2nd vector}
638 \texttt{to}\meta{vector macro}\newline discouraged; maintained for backward compatibility; the only optional asterisk changes the \meta{2nd vector} into its complex conjugate
639 \item \cs{Divvect}\marg{dividend vector}\marg{divisor vector}\marg{output
640 vector macro}
641 \item \cs{DivVect}\meta{dividend vector} \texttt{by}\meta{divisor vector}
642 \texttt{to}\meta{vector macro}\newline maintained for backwards
643 compatibility.
644 \end{itemize}
645
646 \item A new command \cs{segment}\parg{$P_1$}\parg{$P_2$} draws a line that
647 joins the specified points.
648
649 \item Command \cs{Dashline}\parg{$P_1$}\parg{$P_2$}\marg{dash and gap length}
650 draws a dashed line between the specified points; the
651 \meta{dash length} is specified as a coefficient of
652 \cs{unitlenth} so it is proportioned to the diagram scale. The gap
653 between dashes is just as wide as the dashes; they are recomputed by
654 the command in order to slightly adjust the \meta{dash and gap length} so
655 that the line starts at point $P_1$ with a dash, and ends at $P_2$
656 again with a dash.
657
658 \item Command \cs{Dotline}\parg{$P_1$}\parg{$P_2$}\marg{gap}\oarg{diameter}
659 traces a dotted line between the specified points with dots \meta{gap}
660 units apart, starting and ending with a dot at the specified points.
661 Optionally the absolute diameter of the dots may be specified: a
662 diameter of 1\,pt (default) is visible, but it might be too small;
663 a diameter of 1\,mm is really very black, and may be too large; if
664 the diameter is specified without dimensions they are assumed by
665 default to be typographic points.
666
667 \item Command \cs{polyline}, \cs{polygon} and \cs{polygon*} are redefined
668 to accept both coordinate kinds.
669
670 \item Commands \cs{VECTOR}\parg{$P_1$}\parg{$P_2$} and \cs{VVECTOR}, with the same syntax, draw vectors with one arrow tip at the end, or arrow tips at both ends respectively.
671
672 \item New commands \cs{Arc}\parg{center}\parg{start}\marg{angle} and,
673 with the same syntax, \cs{VectorArc} and \cs{VectorARC} draw
674 arcs with the specified \meta{center},
675 starting at point \meta{start}, with an aperture of \meta{angle}
676 degrees (not radians). \cs{Arc} draws the arc without arrow tips;
677 \cs{VectorArc} draws the arc with one arrow tip at the end point;
678 \cs{VectorARC} draws an arc with arrow tips at both ends. \cs{VVectorArc} is an alias of \cs{VectorARC}.
679
680 \item Command \cs{multiput} has been redefined to accept optional
681 arguments, besides the use of coordinates of both kinds. The new syntax
682 is the following:
683 \begin{ttsyntax}[\setfontsize{10.5}]
684 \cs{multiput}\oarg{shift}\parg{origin}\parg{step}\marg{number}\marg{object}\oarg{handler}
685 \end{ttsyntax}
686 where, if you neglect the first and the last (optional) arguments,
687 you have the original syntax; the \meta{origin} point is where the
688 first \meta{object} is placed; \meta{step} is the displacement of a
689 new \meta{object} relative to the previous one; \meta{number} is the
690 total number of \meta{object}s put in place by the command; it is
691 possible to specify the number trough an integer expression computed
692 with the \cs{inteval} function of the L3~language, accessed through
693 the \pack{xfp} package functionalities already included into the
694 \LaTeX kernel. The new features are \meta{shift}, that is used to
695 displace the whole drawing somewhere else (in case some fine tuning is
696 required), and \meta{handler}; the latter is a powerful means to control
697 both the object to be set in place and its position; further on there
698 will be examples that show that the object can be put not only on
699 straight paths, but also un other curves, including parabolas, circles,
700 and other shapes.
701
702 \item Another version of repetitive commands \cs{xmultiput} is very
703 similar to \cs{multiput} but the iterations are controlled in a
704 different way so that it is possible also to draw continuous
705 curves describing analytical functions even with parametric
706 equations. Further on there will be some examples.
707
708 \item The \pack{xfp} package is preloaded because not all functionalities have been made available in the \LaTeX\ kernel; among such functionalities two two are very important, i.e. the L3 “functions”, \cs{fpeval} and \cs{inteval}; the latter executes expressions on integer numbers containing the usual
709 operators \texttt{+, -, *, /}; the division quotient is rounded to the
710 nearest (positive or negative) integer. The former operates with real
711 fractional numbers and, in addition to the usual arithmetical operators
712 as \cs{inteval}, it can use many mathematical functions, from square
713 roots, to exponentials, logarithms, trigonometric and hyperbolic direct
714 and inverse functions\footnote{The implementation of inverse hyperbolic
715 functions at the moment is on the L3~Team “to do” list.}, plus other
716 ones. Normally fractional numbers are operated on decimal strings, with
717 16 fractional places, and 14 integer places but the L3~functions accept
718 also scientific notation. The user can specify truncation or rounding to
719 a specified number of digits. Such integer and fractional mathematical
720 operations are already integrated in most computations performed by
721 \pack{curve2e}.
722
723 \item \pack{curve2e} provides three more L3 functions: \cs{fptest}, \cs{fpwhiledo}, and \cs{fpdowhile} with the following syntax:
724 \begin{ttsyntax}
725 \cs{fptest}\marg{test}\marg{true}\marg{false}
726 \cs{fpdowhile}\marg{test}\marg{actions}
727 \cs{fowhiledo}\marg{test}\marg{actions}
728 \end{ttsyntax}
729 For all these macros the \meta{test} is a logical L3~expression; its
730 operands are logical constants, logical values, logical numeric
731 comparisons; its operators are the typical \texttt{||}, \texttt{\&\&},
732 and \texttt{!}, respectively for OR, AND, and NOT. The logical numerical
733 comparisons are mathematical constants or expressions connected with
734 relation operators, such as \texttt{>, =, <}; such operators may be
735 negated with the NOT operator; therefore, for example, \texttt{!>} means
736 “not greater than”, therefore “lower or equal to”; such operators may be
737 coupled, for example \texttt{>=} makes a valid comparison and it is equal
738 to \texttt{!<}.
739
740 \item The above tests are very useful to control both \cs{fptest} and
741 \cs{fpdowhile} and \cs{fpwhiledo}. The logical \meta{test} result lets
742 \cs{fptest} execute only the \meta{true} or the \meta{false} code.
743 Before using \cs{fpdowhile} or \cs{fpwhiledo} the \meta{test} expression
744 must be initialised to be \texttt{true}; the \meta{actions} should
745 contain some code to be iteratively executed, but they must contain some
746 assignments, typically a change in an iteration counter, such that
747 eventually the \meta{test} logical expression becomes \texttt{false}.
748 Lacking this assignments, the loop continues to infinity, or better,
749 until a fatal error message is issued that informs that the program
750 working memory is exhausted.
751
752 \item
753 The difference between \cs{fpdowhile} and \cs{fpwhiledo} is the order
754 in which the \meta{test} and the first\meta{action} are executed; in
755 facts \cs{fpdowhile} first does the \meta{action} then the \meta{test},
756 while \cs{fpwhiledo} first executes the \meta{test} then the
757 \meta{action}.
758 Since the modification of the test logical value is done by the commands
759 contained in the \meta{actions} this switching of the \meta{test} and
760 \meta{action} produces different results. By adjusting the \meta{test} it
761 is possible to get the same results, but the expressiveness of the
762 \meta{test} may be easier to understand in one way rather than the other.
763 Some of the examples show such different \meta{test} syntaxes.
764
765 \item Such new commands are already used to code the \cs{multiput} and
766 \cs{xmultiput} commands, but they are available also to the user who can
767 operate in a very advanced way; further on, some examples will show
768 certain advanced drawings.
769
770 \item General curves can be drawn by \pack{pic2e} command \cs{curve}
771 that is sort of difficult to use, because the user has to specify
772 also the control points of the third order Bézier splines. Some other
773 new commands are available with \pack{curve2e}, that are supposed
774 to be easier to use; they are described in the following items.
775
776 \item The new command \cs{Curve} joins a sequence of third order
777 splines by simply specifying the node-direction coordinates; i.e. at the
778 junction of two consecutive splines, in an interpolation node the
779 final previous spline tangent has the same direction as that
780 at the second spline first node; if a change of direction is required, an
781 optional new direction can be specified. Therefore this triplet of
782 information has the following syntax:
783 \begin{center}
784 \parg{node}\aarg{direction}\oarg{new direction}
785 \end{center}
786 Evidently the \meta{new direction} is specified only for the nodes
787 that correspond to a cusp. A variation of the command arguments is
788 available by optionally specifying the “looseness” of the curve:
789 \begin{center}
790 \parg{node}\aarg{direction\texttt{;}start\texttt{,}end}\oarg{\dots}
791 \end{center}
792 where \meta{start} is the spline starting “looseness” and \meta{end}
793 is the spline ending one. These (generally different) values
794 are an index of how far the control point is from the adjacent node.
795 With this functionality the user has a very good control on the curve
796 shape and curvature. The optional new direction at a cusp point has the
797 sane extended syntax
798
799 \item A similar command \cs{Qurve} works almost the same way, but it
800 traces a quadratic Bézier spline; this one is specified only with two
801 nodes an a single control point, therefore is less configurable than
802 cubic splines; the same final line may require several quadratic splines
803 when just a single cubic spline might do the same job. Notice also that
804 quadratic splines are just parabolic arcs, therefore without inflection
805 points, while a cubic spline can have one inflexion point.
806
807 \item A further advanced variation is obtained with the new
808 \cs{CurveBetween} command that creates a single cubic spline between two
809 given points with the following syntax:
810 \begin{flushleft}
811 \cs{CurveBetween}\meta{node1} \texttt{And}\meta{node2} \texttt{WithDirs}\meta{dir1}
812 \texttt{And}\meta{dir2}
813 \end{flushleft}
814
815 \item A similar variant command is defined with the following syntax:
816 \begin{flushleft}\ttfamily
817 \cs{CbezierBetween}\meta{node1} And\meta{node2} WithDirs\meta{dir1}
818 And\meta{dir2}\\
819 \qquad UsingDists\meta{dist1} And\meta{dist2}
820 \end{flushleft}
821 Usage examples are shown in section~\ref{sec:examples}
822 \end{enumerate}
823
824
825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826 \section{ Euclidean geometry commands}
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 %%%% In questa sezione ci vorrebbero esempi per ogni singolocomando!!!
829
830 With the already large available power of \pack{curve2e} there was a push
831 towards specialised applications; the first of which was, evidently,
832 geometry; that kind of geometry that was used in the ancient times when
833 mathematicians did not have available the sophisticated means they
834 have today; they did not even have a positional numerical notation, that
835 arrived in the “western world” we are familiar with, just by
836 the XI-XII century; before replacing the roman numbering system, another
837 couple of centuries passed by; real numbers with the notation we use
838 today with a decimal separator, had to wait till the XVI century (at
839 least); many things that naw are taught in elementary school were
840 still a sort of magic until the end of XVIII century.
841
842 Even a simple algebraic second degree equation was a problem.
843 In facts the Renaissance was the artistic period when the classical
844 proportions were brought back to the artists who could not solve the
845 simple equation where a segment of unit length is divided in two
846 unequal parts $x$ and $1-x$ such that the following proportion exists
847 among the various parts and the whole segment:
848 \[
849 \frac{x}{1} = \frac{1-x}{x} \Longrightarrow x = \frac{1}{x} - 1
850 \]
851 today we cam solve the problem by manipulating that simple proportion
852 to get
853 \[
854 x^2 + x -1 = 0
855 \]
856 and we know that the equation has two solution of opposite signs, and
857 that their magnitudes are the reciprocal of one another. Since we are
858 interested in their magnitudes, we adapt the solutions in the form
859 \begin{equation}
860 x_{1,2} = \frac{\sqrt{5} \pm 1}{2}= \sqrt{1+0.5^2}\pm 0.5 \Longrightarrow
861 \begin{cases}x_1=1.618\ldots\\x_2=0.618\ldots \end{cases}\label{equ:aureo}
862 \end{equation}
863 The larger number is called the \emph{golden number} and the smaller
864 one the \emph{golden section}.
865
866 Luca Pacioli, by the turn of centuries XV–XVI, was the tutor of
867 Guidu\-baldo, the son and heir of Federico di Montefeltro, Duke of
868 Urbino\footnote{If you never visited this Renaissance city and its Ducal
869 Palace, consider visiting it; it is one of the many UNESCO Heritage
870 places.}; he wrote the famous book \emph{De Diuina Proportione} that
871 contained also the theory of the golden section accompanied by beautiful
872 drawings of many Platonic solids and other non convex ones, drawn by
873 Leonardo da Vinci. Everything was executed with perfect etchings, even
874 the construction of the golden section; in its basic form\footnote{The
875 third formula in equation~\eqref{equ:aureo} is written in such a way as
876 to explain the graphical construction in figure~\ref{fig:aureo}.} it is
877 reproduced in figure~\ref{fig:aureo}.
878 \begin{figure}
879 \begin{Esempio}[\setfontsize{7}](0.40)
880 \unitlength=0.005\linewidth
881 \begin{picture}(170,140)(0,-70)
882 \AutoGrid
883 \VECTOR(0,0)(170,0)
884 \Pbox(170,0)[t]{x}[0]
885 \Pbox(100,0)[t]{\mathrm{1}}[2]
886 \Pbox(0,0)[r]{O}[2]
887 \Arc(100,0)(50,0){-90}
888 \segment(100,0)(100,70)
889 \segment(0,0)(100,50)
890 \Pbox(50,0)[tr]{\mathrm{0.5}}[2]
891 \ModAndAngleOfVect100,50 to\M and\A
892 \Arc(0,0)(\M,0){\A}\Pbox(\M,0)[bl]{C}[2]
893 \Arc(\M,0)(\M,-50){90}
894 \Arc(\M,0)(\M,-50){-90}
895 \Pbox(\fpeval{\M-50},0)[b]{\mathit{x_2}}[3]
896 \Pbox(\fpeval{\M+50},0)[b]{\mathit{x_1}}[3]
897 \put(\M,0){\Vector(-70:50)}
898 \Pbox(120,-25)[bl]{\mathit{r}=\mathrm{0.5}}[0]
899 \thicklines
900 \segment(0,0)(100,0)
901 \end{picture}
902 \end{Esempio}
903 \caption{The golden section $x_2$ and the golden number $x_1$}\label{fig:aureo}
904 \end{figure}
905
906 By the way figure~\ref{fig:aureo} shows also the code that is used
907 for the drawing done completely with the facilities available just with \pack{curve2e}. It is also a usage example of several commands.
908
909 Illiteracy was very widespread; books were expensive and were
910 common just in the wealthy people mansions.
911
912 Mathematicians in the classical times B.C. up to the artists in the
913 Renaissance, had no other means but to use geometrical constructions with
914 ruler and compass. Even today in schools where calculus is not yet
915 taught as a normal subject, possibly not in certain high school degree
916 courses, but certainly not in elementary and junior high schools, the
917 instructors have to recourse to geometrical constructions. Sometimes, as
918 in Italy, access to public universities is open with no restrictions to
919 all students with a high school diploma for degree courses that are
920 more vocational than cultural. Therefore such students in some university
921 degree courses have to frequent upgrading courses in order to master some
922 more mathematics compared to what they studied during their basic
923 education.
924
925 The instructors nowadays very often prepare some booklets with their
926 lessons; such documents, especially in electronic form, are a good help
927 for many students. And \LaTeX is used to write such documents.
928 Therefore this extension module is mostly dedicated to such instructors.
929
930 The contents of this module is not exhaustive; it just shows a way to
931 use the \pack{curve2e} facilities to extend it to be suited for the
932 kind of geometry they teach.
933
934 Here we describe the new commands provided by this package; then in
935 section~\ref{sec:examples} we show their usage by means of examples.
936
937 \begin{enumerate}[noitemsep]
938 %
939 \item Command \cs{polyvector} is simple extension of the \cs{polyline} command introduced by \pack{pict2e}: its syntax is identical to that of \cs{polyline}; it draws a polyline with an arrow tip at the last segment; it turns out to be very handy while drawing block diagrams. See figure~\ref{fig:vectors}.
940 %
941 \item Command \cs{IntersectionOfLines} is a fundamental one; its syntax is
942 the following:
943 \begin{ttsyntax}\setfontsize{9.5}%
944 \cs{IntersecionOfLines}\parg{point1}\parg{dir1} and\parg{point2}\parg{dir2} to\meta{vector}
945 \end{ttsyntax}
946 were each line is identified with its \meta{point} and its \emph{direction}; \meta{vector} is the complex number that identifies the coordinates of the intersection point; the intersection coordinates go to the output \meta{vector}.
947
948 \begin{Esempio}[\normalsize](0.40)
949 \unitlength=0.01\linewidth
950 \begin{picture}(100,30)
951 \AutoGrid
952 \Dashline(0,0)(100,30){2}
953 \Dashline(100,0)(0,30){2}
954 \IntersectionOfLines%
955 (0,0)(10,3)and%
956 (100,0)(-10,3)to\P
957 \Pbox(\P)[b]{P}[3]
958 \end{picture}
959 \end{Esempio}
960 %
961 \item A second command\cs{IntersectionOfSegments} does almost the same
962 work, but the coordinates of a segment end points define also its
963 direction, which is the argument of the difference of the terminal nodes
964 of each segment; the syntax therefore is the following:
965 \begin{ttsyntax}
966 \cs{IntersectionOfSegments}\parg{point11}\parg{point12}
967 \qquad and\parg{point21}\parg{point22}to\meta{intersection point}
968 \end{ttsyntax}
969 Again the intersection point coordinates go to the output \meta{intersection point}.
970 The first segment is between points 11 and 12, and, similarly, the second
971 segment is between points 21 and 22.
972 \begin{Esempio}[\normalsize](0.40)
973 \unitlength=0.01\linewidth
974 \begin{picture}(100,30)
975 \AutoGrid
976 \segment(0,0)(100,30)
977 \segment(0,30)(100,0)
978 \IntersectionOfSegments%
979 (0,0)(100,30)and%
980 (100,0)(0,30)to\P
981 \Pbox(\P)[b]{P}[3]
982 \end{picture}
983 \end{Esempio}
984 %
985 \item \label{item:CircleWithCenter}Another “intersection” command is
986 \cs{IntersectionsOfLine} to determine both intersections of a line
987 with a circle. The syntax is:
988 \begin{ttsyntax}
989 \cs{IntersectionsOfLine}\parg{point1}\parg{point2}
990 \qquad WithCircle\parg{center}\marg{radius}to\meta{int1} and\meta{int2}
991 \end{ttsyntax}
992 where \meta{point1} and \meta{point2} identify a segment joining such
993 points, and therefore a specific line with the segment direction
994 and passing through a given point; the segment should cross the circle;
995 this circle is identified with its
996 \meta{center} and \meta{radius}; the intersection points \meta{int1} and
997 \meta{int2} are the coordinates of the intersection points; if the line
998 and circle do not intersect, a warning message is issued, shown in the
999 console and written to the \file{.log} file; the intersection points are
1000 assigned the default values \texttt{0,0}, which evidently produce strange
1001 results in the output document, so as to remind the user to give a look
1002 to the \file{.log} file and to review his/her data.
1003 \begin{Esempio}[\normalsize](0.40)
1004 \unitlength=0.01\linewidth\raggedleft
1005 \begin{picture}(60,40)(-10,0)
1006 \AutoGrid
1007 \def\Radius{20}%
1008 \Circlewithcenter 20,20 radius\Radius
1009 \segment(10,0)(50,40)
1010 \IntersectionsOfLine(10,0)(50,40)%
1011 WithCircle(20,20)(20)%
1012 to\Pu and\Pd
1013 \Pbox(\Pu)[b]{P_1}[3]
1014 \Pbox(\Pd)[l]{P_2}[3]
1015 \end{picture}
1016 \end{Esempio}
1017 \medskip
1018 %
1019 \item It is difficult to numerically determine the coordinates of the
1020 intersection points of two circles; it becomes easier if one of the
1021 intersections is known; to this end, a macro to draw a circle with a
1022 given center and passing through a given point is handy:
1023 \begin{ttsyntax}
1024 \cs{CircleThrough}\meta{point}WithCenter\marg{center}
1025 \end{ttsyntax}
1026 draws such circumference.\\[1ex]
1027 \begin{Esempio}[\normalsize](0.40)
1028 \unitlength=0.01\linewidth\raggedleft
1029 \begin{picture}(60,40)
1030 \AutoGrid
1031 \CopyVect10,15to\P
1032 \Pbox(\P)[tr]{P}[2]
1033 \Pbox(30,20)[b]{C}[2]
1034 \def\Ce{30,20}\relax
1035 \CircleThrough\P WithCenter\Ce
1036 \end{picture}
1037 \end{Esempio}
1038 \medskip
1039 %
1040 \item With the above macro it becomes easy to draw two circumferences
1041 with different centers and passing through the same point; therefore
1042 it becomes easy to determine the other intersection point by means of the
1043 following macro:
1044 \begin{ttsyntax}
1045 \cs{Segment}\parg{endpoint1}\parg{endpoint2}SymmetricPointOf\meta{p1}
1046 to\meta{p2}
1047 \end{ttsyntax}
1048 The computation is simple, because the second intersection is the
1049 symmetrical point \meta{p2} of \meta{p1} with respect to the segment
1050 that joins the centers of the given circles intersecting one another
1051 in \meta{p1}.
1052 The following small example displays how to find point $P_2$ symmetrical to $P_1$ with respect to a given line.\\[1ex]
1053 \begin{Esempio}[\normalsize](0.40)
1054 \raggedleft\unitlength=0.01\linewidth
1055 \begin{picture}(60,30)
1056 \AutoGrid
1057 \segment(0,0)(60,30)
1058 \CopyVect40,5to\Pu
1059 \Segment(0,0)(60,30)%
1060 SymmetricPointOf\Pu to\Pd
1061 \Pbox(\Pu)[b]{P_1}[2]
1062 \Pbox(\Pd)[t]{P_2}[2]
1063 \end{picture}
1064 \end{Esempio}
1065 \medskip
1066 %
1067 \item It would be interesting to solve the same problem with help of
1068 the following macro relating to right triangles identified with their
1069 hypothenuse and one of its legs; the other leg is found by means of this
1070 macro:
1071 \begin{ttsyntax}
1072 \cs{LegFromHypothenuse}\meta{length1} AndOtherLeg\meta{length2}
1073 to\marg{length3}
1074 \end{ttsyntax}
1075 In facts, the intersection points of two circles define their common
1076 chord; this chord and the two circle centers define two isosceles
1077 triangles with the same base, the chord; therefore the segment joining
1078 the circle centers, coincides with the chord axis and divides each
1079 isosceles triangle in two right triangles, where the hypotenuse is one
1080 of two radii and the first leg is the distance from the chord middle
1081 point, intersection of the chord and the segment joining the circle
1082 centers; at this point the distance of the second point intersection
1083 from the chord middle point and the coordinates of the second
1084 intersection may be easily computed; of course this is a much clumsier
1085 way to determine the second intersection, but it is useful to solve this
1086 right triangle easy problem. See figure~\ref{fig:2circle-intersections}
1087 where such right triangle legs are used for several tasks.
1088 %
1089 \item Command \cs{ThreePointCircle} draws a circle that goes through three
1090 given points; the syntax is the following:
1091 \begin{ttsyntax}
1092 \cs{ThreePointCircle}\meta{$\star$}\parg{point1}\parg{point2}\parg{point3}
1093 \end{ttsyntax}
1094 A sub product of this macro is formed by the vector \cs{C} that contains
1095 the coordinates of the center of the circle, that might be useful even
1096 if the circle is not drawn; the optional asterisk, if present, does not
1097 draw the circle, but its center is available. See figure~\ref{fig:circumcenter}, where this construction has been used.
1098
1099 \item Alternatively
1100 \begin{ttsyntax}\setfontsize{9.65}%
1101 \cs{ThreePointCircleCenter}\parg{point1}\parg{point2}\parg{point3}to\meta{center vector}
1102 \end{ttsyntax}
1103 computes the three point circle center assigning its coordinates to
1104 \meta{center vector}.
1105 %
1106 \item Command \cs{CircleWithCenter} draws a circle given its center and it
1107 radius; in facts the syntax is the following:
1108 \begin{ttsyntax}
1109 \cs{CircleWithCenter}\meta{center} Radius\meta{Radius}
1110 \end{ttsyntax}
1111 This macro does not require the \cs{put} command to put the circle
1112 in place; it is very handy when the radius value is saved into a macro. %
1113 \item A similar macro \cs{Circlewithcenter} does almost the same; its
1114 syntax is the following:
1115 \begin{ttsyntax}
1116 \cs{Circlewithcenter}\meta{center} radius\meta{radius}
1117 \end{ttsyntax}
1118 Apparently these two commands do the same, but, no, they behave
1119 differently: in the former command the \meta{Radius} is a vector the
1120 modulus of which is computed and used as the radius; in the latter
1121 command the \meta{radius} is a scalar and (its magnitude) is directly
1122 used. See item~\ref{item:CircleWithCenter} of this enumeration where this
1123 command was used.
1124
1125 %
1126 \item The command with syntax:
1127 \begin{ttsyntax}
1128 \cs{AxisOf}\meta{point1} and\meta{point2} to \meta{point3} and\meta{point4}
1129 \end{ttsyntax}
1130 is used to determine the axis of a segment; the given
1131 segment is specified with its end points \meta{point1} and \meta{point2}
1132 and the axis is determined by point \meta{point3} and \meta{point4};
1133 actually \meta{point3} is the middle point of the given segment.\\[1ex]
1134 \begin{Esempio}[\normalsize](0.40)
1135 \raggedleft
1136 \unitlength=0.01\linewidth
1137 \begin{picture}(50,30)
1138 \AutoGrid
1139 \segment(10,0)(40,30)
1140 \AxisOf 10,0 and 40,30 to\Pu\Pd
1141 \Dashline(\Pu)(\Pd){1}
1142 \Pbox(10,0)[br]{P_1}[2]
1143 \Pbox(40,30)[tl]{P_2}[2]
1144 \Pbox(\Pu)[tl]{P_3}[2]
1145 \Pbox(\Pd)[t]{P_4}[2]
1146 \end{picture}
1147 \end{Esempio}
1148 \medskip
1149 %
1150 \item These two commands with syntax:
1151 \begin{ttsyntax}
1152 \cs{SegmentCenter}\parg{point1}\parg{point2}to\meta{center}
1153 \cs{MiddlePointOf}\parg{point1}\parg{point2}to\meta{center}
1154 \end{ttsyntax}
1155 determine just the middle point between two given points. They are
1156 totally equivalent, aliases to one another; sometimes it is more
1157 convenient to use a name, sometimes the other; it helps reading the
1158 code and maintaining it.
1159 %
1160 \item Given a triangle and a specific vertex, it is possible to determine
1161 the middle point of the opposite side; it is not very difficult, but it
1162 is very handy to have all the necessary elements to draw the median line.
1163 The simple syntax is the following:
1164 \begin{ttsyntax}
1165 \cs{TriangleMedianBase}\meta{vertex} on\meta{base1} and\meta{base2}
1166 \qquad to\meta{base middle point}
1167 \end{ttsyntax}
1168
1169 A similar command \cs{TriangleHeightBase} is used to determine the
1170 intersection of the height segment from one vertex to the opposite side;
1171 with triangles that have an obtuse angle, the height base might lay
1172 externally to one of the bases adjacent to such an angle. The syntax is
1173 the following
1174 \begin{ttsyntax}
1175 \cs{TriangleHeigthtBase}\meta{vertex} on\meta{base1} and\meta{base2} to\meta{height base}
1176 \end{ttsyntax}
1177
1178 Similarly there is the \cs{TriangleBisectorBase} macro with
1179 a similar syntax:
1180 \begin{ttsyntax}
1181 \cs{TriangleBisectorBase}\meta{vertex} on\meta{base1} and\meta{base2}
1182 \qquad to\meta{bisector base}
1183 \end{ttsyntax}
1184 See figure~\ref{fig:MHBlines} that contains all three special lines: the median (M) the height (H) and the bisector (B) lines.%%%%!!!!!!!!!
1185 %
1186 \item A triangle \emph{barycenter} is the point where its median lines
1187 intersect; command \cs{TriangleBarycenter} determines its coordinates
1188 with the following syntax.
1189 \begin{ttsyntax}
1190 \cs{TriangleBarycenter}\parg{vertex1}\parg{vertex2}\parg{vertex3} to\meta{barycenter}
1191 \end{ttsyntax}
1192 %
1193 \item A triangle \emph{orthocenter} is the point where its height lines
1194 intersect; command \cs{TriangleOrthocenter} determines its coordinates
1195 with the following syntax:
1196 \begin{ttsyntax}
1197 \cs{TriangleOrthocenter}\parg{vertex1}\parg{vertex2}\parg{vertex3} to\meta{orthocenter}
1198 \end{ttsyntax}
1199 %
1200 \item A triangle \emph{incenter} is the point where its bisector lines
1201 intersect; command \cs{TriangleIncenter} determines its coordinates
1202 with the following syntax:
1203 \begin{ttsyntax}
1204 \cs{TriangleIncenter}\parg{vertex1}\parg{vertex2}\parg{vertex3} to\meta{incenter}
1205 \end{ttsyntax}
1206 %
1207 \item The distance of a specified point from a given segment or line is
1208 computed with the following command
1209 \begin{ttsyntax}
1210 \cs{DistanceOfPoint}\meta{point} from\parg{point1}\parg{point2} to\meta{distance}
1211 \end{ttsyntax}
1212 where \meta{point} specifies the point and \meta{point1} and \meta{point2}
1213 identify two points on a segment or a line; \meta{distance} is a scalar
1214 value.
1215 %
1216 \item In a construction that will be examined in section~\ref{sec:examples}
1217 we need to determine an ellipse axis if the other axis and the focal
1218 distance are know; actually it solves the relation
1219 \begin{equation}a^2= b^2 +c^2\label{equ:axes-foci}\end{equation}
1220 that connects such three quantities; $a$ is always the largest of the
1221 three quantities; therefore the macro tests if the first entry is larger
1222 than the second one: if is is, it computes a Pytagorean difference,
1223 otherwise the user should pay attention to use as the first entry the
1224 smaller among $b$ and $c$, so as to compute a Pytagorean sum. The command
1225 is the following:
1226 \begin{ttsyntax}
1227 \cs{AxisFromAxisAndFocus}\meta{axis or focus} and\meta{focus or axis}
1228 \qquad to\meta{other axis or focus}
1229 \end{ttsyntax}
1230 The word “axis” stands for “semi axis length”; the word “focus" stands
1231 for “focal semi distance”; actually the macro works equally well with
1232 full lengths, instead of half lengths; it is important not to mix
1233 full and half lengths. Such lengths are expressed as factors of
1234 \cs{unitlength}, not as absolute values. This command is described
1235 again when dealing with the specific problem referred to at the
1236 beginning of this list item; the description is going to be more
1237 detailed and another macro is added to avoid possible errors.\\[1ex]
1238 \begin{Esempio}[\setfontsize{9.25}](0.40)
1239 \raggedleft\unitlength=0.01\linewidth
1240 \begin{picture}(80,60)(-40,-30)
1241 \AutoGrid
1242 \ellisse{40}{30}
1243 \CopyVect\fpeval{sqrt(700)},0to\Focus
1244 \segment(0,0)(0,30)
1245 \segment(0,0)(\Focus)
1246 \segment(\Focus)(0,30)
1247 \Pbox(0,0)[tr]{O}[2]
1248 \Pbox(\Focus)[t]{F}[2]
1249 \Pbox(0,15)[r]{b}[0pt]
1250 \Pbox(15,0)[t]{c}[0pt]
1251 \Pbox(14,14)[bl]{a}[0pt]
1252 \end{picture}
1253 \end{Esempio}
1254 \medskip
1255 %
1256 \item Given a segment, i.e. the coordinates of its end points, it is
1257 useful to have a macro that computes its length; at the same time it is
1258 useful to to compute its direction; this operation is not the same as to
1259 compute modulus and argument of a vector, but consists in computing such
1260 quantities from the difference of the vectors pointing to the segment
1261 end points. Possibly better names should be devised for such macros, for
1262 example \cs{DistanceBetweenPoints...} and \cs{AngleOf..} But I could not
1263 find anything really more expressive. These two macros are the
1264 following:
1265 \begin{ttsyntax}
1266 \cs{SegmentLength}\parg{point1}\parg{point2} to\meta{length}
1267 \cs{SegmentArg}\parg{point1}\parg{point2} to\meta{angle}
1268 \end{ttsyntax}
1269 The \meta{angle} is computed in the interval $-180^\circ < \phi \leq
1270 +180^\circ$; it represents the with respect to the positive real axis of
1271 the vector that goes from \meta{point1} to \meta{point2}, therefore the
1272 user must pay attention to the order s/he enters the end point
1273 coordinates.
1274 %
1275 \item The next command \cs{SymmetricalPointOf} is used to find the
1276 reflection of a specified point with respect to a fixed point; of course
1277 the latter is the middle point of the couple, but the unknown to be
1278 determined is not the center of a segment, but one of its end points.
1279 The syntax is the following: In a sense this macro completes the \cs{AxisOf} by finding the other extremity of the axis.
1280 \begin{ttsyntax}
1281 \cs{SymmetricalPointOf}\meta{point1} respect\meta{fixed} to\meta{point2}
1282 \end{ttsyntax}
1283 %
1284 \item Command \cs{RegPolygon} draws a regular polygon inscribed within
1285 a circle of given radius and center, with a specified number of sides;
1286 optional arguments allow to specify color and thickness of the sides,
1287 or the polygon interior color; this macro operates differently from the
1288 one for drawing ellipses, that draws simultaneously an ellipse with
1289 the border of a color and the interior of another one; with this macro
1290 the user who wants to achieve this effect must superimpose to polygons
1291 with different settings; but it would not be too difficult to arrange a
1292 new macro or to modify this one in order to get “bicolor” polygons.
1293 It is not necessary for the purpose of this package, therefore we
1294 let the user express his/her phantasy by creating other macros. The
1295 actual syntax is the following:
1296 \begin{ttsyntax}
1297 \cs{RegPolygon}\meta{$\star$}\parg{center}\marg{radius}\marg{sides}\oarg{angle}\aarg{settings}
1298 \end{ttsyntax}
1299 The initial optional asterisk specifies if the interior has to be
1300 coloured; if yes, the \meta{settings} refer to the color of the
1301 interior; if not, the \meta{settings} refer to the thickness and
1302 color of the sides; no \meta{settings} imply sides drawn with the
1303 default line thickness, generally the one corresponding to \cs{thinlines},
1304 and the default color (generally black) for the sides or the interior.
1305 By default the first vertex is set to an angle of $0^\circ$ with
1306 respect to the \meta{center}; the optional \meta{angle} modifies
1307 this value to what is necessary for a particular polygon. The
1308 \meta{center} itself is optional, in the sense that if it is not
1309 specified the center lays in the origin of the \env{picture} axes; if
1310 this argument is specified, the polygon center is displaced accordingly.
1311 The number of sides in theory may be very high, but it is not wise
1312 to exceed a couple of dozen sides; if the number of sides is too
1313 high, a polygon (completely contained in an A4 page) may become
1314 undistinguishable from a circumference.
1315 Some examples are shown in figures~\ref{fig:pentagon}
1316 and~\ref{fig:filled-pentagon}.
1317 %
1318 \item {\tolerance=3000 Several macros are dedicated to ellipses; their names are spelled
1319 in Italian, “ellisse”, because the name “ellipse” is already taken by
1320 other packages; with Italian command names there should be no
1321 interference with other packages, or the risk is reduced to
1322 a minimum. The various macros are \cs{ellisse}, \cs{Sellisse},
1323 \cs{Xellisse}, \cs{XSellisse}, \cs{EllisseConFuoco} \cs{EllisseSteiner};
1324 the last two control sequence names are aliased with the corresponding
1325 English ones \cs{EllipseWithFocus} and \cs{SteinerEllipse}. For the
1326 other four ones it is wise to avoid English names for the reasons
1327 explained above. After all the Italian and the English names are very
1328 similar and are pronounced almost identically.\par}
1329
1330 {\tolerance=3000 Actually \cs{ellisse} is practically a shorthand for
1331 \cs{Sellisse} because some optional arguments are already fixed, but the
1332 meaning of \cs{fillstroke} depends on the presence or absence of an
1333 initial asterisk; similarly \cs{Xellisse} is a sort of a shorthand for
1334 \cs{XSellisse}; in facts those commands, that contain an ‘S’ in their
1335 names, can optionally perform also the affine \emph{shear}
1336 transformation, while those without the ‘S’ do not execute such
1337 transformation. Figure~\ref{fig:shear} displays a normal ellipse with
1338 its bounding rectangle, and the same ellipse to which the shear affine
1339 transformation is applied; the labeled points represent the third order
1340 Bézier spline nodes and control points.\par}
1341 \begin{figure}[!htb]
1342 \dimendef\Wmp=2000 \Wmp=\dimexpr(\textwidth-\columnsep)/2\relax
1343 \begin{minipage}{\Wmp}\centering
1344 \unitlength=0.007\linewidth
1345 \begin{picture}(100,70)(-50,-35)
1346 \XSellisse(0,0){50}{25}*
1347 \end{picture}
1348 \end{minipage}
1349 \hfill
1350 \begin{minipage}{\Wmp}\centering
1351 \unitlength=0.007\linewidth
1352 \begin{picture}(100,70)(-50,-35)
1353 \XSellisse(0,0)<20>{50}{25}*
1354 \end{picture}
1355 \end{minipage}
1356 \caption{The effect of shearing an ellipse with its bounding rectangle}\label{fig:shear}
1357 \end{figure}
1358 %
1359 \item The syntax of those six commands are the following:
1360 \begin{ttsyntax}
1361 \cs{Sellisse}\meta{$\star$}\marg{semiaxis-h}\marg{semiaxis-v}\oarg{shear}
1362 \cs{ellisse}\meta{$\star$}\marg{semiaxis-h}\marg{semiaxis-v}
1363 \cs{XSellisse}\meta{$\star$}\parg{center}\oarg{angle}\%
1364 \qquad \aarg{shear}\marg{semiaxis-h}\marg{semiaxis-v}\meta{$\star$}\%
1365 \qquad \oarg{settings1}\oarg{settings2}
1366 \cs{Xellisse}\meta{$\star$}\parg{center}\oarg{angle}\marg{semiaxis-h}\%
1367 \qquad\marg{semiaxis-v}\oarg{settings1}\marg{settings2}
1368 \cs{EllipseWithFocus}\meta{$\star$}\parg{vertex1}\parg{vertex2}\parg{vertex3}\parg{focus}
1369 \cs{SteinerEllipse}\meta{$\star$}\parg{vertex1}\parg{vertex2}\parg{vertex3}\oarg{diameter}
1370 \end{ttsyntax}
1371 All require the semi axis lengths; the \meta{semiaxis-h} and
1372 \meta{semiaxis-v} refer to the semi axes before possible rotation by
1373 \meta{angle} degrees, and do not make assumptions on which axis is the
1374 larger one. The optional parameter \meta{shear} is the angle in degrees
1375 by which the vertical coordinate lines are slanted by effect of shearing.
1376 If \meta{shear}, that by default equals zero, is not set
1377 to another value, the asterisks of command \cs{Sellisse} and
1378 \cs{XSellisse} do not have any effect. Otherwise the asterisk of
1379 \cs{Sellisse} forces to draw the ellipse bounding box (rectangle before
1380 shearing, parallelogram after shearing) as shown together with some
1381 marked special points (the vertices, spline nodes and control points
1382 of the quarter circle or quarter ellipse Bézier splines) in
1383 figure~\ref{fig:shear}.
1384 For \cs{ellisse} the asterisk implies filling, instead of stroking the
1385 ellipse contour.
1386 The \meta{setting}~1 and~2 refer to the color filling and/or border
1387 color, and contour thickness, as already explained. For the
1388 \cs{EllipseWithFocus}, the \meta{focus} contains the coordinates
1389 of one of the two ellipse foci; such coordinates should point to
1390 some position \emph{inside} the triangle. The \cs{SteinerEllipse}
1391 requires less data, in the sense that such ellipse is unique; it
1392 is the ellipse internally tangent to the triangle at its side middle
1393 points. See detailed examples in the following section.
1394 %
1395 \end{enumerate}
1396
1397
1398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1399 \section{Examples}\label{sec:examples}
1400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1401 Here we can show some examples of the advanced \pack{curve2e} commands
1402 and of what can be done with this \pack{euclideangeometry} extension.
1403
1404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1405 \subsection{Straight and curved vectors}
1406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1407
1408 Figure~\ref{fig:vectors} shows some vectors and vector arcs with the
1409 code used to draw them; some points are described with cartesian
1410 coordinates and some with polar ones.
1411
1412 \begin{figure}[!htb]
1413 \begin{Esempio}[\setfontsize{8.5}](0.45)
1414 \unitlength=0.01\linewidth
1415 \begin{picture}(100,60)
1416 \AutoGrid
1417 \put(0,30){\vector(1,2){10}}
1418 \put(20,30){\Vector(10,20)}
1419 \VECTOR(40,30)(50,50)
1420 \VVECTOR(60,30)(70,60)
1421 \Arc(100,60)(100,40){-90}
1422 \VectorArc(0,0)(0:20){90}
1423 \VectorARC(100,0)(0:80){-90}
1424 \polyvector(30,0)(35,10)(55,20)(60,0)
1425 \end{picture}
1426 \end{Esempio}
1427 \caption{Some vectors and vector arcs}\label{fig:vectors}
1428 \end{figure}
1429
1430
1431 \begin{figure*}[!tb]
1432 \begin{Esempio}*[\setfontsize{10}](0.40)
1433 \centering
1434 \unitlength=0.006\linewidth\begin{picture}(120,90)
1435 %
1436 \RegPolygon(9,20){20}{6}<\linethickness{3pt}\color{red}>
1437 \RegPolygon(55,20){20}{7}[90]
1438 \RegPolygon(100,20){20}{8}[22.5]<\linethickness{0.5ex}\color{blue}>
1439 %
1440 \put(0,50){%
1441 \RegPolygon(9,20){20}{3}\RegPolygon(9,20){20}{3}[30]
1442 \RegPolygon(9,20){20}{3}[60]\RegPolygon(9,20){20}{3}[90]
1443 %
1444 \RegPolygon*(55,20){20}{4}<\color{green}>
1445 \RegPolygon(55,20){20}{4}<\linethickness{1ex}>
1446 %
1447 \RegPolygon*(100,20){20}{4}[45]<\color{orange}>
1448 \RegPolygon(100,20){20}{4}[45]<\linethickness{1ex}\color{blue}>
1449 }
1450 \end{picture}
1451 \end{Esempio}
1452 \caption{A variety of polygons and their codes}\label{fig:variety-of-polygons}
1453 \end{figure*}
1454
1455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1456 \subsection{Polygons}
1457 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1458 Figures~\ref{fig:pentagon} and~\ref{fig:filled-pentagon} display
1459 a normal and a color filled pentagon with their codes.
1460 Figure~\ref{fig:variety-of-polygons} shows a variety of polygons
1461 with their codes.
1462
1463 \begin{figure}[!htb]
1464 \begin{Esempio}[\setfontsize{10}](0.8)
1465 \unitlength=0.5mm
1466 \begin{picture}(40,32)(-20,-17)
1467 \polyline(90:20)(162:20)(234:20)(306:20)(378:20)(90:20)
1468 \end{picture}
1469 \end{Esempio}
1470 \caption{A normal polygon drawn with \cs{polyline}}
1471 \label{fig:pentagon}
1472 \end{figure}
1473
1474
1475 \begin{figure}[!htb]
1476 \begin{Esempio}[\setfontsize{10}](0.8)
1477 \unitlength=.5mm
1478 \begin{picture}(40,32)(-20,-20)
1479 \color{magenta}
1480 \polygon*(90:20)(162:20)(234:20)(306:20)(378:20)
1481 \end{picture}
1482 \end{Esempio}
1483 \caption{A filled polygon drawn with \cs{polygon}}
1484 \label{fig:filled-pentagon}
1485 \end{figure}
1486
1487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1488 \subsection{Dashed and dotted lines}
1489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1490 For dashed lines it is mandatory to specify the dash length, that
1491 is just as long as the gap between dashes. For dotted lines it is
1492 mandatory to specify the dot gap.
1493 For dotted lines it is also possible to specify the dot size;
1494 it can be specified with an explicit unit of measure, or, if no unit is
1495 specified, it is assumed to be “points”. The \cs{Dotline} takes care
1496 of transforming the implied or the explicit dimension in multiples of
1497 \cs{unitlength}. Figure~\ref{fig:DashDot} shows some examples with their
1498 codes.
1499
1500 \begin{figure}[!htb]
1501 \begin{Esempio}[\setfontsize{10}](0.45)
1502 \unitlength=0.02\linewidth
1503 \begin{picture}(40,40)
1504 \AutoGrid
1505 \Dashline(0,0)(40,10){4}
1506 \put(0,0){\circle*{1}}
1507 \Dashline(40,10)(0,25){4}
1508 \put(40,10){\circle*{1}}
1509 \Dashline(0,25)(20,40){4}
1510 \put(0,25){\circle*{1}}
1511 \put(20,40){\circle*{1}}
1512 \Dotline(0,0)(40,40){2}[2]
1513 \end{picture}
1514 \end{Esempio}
1515 \caption{Dashed and dotted lines}\label{fig:DashDot}
1516 \end{figure}
1517
1518
1519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1520 \subsection{Generic curves}
1521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1522 With the \cs{Curve} macro it is possible to make line art or filled shapes. The hearts drawn in figure~\ref{fig:hearts} show the same shape, the first just stroked and the second color filled.
1523
1524 \begin{figure}[!htb]
1525 \begin{Esempio}[\setfontsize{9}](0.65)
1526 \unitlength=8mm\relax
1527 \begin{picture}(5,5)
1528 \put(0,0){\framebox(5,5){}}\thicklines\roundcap
1529 \Curve(2.5,0)<0.1,1>(5,3.5)<0,1>%
1530 (4,5)<-1,0>(2.5,3.5)<-0.01,-1.2>[-0.01,1.2]%
1531 (1,5)<-1,0>(0,3.5)<0,-1>(2.5,0)<0.1,-1>
1532 \end{picture}
1533 \end{Esempio}
1534
1535 \vspace*{2\baselineskip}
1536
1537 \begin{Esempio}[\setfontsize{9}](0.65)
1538 \unitlength=8mm\relax
1539 \begin{picture}(5,5)
1540 \put(0,0){\framebox(5,5){}}\thicklines\roundcap
1541 \color{orange}\relax
1542 \Curve*(2.5,0)<0.1,1>(5,3.5)<0,1>%
1543 (4,5)<-1,0>(2.5,3.5)<-0.01,-1.2>[-0.01,1.2]%
1544 (1,5)<-1,0>(0,3.5)<0,-1>(2.5,0)<0.1,-1>
1545 \end{picture}
1546 \end{Esempio}
1547 \caption{A stroked and a filled heart shaped contour}
1548 \label{fig:hearts}
1549 \end{figure}
1550
1551 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1552 \subsection{The \cs{multiput} command}
1553 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1554
1555 The new \cs{multiput} and \cs{xmultiput} commands are extensions of the
1556 original \cs{multiput} macro; both are used to put a number of objects
1557 according to a discrete law; but they can produce surprising effects.
1558 Figure~\ref{fig:multiput} displays several examples. As it possible
1559 to see, the black dots are evenly distributed along the canvas diagonal;
1560 the green filled squares are along a sloping down line inclined by
1561 $15^\circ$ as specified by the polar coordinates of the \meta{increment};
1562 the blue filled triangles are distributed along a parabola; the red
1563 stroked diamonds are distributed along a half sine wave.\enlargethispage*{\baselineskip}
1564
1565 \noindent\begin{figure}[!htb]
1566 \begin{Esempio}[\setfontsize{8}](0.55)
1567 \unitlength=0.01\linewidth
1568 \begin{picture}(100,100)
1569 \AutoGrid
1570 \multiput(0,0)(10,10){11}{\circle*{2}}
1571 \color{blue!70!white}
1572 \multiput(0,0)(10,0){11}{%
1573 \RegPolygon*{2}{3}<\color{blue!70!white}>}%
1574 [\GetCoord(\R)\X\Y
1575 \edef\X{\fpeval{\X+10}}
1576 \edef\Y{\fpeval{(\X/10)**2}}
1577 \CopyVect\X,\Y to\R]
1578 \multiput(0,0)(10,1){11}{%
1579 \RegPolygon{2}{4}<\color{magenta}>}%
1580 [\GetCoord(\R)\X\Y
1581 \edef\X{\fpeval{\X+10}}
1582 \edef\Y{\fpeval{sind(\X*1.8)*100}}
1583 \CopyVect\X,\Y to\R]
1584 \multiput(50,50)(-15:5){11}{%
1585 \RegPolygon*{2}{4}[45]<\color{green!60!black}>}
1586 \end{picture}
1587 \end{Esempio}
1588 \caption{Some examples of the \meta{handler} optional argument}
1589 \label{fig:multiput}
1590 \end{figure}
1591
1592 Another interesting construction is a clock quadrant; this is shown
1593 in figure~\ref{fig:orologio}
1594
1595 \begin{figure}[!htb]
1596 \begin{Esempio}[\setfontsize{9.5}](0.525)
1597 \unitlength=0.0095\linewidth
1598 \begin{picture}(100,100)
1599 \AutoGrid
1600 \put(50,50){\thicklines\circle{100}}
1601 \xmultiput[50,50](60:35)(-30:1){12}%
1602 {\makebox(0,0){\circle*{2}}}%
1603 [\MultVect\R by\D to\R]%
1604 \xmultiput[50,50](60:40)(-30:1){12}%
1605 {\ArgOfVect\R to\Ang
1606 \rotatebox{\fpeval{\Ang-90}}%
1607 {\makebox(0,0)[b]{%
1608 \Roman{multicnt}}}}%
1609 [\Multvect{\R}{\D}\R]
1610 \thicklines\put(50,50){\circle*{4}}
1611 \put(50,50){\Vector(37.5:30)}
1612 \put(50,50){\Vector(180:33)}
1613 \end{picture}
1614 \end{Esempio}
1615 \caption{Usage example of the \texttt{\string\xmultiput} command}
1616 \label{fig:orologio}
1617 \end{figure}
1618
1619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1620 \subsection{Drawing mathematical functions}
1621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1622
1623 Figure~\ref{fig:iperbole} shows an equilateral hyperbola; since it
1624 has asymptotes, the drawing must be carefully done avoiding overflows,
1625 and parts of drawing out of the \env{picture} area. Nevertheless
1626 the possibility of describing mathematical functions in terms of L3
1627 functions (in spite of the same name, they are completely different
1628 things) makes it possible to exploit the \meta{settings} argument to
1629 do the job with \cs{xmultiput}.
1630
1631 \begin{figure*}[!tp]
1632 \begin{Esempio}[\setfontsize{9}](0.5)
1633 \unitlength=0.008\linewidth
1634 \begin{picture}(100,100)
1635 \AutoGrid
1636 \VECTOR(0,0)(100,0)\Pbox(100,0)[tr]{x}[0]
1637 \VECTOR(0,0)(0,100)\Pbox(0,100)[tr]{y}[0]
1638 \Pbox(0,0)[r]{O}[3pt]
1639 \thicklines
1640 \moveto(10,100)\countdef\I=2560 \I=11
1641 \xmultiput(0,0)(1,0){101}%
1642 {\lineto(\I,\fpeval{1000/\I})}%
1643 [\advance\I by1 \value{multicnt}=\I]
1644 \strokepath
1645 \end{picture}
1646 \end{Esempio}
1647 \caption{An equilateral hyperbola drawn with a thinly sampled piecewise
1648 continuous line}\label{fig:iperbole}
1649 \end{figure*}
1650
1651 A more complicated drawing can be done by expressing the function to draw
1652 with parametric equations; the idea is to code the math formulas
1653 \[\begin{cases}
1654 x(t) = f_1(t)\\
1655 y(t) = f_2(t)
1656 \end{cases}\]
1657 because it is easy to code the $x$ and the $y$ component and use the
1658 \cs{fpdowhile} command to trace the curve with a piecewise continuous
1659 line; actually a continuous line with a piecewise continuous derivative;
1660 it is important to sample the curve in a sufficiently dense way.
1661 A heart shaped mathematical function taken from the internet%
1662 \footnote{\url{http://mathworld.wolfram.com/HeartCurve.html} reports
1663 several formulas, including the cardioid, but the one we use here is
1664 a different function.} is the following
1665 \begin{align*}
1666 x(t) &= \sin^3(t)\\
1667 y(t) &= \dfrac{13\cos(t)-5\cos(2t)-2\cos(3t)-\cos(4t)}{16}
1668 \end{align*}
1669 Figure~\ref{fig:math-heart} displays the graph, and its code, and, most
1670 important, the L3 definition of the parametric equations. Compared to
1671 the previous equations we applied a scale factor and added the final
1672 term \texttt(2.4) in order to shift a little bit the drawing so as to
1673 vertically center it .
1674
1675 \begin{figure*}[!tbp]
1676 \begin{minipage}{\textwidth}
1677 \def\codefraction{0.5}
1678 \dimendef\Wuno=2000 \Wuno=\codefraction\textwidth
1679 \dimendef\Wdue=2002 \Wdue=\dimexpr\textwidth-\columnsep-\Wuno\relax
1680 \begin{minipage}{\Wuno}\setfontsize{6.9}%
1681 \begin{verbatim}
1682 % Parametric equations of the "heart"
1683 \providecommand\heart[3]{%
1684 \edef\X{\fpeval{#1*16*(sind(#2)^3)}}
1685 \edef\Y{\fpeval{#1*(13*cosd(#2) - 5*cosd(2*#2)
1686 - 2*cosd(3*#2) -cosd(4*#2)+2.4)}}
1687 \CopyVect\X,\Y to#3}
1688 %
1689 % Drawing
1690 \unitlength=0,005\linewidth
1691 \begin{picture}(200,200)(-100,-100)
1692 \AutoGrid
1693 \VECTOR(-100,0)(100,0)\Pbox(100,0)[tr]{x}[0]
1694 \VECTOR(0,-100)(0,100)\Pbox(0,100)[tl]{y}[0]
1695 \Pbox(0,0)[tr]{O}\linethickness{1pt}\bgroup
1696 \edef\scala{\fpeval{100/16}}
1697 \countdef\I=2560 \I=0\roundjoin
1698 \fpdowhile{\I !>360}{\heart\scala\I\Punto
1699 \ifnum\I=0 \moveto(\Punto)\else \lineto(\Punto)\fi
1700 \advance\I by 3}\strokepath\egroup
1701 \end{picture}\end{verbatim}
1702 \end{minipage}
1703 \hfill
1704 \begin{minipage}{\Wdue}\raggedleft
1705 \setfontsize{8}%
1706 %
1707 \providecommand\heart[3]{%
1708 \edef\X{\fpeval{#1*16*(sind(#2)^3)}}
1709 \edef\Y{\fpeval{#1*(13*cosd(#2) - 5*cosd(2*#2)
1710 - 2*cosd(3*#2) -cosd(4*#2)+2.4)}}
1711 \CopyVect\X,\Y to#3}
1712 %
1713 \unitlength=0,005\linewidth
1714 \begin{picture}(200,200)(-100,-100)
1715 \AutoGrid
1716 \VECTOR(-100,0)(100,0)\Pbox(100,0)[tr]{x}[0]
1717 \VECTOR(0,-100)(0,100)\Pbox(0,100)[tl]{y}[0]
1718 \Pbox(0,0)[tr]{O}\linethickness{1pt}\bgroup
1719 \edef\scala{\fpeval{100/16}}
1720 \countdef\I=2560 \I=0\roundjoin
1721 \fpdowhile{\I !>360}{\heart\scala\I\Punto
1722 \ifnum\I=0 \moveto(\Punto)\else \lineto(\Punto)\fi
1723 \advance\I by 3}\strokepath\egroup
1724 \end{picture}
1725 \end{minipage}
1726 \end{minipage}
1727 \caption{A heart shaped mathematical function drawn with a thinly sampled
1728 piecewise continuous line}\label{fig:math-heart}
1729 \end{figure*}
1730
1731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1732 \subsection{ Intersections involving circles}
1733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1734 Determining the intersection of two circles is difficult; algebraically it requires the solution of second degree equations whose coefficients are sort of complicated expressions of the centers and radii; furthermore such equations might not have real roots. The problems are much simpler even geometrically when one circle is intersected by a line, and when two circles share a common point. In the first case there are two intersections, possibly coincident, if the centers distance is shorter than the sum of their radii; in the second case its easy to determine the chord common to both circles and the problem of finding the second intersection becomes that of finding the second end point of the chord.
1735
1736 Figure~\ref{fig:circle-and-line} shows the simple geometrical construction that leads to the determination of the intersections; one of the lines is tangent to the circle and the intersection points $P_3$ and $P_4$ coincide.
1737
1738 \begin{figure}[!htb]
1739 \begin{Esempio}[\setfontsize{9}](0,40)
1740 \unitlength=0.007\linewidth
1741 \begin{picture}(100,100)
1742 \AutoGrid
1743 \IntersectionsOfLine(100,50)(0,20)%
1744 WithCircle(40,40){30}to\Puno and\Pdue
1745 \Pbox(\Puno)[tl]{P_1}[2]
1746 \Pbox(\Pdue)[t]{P_2}[2]
1747 \Dotline(\C)(\Pt){2}[1.5]
1748 \Dotline(\C)(\Pq){2}[1.5]
1749 \Pbox(\Int)[t]{M}[2]
1750 \Dotline(\C)(\Int){2}[1.5]
1751 %
1752 \IntersectionsOfLine(0,70)(100,70)%
1753 WithCircle(40,40){30}to\Ptre and\Pquat
1754 \Pbox(\Ptre)[bl]{P_3}[2]
1755 \Pbox(\Pquat)[br]{P_4}[2]
1756 \IntersectionsOfLine(0,40)(100,100)%
1757 WithCircle(40,40){30}to\Pcin and\Psei
1758 \Pbox(\Pcin)[br]{P_5}[2]
1759 \Pbox(\Psei)[t]{P_6}[2]
1760 \end{picture}
1761 \end{Esempio}
1762 \caption{Intersection of a circle with several lines}\label{fig:circle-and-line}
1763 \end{figure}
1764
1765 Figure~\ref{fig:two-intersecting-circles} shows the geometrical construction to determine the second intersection point $P_2$ of two circles that already have a first common point $P_1$. The common chord and the segment joining the centers are not shown, but the code, although with “strange” point names, shows all the steps necessary to find the second intersection point
1766
1767
1768 \begin{figure}[!htb]\centering
1769 \begin{Esempio}[\setfontsize{9}](0.40)
1770 \unitlength0.007\linewidth
1771 \begin{picture}(100,100)
1772 \AutoGrid
1773 \edef\PCCuno{30,40}
1774 \edef\PCCdue{70,60}
1775 \edef\PCCzero{40,55}
1776 \Pbox(\PCCuno)[t]{C_1}[2]
1777 \Pbox(\PCCdue)[t]{C_2}[2]
1778 \Pbox(\PCCzero)[l]{P_1}[2.5]
1779 \CircleThrough\PCCzero WithCenter\PCCuno
1780 \CircleThrough\PCCzero WithCenter\PCCdue
1781 \Segment(\PCCuno)(\PCCdue)%
1782 SymmetricPointOf\PCCzero to\PCCquat
1783 \Pbox(\PCCquat)[l]{P_2}[2.5]
1784 \end{picture}
1785 \end{Esempio}
1786 \caption{Second intersection point $P_2$ of two circles sharing a first intersection point $P_1$}\label{fig:two-intersecting-circles}
1787 \end{figure}
1788
1789 The following macro allows to determine both intersections, if they exist, of two generic circles; of course the macro is a little more complicated than the above macro that has to find the second intersection when one is already known. Even the reasoning behind the macro is quite different and slightly “creative”.
1790
1791 In facts the reasoning is to avoid any or most analytical computations; analytically it would be quite simple to set up a system of two second degree polynomial equations; after processing such a system it is necessary to solve a second degree equation, but in order to control if there are intersections it should be necessary to discuss the value and sign of the discriminant; it is nothing special when doing all this by hand, but it involves a complicated code in terms of the \LaTeX\ language.
1792
1793 It is much simpler to reason geometrically; imagine to draw two circles; let $a>0$ be the distance of their centers\footnote{If $a=0$ the circles are concentric and do not intersect.}, and let $R_1$ and $R_2$ be their radii. Then if
1794 \[
1795 |R_1 - R_2| \leq a \leq R_1 + R_2
1796 \]
1797 the intersections do exist, even if it is possible that the circles are tangent to one another and the two intersection points become a (double) one; this takes place when either ‘equals’ sign applies. If the left boundary is not satisfied the centers are too close to one another and the internal circle is too small compared to the external one. On the opposite if the upper bound is not satisfied the second circle is outside the first one and too far away.
1798
1799 The macro controls the above range, and if the the input data do not satisfy the range boundaries, there are no intersections: a warning message is issued, but computations go on with non sense values for both output coordinates; may be other errors are produced, but in any case the successive drawing lines will not be acceptable; a good sign to the user who may have not noticed the warning message in his/her console, but is immediately “forced” to consult this manual and find out this explanation; s/he will then review his/her code in oder to change the drawing data.
1800
1801 If the data cope with the above range, the computations go on along this simple reasoning, that it drawn in the left part of figure~\ref{fig;Intersections-of-two-circles}. There you see the segment that joins the two centers, and the intersection points to be found. They are the end points of the chord common to both circles; using as vertices the two centers and such chord as the base, two isosceles triangles are formed; the segment joining the centers bisects both triangles forming four right triangles where the hypotenuse is formed by the pertinent radius, and one leg is half the chord; with reference to the triangles $IC_1P_1$ and $IC_2P_1$, Pythagoras' theorem lets us determine the relation between the common leg $IP_1$ and the other triangle sides; this is the small analytical computation we have to execute, so as to compute the distance $c$ from the center $C_1$ and the common leg length $h$. These two values are sufficient, together with the direction of segment $C_1C_2$ to find the intersection points coordinates.
1802
1803 The syntax il the following
1804 \begin{ttsyntax}
1805 \cs{TwoCirclesIntersections}\parg{C1}\parg{C2}withradii\marg{R1} and\marg{R2} to\meta{P1} and\meta{P2}
1806 \end{ttsyntax}
1807 The symbols are self explanatory; as usual, input data (those entered before the keyword \texttt{to}) may be control sequences (defined with the necessary data), or explicit data; on the opposite the output ones must be control sequences.
1808
1809 \begin{figure}[!htb]
1810 \begin{minipage}{0.475\linewidth}
1811 \unitlength0.01\linewidth
1812 \begin{picture}(100,100)(-50,-50)
1813 \AutoGrid
1814 \VECTOR(-50,0)(50,0) \Pbox(50,0)[tr]{x}[0]
1815 \VECTOR(0,-50)(0,50) \Pbox(0,50)[l]{y}[0]
1816 \edef\Kuno{-10,-10}\edef\RKuno{30}%
1817 \edef\Kdue{20,10}\edef\RKdue{20}
1818 \thicklines
1819 \Circlewithcenter\Kuno radius\RKuno
1820 \Circlewithcenter\Kdue radius\RKdue
1821 \thinlines
1822 \TwoCirclesIntersections(\Kuno)(\Kdue)withradii\RKuno and\RKdue to\Puno and\Pdue
1823 \Pbox(\Kuno)[br]{C_1}[4] \Pbox(\Kdue)[bl]{C_2}[4]
1824 \Pbox(\Puno)[tl]{P_1}[4] \Pbox(\Pdue)[bc]{P_2}[4]
1825 \put(\Kuno){\Vector(-45:\RKuno)}\Pbox(5,-27)[bl]{R_1}[0]
1826 \put(\Kdue){\Vector(-45:\RKdue)}\Pbox(25, 3)[bl]{R_2}[0]
1827 \Pbox(\CI)[t]{I}[4]
1828 %
1829 \segment(\Kuno)(\Kdue)\segment(\Puno)(\Pdue)
1830 \segment(\Kuno)(\Pdue)\segment(\Kdue)(\Pdue)
1831 \segment(\Kuno)(\Puno)\segment(\Puno)(\Kdue)
1832 \end{picture}
1833 \end{minipage}
1834 \hfill
1835 \begin{minipage}{0.475\linewidth}
1836 \unitlength0.01\linewidth
1837 \begin{picture}(100,100)(-50,-50)
1838 \AutoGrid
1839 \VECTOR(-50,0)(50,0) \Pbox(50,0)[tr]{x}[0]
1840 \VECTOR(0,-50)(0,50) \Pbox(0,50)[l]{y}[0]
1841 \edef\Kuno{-10,-10}\edef\RKuno{30}%
1842 \edef\Kdue{20,10}\edef\RKdue{20}
1843 \thicklines
1844 \Circlewithcenter\Kuno radius\RKuno
1845 \Circlewithcenter\Kdue radius\RKdue
1846 \thinlines
1847 \TwoCirclesIntersections(\Kuno)(\Kdue)withradii\RKuno and\RKdue to\Puno and\Pdue
1848 \Pbox(\Kuno)[b]{C_1}[4] \Pbox(\Kdue)[b]{C_2}[4]
1849 \Pbox(\Puno)[tl]{P_1}[4] \Pbox(\Pdue)[b]{P_2}[4]
1850 \put(\Kuno){\Vector(-45:\RKuno)}\Pbox(5,-27)[bl]{R_1}[0]
1851 \put(\Kdue){\Vector(-45:\RKdue)}\Pbox(25,3)[bl]{R_2}[0]
1852 \end{picture}
1853 \end{minipage}
1854 \caption{Intersections of two generic circles}\label{fig;Intersections-of-two-circles}\label{fig:2circle-intersections}
1855 \end{figure}
1856
1857 The code for drawing figure~\ref{fig;Intersections-of-two-circles} is the following.
1858
1859 \begin{Verbatim}
1860 \begin{minipage}{0.475\linewidth}% Geometrical construction
1861 \unitlength0.01\linewidth
1862 \begin{picture}(100,100)(-50,-50)
1863 \AutoGrid
1864 \VECTOR(-50,0)(50,0) \Pbox(50,0)[tr]{x}[0]
1865 \VECTOR(0,-50)(0,50) \Pbox(0,50)[l]{y}[0]
1866 \edef\Kuno{-10,-10}\edef\RKuno{30}%
1867 \edef\Kdue{20,10}\edef\RKdue{20}
1868 \thicklines
1869 \Circlewithcenter\Kuno radius\RKuno
1870 \Circlewithcenter\Kdue radius\RKdue
1871 \thinlines
1872 \TwoCirclesIntersections(\Kuno)(\Kdue)withradii\RKuno
1873 and\RKdue to\Puno and\Pdue
1874 \Pbox(\Kuno)[br]{C_1}[4] \Pbox(\Kdue)[bl]{C_2}[4]
1875 \Pbox(\Puno)[tl]{P_1}[4] \Pbox(\Pdue)[bc]{P_2}[4]
1876 \put(\Kuno){\Vector(-45:\RKuno)}\Pbox(5,-27)[bl]{R_1}[0]
1877 \put(\Kdue){\Vector(-45:\RKdue)}\Pbox(25, 3)[bl]{R_2}[0]
1878 \Pbox(\CI)[t]{I}[4]
1879 %
1880 \segment(\Kuno)(\Kdue)\segment(\Puno)(\Pdue)
1881 \segment(\Kuno)(\Pdue)\segment(\Kdue)(\Pdue)
1882 \segment(\Kuno)(\Puno)\segment(\Puno)(\Kdue)
1883 \end{picture}
1884 \end{minipage}
1885 \hfill
1886 \begin{minipage}{0.475\linewidth}% Clean final result
1887 \unitlength0.01\linewidth
1888 \begin{picture}(100,100)(-50,-50)
1889 \AutoGrid
1890 \VECTOR(-50,0)(50,0) \Pbox(50,0)[tr]{x}[0]
1891 \VECTOR(0,-50)(0,50) \Pbox(0,50)[l]{y}[0]
1892 \edef\Kuno{-10,-10}\edef\RKuno{30}%
1893 \edef\Kdue{20,10}\edef\RKdue{20}
1894 \thicklines
1895 \Circlewithcenter\Kuno radius\RKuno
1896 \Circlewithcenter\Kdue radius\RKdue
1897 \thinlines
1898 \TwoCirclesIntersections(\Kuno)(\Kdue)withradii\RKuno
1899 and\RKdue to\Puno and\Pdue
1900 \Pbox(\Kuno)[b]{C_1}[4] \Pbox(\Kdue)[b]{C_2}[4]
1901 \Pbox(\Puno)[tl]{P_1}[4] \Pbox(\Pdue)[b]{P_2}[4]
1902 \put(\Kuno){\Vector(-45:\RKuno)}\Pbox(5,-27)[bl]{R_1}[0]
1903 \put(\Kdue){\Vector(-45:\RKdue)}\Pbox(25,3)[bl]{R_2}[0]
1904 \end{picture}
1905 \end{minipage}
1906 \end{Verbatim}
1907
1908
1909 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1910 \subsection{Triangles and their special lines}
1911 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1912
1913 Triangles have special lines; they are the median, the height, and the
1914 bisector lines. They join each vertex with a specific point of the
1915 apposite side, respectively with the middle point, the intersection
1916 with the side perpendicular line, and the intersection with the bisector
1917 line. Figure~\ref{fig:MHBlines} displays the construction of the three
1918 special lines relative to a specific vertex. Thanks to the macros
1919 described earlier in the preceding section, this drawing is particularly
1920 simple; most of the code is dedicated to labelling the various points and
1921 to assign coordinate values to the macros that are going to be used
1922 in a symbolic way. The generic triangle (not a regular polygon) requires
1923 one line of code, and the determination of the intersections of the lines
1924 with the suitable triangle side, and their tracing requires two code
1925 lines each.
1926
1927 \begin{figure}[!tb]\centering
1928 \begin{Esempio}[\setfontsize{6.9}](0.4)
1929 \unitlength=0.008\linewidth
1930 \begin{picture}(100,100)(0,-10)
1931 \AutoGrid
1932 \def\Puno{0,0} \def\Pdue{0,80} \def\Ptre{100,55}
1933 {\thicklines\polygon(\Puno)(\Pdue)(\Ptre)}%
1934 \Pbox(\Puno)[tc]{P_1}[2]
1935 \Pbox(\Pdue)[bc]{P_2}[2]\Pbox(\Ptre)[bc]{P_3}[2]
1936 % Median
1937 \TriangleMedianBase\Puno on \Pdue and \Ptre to\M
1938 \Pbox(\M)[bc]{M}[2]\segment(\Puno)(\M)
1939 % Height
1940 \TriangleHeightBase\Puno on \Pdue and\Ptre to\H
1941 \Dotline(\Puno)(\H){2}[1.5]\Pbox(\H)[bc]{H}[1.5]
1942 % Bisector
1943 \TriangleBisectorBase\Puno on\Pdue and\Ptre to\B
1944 \Dashline(\Puno)(\B){1.5}\Pbox(\B)[b]{B}[2]
1945 \end{picture}
1946 \end{Esempio}
1947 \caption{A triangle with the median, the height, and the bisector lines
1948 from a specific vertex}\label{fig:MHBlines}
1949 \end{figure}
1950
1951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1952 \subsection{Special triangle centers}
1953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1954 Three triangle special lines of the same kind intersect each
1955 other in a special point; the median lines intersect in the
1956 \emph{barycenter}, the height lines in the \emph{orthocenter}, the
1957 bisector lines in the \emph{incenter}; these centers may be those of
1958 special circles: see figures~\ref{fig:barycenter}
1959 to~\ref{fig:circumcenter}; the \emph{incircle}, centred in the incenter,
1960 has a special name, because it has the property of being tangent to all
1961 three triangle sides; there is also the circumcircle that passes
1962 through the three vertices, its center is the intersection of the
1963 three side axes.
1964 Figures~\ref{fig:barycenter}, \ref{fig:orthocenter}, \ref{fig:incenter},
1965 and~\ref{fig:circumcenter} display the necessary constructions and,
1966 possibly, also the special circles they are centers of. There is also the \emph{nine point circle}, figure~\ref{fig:9point-circle}. It is worth noting the alla centers fall inside the various triangles, except the orthocenter that falls outside when the triangle is obtuse.
1967
1968 \begin{figure}[!htb]
1969 \begin{Esempio}[\setfontsize{6.5}](0.45)
1970 \unitlength=0.008\linewidth
1971 \begin{picture}(100,100)(0,-10)
1972 \AutoGrid
1973 \def\Puno{0,0}\def\Pdue{0,80}\def\Ptre{100,55}
1974 {\linethickness{0.6pt}\polygon(\Puno)(\Pdue)(\Ptre)}%
1975 \Pbox(\Puno)[tl]{P_1}[1.5]%
1976 \Pbox(\Pdue)[bl]{P_2}[1.5]\Pbox(\Ptre)[bc]{P_3}[1.5]
1977 \TriangleMedianBase\Puno on\Pdue and \Ptre to\Mu
1978 \TriangleMedianBase\Pdue on\Ptre and \Puno to\Md
1979 \TriangleMedianBase\Ptre on\Puno and \Pdue to\Mt
1980 \Dotline(\Puno)(\Mu){3}[1.5]
1981 \Dotline(\Pdue)(\Md){3}[1.5]
1982 \Dotline(\Ptre)(\Mt){3}[1.5]
1983 \IntersectionOfSegments(\Puno)(\Mu)and(\Pdue)(\Md)to\C
1984 \Pbox(\C)[t]{B}[2]
1985 \end{picture}
1986 \end{Esempio}
1987 \caption{Determination of the barycenter}\label{fig:barycenter}
1988 \end{figure}
1989
1990 \begin{figure}[!htb]
1991 \begin{Esempio}[\setfontsize{6.5}](0.45)
1992 \unitlength=0.008\linewidth
1993 \begin{picture}(100,100)(0,-10)
1994 \AutoGrid
1995 \def\Puno{0,0}\def\Pdue{0,80}\def\Ptre{100,55}
1996 {\linethickness{0.6pt}\polygon(\Puno)(\Pdue)(\Ptre)}%
1997 \Pbox(\Puno)[tl]{P_1}[1.5]%
1998 \Pbox(\Pdue)[bl]{P_2}[1.5]\Pbox(\Ptre)[bc]{P_3}[1.5]
1999 \TriangleHeightBase\Puno on\Pdue and \Ptre to\Hu
2000 \TriangleHeightBase\Pdue on\Ptre and \Puno to\Hd
2001 \TriangleHeightBase\Ptre on\Puno and \Pdue to\Ht
2002 \Dotline(\Puno)(\Hu){3}[1.5]
2003 \Dotline(\Pdue)(\Hd){3}[1.5]
2004 \Dotline(\Ptre)(\Ht){3}[1.5]
2005 \IntersectionOfSegments(\Puno)(\Hu)and(\Pdue)(\Hd)to\C
2006 \Pbox(\C)[t]{H}[2]
2007 \end{picture}
2008 \end{Esempio}
2009 \caption{Determination of the orthocenter}\label{fig:orthocenter}
2010 \end{figure}
2011
2012 \begin{figure}[!htb]
2013 \begin{Esempio}[\setfontsize{6}](0.45)
2014 \unitlength=0.008\linewidth
2015 \begin{picture}(100,100)(0,-10)
2016 \AutoGrid
2017 \def\Puno{0,0}\def\Pdue{0,80}\def\Ptre{100,55}
2018 {\linethickness{0.6pt}%
2019 \polygon(\Puno)(\Pdue)(\Ptre)}%
2020 \Pbox(\Puno)[tl]{P_1}[1.5]%
2021 \Pbox(\Pdue)[bl]{P_2}[1.5]
2022 \Pbox(\Ptre)[bc]{P_3}[1.5]
2023 \TriangleBisectorBase\Puno on\Pdue and \Ptre to\Iu
2024 \TriangleBisectorBase\Pdue on\Ptre and \Puno to\Id
2025 \TriangleBisectorBase\Ptre on\Puno and \Pdue to\It
2026 \Dotline(\Puno)(\Iu){3}[1.5]
2027 \Dotline(\Pdue)(\Id){3}[1.5]
2028 \Dotline(\Ptre)(\It){3}[1.5]
2029 \IntersectionOfSegments(\Puno)(\Iu)%
2030 and(\Pdue)(\Id)to\C
2031 \Pbox(\C)[t]{I}[2]
2032 \DistanceOfPoint\C from(\Puno)(\Pdue)to\R
2033 \Circlewithcenter\C radius\R
2034 \end{picture}
2035 \end{Esempio}
2036 \caption{Determination of the incenter and of the incircle}\label{fig:incenter}
2037 \end{figure}
2038
2039 \begin{figure}[!htb]
2040 \begin{Esempio}*[\normalsize](0.45)
2041 \unitlength=0.007\linewidth\centering
2042 \begin{picture}(110,110)(-5,0)
2043 \AutoGrid
2044 \CopyVect20,10to\Pu \Pbox(\Pu)[t]{P_1}
2045 \CopyVect10,90to\Pd \Pbox(\Pd)[br]{P_2}
2046 \CopyVect100,70to\Pt \Pbox(\Pt)[l]{P_3}
2047 {\linethickness{0.6pt}\polygon(\Pu)(\Pd)(\Pt)}%
2048 \AxisOf\Pd and\Pu to\Mu\Du \segment(\Mu)(\Du)
2049 \AxisOf\Pu and\Pt to\Md\Dd \segment(\Md)(\Dd)
2050 \AxisOf\Pt and\Pd to\Mt\Dt\segment(\Mt)(\Dt)
2051 \IntersectionOfSegments(\Mu)(\Du)and(\Md)(\Dd)to\C
2052 \ThreePointCircle*(\Pu)(\Pd)(\Pt)
2053 \Pbox(\C)[l]{C}[3.5]
2054 \end{picture}
2055 \end{Esempio}
2056 \caption{Determination of the circumcenter and of the circumcircle}\label{fig:circumcenter}
2057 \end{figure}
2058
2059 \begin{figure}
2060 \begin{Esempio}*[\small](0.40)
2061 \unitlength=0.007\linewidth\centering
2062 \begin{picture}(100,100)(0,-10)
2063 \AutoGrid
2064 \CopyVect20,0to\Pu \Pbox(\Pu)[t]{P_1}[2pt]
2065 \CopyVect10,80to\Pd \Pbox(\Pd)[b]{P_2}[2pt]
2066 \CopyVect100,60to\Pt \Pbox(\Pt)[b]{P_3}[2pt]
2067 {\polygon(\Pu)(\Pd)(\Pt)\ignorespaces}
2068 \TriangleMedianBase\Pu on\Pd and\Pt to\Pmu\Pbox(\Pmu)[bl]{M_1}[2pt]
2069 \TriangleMedianBase\Pd on\Pt and\Pu to\Pmd\Pbox(\Pmd)[tl]{M_2}[2pt]
2070 \TriangleMedianBase\Pt on\Pu and\Pd to\Pmt \Pbox(\Pmt)[tr]{M_3}[2pt]
2071 \ThreePointCircle(\Pmu)(\Pmd)(\Pmt)
2072 \TriangleHeightBase\Pu on\Pd and\Pt to\Phu\Pbox(\Phu)[b]{H_1}[2pt]
2073 \TriangleHeightBase\Pd on\Pt and\Pu to\Phd\Pbox(\Phd)[tl]{H_2}[2pt]
2074 \TriangleHeightBase\Pt on\Pu and\Pd to\Pht\Pbox(\Pht)[br]{H_3}[2pt]
2075 \segment(\Pu)(\Phu) \segment(\Pd)(\Phd) \segment(\Pt)(\Pht)
2076 \SubVect\Pu from\Phu to\DirHu \SubVect\Pd from\Phd to\DirHd
2077 \SubVect\Pt from\Pht to\DirHt
2078 \IntersectionOfLines(\Pu)(\DirHu)and(\Pt)(\DirHt)to\Po
2079 \Pbox(\Po)[tl]{O}[2pt]
2080 \MiddlePointOf(\Po)(\Pu)to\Pou \Pbox(\Pou)[l]{O_1}[2pt]
2081 \MiddlePointOf(\Po)(\Pd)to\Pod \Pbox(\Pod)[b]{O_2}[2pt]
2082 \MiddlePointOf(\Po)(\Pt)to\Pot \Pbox(\Pot)[bl]{O_3}[2pt]
2083 \ThreePointCircle*(\Pou)(\Pod)(\Pot)
2084 \end{picture}
2085 \end{Esempio}
2086 \caption{The nine point circle with its code}\label{fig:9point-circle}
2087 \end{figure}
2088
2089 Given the triangle with vertices $P_1, P_2, P_3$, the nine point circle is shown in figure~\ref{fig:9point-circle} with its code. The nine point are the triples of $(a)$ the height base point if the height lines; $(b)$ the middle points of the fraction of each height line between each vertex and the orthocenter; $(c)$ the middle points of the sides. It goes by itself that any point triple among the three ones of the nine point circle is good to draw he final circle.
2090
2091
2092
2093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2094 \subsection{Triangles and ellipses}
2095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2096
2097 There are some situations where an ellipse should be inserted within a triangle with some constraints. Some examples are described in the following sub subsections.
2098
2099 The following examples require some new simple macros, described in the
2100 previous sections; some more more examples can be made that require more
2101 complex macros. Even these macros are just examples. For other
2102 applications it is probably necessary to add even more macros.
2103
2104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2105 \subsubsection{The Steiner ellipse}
2106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2107
2108 Let us proceed with the construction of the Steiner ellipse: given a
2109 triangle, there exists only one ellipse that is internally tangent to
2110 the side mid-points.
2111
2112 The geometrical construction goes on this way; suppose you have to draw
2113 the Steiner ellipse of triangle $T$; finding the side middle points
2114 has already been shown, but the process to build the ellipse is still
2115 to be found. So let us chose a side to work as the base of triangle $T$,
2116 and perform an affine shear transformation parallel to the base
2117 so as to move the vertex of triangle $T$, opposite to the base, on the
2118 base axis, we get another triangle $T_1$ that is isosceles; if it is
2119 not yet so, let us make another compression/expansion affine
2120 transformation, so as to get an equilateral triangle $T_2$; this last
2121 triangle is particularly simple to handle, because its Steiner ellipse
2122 reduces to its incircle. If we apply in reverse order the above
2123 transformations we get the Steiner ellipse we were looking for.
2124 The only difficult part is the affine shear transformation.
2125
2126 The L3 functions we already created take care of all such
2127 transformations, but with an optional asterisk we can draw the
2128 intermediate passages where triangles $T_2$ and $T_1$ have their base
2129 shifted and rotated to be horizontal, so that some translations and
2130 rotations are also necessary. Figure~\ref{fig:Steiner-finale} displays
2131 the final result and the code necessary to build it.
2132
2133 \begin{figure}[!htb]
2134 \begin{Esempio}[\setfontsize{8}](0.5)
2135 \unitlength=0.01\linewidth
2136 \begin{picture}(100,110)
2137 \AutoGrid
2138 \SteinerEllipse(10,10)(90,20)(60,105)[2]
2139 \end{picture}
2140 \end{Esempio}
2141 \caption{The Steiner ellipse of a given triangle}
2142 \label{fig:Steiner-finale}
2143 \end{figure}
2144
2145 With just the addition of an asterisk we can draw the whole geometrical
2146 construction; see figure~\ref{fig:Steiner-intermedio}
2147
2148 \begin{figure}[!htb]
2149 \begin{Esempio}[\setfontsize{8}](0.5)
2150 \unitlength=0.01\linewidth
2151 \begin{picture}(100,110)(0,-10)
2152 \AutoGrid
2153 \SteinerEllipse*(10,10)(90,20)(60,105)[2]
2154 \end{picture}
2155 \end{Esempio}
2156 \caption{The construction of the Steiner ellipse of a given triangle}
2157 \label{fig:Steiner-intermedio}
2158 \end{figure}
2159
2160
2161 \begin{figure}[!tbp]\centering
2162 \begin{Esempio}*[\setfontsize{8.2}](0.40)
2163 \unitlength=0.005\linewidth
2164 \begin{picture}(170,160)(-60,-80)
2165 \AutoGrid
2166 \VECTOR(0,-80)(0,80)\Pbox(0,80)[r]{y}[0]
2167 \VECTOR(-60,0)(110,0)\Pbox(110,0)[t]{x}[0]
2168 % Ellipse with given semi axes
2169 \edef\A{40}\edef\B{30}\Xellisse{\A}{\B}[\thicklines]
2170 % Point P on the ellipse
2171 \edef\X{\fpeval{\A*cosd(120)}}\edef\Y{\fpeval{\B*sind(120)}}
2172 \edef\P{\X,\Y}\Pbox(\P)[b]{P}[3]
2173 % Foci coordinates
2174 \edef\C{\fpeval{sqrt(\A**2-\B**2)}}
2175 \CopyVect-\C,0 to\F \CopyVect\C,0 to\Fp\Pbox(\Fp)[t]{F'}[3]
2176 \Pbox(\F)[t]{F}[3]\Pbox(0,0)[tr]{O}[3]
2177 % Director circumference
2178 \edef\Raggio{\fpeval{2*\A}}
2179 \Circlewithcenter\Fp radius\Raggio \Pbox(80,60)[tr]{\ISOGamma{lmss}}[0]
2180 % Tangent construction
2181 \SegmentLength(\P)(\F)to\raggio
2182 \Circlewithcenter\P radius\raggio \Pbox(-10,50)[bl]{\ISOgamma{lmss}}[0]
2183 \SegmentArg(\Fp)(\P)to\Arg\AddVect\Fp and\Arg:\Raggio to\S
2184 \segment(\Fp)(\S)\Pbox(\S)[br]{S}[3]
2185 \segment(\F)(\S)\SegmentCenter(\F)(\S)to\M
2186 \Pbox(\M)[r]{M}[3]\SegmentArg(\F)(\S)to\Arg
2187 % Tangent
2188 \edef\Arg{\fpeval{\Arg-90}}
2189 \AddVect\M and \Arg:50 to\D \Pbox(\D)[l]{D}[3]
2190 \segment(\M)(\D)
2191 \end{picture}
2192 \end{Esempio}
2193 \caption{The director circumference}\label{fig:diretriz}
2194 \end{figure}
2195
2196
2197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2198 \subsubsection{The tangent to an ellipse}\label{ssec:diretriz}
2199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2200 Ellipses have many interesting properties. One that I was not able to find anywhere in the documentation I examined (of course not the totality of available documents on ellipses) except an on-line document written in Portuguese by Sergio Alvez,
2201 \begin{flushleft}\setfontsize{10}%
2202 \url{https://docplayer.com.br/345411-Elipses-inscritas-num-triangulo.html}\end{flushleft}
2203 is the \emph{director circumference}, literal translation of the Portuguese definition \emph{circunfência diretriz}.
2204
2205 Consider an ellipse with its foci $F$ en $F'$, and a generic point $P$ on its contour.
2206 Trace a segment from $F\,P$ and another segment for $P\,F'$; these segments measure the distances from point $P$ to each focus: their sum is the length of the main ellipse axis $2a$, where $a$ is the semi axis. Now lengthen the segment $P\,F'$ to point $S$ by the length of $F\,P$; the length of $S\,F'$ is therefore equal to $2a$; now trace the circumference with center in $F'$ and radius $2a$; this is the \emph{director circumference}, that is labelled with~$\Gamma$.
2207
2208 By construction, then, the circle $\gamma$ centred in $P$ and radius equal to $F\,P$ is tangent to $\Gamma$ in $S$ and passes through $F$. This allows to say that:
2209 \begin{itemize}[noitemsep]
2210 \item the ellipse is the locus of the centres of all circles passing through focus $F$ and internally tangent to the circle $\Gamma$ centred in the other focus $F'$ and with radius $2a$;
2211 \item the axis of segment $S\,F$ is tangent to the ellipse;
2212 \item the tangency point is the point $P$;
2213 \item since this axis passes through the midpoint $M$ of segment $S\,F$ and it is perpendicular to it, the segment $M\,P$ determines the direction of the tangent to the ellipse;
2214 \item notice that points $S$ and $F$ are symmetrical with respect to the tangent in point $P$.
2215 \end{itemize}
2216 Such properties can be viewed and controlled in figure~\ref{fig:diretriz}.
2217
2218 Of course the geometrical construction of figure~\ref{fig:diretriz} can be used also in reverse order; for example it may be given a line to play the role of the tangent, a point on this line to play the role of tangency, and a point not belonging to the line to play the role of a focus, then it is possible to find the other focus laying on a horizontal line passing through the given focus. It suffices to find the symmetrical point of the first focus with respect with the given line, and to draw a line passing through this symmetrical point and the point of tangency that intersects the horizontal line through the first focus, concluding that this is the second focus and that the ellipse major axis length is that of the segment joining this second focus with the above mentioned symmetrical point.
2219
2220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2221 \subsubsection{A triangle internally tangent ellipse given one of its foci}
2222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2223
2224 It is possible to draw an ellipse that is internally tangent to
2225 a triangle if one of its foci is specified; without this specification
2226 the problem is not definite, and the number of such ellipses is
2227 countless.
2228 But with the focus specification, just one ellipse exists with that
2229 tangency constraint. It suffices to find the other focus and at least
2230 one point of tangency, because the focal distance and the sum of
2231 distances of that tangency point from the foci, is sufficient to
2232 determine all the parameters required to draw the ellipse.
2233
2234 As seen in the previous subsection~\ref{ssec:diretriz}, it is sufficient to find the three symmetrical points of the given focus with respect to the three sides, i.e. the three lines that pass through the triangle vertices; and the constructions gives simultaneously the major axis length and the three tangency points, therefore all the elements required to draw the ellipse to be drawn.
2235
2236 \begin{figure}[!tb]\centering
2237 \begin{Esempio}[\setfontsize{7}](0.375)
2238 \unitlength=0.0065\linewidth
2239 \begin{picture}(150,150)(-30,-20)
2240 \AutoGrid
2241 \EllipseWithFocus%
2242 (10,40)(110,10)(0,110)(20,60)
2243 \end{picture}
2244 \end{Esempio}
2245 \caption{An ellipse internally tangent to a triangle, given a focus}
2246 \label{fig:ellisse-interna-finale}
2247 \end{figure}
2248
2249 \begin{figure}[!tb]
2250 \begin{Esempio}*[\normalsize](0.375)
2251 \unitlength0.0065\linewidth
2252 \begin{picture}(150,150)(-30,-20)
2253 \AutoGrid
2254 \EllipseWithFocus*%
2255 (10,40)(110,10)(0,110)(20,60)
2256 \end{picture}
2257 \end{Esempio}
2258 \caption{Construction of the ellipse of figure~\ref{fig:ellisse-interna-finale}}\label{fig:ellisse-interna}
2259 \end{figure}
2260
2261
2262 The geometrical construction, with help of what has been explained in
2263 subsection~\ref{ssec:diretriz}, is easy; the steps to follow, therefore
2264 are the following:\enlargethispage*{\baselineskip}
2265 \begin{itemize}[noitemsep]
2266
2267 \item draw the triangle and the given focus $\mathsf{F}$;
2268
2269 \item find the symmetrical points $\mathsf S_i$ of this
2270 focus with respect to the sides of the triangle;
2271
2272 \item use these three points $\mathsf S_i$ as the vertices of a triangle
2273 with which to draw its circumcircle that turns to be the \emph{director circumference}; actually only its center is of
2274 interest, because it represents the second focus $\mathsf F'$; the
2275 inter focal distance $2c$; is just le length of vector $F' -F$;
2276
2277 \item join with segments each symmetrical point $\mathsf S_i$ with the
2278 second focus $\mathsf F'$ and find their intersections $\mathsf T_i$
2279 with the triangle sides; they represent the tangency points of the
2280 ellipse to be drawn;
2281
2282 \item the radius of the director circumference is the ellipse major axis;
2283
2284 \item equation~\eqref{equ:axes-foci} allows to find the second axis
2285 length; the segment that joins the foci has the required inclination
2286 of the main axis; its middle point is the ellipse center; therefore all
2287 necessary pieces of information to draw the ellipse are known.
2288
2289 \end{itemize}
2290 Figures~\ref{fig:ellisse-interna-finale} and~\ref{fig:ellisse-interna}
2291 display the construction steps and the final result.
2292
2293 \begin{figure}
2294 \begin{Esempio}*[\setfontsize{8.5}](0.40)
2295 \begin{minipage}{0.475\linewidth}\unitlength=0.00815\linewidth
2296 \begin{picture}(120,120)(-10,-10)
2297 \AutoGrid
2298 \polygon(0,0)(0,100)(100,100)(100,0)
2299 {\color{black!10!white}
2300 \polygon*(0,60)(0,0)(60,0)(60,60)
2301 \polygon*(0,60)(40,60)(40,100)(0,100)}
2302 \linethickness{2pt}
2303 \polygon(0,60)(0,0)(60,0)(60,60)
2304 \polygon(0,60)(40,60)(40,100)(0,100)
2305 \linethickness{1pt}
2306 {\color{red}\polygon(60,0)(100,60)(60,60)
2307 \polygon(40,60)(40,100)(100,60)
2308 \Pbox(75,45)[cc]{T_1}[0pt]\Pbox(60,0)[t]{C_1}[3pt]
2309 \Pbox(55,75)[cc]{T_2}[0pt]\Pbox(40,100)[b]{C_2}[3pt]}
2310 \Pbox(20,100)[b]{a}[0pt]\Pbox(70,100)[b]{b}[0pt]
2311 \Pbox(100,80)[l]{a}[0pt]\Pbox(100,30)[l]{b}[0pt]
2312 \Pbox(30,0)[t]{b}[0pt] \Pbox(80,0)[t]{a}[0pt]
2313 \Pbox(0,30)[r]{b}[0pt] \Pbox(0,80)[r]{a}[0pt]
2314 \Pbox(70,80)[bl]{c}[0pt]\Pbox(80,30)[tl]{c}[0pt]
2315 \end{picture}
2316 \end{minipage}
2317 \hfill
2318 \begin{minipage}{0.475\linewidth}\unitlength=0.00815\linewidth
2319 \begin{picture}(120,120)(-10,-10)
2320 \AutoGrid
2321 \polyline(60,0)(100,0)(100,100)(40,100)
2322 \Pbox(20,100)[b]{a}[0pt]\Pbox(70,100)[b]{b}[0pt]
2323 \Pbox(100,80)[l]{a}[0pt]\Pbox(100,30)[l]{b}[0pt]
2324 \Pbox(30,0)[t]{b}[0pt] \Pbox(80,0)[t]{a}[0pt]
2325 \Pbox(0,20)[r]{a}[0pt] \Pbox(0,70)[r]{b}[0pt]
2326 {\color{black!10!white}\polygon*(60,0)(100,60)(40,100)(0,40)}%
2327 {\thicklines\color{red}\polygon(60,0)(100,60)(40,100)(0,40)
2328 \Pbox(15,80)[cc]{T_2}[0pt]\Pbox(60,0)[t]{C_1}[3pt]
2329 \Pbox(20,15)[cc]{T_1}[0pt]\Pbox(40,100)[b]{C_2}[3pt]
2330 \polyline(40,100)(0,100)(0,0)(60,0)}
2331 \Pbox(70,80)[tr]{c}[0pt]\Pbox(80,30)[br]{c}[0pt]
2332 \Pbox(20,70)[tl]{c}[0pt]\Pbox(30,20)[bl]{c}[0pt]
2333 \end{picture}
2334 \end{minipage}
2335 \end{Esempio}
2336 \caption{Two squares partitioned in differente ways}
2337 \label{fig:two squares}
2338 \end{figure}
2339
2340
2341
2342
2343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2344 \subsection{A simple proof of Pythagoras' theorem}
2345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2346 Euclide at his time could not use the algebra symbology we use today; he did not have even an effective way to write numbers; in his time in Greece and in the Near East the numbers were written with letters, the usual alphabetic letters; the Greek alphabet of 24 letters, was extended with three more symbols, stigma (\stigma), qoppa (\qoppa) and sampi (\sampi), for a total of 27 seven symbols divided in three groups of 9 symbols. The first group represented the modern values from~1 to~9, the second group represented the values from~10 to~90, the last group represented the values from~100 to~900. therefore they could easily write numbers up to~999‘, an apex denoting the fact that the letter string meant a number, not a word. For the thousands they used the same symbols preceded by an inverted apex.so they could arrive to ‚9‚9‚9 999‘. The same use of letters for denoting numbers, was in use also among the Phoenicians and the Palestinians; the Kabala is a practice that suggests special informations to those that can interpret such letter/number signs. But it was practically impossible to do any serious calculations, in any case no square roots. This is why geometry was the only means to make “impossible” calculations.
2347
2348 The “Elements” by Euclide contain many theorems and statements that are demonstrated with geometrical constructions; The demonstration of Pythagoras' theorem to my eyes appears too complicated and difficult to understand; the geometrical construction developed hereafter is particularly ingenious and simple to understand.
2349
2350 Assume you have a square triangle of legs $a$ and $b$ and hypothenuse $c$; the theorem states that the area of the square built on the hypotenuse equals the sum of the areas of the squares built on each leg.
2351
2352 Let us prepare two similar squares of equal areas partitioned in differente ways. See figure~\ref{fig:two squares}.
2353 In both images you see the overall squares have side lengths equal to the sum of the right triangle legs; in the left image the grey squares have side lengths equalling each right triangle leg respectively. The overall square contains also two rectangles with side lengths $a$ and $b$ so that the diagonal equals the right triangle hypothenuse.
2354
2355 These diagonals, therefore, partition the respective rectangles in two right triangles with the same dimensions of the original right triangle. In particular two of such triangles are labeled $T_1$ and $T_2$ and the vertices labeled $C_1$ and $C_2$ are emphasised. Let us now rotate both labelled triangles around their labelled vertices so as to obtain the right image, where the overall square has the same sides as the original one, although partitioned in a slightly differente way; their areas are the same; but in this second image the grey square has its side equal to the original right triangle hypothenuse; since the four right triangles contained in the overall squares of both images are equal, thus the sum of their areas are he same; therefore the grey areas in each image are the same and this means that the area of the square built on the hypotenuse equals the sum of the area of the squares built on the legs of the original right triangle. Pythagoras' theorem is proved without any use of algebra.
2356
2357
2358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2359 \section{Conclusion}
2360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2361 We have shown that the \amb{picture} environment, extended with
2362 this package \pack{euclideangeometry} (that takes care of loading
2363 \pack{curve2e} and \pack{pict2e}) can make important diagrams that
2364 certainly were not foreseen by Leslie Lamport when he first wrote the
2365 code for the initial \env{picture} environment.
2366
2367 The reader can easily understand that this package is far from being
2368 exhaustive for all geometrical problems to be solved with ruler and
2369 compass; it shows a way to add more commands to approach further
2370 problems; if any author, who creates new commands, would like to
2371 contribute more macros to this package, I will be happy to integrate
2372 his/her contribution to a new version of this package; depending on the
2373 contribution, I would be very happy to add its author name to this
2374 package author list; for simpler contributions each contributor will be
2375 duly acknowledged.\enlargethispage*{\baselineskip}
2376
2377 Creating new macros to solve more problems is pleasant; the more
2378 difficult the problem, the greater the satisfaction in solving it.
2379
2380
2381 \begin{center}\bfseries
2382 Enjoy using \LaTeX and its possible applications!
2383 \end{center}
2384
2385 \end{document}