Debian Codegraph @

texmf-dist/doc/latex/curve2e/curve2e-manual.tex

raw
1 % !TEX TS-program = pdflatex
2 % !TEX encoding = UTF-8 Unicode
3 \documentclass[a4paper]{article}\errorcontextlines=100
4 \ProvidesFile{curve2e-manual.tex}[2024-11-13 v.2.6.0 curve2e user manual]
5 \hfuzz 10pt
6 %\usepackage[utf8]{inputenc}
7 \usepackage{lmodern,textcomp}
8 \usepackage{mflogo}
9 \usepackage{multicol,amsmath,fancyvrb,graphics,shortvrb}
10 \usepackage{xcolor,verbatim,enumitem,FramedSyntax,trace}
11 \usepackage{curve2e}
12 \MakeShortVerb{\|}
13 \providecommand*\diff{\mathop{}\!\mathrm{d}}
14 \providecommand\meta{}\providecommand\marg{}
15 \renewcommand\meta[1]{{\normalfont\textlangle\textit{#1}\textrangle}}
16 \renewcommand\marg[1]{\texttt{\{\meta{#1}\}}}
17 \providecommand\Marg{}
18 \renewcommand\Marg[1]{\texttt{\{#1\}}}
19 \providecommand\oarg{}
20 \renewcommand\oarg[1]{\texttt{[\meta{#1}]}}
21 \providecommand\Oarg{}
22 \renewcommand\Oarg[1]{\texttt{[#1]}}
23 \providecommand\aarg{}
24 \renewcommand*\aarg[1]{\texttt{<\meta{#1}>}}
25 \providecommand\Aarg{}
26 \renewcommand\Aarg[1]{\texttt{<#1>}}
27 \providecommand\parg{}
28 \renewcommand\parg[1]{\texttt{(\meta{#1})}}
29 \providecommand\Parg{}
30 \renewcommand\Parg[1]{\texttt{(#1)}}
31 \providecommand\pack{}
32 \renewcommand\pack[1]{{\normalfont\textsf{#1}}}
33 \providecommand\file{}
34 \renewcommand\file[1]{{\normalfont\texttt{#1}}}
35 \providecommand\env{}
36 \renewcommand\env[1]{{\normalfont\textsf{\slshape#1}}}\let\amb\env
37 \providecommand\cs{}
38 \renewcommand\cs[1]{{\normalfont\texttt{\char92#1}}}
39
40 \def\LissajousCoefs#1,#2,#3,#4,#5,#6!{%
41 \edef\LAu{#1}\edef\LNu{#2}\edef\LFu{#3}%
42 \edef\LAd{#4}\edef\LNd{#5}\edef\LFd{#6}}
43
44 \def\LissajousCode#1#2{%
45 \edef\X{\fpeval{\LAu*cosd(\LNu*#1+\LFu)}}%
46 \edef\Y{\fpeval{\LAd*cosd(\LNd*#1+\LFd)}}%
47 \CopyVect\X,\Y to#2\ignorespaces}
48
49 \NewDocumentCommand\Lissajous{m o m}{%
50 \IfValueTF{#2}{\LissajousCoefs#2!\relax
51 \LissajousCode{#1}{#3}}%
52 {\ifcsname LAu\endcsname
53 \LissajousCode{#1}{#3}%
54 \else\PackageError{Lissajous}%
55 {I parametri di questa curva di Lissajous\MessageBreak
56 Non sono mai stati definiti}{Non faccio nulla}\fi}%
57 \ignorespaces}
58
59 \makeatletter
60
61 \NewDocumentCommand\Pall{O{1.5} R(){0,0}}{\put(#2){\circle*{#1}}}
62
63 \providecommand\setfontsize{}
64 \DeclareRobustCommand\setfontsize[2][1.2]{%
65 \linespread{#1}\fontsize{#2}{#2}\selectfont}
66
67 \newwrite\example@out
68 \ProvideDocumentEnvironment{Esempio}{ O{\footnotesize} D(){0.50}}
69 % All definitions and assignments are local
70 % #1 := Latex font size command or \setfontsize{<size>}
71 % %2 := \textwidth percentage for the code box; the
72 % complement, less the column gap for the compiled
73 % result
74 %
75 % Syntax: \begin{Esempio}[<size command>](<code box
76 % percentage width>)
77 %
78 % Warning: No extra space is put before and/or after the
79 % display; this environment is assumed to be used
80 % within a figure environment that already provides
81 % its own vertical spaces. Should this environment
82 % be used between paragraphs, the user should
83 % manually provide a convenient amount of space
84 % above and below it.
85 % Remember: This environment sets itself in vertical mode
86 {\par\dimendef\Wboxu=2570 \dimendef\Wboxd=2572
87 \Wboxu=#2\linewidth\relax
88 \Wboxd=\dimexpr\linewidth-\columnsep-\Wboxu\relax
89 \begingroup
90 \@bsphack
91 \immediate\openout\example@out\jobname-temp.tex
92 \let\do\@makeother\dospecials\catcode`\^^M\active
93 \def\verbatim@processline{%
94 \immediate\write\example@out{\the\verbatim@line}}%
95 \verbatim@start\relax}%
96 {\immediate\closeout\example@out\@esphack\endgroup
97 \begin{lrbox}{0}%
98 \begin{minipage}{\linewidth}%
99 \begin{minipage}{\Wboxu}#1\relax
100 \verbatiminput{\jobname-temp.tex}
101 \end{minipage}%
102 \hfill
103 \begin{minipage}{\Wboxd}\raggedleft
104 \input{\jobname-temp}%
105 \end{minipage}
106 \end{minipage}%
107 \end{lrbox}\par\medskip
108 \noindent\makebox[\linewidth]{\box0}\par}
109
110 \providecommand\GetFileInfo[1]{%
111 \def\filename{#1}%
112 \def\@tempb##1 v.##2 ##3\relax##4\relax{%
113 \def\filedate{##1}%
114 \def\fileversion{##2}%
115 \def\fileinfo{##3}}%
116 \edef\@tempa{\csname ver@#1\endcsname}%
117 \expandafter\@tempb\@tempa\relax? ? \relax\relax}
118 %%%%%%%%%%%%%%%%
119 \newenvironment{medaglione}[1][\linewidth]{%
120 \begin{lrbox}{0}%
121 \begin{minipage}{\dimexpr#1-2\fboxsep-2\fboxrule}
122 }{%
123 \end{minipage}\end{lrbox}\fbox{\usebox{0}}\relax
124 }
125
126 \newenvironment{sintassi}{\flushleft\medaglione\obeylines}%
127 {\endmedaglione\endflushleft}
128
129 \providecommand\eu{}
130 \renewcommand\eu{\ensuremath{\mathrm{e}}}
131 %%%%%%%%%%%%%%%%
132 \makeatletter
133 \NewDocumentCommand\Tbox{D(){0,0} O{cc} m O{0pt} D<>{Z}}{\bgroup
134 \edef\TBoxCode{#5}\dimen0=#4\relax %
135 \edef\tempE{\fpeval{round(#4/\unitlength,3)}}%
136 \put(#1){%
137 \ifdim\dimen0=\z@
138 \Zbox(0,0)[#2]{#3}[\z@]%
139 \else
140 \if\TBoxCode V\relax
141 \let\tempC=b\relax
142 \if\tempC #2\edef\tempD{0,-\tempE}\else\edef\tempD{0,\tempE}\fi%
143 \segment(0,0)(\tempD)\Zbox(0,0)[#2]{#3}[\z@]%
144 \else
145 \if\TBoxCode H\relax
146 \let\tempC=l\relax%
147 \if\tempC #2\edef\tempD{-\tempE,0}\else\edef\tempD{\tempE,0}\fi%
148 \segment(0,0)(\tempD)\Zbox(0,0)[#2]{#3}[\z@]%
149 \else
150 \typeout{The specified code\space #5\space is invalid!}%
151 \typeout{\string\Tbox\space ignored}%
152 \fi
153 \fi
154 \fi
155 }\egroup\ignorespaces}%
156
157 \begin{document}
158
159 \author{Claudio Beccari\\{\small\texttt{claudio(dot)beccari(at)gmail(dot)com}}}
160 \title{Package \pack{curve2e} user manual}
161 \GetFileInfo{curve2e.sty}
162 \date{Version \fileversion~--~Last revised \filedate}
163 \maketitle
164 \columnseprule=0.4pt
165 \begin{multicols}{2}
166 \tableofcontents
167 \end{multicols}
168
169 \begin{abstract}\setfontsize{9.5}
170 This file contains the user manual of the \pack{curve2e} extension package to the \pack{pict2e} bundle; the latter was described by Lamport himself in the 1994 second edition of his \LaTeX\ handbook.
171
172 Please take notice that on April 2011 a package \pack{pict2e} upgraded version has been released that incorporates some of the commands defined in early versions of this package \pack{curve2e}; apparently there are no conflicts, because this package contains only the advanced features that extend the above package.
173
174 Since this extension redefines some commands and introduces some more drawing facilities (that allow to draw circular arcs and arbitrary curves with the minimum of user intervention) users need a user manual that contains several actual examples; this auxiliary manual is contained in file
175 |curve2e-manual.pdf|. The software available to show the drawing code and its result after compilation is incompatible with the usual \LaTeX\ |ltxdoc| class for code documentation, therefore a separate user manual has been made available. If users want to explore the \pack{curve2e} code and its documentation they have available the |curve2e.pdf| file. Either file is readable by entering in a terminal window the command |texdoc curve2e-manual| or |texdoc curve2e.pdf|; please do not forget the extension when you want to read the code documentation.
176 \end{abstract}
177
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 \section{Installation}
180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 If \TeX\ system was installed with a \TeX~Live or a MiK\TeX\ complete and updated distribution this package is already installed; in order to verify open a terminal or command prompt window and use it to enter the \texttt{texdoc curve2e-manual} command; as soon as the command is executed a screen window should open displaying this manual. If this does not happen, either you misspelt the command (it happens more often than not), or your installation is not complete and updated.
182
183 I suggest you to use your computer installation facilities to install this bundle. Otherwise, download this curve2e.zip package from one of the CTAN (Comprehensive TeX Archive Network) archives, to your downloads folder.
184 Before doing anything else verify if you have a \emph{personal} \texttt{texmf} tree; if not, create one reading you distribution instruction; let us assume that your personal |texmf| archive is in |HOME/texmf| (on Windows change the slash with a backslash) and |HOME| is a path starting from the root of you hard disk and going though several other folders. On Windows~10 it might be |C:\Users\YourName|; on Linux it might simply be |~|; on Mac it would be |~/\Library|, but sometimes the |HOME| might be different, especially on Windows platforms. Create the following subfolders:
185 \begin{enumerate}[noitemsep]
186 \item |HOME/texmf/source/latex/curve2e/|
187 \item |HOME/texmf/doc/latex/curve2e/|
188 \item |HOME/texmf/tex/latex/curve2e/|
189 \end{enumerate}
190
191 Now move file \file{curve2e.zip} to the |.../source/latex/curve2e/| folder; then decompress the |.zip| file with the software you have available on your platform. Run |pdflatex| on the |.dtx| file; then compile the |curve2e-manual.tex| file. You might need to repeat these compilations two or three times in order to have the table of contents and all the references correctly connected.
192
193 This done, move the |.pdf| files to the |.../doc/latex/curve2e/| folder. and move the |.sty| files to the |.../tex/latex/curve2e/| folder.
194
195 Clear the |.../source/latex/curve2e/| folder from the auxiliary files, all those remaining in the folder except those that have the extensions |.zip|, |.dtx|, |.tex|, and |.txt|. Read the \file{README.txt} file.
196
197 If your \TeX\ system is correctly set up, your files in your personal tree should be immediately usable; probably you have to create or update the file-name database with MiK\TeX; in this case read the documentation of your MiK\TeX\ installation to discover how to~do~it.
198
199 Remember to delete all these subfolders if you decide to install a complete updated version of your favourite distribution, and you'd better keep it updated approximately once every 7 or 10 days. This is much simpler than to struggle with these manual operations.
200
201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 \section{Package \pack{pict2e} and this extension \pack{curve2e}}
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204
205 Package \pack{pict2e} was announced in issue 15 of
206 \file{latexnews} around December 2003; it was declared that
207 the new package would replace the dummy one that had been
208 accompanying every release of \LaTeXe\ since its beginnings
209 in 1994. The dummy package was just issuing an info message
210 that simply announced the temporary unavailability of the
211 real package.
212
213 Eventually Gäßlein and Niepraschk implemented what Lamport
214 himself had already documented in the second edition of his
215 \LaTeX\ handbook, it was a \LaTeX\ package that contained
216 the macros capable of removing all the limitations contained
217 in the standard commands of the original \texttt{picture}
218 environment; specifically what follows.
219
220 \begin{enumerate}[noitemsep]
221 \item The line and vector slopes were limited to the ratios of relative
222 prime one-digit integers of magnitude not exceeding 6 for lines and 4
223 for vectors.
224 %
225 \item Filled and unfilled full circles were limited by the necessarily
226 limited number of specific glyphs contained in the special \LaTeX\
227 \texttt{picture} fonts.
228 %
229 \item Quarter circles radii were also limited for the same reason.
230 %
231 \item Ovals (rectangles with rounded corners) could not be too small
232 because of the unavailability of small radius quarter circles, nor
233 could be too large, in the sense that after a certain radius the
234 rounded corners remained the same curvature and would not increase proportionally to the oval size.
235 %
236 \item Vector tips had only one possible shape and matched the limited
237 number of vector slopes.
238 %
239 \item For circles and inclined lines and vectors just two possible
240 thicknesses were available.
241 \end{enumerate}
242
243 Package \pack{pict2e} removes most if not all the above
244 limitations.
245 \begin{enumerate}[noitemsep]
246 \item Line and vector slopes are virtually unlimited; the only
247 remaining limitation is that the direction coefficients must be
248 three-digit integer numbers; they need not be relatively prime; with
249 the 2009 upgrade even this limitation was removed and now slope
250 coefficients can be any fractional number whose magnitude does not
251 exceed 16\,384, the maximum dimension in points that \TeX\ can handle.
252 %
253 \item Filled and unfilled circles can be of any size.
254 %
255 \item Ovals can be designed with any specified corner curvature and
256 there is virtually no limitation to such curvatures; of course corner
257 radii should not exceed half the lower value between the base and the
258 height of the oval.
259 %
260 \item There are two shapes for the arrow tips; the triangular one
261 traditional with \LaTeX\ vectors, or the arrow tip with PostScript
262 style.
263 %
264 \item The |\linethickness| command changes the thickness of all lines,
265 straight, curved, vertical, horizontal, arrow tipped, et cetera.
266 \end{enumerate}
267
268 This specific extension package \pack{curve2e} adds the following
269 features.
270 \begin{enumerate}[noitemsep]
271 %
272 \item Point coordinates can be specified with macros; this is similar
273 to “naming” points; it eases editing the user's graphic work, because
274 points that are used several times are specified with a single macro;
275 it also eases the transmission of coordinates between different macros
276 and environments. It is also important for the following feature, described in the following entry..
277 %
278 \item Point coordinates my be specified in both cartesian and polar
279 form: internally they are handled as cartesian coordinates, but the
280 user can specify his/her points also in polar form. In order to avoid
281 confusion with other graphic packages, \pack{curve2e} uses the usual
282 comma separated couple \meta{$x,y$} of integer or fractional numbers for
283 cartesian coordinates, and the couple \meta{$\theta$}:\meta{$\rho$} for
284 polar coordinates (the angle preceding the radius).
285
286 All graphic object commands accept polar or cartesian coordinates at
287 the choice of the user who may use for each object the formalism s/he
288 prefers. Also the |\put| and |\multiput| commands have been redefined so
289 as to accept cartesian or polar coordinates.
290
291 Of course the user should pay attention to the meaning of cartesian
292 vs.~polar coordinates. Both imply a displacement with respect to the
293 actual origin of the axes. So when a circle center is placed at
294 coordinates $a,b$ with a normal |\put| command, the circle is placed
295 exactly in that point; with a normal |\put| command the same happens if
296 coordinates $\alpha{:}\rho$ are specified.
297
298 But if the |\put| command is nested into another |\put| command, the
299 current origin of the axes is displaced — this is obvious and the
300 purpose of nesting |\put| commands is exactly that. But if a segment
301 is specified so that its ending point is at a specific distance and in
302 specific direction from its starting point, polar coordinates appear to
303 be the most convenient to use; in this case, though, the origin of the
304 axes becomes the starting point of the segment, therefore the segment
305 might be drawn in a strange way. Attention has been paid to avoid such
306 misinterpretation, but maybe some unusual situation may not have come to
307 my mind; feedback is very welcome. Meanwhile pay attention when you use
308 polar coordinates.
309 %
310 \item At user level most if not all coordinate pairs and slope pairs are
311 treated as \emph{ordered pairs}, that is \emph{complex numbers}; in
312 practice the user does not notice any difference from what s/he was
313 used to, but all the mathematical treatment to be applied to these
314 entities is coded as complex number operations, since complex numbers
315 may be viewed non only as ordered pairs, but also as vectors or as
316 roto-amplification operators.
317 %
318 \item Commands for setting the line terminations were introduced; the
319 user can chose between square or rounded caps; the default is set to
320 rounded caps; now this feature is directly available with \pack{pict2e}.
321 %
322 \item Commands for specifying the way two straight or curves lines
323 join to one another.
324 %
325 \item Originally the |\line| macro was redefined so as to allow large
326 (up to three digits) integer direction coefficients, but maintaining
327 the same syntax as in the original \texttt{picture} environment; now
328 \pack{pict2e} removes the integer number limitations and allows
329 fractional values, initially implemented by \pack{curve2e}; now direction
330 coefficients may be specified in polar form.
331 %
332 \item A new macro |\Line| was originally defined by \pack{curve2e} so
333 as to avoid the need to specify the horizontal projection of inclined
334 lines; now this functionality is available directly with \pack{pict2e};
335 but this \pack{curve2e} macro name now conflicts with the \pack{pict2e}
336 2009 version; therefore its name is changed to |\LIne| and supposedly it
337 will not be used very often, if ever, by the end user (but it is used
338 within this package macros).
339 %
340 \item A new macro |\LINE| was defined in order to join two points
341 specified with their coordinates; this is now the normal behaviour of
342 the |\Line| macro of \pack{pict2e}, so that in this package |\LINE| is
343 now renamed |\segment|; there is no need to use the |\put| command with
344 this segment specification.
345 %
346 \item A new macro |\DashLine| (alias: |\Dline|) is defined in order to
347 draw dashed lines joining any two given points; the dash length and
348 gap (equal to one another) get specified through one of the macro
349 arguments. The starting point may be specified in cartesiano or polar
350 form; the end point in cartesian format specifies the desired end
351 point; but, if the second point is in polar form, it is meant
352 \emph{relative to the starting point}, not as an absolute end point.
353 See the examples further on.
354 %
355 \item A similar new macro |\Dotline| is defined in order to draw dotted
356 straight lines as a sequence of equally spaced dots, where the gap can
357 be specified by the user; such straight line may have any inclination,
358 as well as the above dashed lines. Polar coordinates for the second
359 point have the same relative meaning as specified for the |\Dashline|
360 macro. The dot diameter may be specified with an optional argument; by
361 default this diameter equals the |1pt| width.
362 %
363 \item Similar macros are redefined for vectors; |\vector| redefines the
364 original macro but with the vector slope limitations removed and the
365 vector direction may be given in polar form; |\Vector|
366 gets specified with its two horizontal and vertical components in
367 analogy with |\LIne|; |\VECTOR| joins two specified points (without
368 using the |\put| command) with the arrow pointing to the second point.
369 |\VVECTOR| may be available if used with a sufficiently recent \LaTeX\
370 kernel version; it draws a vector between two given points, with arrow
371 tips at both ends.
372
373 %
374 \item A new macro |\polyline| for drawing polygonal lines is defined
375 that accepts from two vertices up to an arbitrary (reasonably limited)
376 number of them (available now also in \pack{pict2e}); here it is
377 redefined so as to allow an optional specification of the way segments
378 for the polyline are joined to one another. Vertices may be specified
379 with polar coordinates and are always relative to the preceding point.
380 %
381 \item The \pack{pict2e} |\polygon| macro draws closed polylines (in
382 practice general polygons) has been redefined in such a way that it
383 can accept the various vertices specified with (relative) polar
384 coordinates. The |polygon*| macro produces a color filled polygon; the
385 default color is black, but a different color may be specified with the
386 usual |\color| command given within the same group where |\polygon*| is
387 enclosed.
388 %
389 \item A new macro |\Arc| is defined in order to draw an arc with
390 arbitrary radius and arbitrary aperture (angle amplitude); this
391 amplitude is specified in sexagesimal degrees, not in radians; a
392 similar functionality is now achieved with the |\arc| macro of
393 \pack{pict2e}, which provides also the starred version |\arc*| that
394 fills up with the current color the sector generated by a circular arc.
395 It must be noticed that the syntax is slightly different, so that it's
396 reasonable that these commands, in spite of producing identical arcs,
397 might be more comfortable with this or that syntax.
398 %
399 \item Two new macros |\VectorArc| and |\VectorARC| (alias |\VVectorArc|)
400 are defined in order to draw circular arcs with an arrow at one or both
401 ends.
402 %
403 \item A new macro |\Curve| is defined so as to draw arbitrary curved
404 lines by means of cubic Bézier splines; the |\Curve| macro requires
405 only the curve nodes and the directions of the tangents at each
406 node. The starred version fills up the interior of the curve with the
407 current color.
408 %
409 \item The above |\Curve| macro is a recursive macro that can draw an
410 unlimited (reasonably limited) number of connected Bézier spline arcs
411 with specification of the tangent direction at the interpolation nodes.
412 It is possible to use a lower level macro |\CbezierTo| that does the
413 same but lets the user specify the control points of each arc; it is
414 more difficult to use but it is more performant.|\Curve| recognises also
415 an optional argument to set a direction change, that is a cusp.
416 %
417 \item The basic macros used within the cumulative |\Curve| macro can be
418 used individually in order to draw any curve, one cubic arc at the
419 time; but they are intended for internal use, even if it is not
420 prohibited to use them; by themselves such arcs are not different form
421 those used by |Curve|, but the final command, |\FillCurve|, should be
422 used in place of |\CurveFinish|, so as to fill up the closed path with
423 the locally specified color; see figure~\ref{fig:colored-curve}.
424 It is much more convenient to use the starred version of the |\Curve|
425 macro.
426 \end{enumerate}
427
428 The \pack{pict2e} package already defines macros such as |\moveto|,
429 |\lineto|, |\curveto|, |\closepath|, |\fillpath|, and |\strokepath|;
430 |curve2e| just redefines them so as to accept also polar coordinates;
431 of course these macros can be used by the end user, and sometimes they
432 perform better than the macros defined in this package, because the
433 user has a better control on the position of the Bézier splines
434 control points; in this case the control points are sort of rigid. It
435 would be very useful to resort to the \pack{hobby} package, but its
436 macros are compatible with those of the \pack{tikz} and \pack{pgf}
437 packages, not with\pack{curve2e}; an interface should be created in
438 order to deal with the \pack{hobby} package, but this has not been
439 done yet.
440
441 In order to make the necessary calculations many macros have been
442 defined so as to use complex number arithmetics to manipulate point
443 coordinates, directions (unit vectors, also known as ‘versors’),
444 rotations and the like. In the first versions of this package the
445 trigonometric functions were also defined in a way that the author
446 believed to be more efficient than those defined by the \texttt{trig}
447 package; in any case the macro names were sufficiently different to
448 accommodate both definition sets in the same \LaTeX\ run. With the
449 progress of the \LaTeX3 language, package \pack{xfp} functionalities
450 have become available, and any sort of calculations can be done floating
451 point decimal numbers; therefore the most common algebraic, irrational
452 and transcendental functions can be computed in the background with the
453 stable internal floating point facilities. We maintain some computation
454 with complex number algebra, but use the |xfp| functionalities for
455 other computations.
456
457 Many aspects of this extension could be fine tuned for better
458 performance; many new commands could be defined in order to further
459 extend this extension. If the new service macros are accepted by other
460 \TeX\ and \LaTeX\ programmers, this version could become the start for
461 a real extension of the \pack{pict2e} package or even become a part of
462 it. Actually some macros have already been included in the \pack{pict2e}
463 package. The |\Curve| algorithm, as said before, might be redefined
464 so as to use the macros introduced by the \pack{hobby} package, that
465 implements for the \pack{tikz} and \pack{pgf} packages the same
466 functionalities that John Hobby implemented for the \MF\ and \MP\
467 programs.
468
469 For these reasons I suppose that every enhancement should be submitted
470 to Gäßlein, Niepraschk, and Tkadlec who are the prime maintainers of
471 \pack{pict2e}; they are the only ones who can decide whether or not
472 to incorporate new macros in their package.
473
474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
475 \section{Summary and examples of new commands}
476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477
478 This package \pack{curve2e} extends the power of \pack{pict2e} with
479 the following modifications and the following new commands.
480 \begin{enumerate}[noitemsep]
481 \item This package \pack{curve2e} calls directly the \LaTeX\ packages
482 |color| and \pack{pict2e}; it passes to the latter one any possible
483 option that it can receive; actually the only options that make sense
484 for \pack{pict2e} are those concerning the arrow tip shapes, either
485 \LaTeX\ (default) or PostScript styled, because it is assumed that if
486 this package is used, the original \LaTeX\ commands are of no interest:
487 see the \pack{pict2e} documentation in order to find the correct options
488 \pack{pict2e} can receive. If the user wants to use the \pack{xcolor}
489 package, it has to load it \emph{before} \pack{curve2e}.
490 %%
491 \item Since they are used very much in the following examples, we recall some commands to label certain drawing elements, such as points, lines, arcs, and similar lines, and to insert legends in some figures. They are \cs{legenda}, \cs{Zbox} and \cs{Pbox}; their syntax is the following:
492 \begin{Sintassi}[9.75]\ttfamily
493 |\legenda|\parg{coordinates}\marg{formula}
494 |\Zbox|\parg{coordinates}\oarg{position}\marg{formula}\oarg{dot diameter}
495 |\Pbox|\parg{coordinates}\oarg{position}\marg{text}\oarg{dot diameter}\meta{\texttt{*}}\aarg{angle}
496 \end{Sintassi}
497 They are described in any up to date documentation of \pack{curve2e}.
498 %%
499 \item The user is offered new commands in order to control the line
500 terminators and the line joins; specifically:
501 \begin{itemize}
502 \item |\roundcap|: the line is terminated with a semicircle;
503 \item |\squarecap|: the line is terminated with a half square;
504 \item |\roundjoin|: two lines are joined with a rounded join;
505 \item |\beveljoin|: two lines are joined with a bevel join;
506 \item |\miterjoin|: two lines are joined with a miter join.
507 \end{itemize}
508 All the above commands should respect the intended range; but since
509 they act at the PostScript or PDF level, not at \TeX\ level, it might
510 be necessary to issue the necessary commands in order to restore the
511 previous terminator or join; in other words, groups and environments do
512 not have any influence on these commands.
513 %%
514 \item The commands
515 \begin{Sintassi}
516 |\linethickness|\marg{thickness}
517 |\thicklines|
518 |\thinlines|
519 |\defaultlinethickness|\marg{thickness}
520 \end{Sintassi}
521 always redefine the internal |\@wholewidth| and |\@halfwidth| so that the
522 latter ones always refer to a full width and to a half of it in this way
523 if you issue the command {\setfontsize{8.75}|\defaultlinethickness{2pt}|}
524 all thin lines will be drawn with a thickness of 1\,pt while, if a
525 drawing command directly refers to the internal value |\@wholewidth|,
526 its line will be drawn with a thickness of 2\,pt. If one issues the
527 declaration |\thinlines| all lines will be drawn with
528 a 1\,pt width, but if a command refers to the internal value
529 |\@halfwidth| the line will be drawn with a thickness of 0.5\,pt.
530 The command |\linethickness| redefines the above internals but does not
531 change the default width value; all these width specifications apply to
532 all lines, straight ones, curved ones, circles, ovals, vectors, dashed
533 lines, and so on. It's better to recall that |\thinlines| and
534 |\thicklines| are declarations that do not take arguments; on the pposite
535 the other commands, as shown in the above syntax medallion, accept a
536 specific thickness value, that is either a length specification complete
537 of its units, or a dimensional expression.
538 %%
539 \item Straight lines and vectors are redefined in such a way that
540 fractional slope coefficients may be specified; the zero length line and
541 vector does not produce errors and is ignored; the zero length vectors
542 draw only the arrow tips.
543 %%
544 \item New line and vector macros are defined that avoid the necessity
545 of specifying the horizontal component; |\put(3,4){\LIne(25,15)}|
546 specifies a segment that starts at point $(3,4)$ and goes to point
547 $(3+25,4+15)$; the command |\segment(3,4)(28,19)| achieves the same
548 result without the need of using the |\put| command. Therefore |\LIne|
549 is just for internal usage, rather than a user command. Now
550 \pack{curve2e} has available also the “arc vectors” with the arrow tips
551 at one or at both ends. The |\segment| syntax is
552 \begin{Sintassi}
553 \cs{segment}\parg{starting point}\parg{ending point}
554 \end{Sintassi}
555
556 The same applies to the vector commands |\Vector| and |\VECTOR| and
557 |\VVECTOR|; the latter command behaves as |\VECTOR| but draws a vector
558 with arrow tips at both ends; furthermore this command is available
559 only with main versions~2 or higher of \pack{curve2e}.
560 \begin{Sintassi}\small
561 |\put|\parg{starting point}\Marg{\cs{Vector}\parg{vector cartesian or polar components}}
562 |\VECTOR|\parg{starting point}\parg{ending point}
563 |\VVECTOR|\parg{starting point}\parg{ending point}
564 \end{Sintassi}
565
566
567 Experience has shown that the commands intended
568 to join two specified points are particularly
569 useful; see figure~\ref{fig:vectors}.
570
571 \begin{figure}[!hb]
572 \begin{Esempio}[\small](0.60)
573 \unitlength=0.01\linewidth
574 \begin{picture}(80,20)
575 \AutoGrid[red]
576 \put(0,0){\vector(1.5,2.3){10}}
577 \put(20,0){\Vector(10,15.33333)}
578 \VECTOR(40,0)(50,15.33333)
579 \ifdefined\VVECTOR \VVECTOR(60,0)(80,10)\fi
580 \end{picture}
581 \end{Esempio}
582 \caption{Three (displaced) identical vectors
583 obtained with the three
584 vector macros\ifdefined\VVECTOR; a double
585 tipped vector is also shown\fi. The darker
586 cyan color is an usage example optional grid
587 coloring }\label{fig:vectors}
588 \end{figure}
589 %
590 \item The |\polyline| command has already been introduced in \pack{pict2e}: in \pack{curve2e} it is redefined so as to accept also polar coordinates; this new version of |\polyline| accepts also an optional argument to specify how two consecutive segments join together; it accepts an unlimited list of point coordinates, possibly stored in macros, enclosed within round parentheses; the command draws a sequence of connected segments that join in order the specified points; the syntax is:
591 \begin{Sintassi}
592 \cs{polyline}\oarg{optional join style}\parg{$P_1$}\parg{$P_2$}\texttt{...}\parg{$P_n$}
593 \end{Sintassi}
594 See figure~\ref{fig:polyline} where a regular pentagon is drawn; usage
595 of polar coordinates is also shown; please notice how polar
596 coordinates act in this figure.
597
598 \begin{figure}[!ht]
599 \begin{Esempio}[\small](0.55)
600 \unitlength=0.5mm
601 \begin{picture}(40,32)(-20,-17)
602 \polyline(90:20)(162:20)(234:20)(306:20)(378:20)(90:20)
603 \end{picture}
604 \end{Esempio}
605 \caption{Polygonal line obtained by means of the \texttt{\string\polyline}
606 command; vertex coordinates are in polar form.}
607 \label{fig:polyline}
608 \end{figure}
609
610 Examples of using polar and cartesian coordinates are shown in figure~\ref{fig:polar}. Notice the
611 |\AutoGrid| macro that draws the grid of mesh lines that are very useful to set objects at the right positions. The main lines are
612 \verb|10\unitlength| apart so that the main squares are clearly visible; if the squares are too small only the median lines are traced with thinner lines; if the squares are not so small thin lines are traced \verb|2\unitlength| apart; otherwise the thin median lines and the thinner \verb|1\unitlength| apart are traced as in regular millimetre drawing paper. The rendering on the screen depends very much on its pixel density, nevertheless we think that e nicely thick grid is very helpful while drawing geometric graphs. When the drawing is completed the \verb|\AutoGrid| command may be commented out so that the grid does not appear in the final document.
613
614 \begin{figure}[htb]
615 \begin{Esempio}[\normalsize]%
616 \unitlength=0.02\textwidth
617 \begin{picture}(40,30)
618 \AutoGrid
619 \Zbox(40,0)[l]{40,0}[1]
620 \Zbox(90:30)[bc]{90{:}30}[1]
621 \Zbox(45:30)[bc]{45{:}30}[1]
622 \Zbox(30,30)[bc]{30,30}[1]
623 \multiput(0,0)(20:10){5}%
624 {\makebox(0,0){\rule{1.5mm}{1.5mm}}}
625 \end{picture}
626 \end{Esempio}
627 \caption[Use of cartesian and absolute polar coordinates]{Use of
628 cartesian and absolute polar coordinates. The \texttt{\string\Zbox}
629 macro is just a shortcut to set a small dot with a (math) legend close
630 to it.}
631 \label{fig:polar}
632 \end{figure}
633
634 A similar example may be obtained with the |\polygon| macro that does
635 not require to terminate the polyline at the starting point.
636 Figure~\ref{fig:polygon} shows how to get a coloured filled pentagon.
637
638 \begin{figure}[!ht]
639 \begin{Esempio}[\normalsize]%
640 \unitlength=.5mm
641 \begin{picture}(40,32)(-20,-20)
642 \color{magenta}
643 \polygon*(90:20)(162:20)(234:20)(306:20)(378:20)
644 \end{picture}
645 \end{Esempio}
646 \caption{A pentagon obtained by means of the \texttt{\string\polygon*}
647 command; vertex coordinates are in relative polar form.}
648 \label{fig:polygon}
649 \end{figure}
650 %
651 \item The new command |\Dashline| (alias: |\Dline| for backwards
652 compatibility):
653 \begin{Sintassi}
654 |\Dashline|\parg{first point}\parg{second point}\marg{dash and gap length}
655 \end{Sintassi}
656 draws a dashed line containing as many dashes as possible, just as long
657 as specified, and separated by a gap exactly the same size; actually,
658 in order to make an even gap-dash sequence, the desired dash length is
659 used to do some computations in order to find a suitable length, close
660 to the one specified, such that the distance of the end points is
661 evenly divided in equally sized dashes and gaps.
662 The end points may be anywhere in the drawing area, without any
663 constraint on the slope of the joining segment. The desired dash length
664 is specified as a fractional multiple of |\unitlength|; see
665 figure~\ref{fig:dashline}.
666
667 \begin{figure}[!ht]
668 \begin{Esempio}[\normalsize]%
669 \unitlength=1mm
670 \begin{picture}(40,40)
671 \AutoGrid(40,40)
672 \Dashline(0,0)(40,10){4}
673 \put(0,0){\circle*{2}}
674 \Dashline(40,10)(0,25){4}
675 \put(40,10){\circle*{2}}
676 \Dashline(0,25)(20,40){4}
677 \put(0,25){\circle*{2}}
678 \put(20,40){\circle*{2}}
679 \Dotline(0,0)(40,40){2}[0.75mm]
680 \put(40,40){\circle*{2}}
681 \end{picture}
682 \end{Esempio}
683 \caption{Dashed lines and graph grid}\label{fig:dashline}
684 \end{figure}
685
686 Another example of usage of cartesian and polar coordinates usage is
687 shown in figure~\ref{fig:polar} together with its code.
688
689 \begin{figure}
690 \begin{Esempio}[\normalsize]%
691 \unitlength=0.025\textwidth
692 \begin{picture}(40,30)
693 \noinnerlines % <-------- !
694 \AutoGrid(40,30)\thicklines
695 \color{red}%
696 \Dashline(0,0)(40,10){2}
697 \Dashline(0,0)(40,20){2}
698 \Dashline(0,0)(40,30){2}
699 \Dashline(0,0)(30,30){2}
700 \Dashline(0,0)(20,30){2}
701 \Dashline(0,0)(10,30){2}
702 \Dashline(40,0)(108:30){2}
703 \Dashline(40,0)(126:30){2}
704 \Dashline(40,0)(144:30){2}
705 \Dashline(40,0)(162:30){2}
706 \end{picture}
707 \end{Esempio}
708 \caption{Different length dashed lines with the same nominal dash
709 length; notice the relative polar coordinates used for the dashed
710 lines starting at the grid lower right vertex.}
711 \label{fig:dashedlines}
712 \end{figure}
713 %%
714 \item Analogous to |\Dashline|, a new command |\Dotline| draws a dotted
715 line with the syntax:
716 \begin{flushleft}
717 |\Dotline|\parg{first point}\parg{end point}\marg{dot gap}
718 \end{flushleft}
719 See figures~\ref{fig:dashline} and~\ref{fig:dottedlines} for examples.
720
721 \begin{figure}[htb]
722 \begin{Esempio}[\normalsize]%
723 \unitlength=0.025\textwidth
724 \begin{picture}(40,30)
725 \AutoGrid(40,30)
726 \Dotline(0,0)(40,10){1.5}[2pt]
727 \Dotline(0,0)(40,20){1.5}[2pt]
728 \Dotline(0,0)(40,30){1.5}[2pt]
729 \Dotline(0,0)(30,30){1.5}[2pt]
730 \Dotline(0,0)(20,30){1.5}[2pt]
731 \Dotline(0,0)(10,30){1.5}[2pt]
732 {\color{red}\relax
733 \Dotline(40,0)(108:30){1.5}
734 \Dotline(40,0)(126:30){1.5}[2pt]
735 \Dotline(40,0)(144:30){1.5}[2pt]
736 \Dotline(40,0)(162:30){1.5}[2pt]}%
737 \end{picture}
738 \end{Esempio}
739 \caption{Different length dotted lines with the same nominal dot gap;
740 again notice the relative polar coordinates for the dotted lines
741 starting at the grid lower right vertex.}
742 \label{fig:dottedlines}
743 \end{figure}
744 %%
745 \item |\GraphGrid| and |\AutoGrid| are commands that draw a red grid
746 under the drawing with lines separated |10\unitlength|s apart; it is
747 described only with a comma separated couple of numbers, representing
748 the base and the height of the grid, see figure~\ref{fig:dashline}; it's
749 better to specify multiples of ten and the grid can be placed anywhere
750 in the drawing canvas by means of |\put|, whose cartesian coordinates
751 are multiples of 10; nevertheless the grid line distance is rounded to
752 the nearest multiple of 10, while the point coordinates specified to
753 |\put| are not rounded at all; therefore some care should be used to
754 place the working grid on the drawing canvas.
755 \begin{Sintassi}
756 |\GraphicGrid|\parg{grad base, grid height}
757 |\AutoGrid|
758 \end{Sintassi}
759 This grid is intended as an aid while drawing; even if you sketch your
760 drawing on millimetre paper, the drawing grid turns out to be very
761 useful; one must only delete or comment out the command when the drawing
762 is finished. Several examples of usage of such grid are shown in several
763 figures.
764
765 |\Autogrid| does not require arguments, but requires the canvas
766 dimensions and offsets to be specified as multiples of~10; if the latter
767 are specified they are simply ignored.
768 %%
769 \item New trigonometric function macros have been computed by means of
770 the functionalities of the |xfp| included in the \LaTeX\ kernel. The
771 difference with the other existing macros is that angles are specified
772 in sexagesimal degrees, so that the users need not transform to radians.
773 The computations are done taking into account that “abnormal” values that
774 can occasionally be avoided, for example $\tan 90^\circ$ must be avoided
775 and replaced with a suitably large number, because the \TeX\ system does
776 not handle “infinity”.
777
778 These trigonometric functions are used within the complex number
779 macros; but if the user wants to use them the syntax is the following:
780 \begin{Sintassi}
781 \cs{SinOf}\meta{angle}\texttt{to}\meta{control sequence}
782 \cs{CosOf}\meta{angle}\texttt{to}\meta{control sequence}
783 \cs{TanOf}\meta{angle}\texttt{to}\meta{control sequence}
784 \end{Sintassi}
785 The \meta{control sequence} may then be used, for example, as a
786 multiplying factor of a length.
787 %%
788 \item Arcs can be drawn as simple circular arcs, or with one or two
789 arrows at their ends (curved vectors); the syntax is:
790 \begin{Sintassi}
791 \cs{Arc}\parg{center}\parg{starting point}\marg{angle}
792 \cs{VectorArc}\parg{center}\parg{starting point}\marg{angle}
793 \cs{VectorARC}\parg{center}\parg{starting point}\marg{angle}
794 \cs{VVectorArc}\parg{center}\parg{starting point}\marg{angle}
795 \end{Sintassi}
796 If the angle is specified numerically it must be enclosed in braces,
797 while if it is specified with a control sequence the braces (curly
798 brackets) are not necessary. The above macro |\Arc| draws a simple
799 circular arc without arrows; |\VectorArc| draws an arc with an arrow
800 tip at the ending point; |\VectorARC| (alias |\VVectorArc|) draws an
801 arc with arrow tips at both ends; see figure~\ref{fig:arcs}.
802
803 Notice that the starting point may be specified with polar coordinates; differently to cartesian coordinates, that are absolute with respect with the drawing axes, the polar ones are relative to the center of the arcs with or without vector tips.
804 \begin{figure}
805 \begin{Esempio}[\small]%
806 \unitlength=0.5mm
807 \begin{picture}(60,40)
808 \GraphGrid(60,40)
809 \Arc(0,20)(30,0){60}
810 \VECTOR(0,20)(30,0)\VECTOR(0,20)(32.5,36)
811 \VectorArc(0,20)(15,10){60}
812 \put(20,20){\makebox(0,0)[l]{$60^\circ$}}
813 \VectorARC(60,20)(60,0){-180}
814 \VVectorArc(60,20)(135:10){90}
815 \end{picture}
816 \end{Esempio}
817 \caption{Arcs and curved vectors}\label{fig:arcs}
818 \end{figure}
819 %%
820 \item The available commands allow to create the drawings necessary to prove some geometrical theorems; for example let us prove the Pitagora's theorem. Figure~\ref{fig:pitagora} displays a right triangle with its hypothenuse laying horizontally; its vertices are labeled \textsf{A}, \textsf{B}, and \textsf{C}, being \textsf{A} the right angle vertex. The height relative to the hypothenuse intersects this side in point \textsf{H}, and divides the whole triangle \textsf{ABC}, in two similar smaller ones \textsf{AHC}, and\textsf{ABH}. Segments \textsf{CH}, and\textsf{HB}, add to the whole hypothenuse length. Figure~\ref{fig:pitagora} displays also the square \textsf{CBDE}, built on the hypothenuse and divided in two rectangles \textsf{CHFE}, and \textsf{HBDF}, where \textsf{HF} is the continuation of the height line.
821
822 The lengths of the original right triangle sides are $a, b, c$ as marked on the figure; Point \textsf{H} divides the hypothenuse of length $c$ in two shorter segments of lengths $d, e$, respectively, as marked in the figure
823
824 Since the three triangles are similar, we can set up the relationships between their sides:
825 \begin{align*}
826 d : a = a : c &\Longrightarrow d = a^2/c\\
827 e : b = b : c &\Longrightarrow e = b^2/c
828 \end{align*}
829
830 Therefore rectangle \textsf{CHFE} area equals $ c\cdot d = c\cdot a^2/c = a^2$. Similarly rectangle \textsf{HBDF} area equals $ c\cdot e = c\cdot b^2/c = b^2$. The square built on the hypothenuse has an area equal to $c^2$; therefore it is
831 \begin{equation*}
832 c^2 = a^2 + b^2
833 \end{equation*}
834 which proves the Pitagora's theorem.
835
836 \begin{figure}
837 \centering
838 \begin{Esempio}
839 \unitlength=1mm
840 \begin{picture}(70,80)(-10,-50)
841 \AutoGrid
842 \thicklines
843 \polygon(0,0)(50,0)(18,24)
844 \thinlines
845 \polyline(0,0)(0,-50)(50,-50)(50,0)
846 \Pbox(0,0)[r]{C}[0.75ex]
847 \Pbox(18,0)[bl]{H}[0.75ex]
848 \Pbox(50,0)[l]{B}[0.75ex]
849 \Pbox(18,24)[b]{A}[0.75ex]
850 \Pbox(0,-50)[br]{E}[0.75ex]
851 \Pbox(50,-50)[bl]{D}[0.75ex]
852 \Pbox(18,-50)[br]{F}[0.75ex]
853 \Zbox(10,12)[br]{a}[0]
854 \Zbox(33,12)[bl]{b}[0]
855 \Zbox(25,0)[t]{c}[0]
856 \Zbox(9,0)[b]{d}[0]
857 \Zbox(30,0)[b]{e}[0]
858 \Zbox(50,-25)[r]{c}[0]
859 \Zbox(25,-50)[b]{c}[0]
860 \Zbox(0,-25)[l]{c}[0]
861 \Dashline(18,24)(18,-50){1.5}
862 \end{picture}
863 \end{Esempio}
864 \caption{Geometrical construction to prove Pitagora's theorem}
865 \label{fig:pitagora}
866 \end{figure}
867 %%
868 \item A multitude of commands have been defined in order to manage
869 complex numbers; actually complex numbers are represented as a comma
870 separated pair of fractional numbers; internally these macros use
871 only the cartesian form, and output, unless
872 differently specified is also in cartesian form; but input can be in
873 polar form. They are used to address specific points in the drawing
874 plane, but also as operators so as to scale and rotate other objects.
875 In the following \meta{vector} means a comma separated pair of
876 fractional numbers, \meta{vector macro} means a macro that contains a
877 comma separated pair of fractional numbers; \meta{angle macro} means a
878 macro that contains the angle of a vector in sexagesimal degrees;
879 \meta{argument} means a brace delimited numeric value, even a macro;
880 \meta{numeric macro} means a macro that contains a fractional number;
881 \textit{macro} is a valid macro name, i.e.~a backslash followed by
882 letters, or anything else that can receive a definition. A
883 \emph{direction} of a vector is its versor; the angle of a vector is
884 the angle between the vector and the positive $x$ axis in
885 counterclockwise direction, as it is used in the
886 Euler formula $ \vec{v} = M\eu^{\mathrm{j}\varphi}$.
887
888 \begin{Sintassi}
889 |\MakeVectorFrom|\meta{numeric macro}\meta{numeric macro}|to|\meta{vector macro}
890 |\CopyVect|\meta{first vector}|to|\meta{second vector macro}
891 |\ModOfVect|\meta{vector}|to|\meta{modulus macro}
892 |\DirOfvect|\meta{vector}|to|\meta{versor macro}
893 |\ModAndDirOfVect|\meta{vector}|to|\meta{modulus macro}|and|\meta{versor macro}
894 |\ModAndAngleOfVect|\meta{vector}|to|\meta{modulus macro}|and|\meta{angle macro}
895 {\setfontsize{10}|\DistanceAndDirOfVect|\meta{1st vector} |minus|\meta{2nd vector}
896 \qquad\qquad|to|\meta{distance macro} |and|\meta{versor macro}}
897 |\XpartOfVect|\meta{vector}|to|\meta{macro}
898 |\YpartOfVect|\meta{vector}|to|\meta{macro}
899 \end{Sintassi}
900
901
902 \begin{Sintassi}
903 |\DirFromAngle|\meta{angle}|to|\meta{versor macro}
904 |\ArgOfVect|\meta{vector}|to|\meta{angle macro}
905 |\ScaleVect|\meta{vector}|by|\meta{scaling factor}|to|\meta{vector macro}
906 |\ConjVect|\meta{vector}|to|\meta{conjugate vector macro}
907 |\SubVect|\meta{subtrahend vector}|from|\meta{minuend vector}|to|\meta{vector macro}
908 |\AddVect|\meta{first vector}|and|\meta{second vector}|to|\meta{vector macro}
909 |\Multvect|\marg{first vector}*\marg{second vector}*\marg{vector macro} (\textcolor{blue}{the
910 \qquad\qquad asterisks are optional; either one changes the second vector
911 \qquad\qquad into its complex conjugate})
912 |\MultVect|\meta{first vector}|by|\meta{second vector}|to|\meta{vector macro}
913 \qquad\qquad (\textcolor{red}{discouraged; maintained for backwards compatibility})
914 |\MultVect|\meta{first vector}|by*|\meta{second vector}|to|\meta{vector macro}
915 \qquad\qquad (\textcolor{red}{discouraged; maintained for backwards compatibility})
916 |\Divvect|\marg{dividend vector}\marg{divisor vector}\marg{vector macro} {\color{blue}notice
917 \qquad\qquad that this new command warns the user if the divisor is zero}
918 |\DivVect|\meta{dividend vector}|by|\meta{divisor vector}|to|\meta{vector macro}
919 \qquad\qquad (\textcolor{red}{discouraged: maintained for backwards compatibility})
920 \end{Sintassi}
921 %%
922 \item General curves can be drawn with the \pack{pict2e} macro
923 |\curve| but it requires the specification of the third-order
924 Bézier-spline control points; sometimes it's better to be very
925 specific with the control points and there is no other means to
926 do a decent graph; sometimes the curves to be drawn are not so
927 tricky and a general set of macros can be defined so as to
928 compute the control points, while letting the user specify only
929 the nodes through which the curve must pass, and the tangent
930 direction of the curve in such nodes. Such commands are the following:
931 \begin{itemize}[noitemsep]
932
933 \item \cs{Curve} draws a sequence of arcs as explained above, using
934 third order (cubic) Bézier splines. The starred version of this command
935 fills the internal part of the curve with the current color; if the
936 last arc finishes where the fist arc starts, it is clear what is the
937 interior; if it does not, the driver (not the code of this package,
938 but the driver between this code and the physical representation on
939 paper or screen) assumes a straight line closure of the whole path.
940 The syntax offers several variants but it is substantially the following:
941 \begin{Sintassi}
942 |\Curve|\parg{node}\aarg{direction}\dots\parg{node}\aarg{direction}
943 |\Curve*|\parg{node}\aarg{direction}\dots\parg{node}\aarg{direction}
944 \qquad\qquad\dots\aarg{direction}\oarg{new direction}\parg{node}\dots
945 \end{Sintassi}
946 See some more explanation below.
947
948 \item \cs{Qurve} is similar to |\Curve|, but with second order
949 (quadratic) Bézier splines. The starred version fills the interior
950 with the current color. Its syntax si similar to that of |\Curve|.
951
952 \item \cs{CurveBetween} draws a single cubic Bézier spline between two
953 given nodes and with two given direction vectors. This macro is similar to |\Curve|, but it is used to draw a third order Bézier curve between just two nodes and require just two directions
954
955 \item \cs{CBezierBetween} draws a single cubic Bézier spline between
956 two given nodes, with two given direction versors along which the
957 control node distances are specified. This is the most general macro
958 (rather difficult to use) with which not only the arc end points are
959 specified but also the control nodes coordinates are given. It is similar to |\CurveBetween| but the contol points of the single arc can be specified; the arc is perfect, but the syntax is more complicated. See below for examples.
960
961 \end{itemize}
962
963 % le equazioni parametriche del cuore, da stackexchange, sono
964 %\def\x(#1){sin(#1)^3}
965 %\def\y(#1){(13*cos(#1)-5*cos(2*#1)-2*cos(3*#1)-cos(4*#1))/16}
966 % Varrebbe a penda di provarle con curve2e
967 %
968 \begin{figure}[!ht]
969 \begin{Esempio}[\small]%
970 \unitlength=8mm\relax
971 \begin{picture}(5,5)
972 \put(0,0){\framebox(5,5){}}\thicklines\roundcap
973 \Curve(2.5,0)<0.1,1>(5,3.5)<0,1>%
974 (4,5)<-1,0>(2.5,3.5)<-0.1,-1.2>[-0.1,1.2]%
975 (1,5)<-1,0>(0,3.5)<0,-1>(2.5,0)<0.1,-1>
976 \end{picture}
977 \end{Esempio}
978 \caption{A heart shaped curve with cusps drawn with \texttt{\string\Curve}}
979 \label{fig:curve}
980
981 \vspace*{2\baselineskip}
982
983 \begin{Esempio}[\small]%
984 \unitlength=8mm\relax
985 \begin{picture}(5,5)
986 \put(0,0){\framebox(5,5){}}\thicklines\roundcap
987 \color{green}\relax
988 \Curve*(2.5,0)<0.1,1>(5,3.5)<0,1>%
989 (4,5)<-1,0>(2.5,3.5)<-0.1,-1.2>[-0.1,1.2]%
990 (1,5)<-1,0>(0,3.5)<0,-1>(2.5,0)<0.1,-1>
991 \end{picture}
992 \end{Esempio}
993 \caption{Coloring the inside of a closed path drawn with \texttt{\string\Curve*}}
994 \label{fig:colored-curve}
995 \end{figure}
996
997 The main macro is |\Curve| and must be followed by an “unlimited”
998 sequence of node-direction coordinates as a quadruple
999 defined as
1000 \[
1001 \parg{node coordinates}\aarg{direction vector}
1002 \]
1003 Possibly if a sudden change of direction has to be performed (cusp)
1004 another item can be inserted after one of those quadruples in the form
1005 \[
1006 \mbox{\dots\parg{...}\aarg{...}\oarg{new direction vector}\parg{...}\aarg{...}\dots}
1007 \]
1008
1009 Sometimes it is necessary to specify the “tension” or the “looseness”
1010 of a specific Bézier arc; such tension parameters range from 0 (zero)
1011 to~4; the zero value implies a very stiff arc, as if it was a string
1012 subject to a high tension (i.e. with zero looseness); a value of~4
1013 implies a very low tension (very high looseness), almost as if the
1014 string was not subject to any tension. In \MF\ or \MP\ language such a
1015 concept is used very often; in this package, where the Hobby
1016 algorithms are not used, the parameter value appears to mean the
1017 opposite of tension.
1018 A couple of comma separated tension values may be optionally used, they
1019 are separated with a semicolon from the direction vector,
1020 and they apply to the arc terminating with the last node; their
1021 specification must precede any possible change of tangent according to
1022 this syntax\footnote{The tension may be specified only for cubic
1023 splines, because the quadratic ones do not use enough parameters to
1024 control the tension; not all commands for drawing cubic splines accept
1025 this optional tension specification.}:
1026 \[
1027 \makebox[\linewidth]{\small\dots\parg{node}\Aarg{\meta{direction vector};\meta{start tension},\meta{end tension}}\parg{node}\aarg{dirextion}\dots}
1028 \]
1029
1030 The |\Curve| macro does not (still) have facilities for cycling the
1031 path, that is to close the path from the last specified node-direction
1032 to the first specified node-direction; but, as already mentioned, if
1033 the ending node of the last arc does not coincide with the starting
1034 node of the first arc, a straight line is assumed to join such nodes;
1035 this line does not get drawn, but with starred commands no lines are
1036 drawn because only the interior is coloured.
1037 The tangent direction need not be specified with a unit vector,
1038 although only its direction is relevant; the scaling of the specified
1039 direction vector to a unit vector is performed by the macro itself.
1040 Therefore one cannot specify the fine tuning of the curve convexity as
1041 it can be done with other programs or commands, as, for example, with
1042 \MF\ or the |pgf/tikz| package and environment.
1043 See figure~\ref{fig:curve} for an example.
1044
1045 With the starred version of |\Curve|, instead of stroking the contour,
1046 the macro fills up the contour with the selected current color, see
1047 figure~\ref{fig:colored-curve}.
1048
1049 Figure~\ref{fig:arcspline} shows a geometric construction that
1050 contains the geometric elements and symbols used to determine the
1051 parameters of a cubic spline required to draw a quarter circle. This
1052 construction contains many of the commands described so far.
1053
1054 \begin{figure}[p]
1055 \begin{minipage}{\linewidth}\small
1056 \begin{verbatim}
1057 \unitlength=0.007\textwidth
1058 \begin{picture}(100,90)(-50,-50)
1059 \put(-50,0){\vector(1,0){100}}\put(50,1){\makebox(0,0)[br]{$x$}}%
1060 \put(20,-1){\makebox(0,0)[t]{$s$}}%
1061 \put(0,0){\circle*{2}}\put(-1,-1){\makebox(0,0)[tr]{$M$}}%
1062 \legenda(12,-45){s=\overline{MP_2}=R\sin\theta}%
1063 \put(0,-50){\vector(0,1){90}}%
1064 \put(1,40){\makebox(0,0)[tl]{$y$}}%
1065 \put(0,-40){\circle*{2}}\put(1,-41){\makebox(0,0)[lt]{$C$}}%
1066 \segment(0,-40)(-40,0)\segment(0,-40)(40,0)%
1067 \put(-41,1){\makebox(0,0)[br]{$P_1$}}\put(-40,0){\circle*{2}}%
1068 \put(41,1){\makebox(0,0)[bl]{$P_2$}}\put(40,0){\circle*{2}}%
1069 \put(0,0){\linethickness{1pt}\Arc(0,-40)(40,0){90}}%
1070 \segment(-40,0)(-20,20)\put(-20,20){\circle*{2}}%
1071 \put(-20,21.5){\makebox(0,0)[b]{$C_1$}}%
1072 \segment(40,0)(20,20)\put(20,20){\circle*{2}}%
1073 \put(20,21.5){\makebox(0,0)[b]{$C_2$}}%
1074 \put(0,-40){\put(0,56.5685){\circle*{2}}%
1075 \put(1,58){\makebox(0,0)[bl]{$P$}}}%
1076 \VectorARC(0,-40)(15,-25){45}\put(10,-18){\makebox(0,0)[c]{$\theta$}}%
1077 \VectorARC(40,0)(20,0){-45}\put(19,5){\makebox(0,0)[r]{$\theta$}}%
1078 \VectorARC(-40,0)(-20,0){45}\put(-19,5){\makebox(0,0)[l]{$\theta$}}%
1079 \put(-20,-18){\makebox(0,0)[bl]{$R$}}%
1080 \put(-32,13){\makebox(0,0)[bl]{$K$}}%
1081 \put(32,13){\makebox(0,0)[br]{$K$}}%
1082 \end{picture}
1083 \end{verbatim}
1084 \end{minipage}
1085 \par
1086 \vspace*{\stretch{1}}
1087 \par
1088 \begin{minipage}{\linewidth}\centering
1089 % \unitlength=0.007\textwidth
1090 % \begin{picture}(100,90)(-50,-50)
1091 % \put(-50,0){\vector(1,0){100}}\put(50,1){\makebox(0,0)[br]{$x$}}%
1092 % \put(20,-1){\makebox(0,0)[t]{$s$}}%
1093 % \put(0,0){\circle*{2}}\put(-1,-1){\makebox(0,0)[tr]{$M$}}%
1094 % \legenda(12,-45){s=\overline{MP_2}=R\sin\theta}%
1095 % \put(0,-50){\vector(0,1){90}}%
1096 % \put(1,40){\makebox(0,0)[tl]{$y$}}%
1097 % \put(0,-40){\circle*{2}}\put(1,-41){\makebox(0,0)[lt]{$C$}}%
1098 % \segment(0,-40)(-40,0)\segment(0,-40)(40,0)%
1099 % \put(-41,1){\makebox(0,0)[br]{$P_1$}}\put(-40,0){\circle*{2}}%
1100 % \put(41,1){\makebox(0,0)[bl]{$P_2$}}\put(40,0){\circle*{2}}%
1101 % \put(0,0){\linethickness{1pt}\Arc(0,-40)(40,0){90}}%
1102 % \segment(-40,0)(-20,20)\put(-20,20){\circle*{2}}%
1103 % \put(-20,21.5){\makebox(0,0)[b]{$C_1$}}%
1104 % \segment(40,0)(20,20)\put(20,20){\circle*{2}}%
1105 % \put(20,21.5){\makebox(0,0)[b]{$C_2$}}%
1106 % \put(0,-40){\put(0,56.5685){\circle*{2}}%
1107 % \put(1,58){\makebox(0,0)[bl]{$P$}}}%
1108 % \VectorARC(0,-40)(15,-25){45}
1109 % \put(10,-18){\makebox(0,0)[c]{$\theta$}}%
1110 % \VectorARC(40,0)(20,0){-45}
1111 % \put(19,5){\makebox(0,0)[r]{$\theta$}}%
1112 % \VectorARC(-40,0)(-20,0){45}
1113 % \put(-19,5){\makebox(0,0)[l]{$\theta$}}%
1114 % \put(-20,-18){\makebox(0,0)[bl]{$R$}}%
1115 % \put(-32,13){\makebox(0,0)[bl]{$K$}}%
1116 % \put(32,13){\makebox(0,0)[br]{$K$}}%
1117 % \end{picture}
1118 \end{minipage}
1119 \caption{The code to display the nodes and
1120 control points for an arc to be approximated
1121 with a cubic Bézier spline}
1122 \label{fig:arcspline}
1123 \end{figure}
1124
1125
1126 To show what you can do with |\CurveBetween| see the code and result
1127 shown in figure~\ref{fig:curva-due-punti}. Notice the effect of
1128 changing the directions at both or at the end nodes of a single cubic
1129 spline. The directions are conveniently expressed with unit vectors
1130 described by polar coordinates. The |\CurveBetween| macro is built on
1131 |\CBezierBetween|; this latter command is very complicated to describe and its use is reserved to experienced users; its syntax is described in the code documentation file |cureve2e.pdf|; the reader is encouraged to examine it in case s/he is willing to use it.
1132
1133 \begin{figure}\centering\unitlength=0.004\textwidth
1134 \begin{picture}(220,120)(-50,-20)
1135 \put(0,60){\Line(-50,0)(50,0)
1136 \CurveBetween-50,0and50,0WithDirs15:1and{-15:1}
1137 \CurveBetween-50,0and50,0WithDirs30:1and{-30:1}
1138 \CurveBetween-50,0and50,0WithDirs45:1and{-45:1}
1139 \CurveBetween-50,0and50,0WithDirs60:1and{-60:1}
1140 \CurveBetween-50,0and50,0WithDirs75:1and{-75:1}
1141 \CurveBetween-50,0and50,0WithDirs90:1and{-90:1}}
1142 \put(120,60){%
1143 \Line(-50,0)(50,0)
1144 \CurveBetween-50,0and50,0WithDirs15:1and{15:1}
1145 \CurveBetween-50,0and50,0WithDirs30:1and{30:1}
1146 \CurveBetween-50,0and50,0WithDirs45:1and{45:1}
1147 \CurveBetween-50,0and50,0WithDirs60:1and{60:1}
1148 \CurveBetween-50,0and50,0WithDirs75:1and{75:1}
1149 \CurveBetween-50,0and50,0WithDirs90:1and{90:1}}
1150 \put(0,0){%
1151 \Line(-50,0)(50,0)
1152 \CurveBetween-50,0and50,0WithDirs45:1and{-15:1}
1153 \CurveBetween-50,0and50,0WithDirs45:1and{-30:1}
1154 \CurveBetween-50,0and50,0WithDirs45:1and{-45:1}
1155 \CurveBetween-50,0and50,0WithDirs45:1and{-60:1}
1156 \CurveBetween-50,0and50,0WithDirs45:1and{-75:1}
1157 \CurveBetween-50,0and50,0WithDirs45:1and{-90:1}}
1158 \put(120,0){%
1159 \Line(-50,0)(50,0)
1160 \CurveBetween-50,0and50,0WithDirs45:1and{15:1}
1161 \CurveBetween-50,0and50,0WithDirs45:1and{30:1}
1162 \CurveBetween-50,0and50,0WithDirs45:1and{45:1}
1163 \CurveBetween-50,0and50,0WithDirs45:1and{60:1}
1164 \CurveBetween-50,0and50,0WithDirs45:1and{75:1}
1165 \CurveBetween-50,0and50,0WithDirs45:1and{90:1}}
1166 \end{picture}
1167 \caption{Curves between two points with different start and end slopes}\label{fig:curva-due-punti}
1168 \end{figure}
1169
1170 A little more complicated is the use of the
1171 |\CBezierBetween| macro, figure~\ref{fig:Cbezier}. The
1172 directions are specified with unit vectors in polar form;
1173 the control points are specified by adding their distances
1174 from their neighbouring nodes; actually the right distance
1175 is maintained to the value~1, while the left one increases
1176 from~4 to~10.
1177 The black line corresponds to the standard |\CurveBetween|
1178 where the default distance is computed to trace an arc of a
1179 circle and is approximately~3.5.
1180
1181 \begin{figure}[!tb]
1182 \begin{minipage}[t]{0.52\textwidth}\small
1183 \begin{verbatim}
1184 \unitlength=0.1\textwidth
1185 \begin{picture}(10,3)
1186 \CurveBetween0,0and10,0WithDirs1,1and{1,-1}
1187 \color{red}%
1188 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists4And{1}
1189 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists6And{1}
1190 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists8And{1}
1191 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists10And{1}
1192 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists12And{1}
1193 \end{picture}
1194 \end{verbatim}
1195 \end{minipage}
1196 \hfill
1197 \begin{minipage}{0.40\textwidth}\raggedleft
1198 \unitlength=0.1\textwidth
1199 \begin{picture}(10,3)(0,1.25)
1200 \CurveBetween0,0and10,0WithDirs1,1and{1,-1}
1201 \color{red}%
1202 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists4And{1}
1203 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists6And{1}
1204 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists8And{1}
1205 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists10And{1}
1206 \CbezierBetween0,0And10,0 WithDirs45:1And-45:1UsingDists12And{1}
1207 \end{picture}
1208 \end{minipage}
1209 \caption{Comparison between similar arcs drawn with \cs{CurveBetween} with the default tension values (black)
1210 and with several tension values specified (red)}
1211 \label{fig:Cbezier}
1212 \end{figure}
1213
1214 In figure~\ref{fig:tensions} the effect of tension
1215 specification is shown. The red line corresponds to the
1216 default tension, since the tension values are not specified.
1217 The black lines correspond to the various values used in the
1218 various commands to the |\Curve| macro.
1219 With a tension of zero, the spline is almost coincident
1220 with the horizontal base line of the frame. Increasing the
1221 parameter value to~4.5, the curved becomes taller and
1222 taller, until it wraps itself displaying an evident loop.
1223 We would say that the value of ~2 is a reasonable maximum
1224 one and that increasing that value is just to obtain special
1225 effects.
1226
1227 \begin{figure}[!htb]\centering
1228 \begin{Esempio}[\setfontsize{8.5}]%
1229 \unitlength=0.01\textwidth
1230 \begin{picture}(70,70)
1231 \put(0,0){\color{black}\framebox(70,70){}}
1232 \put(0,0){\color{red}%
1233 \Curve(0,0)<1,1>(70,0)<1,-1>}
1234 \Curve(0,0)<1,1>(70,0)<1,-1;0,0>
1235 \Curve(0,0)<1,1>(70,0)<1,-1;0.2,0.2>
1236 \Curve(0,0)<1,1>(70,0)<1,-1;2,2>
1237 \Curve(0,0)<1,1>(70,0)<1,-1;4.5,4.5>
1238 \Curve(0,0)<1,1>(70,0)<1,-1;0,3>
1239 \Curve(0,0)<1,1>(70,0)<1,-1;3,0>
1240 \end{picture}
1241 \end{Esempio}
1242 \caption{The effects of tension factors}\label{fig:tensions}
1243 \end{figure}
1244
1245 Figure~\ref{fig:sinewave} displays two approximations of
1246 a sine wave; Bézier splines can approximate transcendental
1247 curves, but the approximation may be a poor one, depending
1248 on the approximated curve, when few arcs are used to draw
1249 it. With arcs specified with more complicated macros the
1250 approximation is better even with a lower number of arcs.
1251 With many arcs it is possible to approximate almost nything.
1252 On the left side of figure~\ref{fig:sinewave} a modest
1253 approximation is obtained with just three standard arcs
1254 obtained with |\Curve| and four node specifications; on the
1255 right we have just two arcs created with |\CBezierBetween|
1256 with tension specification and control point distances;
1257 this drawing is almost undistinguishable from a real
1258 sinusoid.
1259
1260 \begin{figure}[!htb]
1261 \begin{minipage}{\linewidth}\small
1262 \begin{verbatim}
1263 \unitlength=0.01\textwidth
1264 \begin{picture}(100,50)(0,-25)
1265 \put(0,0){%
1266 \VECTOR(0,0)(45,0)\VECTOR(0,-25)(0,25)
1267 \Pbox(45,0)[b]{x}[0]\Pbox(0,26)[tl]{y[0]}
1268 \Curve(0,0)<77:1>(10,20)<1,0;2,0.4>(30,-20)<1,0;0.4,0.4>(40,0)<77:1;0.4,2>
1269 }
1270 \put(55,0){%
1271 \VECTOR(0,0)(45,0)\VECTOR(0,-25)(0,25)
1272 \Pbox(45,0)[b]{x}[0]\Pbox(0,26)[tl]{y}[0]
1273 \CbezierBetween0,0And20,0WithDirs77:1And-77:1UsingDists28And{28}
1274 \CbezierBetween20,0And40,0WithDirs-77:1And77:1UsingDists28And{28}}
1275 \end{picture}
1276 \end{verbatim}
1277 \end{minipage}\vspace{\baselineskip}
1278
1279 \begin{minipage}{\linewidth}
1280 \unitlength=0.01\textwidth
1281 \begin{picture}(100,50)(0,-25)
1282 \put(0,0){\VECTOR(0,0)(45,0)\VECTOR(0,-25)(0,25)
1283 \Pbox(45,0)[b]{x}[0]\Pbox(0,26)[tl]{y}[0]
1284 \Curve(0,0)<77:1>(10,20)<1,0;2,0.4>(30,-20)<1,0;0.4,0.4>(40,0)<77:1;0.4,2>
1285 }
1286 \put(55,0){\VECTOR(0,0)(45,0)\VECTOR(0,-25)(0,25)
1287 \Pbox(45,0)[b]{x}[0]\Pbox(0,26)[tl]{y}[0]
1288 \CbezierBetween0,0And20,0WithDirs77:1And-77:1UsingDists28And{28}
1289 \CbezierBetween20,0And40,0WithDirs-77:1And77:1UsingDists28And{28}}
1290 \end{picture}
1291 \end{minipage}
1292 \caption{A sequence of arcs; the left figure has been drawn with the
1293 \cs{Curve} command with a sequence of four couples of node-direction
1294 arguments; the right figure has been drawn with two commands
1295 \cs{CbezierBetween} that include also the specification of the control
1296 points}
1297 \label{fig:sinewave}
1298 \end{figure}
1299
1300 In figure~\ref{fig:quadratic-arcs} some lines are shown;
1301 they are drawn with quadratic splines by means of the
1302 |\Qurve| macro. In the left there are some open and closed
1303 curves inscribed within a square.
1304 On the right a “real" circle is compared to a quadratic
1305 spline circle; the word “real” is emphasised because it
1306 actually is an approximation with four quarter-circle cubic
1307 splines that, in spite of being drawn with third degree
1308 parametric polynomials, approximate very well a real circle;
1309 on the opposite the quadratic spline circle is clearly a
1310 poor approximation even if the maximum radial error amounts
1311 just to about 6\% of the radius.
1312
1313 \begin{figure}[!htb]
1314 \begin{minipage}{\linewidth}
1315 \begin{Verbatim}[fontsize=\setfontsize{7.75}]
1316 \unitlength=0.0045\textwidth
1317 \begin{picture}(100,100)
1318 \put(0,0){\framebox(100,100){}}
1319 \put(50,50){%
1320 \Qurve(0,-50)<1,0>(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>(0,-50)<1,0>
1321 \color{green}
1322 \Qurve*(0,-50)<0,1>(50,0)<1,0>[-1,0](0,50)<0,1>[0,-1](-50,0)<-1,0>[1,0](0,-50)<0,-1>
1323 }
1324 \Qurve(0,0)<1,4>(50,50)<1,0>(100,100)<1,4>
1325 \put(5,50){\Qurve(0,0)<1,1.5>(22.5,20)<1,0>(45,0)<1,-1.5>%
1326 (67.5,-20)<1,0>(90,0)<1,1.5>}
1327 \Zbox(0,0)[tc]{0,0}\Zbox(100,0)[tc]{100,0}
1328 \Zbox(100,100)[bc]{100,100}\Zbox(0,100)[bc]{0,100}
1329 \Pall[2](0,0)\Pall[2](100,0)\Pall[2](100,100)\Pall[2](0,100)
1330 \end{picture}
1331 \hfill
1332 \begin{picture}(100,100)
1333 \put(0,0){\framebox(100,100){}}
1334 \put(50,50){%
1335 \Qurve(0,-50)<1,0>(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>(0,-50)<1,0>
1336 \Curve(0,-50)<1,0>(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>(0,-50)<1,0>}
1337 \Zbox(50,50)[t]{O}\Pall[2](50,50)\put(50,50){\Vector(45:50)}\Zbox(67,70)[tl]{R}
1338 \end{picture}
1339 \end{Verbatim}
1340 \end{minipage}\vspace{2\baselineskip}
1341
1342 \begin{minipage}{\linewidth}
1343 \unitlength=0.0045\textwidth
1344 \begin{picture}(100,100)
1345 \put(0,0){\framebox(100,100){}}
1346 \put(50,50){\Qurve(0,-50)<1,0>(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>(0,-50)<1,0>}
1347 \put(50,50){\color{green}%
1348 \Qurve*(0,-50)<0,1>(50,0)<1,0>[-1,0](0,50)<0,1>[0,-1](-50,0)<-1,0>[1,0](0,-50)<0,-1>}
1349 \Qurve(0,0)<1,4>(50,50)<1,0>(100,100)<1,4>
1350 \put(5,50){\Qurve(0,0)<1,1.5>(22.5,20)<1,0>(45,0)<1,-1.5>(67.5,-20)<1,0>(90,0)<1,1.5>}
1351 \Zbox(0,0)[tc]{0,0}\Zbox(100,0)[tc]{100,0}
1352 \Zbox(100,100)[bc]{100,100}\Zbox(0,100)[bc]{0,100}
1353 \Pall[2](0,0)\Pall[2](100,0)\Pall[2](100,100)\Pall[2](0,100)
1354 \end{picture}
1355 \hfill
1356 \begin{picture}(100,100)
1357 \put(0,0){\framebox(100,100){}}
1358 \put(50,50){\Qurve(0,-50)<1,0>(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>(0,-50)<1,0>
1359 \Curve(0,-50)<1,0>(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>(0,-50)<1,0>}
1360 \Zbox(50,50)[t]{O}\Pall[2](50,50)\put(50,50){\Vector(45:50)}\Zbox(67,70)[tl]{R}[0]
1361 \end{picture}
1362 \end{minipage}
1363
1364 \caption{\rule{0pt}{4ex}Several graphs drawn with quadratic
1365 Bézier splines. On the right a quadratic spline circle is
1366 compared with a cubic line circle.}
1367 \label{fig:quadratic-arcs}
1368 \end{figure}
1369
1370 Notice that the previous version of \pack{curve2e} contained
1371 an error and would color the outside of the green four-pointed
1372 star. The |curve2e-v161| package, attached to this bundle, has
1373 been corrected; therefore it is not actually identical to the
1374 previous version, although the latter one performed correctly
1375 for everything else except for color filled quadratic paths.
1376
1377 The “real” circle, even if rendered with quarter circles, is visually very similar to a true circumference, but any Bézier circle arc that approximates a circumference arc of the same amplitude, displays a small error at an angle of 1/4 and 3/4 the total arc amplitude; this error diminishes as the total arc amplitude diminishes, nevertheless the error is there. If the arc amplitude amounts to 180°, the maximum error is at 45° and at 135° angular distances from the staring point. It amounts to 2\% of the arc radius; see figure~\ref{fig:halfcircle}, where a half circle is compared with a sequence of four arcs of 45° each, drawn by means of the \cs{Curve} macro; the code is the following:
1378 \begin{verbatim}
1379 \unitlength=0.005\linewidth
1380 \begin{picture}(100,50)(-50,0)
1381 \AutoGrid
1382 \Zbox(0,0)[t]{\textsf{O}}[1]
1383 \Arc(0,0)(50,0){180}
1384 \VECTOR(0,0)(45:50)\Zbox(45:25)[br]{R}[0]
1385 \Curve(50,0)<0,1>(45:50)<135:1>(0,50)<-1,0>%
1386 (135:50)<225:1>(-50,0)<0,-1>
1387 % \Arc(0,0)(50,0){90}\Arc(0,0)(0,50){90}
1388 % \Curve(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>
1389 \end{picture}
1390 \end{verbatim}
1391
1392 \begin{figure}\centering
1393 \unitlength=0.005\linewidth
1394 \begin{picture}(100,50)(-50,0)
1395 \AutoGrid
1396 \Zbox(0,0)[t]{\textsf{O}}[1]
1397 \Arc(0,0)(50,0){180}
1398 \VECTOR(0,0)(45:50)\Zbox(45:25)[br]{R}[0]
1399 \Curve(50,0)<0,1>(45:50)<135:1>(0,50)<-1,0>%
1400 (135:50)<225:1>(-50,0)<0,-1>
1401 % \Arc(0,0)(50,0){90}\Arc(0,0)(0,50){90}
1402 % \Curve(50,0)<0,1>(0,50)<-1,0>(-50,0)<0,-1>
1403 \end{picture}
1404 \caption{Comparison between a 180° arc (red) drawn with the \cs{Arc} macro, and a comparable half circle (blaxk) drawn with four 45° \cs{Curve} arcs}\label{fig:halfcircle}
1405 \end{figure}
1406
1407 The circle radius amounts to $R=50$\cs{unitlength}, while the external line, drawn with \cs{Arc}, at 45° displays the maximum distance from the circle center \textsf{O}; it amounts to $51$\cs{unitlength}, 2\% larger than the correct value. In most circumstances this error is negligible, but sometimes the drawing by means of \cs{Curve} is more appropriate.
1408
1409 An alternative solution consists in tracing two consecutive arcs of 90° each drawn with \cs{Arc}, instead of four arcs of 45° each drawn with \cs{Curve} or with \cs{Arc}. The code above contains also the other solutions; they are commented out but the user can copy the code and paste it in a personal \texttt{.tex} file, so that each solution can be tested individually, so as to remark the (invisible) differences.
1410
1411 %
1412 \item The new version of |\multiput| is backwards compatibile with
1413 the original version contained in the \LaTeX\ kernel. The new macro
1414 adds the handling of the coordinate increments from one position to
1415 the next for the \meta{object} to include in the drawing.
1416 The syntax is the following:
1417 \begin{Sintassi}\setfontsize{8}
1418 |\multiput|\parg{initial point}\parg{increment}\marg{number of items}\marg{object}\oarg{handler}
1419 \end{Sintassi}
1420 The only small change is the addition of the last optional argument that allows to do several interesting actions on the sequence o objects to be repeated, for example, to set them on a curved line, instead of on a straight line, as shown in figure~\ref{pag:multiput}.
1421
1422 In this figure we show the code for the picture shown there. The red grid
1423 is nothing new, except that it displays the traditional |\multiput| used
1424 in this code, shown in a previous example, produces exactly the same
1425 result. But for what concerns the four “graphs” on the grid, it displays
1426 an alignment of black dots along the diagonal of the grid (again
1427 traditional |\multiput| rendered with the new version); a number of blue
1428 dots along a parabola; another number of magenta coloured dots alined
1429 along a half sine wave; a number of little green squares aligned along
1430 a $-15~\circ$ sloping line starting from the center of the grid; notice
1431 the polar values that are used as polar relative coordinate increments.
1432
1433 \noindent\begin{figure}[!htb]
1434 \begin{minipage}{0.45\linewidth}
1435 \begin{Verbatim}[fontsize=\setfontsize{8}]
1436 \unitlength=0.01\linewidth
1437 \begin{picture}(100,100)
1438 \GraphGrid(100,100)
1439 \multiput(0,0)(10,10){11}{\circle*{2}}
1440 \color{blue!70!white}
1441 \multiput(0,0)(10,0){11}{\circle*{2}}%
1442 [\GetCoord(\R)\X\Y
1443 \edef\X{\fpeval{\X+10}}
1444 \edef\Y{\fpeval{(\X/10)**2}}
1445 \CopyVect\X,\Y to\R]
1446 \color{magenta}
1447 \multiput(0,0)(10,1){11}{\circle*{2}}%
1448 [\GetCoord(\R)\X\Y
1449 \edef\X{\fpeval{\X+10}}
1450 \edef\Y{\fpeval{sind(\X*1.8)*100}}
1451 \CopyVect\X\Y to\R]
1452 \color{green!80!black}
1453 \multiput(50,50)(-15:5){11}}{%
1454 \polygon*(-1,-1)(1,-1)(1,1)(-1,1)}
1455 \end{picture}
1456 \end{Verbatim}
1457 \end{minipage}
1458 \hfill
1459 \begin{minipage}{0.45\linewidth}
1460 \unitlength=0.01\linewidth
1461 \begin{picture}(100,100)
1462 \GraphGrid(100,100)
1463 \multiput(0,0)(10,10){11}{\circle*{2}}
1464 \color{blue!70!white}
1465 \multiput(0,0)(10,0){11}{\circle*{2}}%
1466 [\GetCoord(\R)\X\Y
1467 \edef\X{\fpeval{\X+10}}
1468 \edef\Y{\fpeval{(\X/10)**2}}
1469 \CopyVect\X,\Y to\R]
1470 \color{magenta}
1471 \multiput(0,0)(10,1){11}{\circle*{2}}%
1472 [\GetCoord(\R)\X\Y
1473 \edef\X{\fpeval{\X+10}}
1474 \edef\Y{\fpeval{sind(\X*1.8)*100}}
1475 \CopyVect\X,\Y to\R]
1476 \color{green!60!black}
1477 \multiput(50,50)(-15:5){11}{\polygon*(-1,-1)(1,-1)(1,1)(-1,1)}
1478 \end{picture}
1479 \end{minipage}
1480 \caption{Some examples of the \meta{handler} optional argument}\label{pag:multiput}
1481 \end{figure}
1482
1483 A new command |\xmultiput| (not available with the previous versions
1484 of \pack{curve2e}) is extended with respect to the original
1485 |\multiput|; it is defined by using some L3 functions; in particular the
1486 cycling counter is accessible to the \LaTeX\ commands and it is stepped
1487 up from~1 to the value specified in the proper command argument
1488 (in the original command it starts from that value and is stepped down
1489 to zero). See the figure on page~\ref{pag:orologio} to inspect its
1490 usage. It is important to notice that if the command|\rotatebox|
1491 has to be used, as in the example of figure~\ref{pag:orologio}, the
1492 package |graphicx| should be also loaded, because \pack{curve2e} does
1493 not load it.
1494
1495 Th |\xmultiput| syntax is the is similar to that of |\multiput| but besides the stepping up or down of the iteration counter, it can access and modify certain internal with the commands that appear in the \meta{handler} argument. Actually this \meta{handler} is available also with |\multiput|. In both cases the handler can be defined to modify some internals, including the iteration counter only for |\xmultipot|, but also the |\R| and |\D| internals; |\R| contains the coordinates where to put the \meta{object}, while |\D|, if set, contains the angle of rotation of the object. The code and picture examples in figures~\ref{pag:multiput} and~\ref{pag:orologio} show some examples of usage through tis \meta{handler} code.
1496 .
1497 \begin{Sintassi}\small
1498 |\xmultiput|\parg{initial point}\parg{increment}\marg{iterations}\marg{object}\oarg{handler}
1499 \end{Sintassi}
1500
1501
1502 \begin{figure}[!htb]
1503 \begin{minipage}{0.45\textwidth}\setfontsize{9.5}%
1504 \begin{verbatim}
1505 \unitlength=0.0095\linewidth
1506 \begin{picture}(100,100)
1507 \GraphGrid(100,100)
1508 \put(50,50){\thicklines\circle{100}}
1509 \xmultiput[50,50](60:40)(-30:1){12}%
1510 {\makebox(0,0){\circle*{2}}}%
1511 [\MultVect\R by\D to\R]%
1512 \xmultiput[50,50](60:46)(-30:1){12}%
1513 {\ArgOfVect\R to\Ang
1514 \rotatebox{\fpeval{\Ang-90}}%
1515 {\makebox(0,0)[b]{\Roman{multicnt}}}}%
1516 [\Multvect{\R}{\D}\R]
1517 \end{picture}
1518 \end{verbatim}
1519 \end{minipage}
1520 \hfill
1521 \begin{minipage}{0.40\textwidth}\raggedleft
1522 \unitlength=0.0095\linewidth
1523 \begin{picture}(100,100)
1524 \GraphGrid(100,100)
1525 \put(50,50){\thicklines\circle{100}}
1526 \xmultiput[50,50](60:40)(-30:1){12}%
1527 {\makebox(0,0){\circle*{2}}}[\Multvect{\R}{\D}{\R}]%
1528 \xmultiput[50,50](60:43)(-30:1){12}%
1529 {\ArgOfVect\R to\Ang\rotatebox{\fpeval{\Ang-90}}%
1530 {\makebox(0,0)[b]{\Roman{multicnt}}}}%
1531 [\Multvect{\R}{\D}\R]
1532 \end{picture}
1533 \end{minipage}
1534 \caption{Usage example of the \texttt{\string\xmultiput} command}
1535 \label{pag:orologio}\hfill
1536 \end{figure}
1537
1538 \item This implementation of \pack{curve2e} includes an extension
1539 to package |xfp|, in the sense that adds three more L3 commands:
1540 |\fptest|, |\fpdowhile|, |\fpwhiledo| to the two already contained and
1541 documented in the latter package. The syntax of such new commands
1542 is the following
1543 \begin{Sintassi}
1544 \cs{fptest}\marg{test}\marg{true}\marg{false}
1545 \cs{fpdowhile}\marg{test}\marg{operations to be repeated}
1546 \cs{fpwhiledo}\marg{test}\marg{operations to be repeated}
1547 \end{Sintassi}
1548 The macro |\fptest| requires two further arguments that contain
1549 what to do if the \meta{test} is true, and what to do if the
1550 \meta{test} is false.
1551 The \meta{test} is a logical expressions that connects math relation
1552 expressions, even floating point ones, by means of \emph{logical
1553 operators}; such operators are \verb+||+, \verb|&&|, and \verb|!|,
1554 respectively for OR, AND, NOT; math relation expressions contain
1555 relation operators, even negated ones: for example \verb|!<| means
1556 “not lower than”, which is equivalent to “equal or grater than”, i.e.
1557 \verb|=>|. The logical expression is parsed left to right and normal
1558 parentheses may be used to alter this sequence. The logical operators
1559 work also between logical variables, therefore the \meta{test} may
1560 contain an interesting mixture of relation and logical operators.
1561
1562 Before using |\fpdowhile| and |\fpwhiledo|, the arguments of \meta{test}
1563 depends-on must be set so that the test is true; during the execution
1564 of the \meta{operations to be repeated} there must be some setting
1565 that eventually renders the \meta{test} false. The user should
1566 pay attention to set the elements that \meta{test} depends on,
1567 because the risk is to enter an infinite loop and end up with some
1568 error message stating that the working memory of the program is full.
1569 Notice that |\fpdowhile| first puts the \meta{operations to be repeated}
1570 into the work flow then checks the \meta{test} and possibly repeats the
1571 cycle; on the opposite, |\fpwhiledo| first checks the \meta{test} then
1572 possibly inserts the \meta{operations to be repeated} and cycles.
1573 Evidently with the same \meta{test} the two while cycles produce
1574 different results with a little, but important difference: if the input
1575 data are macros defined by previous computations, there is no guarantee
1576 that the \meta{test} is initially true; if it sis false, |fpwhiledo|
1577 does not do anything, while |\fpdowhile| executes one cycle and produces
1578 in the output stream something that might be nonsense. Cycles done
1579 with |\fpwhiledo| should be safer and should be preferred.
1580
1581 Nevertheless such commands are very useful also for drawing graphics;
1582 the |xmultiput| command already makes use of such L3~functions.
1583
1584 As an example of use, we show how to plot a mathematical function
1585 expressed in parametric form:
1586 \[\begin{cases}
1587 x = f_1(t)\\
1588 y = f_2(t)
1589 \end{cases}\]
1590 The plot is executed with a piecewise linear approximation of the
1591 curve; if the $t$ steps are sufficiently small, the plot turns out to
1592 be very nice; here we show an example where we plot a Lissajous curve
1593 with two sinusoids of different periods.
1594
1595 We start by defining the Lissajous function with arguments
1596 to specify the parameter $t$, the sinusoid amplitudes $A_1, A_2$,
1597 the respective “frequencies”, by means of integer multiples of
1598 a unit pulsation, $N_1, N_2$, and the initial phases
1599 $\phi_1, \phi_2$ of such sinusoids. It is better to keep
1600 apart the input of the curve coefficients from the actual curve
1601 argument/parameter and output point coordinates:
1602 \begin{verbatim}
1603 \def\LissajousCoefs#1,#2,#3,#4,#5,#6!{%
1604 \edef\LAu{#1}\edef\LNu{#2}\edef\LFu{#3}%
1605 \edef\LAd{#4}\edef\LNd{#5}\edef\LFd{#6}}
1606
1607 \def\LissajousCode#1#2{%
1608 \edef\X{\fpeval{\LAu*cosd(\LNu*#1+\LFu)}}%
1609 \edef\Y{\fpeval{\LAd*cosd(\LNd*#1+\LFd)}}%
1610 \CopyVect\X,\Y to#2\ignorespaces}
1611 \end{verbatim}
1612 As it is shown, the coefficients are specified as a comma separated
1613 list; the \verb|!| list terminator is taken care by the actual
1614 drawing command.
1615
1616 Then the curve drawing command requires the coefficient specification
1617 only the first time it is used; some messages\footnote{Here it would
1618 be better to have available a “Macro Error” message; such a macro
1619 is not available, but it would be possible to define it by means
1620 of the \cs{GenericError} macro provided by the \LaTeX2e\ kernel.
1621 Here we skip this definition in order to avoid overloading this
1622 documentation with such details.} are output if the coefficients
1623 have been “forgotten”.
1624 \begin{verbatim}
1625 \NewDocumentCommand\Lissajous{m o m}{%
1626 \IfValueTF{#2}{\LissajousCoefs#2!\relax
1627 \LissajousCode{#1}{#3}}%
1628 {\ifcsname LAu\endcsname
1629 \LissajousCode{#1}{#3}%
1630 \else\PackageError{curve2e}%
1631 {This Lissajous' curve coefficients\MessageBreak
1632 are missing}{Nothing done}\fi}%
1633 \ignorespaces}
1634 \end{verbatim}
1635
1636 The syntax is the following:
1637 \begin{Sintassi}
1638 \cs{Lissajous}\marg{in}\Oarg{\meta{$A_1$},\meta{$N_1$},\meta{$\phi_1$},\meta{$A_2$},\meta{$N_2$},\meta{$\phi_2$}}\meta{$P_{\mathrm{out}}$}
1639 \end{Sintassi}
1640 where \meta{$P_{\mathrm{out}}$} is a macro that gets
1641 defined with the cartesian coordinates of the computed output
1642 point. Arguments \meta{in} (the $t$ parameter) and \meta{$P_\mathrm{out}$} (the comput coordinates) need not be enclosed within braces if they are given as macros; actually the code shown in figure~\ref{fig:lissajous} shows such procedure that renders the input code simpler to read.
1643
1644 After this definition the diagram is plotted in
1645 figure~\ref{fig:lissajous}.
1646 %
1647 \begin{figure}[!htb]\centering
1648 \begin{Esempio}[\setfontsize{8.5}](0.55)
1649 \unitlength=0.01\linewidth
1650 \begin{picture}(100,100)(-50,-50)
1651 \AutoGrid
1652 \VECTOR(-50,0)(50,0)\Pbox(50,0)[tr]{x}[0]
1653 \VECTOR(0,-50)(0,50)\Pbox(0,50)[tr]{y}[0]
1654 \Pbox(0,0)[tr]{O}[2]
1655 \thicklines
1656 {\countdef\I=2560 \I=0
1657 \fpdowhile{\I !> 360}{%
1658 \fptest{\I=0}%
1659 {\Lissajous\I[40,2,90,40,3,0]\Pout
1660 \moveto(\Pout)}%
1661 {\Lissajous\I\Pout
1662 \lineto(\Pout)}%
1663 \advance\I by1}\strokepath}%
1664 \end{picture}
1665 \end{Esempio}
1666 \caption{A Lissajous diagram}\label{fig:lissajous}
1667 \end{figure}
1668
1669 For the independent variable $t$, the parameter of the Lissajous
1670 parametric equations, it is better to work with degrees instead
1671 of radians, and with integer numbers, so that the whole range
1672 from $0^\circ$ to $360^\circ$ is certainly spanned. Notice the
1673 braces that include the code for the Lissajous diagram; they may
1674 be useful to render that group suitable to be |\put| somewhere
1675 else than with its center at the origin of the canvas axes,
1676 and/or to be used as the second argument of a
1677 \cs{rotatebox}\marg{angle} command so as to rotate the whole
1678 diagram.
1679 %
1680 \item Another useful application of |\fpdowhile| is the following: when making a diagram the axes should get suitable labeled ticks in order to show the graduations; the label of each tick should lay close to the axis on the other side than the tick. It is also necessary to know if the axis to be marked is horizontal or vertical, since in the former case each tick is vertical, while in the latter case it is horizontal. The example in figure~\ref{fig:ticks} shows both the code and its usage. The syntax of the |\Tbox| macro is the following.
1681 \begin{Sintassi}
1682 |\Tbox|\parg{coordinates}\oarg{reference}\marg{label}\oarg{size}\aarg{direction}
1683 \end{Sintassi}
1684 where \meta{coordinates} indicates the position of the tick base along its axis; \meta{reference} is a letter, either |t| (if the axis is on top of the label) or |b|(if the axis is at the bottom of the label) for vertical ticks or either |r| (if the axis is at the right of the label) or |l| (if the axis is at the left of the label) for horizontal ticks; \meta{label} is the value of the scale or a literal label that by default is typeset in math mode, so that a math symbol may be used without the need of entering math mode, while in the unusual circumstance that a textual label is to be used, users should use the |\text| macro; the \meta{size} argument is the size of the tick: if such size is zero, just the label is set, but in this case the |\Tbox| macro behaves as the the |\Zbox| one, and accepts two reference codes in order to print the label the same as |\Zbox| would do when the dot size is zero; the \meta{direction} argument is the letter |V| for vertical ticks, and |H| for horizontal ticks. There is some redundancy because |\Tbox| may behave as |\Zbox|, but experience shows that this is not a problem.
1685
1686 The source preamble should contain the following code.
1687 {\small\begin{verbatim}
1688 \makeatletter
1689 \NewDocumentCommand\Tbox{D(){0,0} O{cc} m O{0pt} D<>{Z}}{\bgroup
1690 \edef\TBoxCode{#5}\dimen0=#4\relax %
1691 \edef\tempE{\fpeval{round(#4/\unitlength,3)}}%
1692 \put(#1){%
1693 \ifdim\dimen0=\z@
1694 \Zbox(0,0)[#2]{#3}[\z@]%
1695 \else
1696 \if\TBoxCode V\relax
1697 \let\tempC=b\relax
1698 \if\tempC #2\edef\tempD{0,-\tempE}\else\edef\tempD{0,\tempE}\fi
1699 \segment(0,0)(\tempD)\Zbox(0,0)[#2]{#3}[\z@]%
1700 \else
1701 \if\TBoxCode H\relax
1702 \let\tempC=l\relax%
1703 \if\tempC #2\edef\tempD{-\tempE,0}\else\edef\tempD{\tempE,0}\fi
1704 \segment(0,0)(\tempD)\Zbox(0,0)[#2]{#3}[\z@]%
1705 \else
1706 \typeout{The specified code\space #5\space is invalid!}%
1707 \typeout{\string\Tbox\space command ignored}%
1708 \fi
1709 \fi
1710 \fi
1711 }\egroup\ignorespaces}%
1712 \end{verbatim}
1713 }
1714 If the code is contained in a personal |.sty| file the
1715 |\makeatletter| should be omitted.
1716
1717 As it can be seen, the fifth argument code is preset to to |Z| so that if users forget to specify it, error messages pop op and can be seen in both the console window and in the log file, but no tick and label are typeset. This kind of commands to label in one way or another may be very useful depending on the users' kind of drawings. Figure~\ref{fig:labeled diagram} contains also the iterations to label the axes and are done with the
1718 |\fpdowhile| macro; it can be seen that the actual coordinate of each tick is transformed into the actual label that is put in its position by the
1719 |\Zbox| command; of course the diagram scale and the actual label are related to one another but do not have the same value.
1720
1721 \begin{figure}
1722 {\small\begin{verbatim}
1723 \centering\unitlength=0.007\linewidth
1724 \begin{picture}(100,70)(-50,-10)%
1725 \AutoGrid
1726 \thicklines
1727 \VECTOR(-50,0)(50,0)\Zbox(50,0)[br]{x}[0pt]%
1728 \VECTOR(0,0)(0,60)\Zbox(0,60)[tl]{y}[0pt]%
1729 %
1730 {\def\Coord{-40}%
1731 \fpdowhile{\Coord<=40}{\edef\X{\fpeval{round(\Coord/20,1)}}%
1732 \Tbox(\Coord,0)[t]{\X}[1.5mm]<V>\edef\Coord{\fpeval{\Coord+10}}}%
1733 %
1734 \def\Coord{10}%
1735 \fpdowhile{\Coord<=50}{\edef\Y{\fpeval{round(\Coord/20,1)}}%
1736 \Tbox(0,\Coord)[r]{\Y}[1.5mm]<H>\edef\Coord{\fpeval{\Coord+10}}}%
1737 }%
1738 %
1739 {\color{blue}\linethickness{1.5pt}%
1740 \Curve(-40,0)<1,0>(0,20)<45:1>% Parabola: y=0.25(x_2)^2
1741 \Curve(0,20)<1,0>(20,0)<0,-1>% Quarter circle: x^2+y^2=1
1742 \Curve(20,0)<0,1>(40,34.64)<49:1>}% Hyperbola:x^2-y^=1
1743 \thinlines
1744 \Dashline(0,0)(45,45){2}% asymptote
1745 \end{picture}
1746 \end{verbatim}
1747 }
1748 \bigskip
1749
1750 \centering\unitlength=0.007\linewidth
1751 \begin{picture}(100,70)(-50,-10)%
1752 \AutoGrid
1753 \thicklines
1754 \VECTOR(-50,0)(50,0)\Zbox(50,0)[br]{x}[0pt]%
1755 \VECTOR(0,0)(0,60)\Zbox(0,60)[tl]{y}[0pt]%
1756 %
1757 {\def\Coord{-40}%
1758 \fpdowhile{\Coord<=40}{\edef\X{\fpeval{round(\Coord/20,1)}}%
1759 \Tbox(\Coord,0)[t]{\X}[1ex]<V>\edef\Coord{\fpeval{\Coord+10}}}%
1760 %
1761 \def\Coord{10}%
1762 \fpdowhile{\Coord<=50}{\edef\Y{\fpeval{round(\Coord/20,1)}}%
1763 \Tbox(0,\Coord)[r]{\Y}[1ex]<H>\edef\Coord{\fpeval{\Coord+10}}}%
1764 }%
1765 {\color{red}\linethickness{1.5pt}%
1766 \Curve(-40,0)<1,0>(0,20)<45:1>% Parabola: y=0.25(x_2)^2
1767 \Curve(0,20)<1,0>(20,0)<0,-1>% Quarter circle: x^2+y^2=1
1768 \Curve(20,0)<0,1>(40,34.64)<49:1>}% Hyperbola:x^2-y^2=1
1769 \thinlines
1770 \Dashline(0,0)(45,45){2}% asymptote
1771 \end{picture}
1772 \caption{The code to draw a diagram with labeled axes}\label{fig:labeled diagram}
1773 \end{figure}
1774 %
1775 \end{enumerate}
1776
1777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1778 \section{Remarks}
1779 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1780
1781 In spite of the relative simplicity of the macros contained in this
1782 package, the described macros, as well as the original ones included in
1783 the \pack{pict2e} package, allow to produce fine drawings that were
1784 unconceivable with the original \LaTeX\ picture environment. Leslie
1785 Lamport himself announced an extension to his environment when \LaTeXe\
1786 was first released in 1994; in the |ltnews| news-letter of December
1787 2003, the first implementation of Lamport's extension was announced;
1788 the first version of this package \pack{curve2e} was issued in 2006.
1789 It was time to have a better drawing environment; this package
1790 is a simple attempt to follow the initial path while further extending
1791 the drawing facilities.
1792
1793 There are other packages in the \textsc{ctan} archives that deal with
1794 tracing curves of various kinds. \pack{PSTricks} and \pack{pgf/tikz} are
1795 the most powerful ones. And they are becoming the standard for computer
1796 drawing. Their documentation is huge and the multitude of extra modules
1797 to perform special tasks is countless. Therefore they are difficult to
1798 use; when the user gets used to their particular syntax and got
1799 sufficient familiarity with several modules, s/he can use these bundles
1800 very comfortably.
1801
1802 This difficulty in becoming a TikZ or PS expert is why I think a simpler
1803 drawing machinery should be appreciated. I admit it: I like the
1804 \env{picture} environment; and I like to deal with simple codes so as to
1805 create my own macros.
1806
1807 But there is also \pack{curves} that is intended to draw almost
1808 anything by using little dots or other symbols partially superimposed
1809 to one another. It uses only quadratic Bézier curves and the curve
1810 tracing is eased by specifying only the curve nodes, without specifying
1811 the control nodes; with a suitable package option, it is
1812 possible to reduce the memory usage by using short straight segments
1813 drawn with the PostScript facilities offered by the |dvips| driver.
1814
1815 Another package, \pack{ebezier} performs about the same as
1816 \pack{curve2e} but draws its Bézier curves by using little dots
1817 partially superimposed to one another. The documentation is quite
1818 interesting since it explains very clearly what exactly are the Bézier
1819 splines. Apparently \pack{ebezier} should be used only for DVI output
1820 without recourse to PostScript or PDF machinery.
1821
1822 The \pack{picture} package extends the performance of the \env{picture}
1823 environment (extended with \pack{pict2e}) by accepting coordinates
1824 and lengths in real absolute dimensions, not only as multiples of
1825 |\unitlength|; it provides commands to extend that functionality to
1826 other packages. In certain circumstances it may be very useful.
1827
1828 Package \pack{xpicture} builds over the \env{picture} \LaTeX\
1829 environment so as to allow to draw the usual curves that are part
1830 of an introductory analytic geometry course; lines, circles,
1831 parabolas, ellipses, hyperbolas, and polynomials; the syntax is
1832 rather comfortable, although it is not a simple extension of the
1833 \env{picture} own syntax; for all these curves it uses the quadratic
1834 Bézier splines.
1835
1836 Package \pack{hobby} extends the cubic Bézier spline handling with the
1837 algorithms John Hobby created for \MF\ and \MP. But by now this package
1838 interfaces very well with |tikz|; it has not (yet) been adapted to the
1839 common \env{picture} environment extended with \pack{pict2e}, and,
1840 why not, with \pack{curve2e}.
1841
1842 If you are interested in further extensions of |curve2e|, besides creating yourself the macros you need, examine the |euclideangeometry| package; I created it in order to have available further functionalities useful to deal with more complicated geometrical constructions. Another small extension is |graphpaper| by which users can produce themselves drawing paper with bilinear coordinates, semi-logarithmic and bi-logarithmic coordinates, polar linear or semilogarithmic coordinates, and Smith charts. They are an extension chain of the packages that extend the picture environment: |graphpaper| calls |euclideangeometry| which calls
1843 |curve2e| which calls |pict2e|. I find all this very useful. Of corse these packages and their documentation are all contained in \TeX~Live.
1844
1845 I am about to complete a book on electromagnetism and electronic circuit theory: it contains some 300 drawings, diagrams, electronic circuits. I created them with |curve2e| and some macros based on this |picture| extension package. The graphics of my book are pretty nice, and I am sure that a professional technical artist can draw better ones, but such an artist would be very expensive and the process would require a lot of time to correct, modify, add details, and so on, while doing things by oneself is certainly a better solution. Packages |tikz|/|pgfplots| and |PStricks|? Certainly they are very good and much more powerful, but, besides being sort of difficult to learn to use, they require a lot of working memory and more often than not I ran out of computer memory.
1846
1847 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1848 \section{Acknowledgements}
1849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1850
1851 I wish to express my deepest thanks to the many persons who submitted notices about bugs or inconsistencies.
1852
1853 Michel Goosens spotted some errors and very kindly submitted
1854 them to me so that I was able to correct them.
1855
1856 I collaborated extensively with Josef Tkadlec in order to
1857 implement a better real long division so as to get correctly
1858 the quotient fractional part and to avoid as much as
1859 possible any numeric overflow; many Josef's ideas were
1860 incorporated in the long division macro that was implemented
1861 in the previous version of this package, although the macro
1862 used by Josef was slightly different. Both versions
1863 aim/aimed at a better accuracy and at widening the operand
1864 ranges.
1865 In this version of \pack{curve2e} I abandoned our long
1866 division macro, and substituted it with the floating point
1867 division provided by the |xfp| package functionalities that
1868 are now part of the \LaTeX\ kernel.
1869
1870 Daniele Degiorgi spotted a fault in the kernel definition of
1871 |\linethickness| that heavily influenced also \pack{curve2e}; see the code documentation \file{curve2e.pdf} file.
1872
1873 Domenicus van der Wijst spotted a sneaky bug in the updated |\Arc| macro; for arcs not wider than $180^\circ$ that macro worked properly, while for larger angle apertures it produced syntax errors. It was just a typo, but very sneaky.
1874
1875 Jin-Hwan Cho and Juho Lee suggested a small but crucial modification in order to have \pack{curve2e} work smoothly also with XeTeX (XeLaTeX). Actually if \pack{pict2e}, version 0.2x or later, dated 2009/08/05 or later, is being used, such modification is not necessary any more, but it is true that it was imperative when legacy versions were used.
1876
1877 Ashish Kumar Das spotted an inconsistency in the design of vectors with PostScript style arrow tips with large line width settings, that did not show up with \LaTeX\ styled ones.
1878
1879
1880 \end{document}
1881
1882
1883