diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-02 22:58:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-02 22:58:30 +0000 |
commit | 974049fc5bfe6f05001c1e9ea136448852679a0e (patch) | |
tree | f4d7cc769bb15ab31990f90060b7d6ba1688fadd /Master | |
parent | 8b511d7868b89cd4504656503dc9e3f4f8c2a1f6 (diff) |
new latex package xpicture (2jan13)
git-svn-id: svn://tug.org/texlive/trunk@28704 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/xpicture/README | 117 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xpicture/xpicture-doc.pdf | bin | 0 -> 874526 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/xpicture/xpicture-doc.tex | 3105 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xpicture/xpicture.pdf | bin | 0 -> 403099 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/xpicture/xpicture.dtx | 3570 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-pictures.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/xpicture.tlpsrc | 0 |
8 files changed, 6794 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/xpicture/README b/Master/texmf-dist/doc/latex/xpicture/README new file mode 100644 index 00000000000..6a7705ed90e --- /dev/null +++ b/Master/texmf-dist/doc/latex/xpicture/README @@ -0,0 +1,117 @@ + + The xpicture package, version 1.2a + (Several extensions of the "picture" standard environment, + including graphs of functions and parametric curves) + Robert Fuster, 2012/12/17 + + +1. Licence +---------- +This material is subject to the LaTeX Project Public License. + +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +for the details of that license. + + +2. About this package +--------------------- + +The xpicture package introduces several new graphical instructions, +and some enriched versions of standard instructions used inside the picture +environment that, among other utilities, will provide the possibility of +using different reference systems and a fine control the precise position +where the objects are placed in your drawing. + +But the most interesting feature of this package is the ability to draw high +quality curves such that conic sections, graphs of elementary functions and +parametric curves, from LaTeX and using the typical LaTeX syntax. + +The new instructions defined by this package can be classified as follows: + + -- Reference systems and coordinates: + + - Declaration and use of different reference systems, + with Cartesian or polar coordinates. + - Instructions to show Cartesian or polar reference systems. + + -- An alternative to the picture environment, compatible with + the new reference systems. + + -- Alternative instructions or extensions of the standard picture + commands and those defined by the packages pict2e and curve2e: + + - Enriched versions of marks \put and \multiput, providing an + adequate control of the precise position in which objects + are composed. + - Instructions for drawing straight segments, vectors + (in any direction and using any reference system), polygonal + lines, and regular and arbitrary polygons. + + -- Regular curves: + + - Instructions for drawing conic sections (circles, ellipses, + hyperbolas and parabolas) and arcs of these curves. + - Instructions to graph functions and parametrically defined + curves. + + +This package requires the "calculator" and "calculus" packages. You can +download these packages from CTAN: + + /macros/latex/contrib/calculator + +Packages "pict2e", "curve2e" and "xcolor" are also needed. These packages are +included in major TeX distributions. + + +3. Installation and documentation +--------------------------------- + +After uncompressing "xpicture.zip" you will have the following files: + + -- "README". This file. + -- "xpicture.dtx". The source file. + -- "xpicture-doc.pdf". The compiled "xpicture" user manual. + -- "xpicture-doc.tex". The user manual source file. + -- "xpicture.tds.zip". Ready to use tds-structures zip file. + +Then, you can install the package in two ways: + + a) Unpacking the zip file xpicture.tds.zip into your local texmf tree + and updating the file database, or + + b) By compiling the source file "xpicture.dtx" in the following sequence + + >> pdflatex xpicture.dtx + >> pdflatex xpicture.dtx + >> makeindex -s gind.ist -o xpicture.ind xpicture.idx + >> pdflatex xpicture.dtx + + Then, several files will be generated: + + "xpicture.sty" (the package). + Move this file where LaTeX search for (typically, in a local + texmf tree, at tex/latex/xpicture/) and refresh the file database. + + "xpicture.pdf" (documented source and reference manual). + + "xpicture.cfgxmpl" (costumizable local configuration file). + + Recall that the user manual is not "xpicture.pdf", but + "xpicture-doc.pdf". If you re-compile this file, + many small files, named "xpictureNN.tex" are generated. + These files contain the source code of all examples included + in the manual. + You can store or discard this files. + +Please, visit the "xpicture" homepage at + + http://www.upv.es/~rfuster/xpicture + +--------------------------------------------------- +Robert Fuster +rfuster@mat.upv.es + +Universitat Polit\`ecnica de Val\`encia, 2012/12/17 +--------------------------------------------------- + diff --git a/Master/texmf-dist/doc/latex/xpicture/xpicture-doc.pdf b/Master/texmf-dist/doc/latex/xpicture/xpicture-doc.pdf Binary files differnew file mode 100644 index 00000000000..65863bad688 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xpicture/xpicture-doc.pdf diff --git a/Master/texmf-dist/doc/latex/xpicture/xpicture-doc.tex b/Master/texmf-dist/doc/latex/xpicture/xpicture-doc.tex new file mode 100644 index 00000000000..df3ce30ded4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xpicture/xpicture-doc.tex @@ -0,0 +1,3105 @@ +\documentclass{article} + +\usepackage[a4paper,margin=2cm]{geometry} +\usepackage[T1]{fontenc} + +\usepackage{xpicture} + +\usepackage{ifthen} +\usepackage{array} +\usepackage{fancyvrb} +\usepackage[colorlinks]{hyperref} + +\usepackage{amsmath} +\usepackage{paralist} +\usepackage{graphicx} +\usepackage{makeidx} +\makeindex +\renewcommand{\today}{2012/12/17} + +\newcommand{\TIT}{\textit} +\newcommand{\TTT}{\texttt} +\newcommand{\TTTit}[1]{\TTT{\TIT{#1}}} +\newcommand{\cs}[1]{\mbox{\textnormal{\TTT{\textbackslash #1}}}} +\newcommand{\environ}[1]{\textnormal{\TTT{#1}}} +\newcommand{\package}[1]{\textnormal{\TTT{#1}}} +\newcommand{\ttindex}[1]{\index{#1@\texttt{#1}}} +\newcommand{\ttslashindex}[1]{\index{#1@\texttt{\textbackslash #1}}} +\newcommand{\csdef}[1]{\cs{#1}\ttslashindex{#1}} +\newcommand{\packagedef}[1]{% + \package{#1}\index{#1@\texttt{#1} (package)}} +\newcommand{\environdef}[1]{% + \package{#1}\index{#1@\texttt{#1} (environment)}} +\newcommand{\optiondef}[1]{% + \textnormal{\TTT{#1}}\index{#1@\texttt{#1} (package option)}} +\newcounter{exem}\stepcounter{exem} +\newenvironment{exemple}{% + \VerbatimEnvironment\begin{VerbatimOut}{./xpicture\theexem.tex}}{% + \end{VerbatimOut} + \par\medskip\noindent + \marginpar{\fbox{Ex. \theexem}}\begin{minipage}{\linewidth} + \begin{minipage}{0.45\linewidth} + \setlength{\parindent}{2ex} + \catcode`\%=14 + \input{./xpicture\theexem} + \end{minipage}\hfill + \begin{minipage}{0.45\linewidth} + \small + \VerbatimInput{./xpicture\theexem.tex} + \end{minipage} + \end{minipage} + \stepcounter{exem}\par\bigskip\noindent} +\newenvironment{Exemple}{% + \VerbatimEnvironment\begin{VerbatimOut}{./xpicture\theexem.tex}}{% + \end{VerbatimOut} + \par\noindent + \marginpar{\fbox{Ex. \theexem}}\fbox{\begin{minipage}{\linewidth} + \begin{minipage}{\linewidth} + \setlength{\parindent}{2ex} + \bigskip\par + \catcode`\%=14 + \input{./xpicture\theexem} + \end{minipage}\medskip\par + \hspace*{0.125\linewidth}\rule{0.75\linewidth}{0.4pt}\par\medskip + \small + \VerbatimInput{./xpicture\theexem.tex} + \end{minipage}}\stepcounter{exem}\par\bigskip\noindent} + +\begin{document} +\begin{titlepage} + \centering + \bfseries\Large Robert Fuster + + \rule{\textwidth}{1pt} + + The \textsf{xpicture} package + + (\Verb+http://www.upv.es/~rfuster/xpicture+) + + Several extensions of the \textsf{picture} standard environment + + User Manual + \vspace{\stretch{1}} + \begin{Exemple} + \setlength{\unitlength}{1cm} + \footnotesize + \DIVIDE{1}{12}{\invXII} + \MULTIPLY{12}{\numberTWOPI}{\phione} + \MULTIPLY{12}{64}{\divisions} + + \COMPOSITIONfunction{\EXPfunction}{\COSfunction}{\Afunction} + \SCALEVARIABLEfunction{4}{\COSfunction}{\Bfunction} + \SCALEVARIABLEfunction{\invXII}{\SINfunction}{\cfunction} + \POWERfunction{\cfunction}{5}{\Cfunction} + \LINEARCOMBINATIONfunction{1}{\Afunction}{-2}{\Bfunction}{\ABfunction} + \SUMfunction{\ABfunction}{\Cfunction}{\ABCfunction} + \PRODUCTfunction{\SINfunction}{\ABCfunction}{\Xfunction} + % x=(sin t)(exp(cos t)-2 cos 4t + (sin(t/12))^5) + \PRODUCTfunction{\COSfunction}{\ABCfunction}{\Yfunction} + % y=(cos t)(exp(cos t)-2 cos 4t + (sin(t/12))^5) + \PARAMETRICfunction{\Xfunction}{\Yfunction}{\butterfly} + \centering + \begin{Picture}(-4,-3)(4,4) + \PlotParametricFunction[\divisions]\butterfly{0}{\phione} + \end{Picture} + \begin{gather*} + x=\sin t\left(\mathrm e^{\cos t}-2\cos 4t + +\sin^5\left(\frac t{12}\right)\right) \\ + y=\cos t\left(\mathrm e^{\cos t}-2\cos 4t + +\sin^5\left(\frac t{12}\right)\right) + \end{gather*} + \end{Exemple} + \footnotesize\today +\end{titlepage} +\stepcounter{page} + +\tableofcontents +\newpage + + The \package{xpicture} package extends the + \environ{picture} standard environment + and packages \package{pict2e} and \package{curve2e}, + adding the ability to work with arbitrary + reference systems and with Cartesian or polar coordinates. + In addition to other utilities, + the greater interest of \package{xpicture} + lies in its capacity to draw function graphs, + conic sections and arcs, and parametrically defined curves. + + This is the user manual of \package{xpicture}. + Technical documentation and reference manual are contained + in file \texttt{xpicture.pdf}, distributed together with the package. + +\section{Introduction. New graphical instructions} +The \package{xpicture} package introduces several new graphical +instructions, and some enriched versions of standard +instructions used inside the \environ{picture} environment. +All these new instructions can be classified as follows: +\begin{itemize} + \item Reference systems and coordinates: +\begin{itemize} +\item Declaration and use of different reference systems, +with Cartesian or polar coordinates. +\item Instructions to show Cartesian or polar reference systems. +\end{itemize} + \item An alternative to the \environ{picture} environment, +compatible with the new reference systems. + \item Alternative instructions or extensions of the standard + \environ{picture} commands and those defined by the packages + \packagedef{pict2e} and \packagedef{curve2e}: +\begin{itemize} + \item Enriched versions of marks \cs{put} and \cs{multiput}, + providing an adequate control of the precise position +in which objects are composed +(this functionality is especially useful in the composition +of not strictly graphical objects, such as formulas or labels). +\item Instructions for drawing straight segments, vectors +(in any direction and using any reference system), polygonal lines, +and regular and arbitrary polygons. +\end{itemize} +\item Regular curves: +\begin{itemize} +\item Instructions for drawing conic sections (circles, ellipses, +hyperbolas and parabolas) and arcs of these curves. +\item Instructions to graph functions and parametrically defined curves +(this is the most interesting feature of this package). +\end{itemize} +\end{itemize} + +The only requeriments for \package{xpicture} are packages +\packagedef{calculator}, \packagedef{calculus}, +\packagedef{curve2e} and \packagedef{xcolor}. +Therefore, it works with any \TeX{} +extension compatible with these packages. You can compile a document +including \package{xpicture} pictures directly with +\TTT{pdflatex},\ttindex{pdflatex} +\TTT{lualatex},\ttindex{lualatex} +\TTT{xelatex}\ttindex{xelatex} +or indirectly, via \TTT{latex/dvips}\ttindex{latex},\ttindex{dvips} + \TTT{latex/dvips/dvipdfm},\ttindex{dvipdfm} \ldots +Pure \TTT{dvi} files are not supported, but some \TTT{dvi} previewers +may show partially \package{xpicture} draws included in \TTT{dvi} files. + +\section{A preliminary observation. + Compatibility with text composition in color} +The \package{xpicture} package automatically loads the +\packagedef{xcolor} package. +So, we can compose our +pictures (and the whole document) in various colors. However, +when used in the body of the \textsf{picture} environment, +marks \cs{color} and \cs{colortext} +often introduce spurious spaces. +For this reason, the \package{xpicture} package introduces the new command +\csdef{pictcolor}. +\begin{Verbatim}[commandchars=\|\[\]] +\pictcolor{|TIT[color]} +\end{Verbatim} +This mark behaves like the \cs{color} command, but does not produces these +inappropriate spaces. +To change colors inside a picture, instead of \cs{color} or \cs{colortext}, +use always the \cs{pictcolor} declaration. + +\section{Coordinate systems and the \environ{Picture} environment} +\subsection{Coordinates} +The standard \environ{picture} environment establishes +a rectangular coordinate system, so that all +graphic objects are placed in the picture using the canonical +coordinates of the plane. From now on, we will call +this reference system \emph{the standard reference system}. +Loading the \package{xpicture} package, we can use any other affine +reference system and combine it with the use of polar coordinates. + +\subsubsection{Reference systems} +The \package{xpicture} package allows us to use other reference systems. +For the purpose we are interested, a reference system consists +of an origin of coordinates and a pair of linearly independent vectors. +Typing\ttslashindex{referencesystem} +\begin{Verbatim}[commandchars=\|\[\]] +\referencesystem(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1])(|TIT[x2],|TIT[y2]) +\end{Verbatim} +we declare the new reference system with origin at point +$(\TTT{\TIT{x0}},\TTT{\TIT{y0})} $ and coordinate vectors +$(\TTT{\TIT{x1}},\TTT{\TIT{y1}})$ and +$(\TTT{\TIT{x2}},\TTT{\TIT{y2}})$. +If the coordinates of the point $P$ with respect to this reference system +are $(\bar{\TTT{\TIT{x}}},\bar{\TTT{\TIT{y}}})$, then the +coordinates of $ P $ with respect to the standard system, +$(\TTT{\TIT{x}},\TTT{\TIT{y}})$, are calculated with the formula +\newenvironment{qmatrix}{\left[\begin{matrix}}{\end{matrix}\right]} +\[ + \begin{qmatrix} + \TTT{\TIT{x}} \\ \TTT{\TIT{y}} + \end{qmatrix}=\begin{qmatrix} + \TTT{\TIT{x0}} \\ \TTT{\TIT{y0}} + \end{qmatrix} + + \begin{qmatrix} + \TTT{\TIT{x1}} & \TTT{\TIT{x2}} \\ + \TTT{\TIT{y1}} & \TTT{\TIT{y2}} + \end{qmatrix} \begin{qmatrix} + \bar{\TTT{\TIT{x}}} \\ \bar{\TTT{\TIT{y}}} + \end{qmatrix} +\] + +For example, +\begin{Verbatim}[commandchars=\|\[\]] +\referencesystem(1,2)(1,0)(0.5,0.5) +\end{Verbatim} +sets a new reference system that has its origin in the point $O(1,2)$ +and the coordinate vectors $\vec u_1=(1,0)$ and $\vec u_2=(1/2,1/2)$. +The following pictures show this coordinate system built on the standard +reference system +and a Cartesian grid refered to the new reference system. + +\noindent +\setlength\unitlength{1cm}% + \renewcommand{\Pictlabelsep}{0.2} +\begin{Picture}(-3.1,-3.1)(3.1,3.1) +\put(-1.5,0){\line(1,0){3}} +\put(0,-1.5){\line(0,1){3}} +{\makenolabels +\cartesianaxes(-3,-3)(3,3)} +\thicklines + \xVECTOR(0,0)(1,2) +\pictcolor{red} +\referencesystem(1,2)(1,0)(0.5,0.5) +\Put[-45](0,0){$O$} +\renewcommand\axescolor{red} +\renewcommand\axeslabelcolor{red} +\cartesianaxes(-2.1,-2.1)(2.1,2.1) +\linethickness{1pt} +\xVECTOR(0,0)(1,0) +\xVECTOR(0,0)(0,1) +\rPut{SE}(1,0){$\vec u_1$} +\Put[SE](0,1){$\vec u_2$} +\end{Picture} +\hfill% +{\referencesystem(1,2)(1,0)(0.5,0.5) +\begin{Picture}(-3.6,-3.6)(3.5,3.5) +\thinlines +\cartesiangrid(-3,-3)(3,3) +\pictcolor{red} +\linethickness{1pt} +\xVECTOR(0,0)(1,0) +\xVECTOR(0,0)(0,1) +\end{Picture}} + +Alternatively, you can use the \csdef{changereferencesystem} declaration: +in the instruction +\begin{Verbatim}[commandchars=\|\[\]] +\changereferencesystem(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1])(|TIT[x2],|TIT[y2]) +\end{Verbatim} +point $(\TTT{\TIT{x0}},\TTT{\TIT{y0})}$ and vectors +$(\TTT{\TIT{x1}},\TTT{\TIT{y1}})$ i $(\TTT{\TIT{x2}},\TTT{\TIT{y2}})$ +are not refered to the standard system, +but to the \emph{active} reference system.\footnote{% +In other words, the instruction +\cs{referencesystem} changes from the standard reference system +to the new one, while +\cs{changereferencesystem} changes from the active system.} +Moreover, as the more interesting (and frequent) reference system changes +consist of translations of the origin, rotations of the axes +and symmetries, \package{xpicture} +introduces three specific commands to these special cases: +\ttslashindex{translateorigin} +\begin{Verbatim}[commandchars=\|\[\]] +\translateorigin(|TIT[x0],|TIT[y0]) +\end{Verbatim} +moves the origin to the specified coordinates. +\ttslashindex{rotateaxes} +\begin{Verbatim}[commandchars=\|\[\]] +\rotateaxes{|TIT[angle]} +\end{Verbatim} +rotates the axes. The \TTT{\TIT{angle}} parameter is interpreted +as the rotation angle in radians +(if the \csdef{radiansangles} declaration is active) or in +sexagesimal degrees (if the \csdef{degreesangles} declaration is active). +And\ttslashindex{symmetrize} +\begin{Verbatim}[commandchars=\|\[\]] +\symmetrize{|TIT[angle]} +\end{Verbatim} +performs a symmetry, being \TTT{\TIT{angle}} +the angle between the $x$ axis and the symmetry axis. +Also here, the \csdef{radiansangles} and \csdef{degreesangles} +declarations determine if angles are +interpreted as radians or degrees. +% +These three declarations always apply to the active reference system. +\begin{Exemple} +\newcommand{\mypicture}{% +{\thicklines +\xVECTOR(-1,-1)(1,1) +\pictcolor{red}\Circle{1} +\pictcolor{blue}\regularPolygon{1}{4} +\polarreference\degreesangles +\pictcolor{green}\Polygon(1,90)(0,0)(1,-30)}} +\centering +\setlength{\unitlength}{1cm} +\fbox{\begin{Picture}[black!5!white](-1.5,-6.5)(14.5,1.5) +\cartesiangrid(-1,-1)(14,1) +\mypicture +{\referencesystem(3,0)(1,1)(1,0) +\mypicture +\changereferencesystem(0,4)(-1,1)(1,-2) +\mypicture} +\degreesangles +\translateorigin(10,0) +{\rotateaxes{45} +\mypicture} +\translateorigin(3,0) +\symmetrize{45} +\mypicture +\referencesystem(6.5,-4)(7,0)(0,-2)\mypicture +\end{Picture}} +\end{Exemple} + +The \csdef{standardreferencesystem} declaration restores the standard +reference. + +\medskip + +Changes of reference system can +be used inside or outside the \environ{Picture} environment. +In the next sections we will see what are the effects produced in each case. + +\subsubsection{Polar coordinates} +Instead of Cartesian coordinates, we can refer to a point $P$ using the +polar coordinates $(r,\phi)$ of this point: +$r$ is the distance from the origin $O$ and $\phi$ is the angle between +the first coordinate vector and the $OP$ segment. +The \csdef{cartesianreference} and \csdef{polarreference} declarations +establish the coordinates of one or the other type. +By default, the Cartesian coordinates are used, but in some cases +is much easier determine polar coordinates. +Additionally, the \csdef{radiansangles} and \csdef{degreesangles} +declarations +sets angle measuring in radians or in degrees, respectively +(by default, angles are measured in radians). + +The following example shows a typical situation in which it is more +appropriate to use polar coordinates: +the \emph{natural} way to enter coordinates on a circle is using +polar coordinates. + +\begin{exemple} +\setlength{\unitlength}{3cm} +\fbox{\begin{Picture}(-1.3,-1.3)(1.3,1.3) +\polarreference +\degreesangles + +\renewcommand{\Pictlabelsep}{0.1} + +\multiPut(1,0)(0,30){12}{\circle*{0.05}} + % Put twelve dots, one unit apart, + % at 0, 30, 60, ..., 330 degrees + +\cPut{90}(1,90){\textsc{xii}} +\cPut{0}(1,0){\textsc{iii}} +\cPut{270}(1,270){\textsc{vi}} +\cPut{180}(1,180){\textsc{ix}} + +\pictcolor{blue}\thicklines + +\arrowsize{8}{2} +\xtrivVECTOR(0,0)(0.5,37.5) +\xtrivVECTOR(0,0)(0.9,180) + +\Put(0,0){\circle*{0.1}} +\linethickness{4pt} +\Circle{1.3} +\end{Picture}} +\end{exemple} + +The new commands defined in the \package{xpicture} package and requiring +some kind of coordinates support polar coordinates, +except the \environ{Picture} and \environ{xpicture} environments +and the \cs{cartesianaxes} and \cs{cartesiangrid} environments. +\subsection{The \environ{Picture} (or \environ{xpicture}) environment} +The \package{xpicture} package supports all drawing commands +from standard \LaTeX; +in particular, you can use the \environ{picture} environment. +However, in the expression +\begin{Verbatim}[commandchars=\|\[\]] +\begin{picture}(|TIT[x],|TIT[y])(|TIT[x0],|TIT[y0]) +\end{Verbatim} +the pairs of numbers \TTT{(\TIT x,\TIT y)} and +\TTT{(\TIT{x0},\TIT{y0})} always denote standard coordinates, +namely, +the \environ{picture} environment only uses the standard reference, +thus it defines, as drawing area, the rectangle +\TTT{[\TIT{x0},\TIT{x-x0}]}$\times$\TTT{[\TIT{y0},\TIT{y-y0}]}, +regardless of whether this is the active reference. +If we want draw a picture referring coordinates to an alternative reference +system, to determine the appropriate drawing area in absolute coordinates +is not obvious (and often is difficult). +However, the \environdef{Picture} environment +defines a working area on the active reference system: the +\begin{Verbatim}[commandchars=\|\{\}] +\begin|{Picture|}[|TIT{color}](|TIT{x0},|TIT{y0})(|TIT{x1},|TIT{y1}) +\end{Verbatim} +instruction fixes the drawing area +\TTT{[\TIT{x0},\TIT{x1}]}$\times$\TTT{[\TIT{y0},\TIT{y1}]}, +refered to the active reference system. +Here, the \TTT{(\TIT{x0},\TIT{y0})} i \TTT{(\TIT{x1},\TIT{y1})} +coordinates are always rectangular +(even when reference in polar coordinates is active). +More precisely, this environment defines a \environ{picture} box +that circumscribes our drawing area. +If the optional argument is used, background is colored in the given +\textit{color}. + +\emph{Very important: note that the syntax of the +\environ{picture} environment is not analogous +to the new environment \environ{Picture}}: +Here two pairs of coordinates are required, +\TTT{(\TIT{x0},\TIT{y0})} and \TTT{(\TIT{x1},\TIT{y1})}, +representing two opposite corners of the drawing area.\footnote{% +Although it may seem more \emph{logical} +preserve the syntax of \environ{picture} environment, +it is more natural to define the drawing area in that way.} +Obviously, if the reference sustem is the standard, expression +\begin{Verbatim}[commandchars=\|\[\]] +\begin{Picture}(0,0)(|TIT[x],|TIT[y]) +\end{Verbatim} +is equivalent to +\begin{Verbatim}[commandchars=\|\[\]] +\begin{picture}(|TIT[x],|TIT[y]) +\end{Verbatim} + +The following example shows the boxes produced by the +\environ{picture} and \environ{Picture} environments. + +\medskip + +\begin{Exemple} + \begin{center} + \setlength{\unitlength}{0.5cm} + \referencesystem(0,0)(1,-1)(1,1) + + \fbox{\begin{picture}(6,6)(-3,-3) + \cartesiangrid(-3,-3)(3,3) + \end{picture}}\qquad + \fbox{\begin{Picture}(-3,-3)(3,3) + \cartesiangrid(-3,-3)(3,3) + \end{Picture}} + \end{center} +\end{Exemple} + +The left picture does not fit the box. + In fact, some elementary geometric considerations +shown that a square box of $ 12\times12$ units of length must be reserved, +\begin{Verbatim}[commandchars=\|\[\]] +\begin{picture}(12,12)(-6,-6) +\end{Verbatim} +The use of the \environ{Picture} environment frees us to determine the +actual dimensions of the drawing. + +The new environment \environdef{xpicture} is an alias to the +\environ{Picture} environment. +Its sintax and its behavior are identical. + +On the other hand, the \csdef{draftPictures} declaration +disables all the instructions defined in this package, +replacing each picture set in a \environ{Picture} environment +by a parallelogram circumscribed by a white rectangle (the box that shows +the area reserved for the drawing).\footnote{If you use an instruction +not directly defined by \package{xpicture} (inside of a \environ{Picture} +environment), this instruction may take effect.} + +\begin{center} +\setlength{\unitlength}{1cm} +\draftPictures + +\begin{minipage}{5cm}\centering +\begin{Picture}(0,0)(5,5) +\end{Picture} + +\verb+\standardreferencesystem+ +\end{minipage}\quad +\begin{minipage}{7.5cm}\centering +\referencesystem(0,0)(1,0)(0.5,1) +\begin{Picture}(0,0)(5,5) +\end{Picture} + +\verb+\referencesystem(0,0)(1,0)(0.5,1)+ +\end{minipage} +\end{center} + +\subsection{Coordinate axes} +Instruction\ttslashindex{cartesianaxes} +\begin{Verbatim}[commandchars=\|\[\]] +\cartesianaxes(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1]) +\end{Verbatim} +draws the coordinate axes corresponding to the +\TTT{[\TIT{x0},\TIT{x1}]}$\times$\TTT{[\TIT{y0},\TIT{y1}]} rectangle. +Arguments \TTT{\TIT{x0}}, \TTT{\TIT{y0}}, +\TTT{\TIT{x1}} and \TTT{\TIT{y1}} must satisfy the conditions +\TTT{\TIT{x0}}$<$\TTT{\TIT{x1}} and \TTT{\TIT{y0}}$<$\TTT{\TIT{y1}}. +Here, coordinates \TTT{(\TIT{x0},\TIT{y0})} and \TTT{(\TIT{x1},\TIT{y1})} +are always rectangular (even when reference in polar coordinates is active). +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.75cm}% +\begin{Picture}[black!10!white](-4,-3)(4,3) +\renewcommand{\Pictlabelsep}{0.2} +\cartesianaxes(-3.5,-2.5)(3.5,2.5) +\Put[r](3.5,0){$x$} +\Put[t](0,2.5){$y$} +\end{Picture} +\end{center} +\end{exemple} +\begin{exemple} +\begin{center} +\referencesystem(0,0)(1,0)(0.5,1) +\setlength{\unitlength}{0.75cm}% +\begin{Picture}[black!10!white](-4,-3)(4,3) +\renewcommand{\Pictlabelsep}{0.2} +\cartesianaxes(-3.5,-2.5)(3.5,2.5) +\Put[r](3.5,0){$x$} +\Put[t](0,2.5){$y$} +\end{Picture} +\end{center} +\end{exemple} +The following parameters control the style of the axes, the cut marks +and labels on the axes: + +\subsubsection{The style of the axes} +\begin{description} +\item[\csdef{axescolor}] By default, the axes color is \TTT{black}, but +we can change it by redefining the \cs{axescolor} declaration. For example, +\begin{Verbatim}[commandchars=\|\[\]] +\renewcommand{\axescolor}{orange} +\end{Verbatim} + +We must use a color name predefined in the package \textsf{xcolor} +or defined by the user (for example, using the \cs{definecolor} command). +\item[\csdef{axesthickness}] Length determining the thickness of axes +(default \verb+1 pt+). +You can modify it using any command that fixes a length (as \cs{setlength} +or \cs{settowidth}). +\item[\csdef{xunitdivisions}, \csdef{yunitdivisions}] Number of subdivisions of +the unit (in each axis). +By default, 1. These arguments can also be redefined using +the \cs{renewcommand} command (they must be positive integers). +\end{description} +\begin{exemple} +\renewcommand{\xunitdivisions}{2} +\renewcommand{\yunitdivisions}{3} + +\begin{center} +\setlength{\unitlength}{1cm}% +\begin{Picture}(-4,-4)(4,4) +\cartesianaxes(-3.5,-3.5)(3.5,3.5) +\end{Picture} +\end{center} +\end{exemple} +\subsubsection{Axes position} +The coordinate axes (and also tags and cut marks) +are placed by default in the traditional way, on the $y = 0$ (the $x$ axis) +and $x = 0$ (the $y$ axis) lines. +However, sometimes the fact that labels are inside the graphic can be +annoying.\footnote{And produces strange effects when the origin $(0.0)$ +is not in the drawing area.} +Alternatively, we can place axes and tags at the +lower and left sides of the coordinate rectangle. +To choose between these two options we should use the following +declarations: +\begin{description} +\item[\csdef{internalaxes}, \csdef{externalaxes}] +If the \cs{internalaxes} declaration is active, then axes lies +on $y=0$ and $x=0$. + +However, if we activate the \cs{externalaxes} declaration, the axes +produced by the instruction +\begin{Verbatim}[commandchars=\|\[\]] +\cartesianaxes(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1]) +\end{Verbatim} +lies on $y=\TTT{\TIT{y0}}$ and $x=\TTT{\TIT{x0}}$. + +By default, the \cs{internalaxes} declaration is active. +\end{description} +\begin{exemple} +\renewcommand{\xunitdivisions}{2} +\renewcommand{\yunitdivisions}{2} + +\begin{center} +\externalaxes +\setlength{\unitlength}{1cm}% +\begin{Picture}(-4,-4)(4,4) +\cartesianaxes(-3.5,-3.5)(3.5,3.5) +\end{Picture} +\end{center} +\end{exemple} + +\subsubsection{Tags style} +The numerical tags on the axes are made in math mode. +If you need textual labels, put them in a \cs{mbox} or, +using \package{amsmath}, a \cs{text} box. +We can control the color, attributes and distance to the axes of these tags, +redefining +(with \cs{renewcommand}) the following marks: +\begin{description} +\item[\csdef{axeslabelcolor}] The color of the numerical tags on the axes. +By default, this color is identical to the axes color. +\item[\csdef{axeslabelsize}] Size of numerical tags. +By default, \cs{small}. +\item[\csdef{axeslabelmathversion}] + Mathversion of numerical tags. +By default, \TTT{normal}.\footnote{Standard \emph{math versions} +are \TTT{normal} and \TTT{bold}, but some packages +define other math versions.} +\item[\csdef{axeslabelmathalphabet}] Mathalphabet of numerical tags. +By default, \cs{mathrm}. +\item[\csdef{axislabelsep}] Distance between tags and cut marks, +measured in \cs{unitlength} units;\footnote{The distance between axes and +tags equals \cs{ticssize}$+$\cs{axislabelsep}.} +by default, \verb+0.1+ (see later the description of \cs{makenotics}). +\end{description} + +\subsubsection{Tags position} +Position of tags is controlled by two declarations: +\begin{description} +\item[\cs{xlabelpos\{\TIT{position}\}}]\ttslashindex{xlabelpos} +change the relative position of labels in $x$ axis. +Admissible values are those allowed in the \TTT{\TIT{position}} +argument of command \cs{Put} (see subsection~\ref{subsec:put}). +Default is \verb+-90+. +\item[\cs{ylabelpos\{\TIT{position}\}}]\ttslashindex{ylabelpos} +change the relative position of labels in $y$ axis. +Default is \verb+180+. +\end{description} + +\subsubsection{Style of cut marks} +Units (and, optionally, unit fractions) are marked over axes with small +segments, +the style of which is controlled by the following parameters: +\begin{description} +\item[\csdef{ticssize}, \csdef{secundaryticssize}] +These lengths control the size of the tics: +\cs{ticssize} is half the length of main cuts +(by default, \verb+4pt+) +and \cs{secundaryticssize} is half the length of secundary cuts +(by default, \verb+2pt+). +\item[\csdef{ticsthickness}] Thickness of the marks on axes +(by default, \verb+1pt+). +\item[\csdef{ticscolor}] Color of the marks on axes (by default, \verb+black+). +\end{description} +\begin{exemple} +\renewcommand{\axescolor}{blue} +\setlength{\axesthickness}{3pt} +\renewcommand{\xunitdivisions}{2} +\renewcommand{\yunitdivisions}{3} + +\renewcommand{\axeslabelcolor}{teal} +\renewcommand{\axeslabelsize}{\footnotesize} +\renewcommand{\axeslabelmathversion}{bold} +\renewcommand{\axeslabelmathalphabet}{\mathsf} +\renewcommand{\axislabelsep}{0.05} +\xlabelpos{ttl} +\ylabelpos{r} + +\setlength{\ticssize}{0.2cm} +\setlength{\secundaryticssize}{0.1cm} +\setlength{\ticsthickness}{2pt} +\renewcommand{\ticscolor}{blue!50} + +\begin{center} +\degreesangles +\rotateaxes{-30} +\setlength{\unitlength}{0.75cm}% +\begin{Picture}(-5,-4)(5,4) +\cartesianaxes(-4.5,-3.5)(4.5,3.5) +\end{Picture} +\end{center} +\end{exemple} + +\subsubsection{Removing and directly printing cut marks and labels} +\begin{description} + \item [\csdef{maketics}, \csdef{makenotics}] + These two declarations determine if + divisions on the axes should be marked or not. + By default the \cs{maketics} declaration is active. + +If divisions are not marked, the \csdef{axislabelsep} +declaration determines the distance between axes and labels. +\end{description} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.75cm}% +\begin{Picture}(-4.5,-2.5)(4.5,2.5) +\makenotics +\cartesianaxes(-4,-2)(4,2) +\end{Picture} +\end{center} +\end{exemple} +\begin{description} + \item [\csdef{makelabels}, \csdef{makenolabels}] Two declarations +determining whether numerical labels on the axes must appear or not. +By default, the \cs{makelabels} declaration is active. +\end{description} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.75cm}% +\begin{Picture}(-4.5,-2.5)(4.5,2.5) +\makenolabels +\cartesianaxes(-4,-2)(4,2) +\end{Picture} +\end{center} +\end{exemple} + +Declarations \cs{makenotics} and \cs{makenolabels} +can be useful when you want to show only some specific coordinates, +when the points to be highlighted on the axes are not integers +and when you need to print labels in some special format. In this cases +you can plot tics and/or print labels using the following commands. +\begin{description} +\item [\cs{plotxtic\{\TIT{x-coor}\}}, \cs{plotytic\{\TIT{y-coor}\}}] +\ttslashindex{plotxtic}\ttslashindex{plotytic} +plot a tic for the given \TIT{x} or \TIT{y} coordinate. +\item [\cs{printxlabel\{\TIT{x-coor}\}\{\TIT{label}\}}, + \cs{printylabel\{\TIT{y-coor}\}\{\TIT{label}\}}] +\ttslashindex{printxlabel}\ttslashindex{printylabel} +print \TIT{label} +for the given \TIT{x} or \TIT{y} coordinate. Labels are printed in math mode. +\item [\cs{printxticlabel\{\TIT{x-coor}\}\{\TIT{label}\}}, + \cs{printyticlabel\{\TIT{y-coor}\}\{\TIT{label}\}}] +plot a tic and print \TIT{label} for the given \TIT{x} or \TIT{y} coordinate. +\end{description} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{1cm}% +\begin{Picture}(-4.5,-0.5)(4.5,3.5) +\makenolabels +\makenotics +\cartesianaxes(-4,0)(4,3) + +\plotytic{0.5} +\printylabel{0.5}{1/2} +\printxticlabel{2}{2} + +\Polyline(2,0)(2,0.5)(0,0,5) +\thicklines +\SCALEfunction{0.125}{\SQUAREfunction}{\F} +\PlotFunction[3]{\F}{-4}{4} +\end{Picture} +\end{center} +\end{exemple} + +Multiple equally spaced tics and/or labels can be drawn simultaneously: +\begin{description} +\item [\cs{plotxtics\{\TIT{firstcoor}\}\{\TIT{incr}\}\{\TIT{bound}\}}, + \cs{plotytics\{\TIT{firstcoor}\}\{\TIT{incr}\}\{\TIT{bound}\}}] +\ttslashindex{plotxtics}\ttslashindex{plotytics} +plot several (\TIT{x} or \TIT{y}) tics, +from the initial coordinate \TIT{firstcoor}; \TIT{incr} is the distance +between consecutive tics, and the last tic is not in a position +greater than \TIT{bound}. +\item [\cs{printxlabels[\TIT{digits}]\{\TIT{firstcoor}\}\{\TIT{incr}\}% + \{\TIT{bound}\}}, + \cs{printylabels[\TIT{digits}]\{\TIT{firstcoor}\}\{\TIT{incr}\}% + \{\TIT{bound}\}}] +\ttslashindex{printxlabels}\ttslashindex{printylabels} print several labels, +from the initial coordinate \TIT{firstcoor}; \TIT{incr} is the distance +between consecutive label positions, +and the last position is not greater than \TIT{bound}. +The optional argument \TIT{digits} is the number of decimal digits to be +printed (by default, numbers are printed with its natural number of decimals). +\item [\cs{printxticslabels[\TIT{digits}]\{\TIT{firstcoor}\}\{\TIT{incr}\}% + \{\TIT{bound}\}}]\ttslashindex{printxticslabels} + plot \TIT{x} tics and labels simultaneously. +\item [\cs{printyticslabels[\TIT{digits}]\{\TIT{firstcoor}\}\{\TIT{incr}\}% + \{\TIT{bound}\}}]\ttslashindex{printyticslabels} + plot \TIT{y} tics and labels simultaneously. +\end{description} +\begin{exemple} +\externalaxes +\setlength{\unitlength}{1cm} +\renewcommand{\axeslabelsize}{\tiny} +\referencesystem(0,0)(1.5,0)(0,2) +\begin{center} +\begin{Picture}(-2.5,-1.5)(2.5,1.5) +\makenotics +\makenolabels +\cartesianaxes(-2.25,-1.25)(2.25,1.25) +\printxticslabels[1]{-2}{0.5}{2.25} +\printyticslabels[4]{-1}{0.25}{1} +\end{Picture} +\end{center} +\end{exemple} +\begin{Exemple} +\setlength{\unitlength}{1cm} +\begin{center} +\begin{Picture}(-7,-2.5)(7,2.5) +{\referencesystem(0,0)(\numberHALFPI,0)(0,1) +\renewcommand{\xunitdivisions}{2} +\renewcommand{\yunitdivisions}{2} +\makenolabels +\renewcommand{\Pictlabelsep}{0.25} +\cartesianaxes(-4.2,-2.2)(4.2,2.2) + +\printylabels{-2}{0.5}{2} + +\highestlabel{$-3\pi/2$} +\printxlabel{-4}{-2\pi} +\printxlabel{-3}{-3\pi/2} +\printxlabel{-2}{-\pi} +\printxlabel{-1}{-\pi/2} +\printxlabel{1}{\pi/2} +\printxlabel{2}{\pi} +\printxlabel{3}{3\pi/2} +\printxlabel{4}{2\pi} +} +\end{Picture} +\end{center} +\end{Exemple} + +\subsection{Cartesian grids} +As an alternative to the \cs{cartesianaxes} command, +we can use \csdef{cartesiangrid}, +to better visualize the coordinates: +\begin{Verbatim}[commandchars=\|\[\]] +\cartesiangrid(|begin[math]x0,y0|end[math])(|begin[math]x1,y1|end[math]) +\end{Verbatim} +\begin{exemple} +\definecolor{myblue}{cmyk}{1,1,0,0.5} +\renewcommand{\gridcolor}{myblue} +\renewcommand{\secundarygridcolor}{cyan} +\setlength{\gridthickness}{0.5pt} +\setlength{\secundarygridthickness}{0.1pt} +\renewcommand{\xunitdivisions}{5} +\renewcommand{\yunitdivisions}{5} +\renewcommand{\axeslabelsize}{\footnotesize} +\begin{center} +\setlength{\unitlength}{1cm} +\begin{Picture}(-3.5,-2.5)(3.5,2.5) +\cartesiangrid(-3.4,-2.4)(3.4,2.4) +\end{Picture} +\end{center} +\end{exemple} +\begin{exemple} +\definecolor{myblue}{cmyk}{1,1,0,0.5} +\renewcommand{\gridcolor}{myblue} +\renewcommand{\secundarygridcolor}{cyan} +\setlength{\gridthickness}{0.5pt} +\setlength{\secundarygridthickness}{0.1pt} +\renewcommand{\xunitdivisions}{5} +\renewcommand{\yunitdivisions}{5} +\renewcommand{\axeslabelsize}{\footnotesize} +\begin{center} +\setlength{\unitlength}{1cm} +\referencesystem(0,0)(1,0)(0.25,1) +\externalaxes +\begin{Picture}(-4,-3)(4,3) +\cartesiangrid(-3.4,-2.4)(3.4,2.4) +\end{Picture} +\end{center} +\end{exemple} + +\subsubsection{Grid style} +Note that, in addition to the parameters outlined above, there are the +following ones, which control the style of the grid +(as in previous cases, these parameters are changed +by redefining them with the \cs{renewcommand} declaration, +or using the usual instructions when they are lengths). + +\begin{description} + \item [\csdef{gridcolor}] determines the color of main divisions in the grid +(regardless of the axes color). By default, this color is \verb+gray+. + \item [\csdef{secundarygridcolor}] determines the color of secundary +divisions in the grid. +By default, \verb+lightgray+). +\item[\csdef{gridthickness}] thickness of main divisions +(by default, \verb+0.4pt+). +\item[\csdef{secundarygridthickness}] thickness of secundary divisions +(by default, \verb+0.2pt+). +\end{description} +\subsection{Polar grids} +Finally, instead of Cartesian axes, we can construct a polar grid +(obviously, this option will be interesting when we use polar coordinates). +\ttslashindex{polargrid} +\begin{Verbatim}[commandchars=\|\[\]] +\polargrid{|TIT[radius]}{|TIT[circledivs]} +\end{Verbatim} +(\TTT{\TIT{radius}} and \TTT{\TIT{circledivs}} are, respectively, +the radius and the number of divisions of the circle +(\TTT{\TIT{circledivs}}must be a positive integer). + +This command supports the same parameters that \cs{cartesianaxes} and +\cs{cartesiangrid} (when they makes sense), and also the following: +\begin{description} +\item[\csdef{runitdivisions}] Number of radial subdivisions of the unit. +By default, $1$ (it must be a positive integer). +\end{description} +\begin{exemple} +\renewcommand{\runitdivisions}{2} +\setlength{\unitlength}{0.75cm} +\renewcommand{\gridcolor}{magenta} +\begin{center} +\begin{Picture}(-4,-4)(4,4) +\polargrid{3.5}{12} +\end{Picture} +\end{center} +\end{exemple} +\begin{exemple} +\renewcommand{\runitdivisions}{2} +\setlength{\unitlength}{0.75cm} +\renewcommand{\gridcolor}{magenta} +\referencesystem(0,0)(1,-1)(0.5,0.5) +\begin{center} +\begin{Picture}(-3.5,-3.5)(3.5,3.5) +\polargrid{3.5}{12} +\end{Picture} +\end{center} +\end{exemple} +\begin{description} +\item[\csdef{degreespolarlabels}, \csdef{radianspolarlabels}] +Arcs are printed, by default, in radians. +If you want angular units mesured in degrees, +use the \csdef{degreespolarlabels} declaration (obviously, +\csdef{radianspolarlabels} recovers tags in radians). +\end{description} +\begin{exemple} +\begin{center} +\degreespolarlabels +\setlength{\unitlength}{1cm} +\begin{Picture}(-4,-4)(4,4) +\polargrid{3}{24} +\end{Picture} +\end{center} +\end{exemple} +\begin{description} +\item[\csdef{rlabelpos}] Relative position of labels in polar axis. +Admissible values are those allowed in the \TTT{\TIT{position}} +argument of command \cs{Put} (see subsection~\ref{subsec:put}). +Default is \verb+bbr+. +\end{description} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{1cm} +\begin{Picture}(-4,-4)(4,4) +\rlabelpos{b} +\polargrid{3.5}{10} +\end{Picture} +\end{center} +\end{exemple} + + +To remove tags on the polar axis and angles you can use the +\csdef{makenolabels} declaration. + +\section[Alternatives to some standard commands]{% + Alternatives to standard commands + \cs{put},\cs{multiput}, \cs{line}, and \cs{vector}} +Standard commands used inside the \environ{picture} environment +are not modified by this package +(although if we include these commands in the body of a \environ{Picture} +environment). +In particular, there does not affect the \cs{referencesystem} declaration. +This package introduces similar commands to those which are sensitive to the +active reference system and give us a greater control over their behavior. +These are the instructions described below. + +\subsection{Extensions of the \cs{put} command}\label{subsec:put} + \begin{description} + \item[\csdef{Put}, \csdef{cPut}, \csdef{rPut}] +\mbox{} + +\begin{Verbatim}[commandchars=\|\{\}] +\Put[|TIT{position}](|TIT{x},|TIT{y})|{|TIT{object}|} +\Put*[|TIT{position}](|TIT{x},|TIT{y})|{|TIT{object}|} +\cPut|{|TIT{position}|}(|TIT{x},|TIT{y})|{|TIT{object}|} +\rPut|{|TIT{position}|}(|TIT{x},|TIT{y})|{|TIT{object}|} +\rPut*|{|TIT{position}|}(|TIT{x},|TIT{y})|{|TIT{object}|} +\end{Verbatim} +place the drawing pointer in the point +of coordinates \verb+(+\TTT{\TIT{x}}\verb+,+\TTT{\TIT{y}}\verb+)+ +with respect to the active reference system (which may coincide or not with +the standard system). +These commands differ in the criteria used to determine the precise position +of the object. + +Involved parameters are (see below) +\ttslashindex{Pictlabelsep} +\ttslashindex{defaultPut} +\ttslashindex{highestlabel} +\begin{Verbatim}[commandchars=\|\[\]] +\Pictlabelsep|{|TIT[distance]|} +\defaultPut|{c|}/\defaultPut|{r|} +\highestlabel|{|TIT[text]|} +\end{Verbatim} +\medskip + +In the following example, the red circle (included as an argument in the +\cs{put} command) is at the point +of standard coordinates $(1,-1)$; however, in the case of the +blue circle, coordinates $(1,-1)$ refer to the active reference system. +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.75cm} +\referencesystem(0,0)(1,-1)(1,1) +\begin{Picture}(-2.5,-2.5)(2.5,2.5) +\cartesiangrid(-2,-2)(2,2) +\pictcolor{red} +\put(1,-1){\circle*{0.25}} +\pictcolor{blue} +\Put(1,-1){\circle*{0.25}} +\end{Picture} +\end{center} +\end{exemple} + +Recall that coordinates can be rectangular or polar, and angles may +be measured in radians or in degrees. +\begin{exemple} +\begin{center} +\setlength{\unitlength}{1cm} +\begin{Picture}(-2.5,-2.5)(2.5,2.5) +\cartesiangrid(-2,-2)(2,2) +\polarreference +\pictcolor{blue} +\Put(1,\numberHALFPI){\circle*{0.25}} +\degreesangles +\pictcolor{red} +\Put(1,180){\circle*{0.25}} +\end{Picture} +\end{center} +\end{exemple} +\subsubsection{Accurate positioning of the graphical object} +The \TTT{\TIT{position}} argument allows us to fix the relative position of +\TTT{\TIT{object}} respect to point \TTT{(\TIT{x},\TIT{y})}. +Note that this argument is optional in \cs{Put} and \cs{Put*}, +but mandatory in the other commands we are describing. +The purpose of this parameter is to rationalize the disposition of +objects, especially when they are not strictly graphical objects +(but labels, text boxes or mathematical formulas). In these cases, +the appropriate choice of coordinates seems a problem that is not well +solved with standard instructions, despite the special syntax of the +\cs{makebox} command in the \environ{picture} environment. +For example, in this picture (which we made using only the standard +\LaTeX{} commands) +\begin{center} +\setlength{\unitlength}{2cm} + +\begin{picture}(7,3)(-0.5,-1.5) + +\put(0,0){\line(1,0){7}} +\put(0,-1.5){\line(0,1){3}} +\put(0,-1.5){\line(0,-1){0}} +\multiput(1.570796,-0.1)(1.570796,0){4}{\line(0,1){0.2}} +\multiput(-0.1,-1)(0,1){3}{\line(1,0){0.2}} + +\qbezier(0,0)(1,1)(1.570796,1) +\qbezier(1.570796,1)(2.141593,1)(3.141593,0) +\qbezier(3.141593,0)(4.141593,-1)(4.712389,-1) +\qbezier(4.712389,-1)(5.283185,-1)(6.283185,0) + +\put(-1.570796,0){% + \qbezier(1.570796,1)(2.141593,1)(3.141593,0) + \qbezier(3.141593,0)(4.141593,-1)(4.712389,-1) + \qbezier(4.712389,-1)(5.283185,-1)(6.283185,0)} +\put(4.712389,0){\qbezier(0,0)(1,1)(1.570796,1)} + +\put(2.356194,0.707107){$\sin x$} +\put(6.283185,1){$\cos x$} +\put(-0.15,-1){\makebox(0,0)[r]{$-1$}} +\put(-0.15,0){\makebox(0,0)[r]{$0$}} +\put(-0.15,1){\makebox(0,0)[r]{$1$}} +\put(1.570796,-0.15){\makebox(0,0)[t]{$\pi/2$}} +\put(3.141593,-0.15){\makebox(0,0)[t]{$\pi$}} +\put(4.712389,-0.15){\makebox(0,0)[t]{$3\pi/2$}} +\put(6.283185,-0.15){\makebox(0,0)[t]{$2\pi$}} +\end{picture} +\end{center} +we have located numerical labels ($0$, $1$, $\pi$\ldots) at +\TTT{0.15\cs{unitlength}} of its \emph{natural} position over the axes, +while the reference points of tags +``$\sin x$'' and ``$\cos x$'' are just in points $(3\pi/4,\sin(3\pi/4))$ and +$(2\pi,1)$, using these instructions: +\begin{Verbatim} +\put(2.356194,0.707107){$\sin x$} +\put(6.283185,1){$\cos x$} +\put(-0.15,-1){\makebox(0,0)[r]{$-1$}} +\put(-0.15,0){\makebox(0,0)[r]{$0$}} +\put(-0.15,1){\makebox(0,0)[r]{$1$}} +\put(1.570796,-0.15){\makebox(0,0)[t]{$\pi/2$}} +\put(3.141593,-0.15){\makebox(0,0)[t]{$\pi$}} +\put(4.712389,-0.15){\makebox(0,0)[t]{$3\pi/2$}} +\put(6.283185,-0.15){\makebox(0,0)[t]{$2\pi$}} +\end{Verbatim} + +If we change the value of \cs{unitlength}, then these values become +inappropriate and we need to change several lines of code. +\begin{center} +\setlength{\unitlength}{1cm} + +\begin{picture}(7,3)(-0.5,-1.5) + +\put(0,0){\line(1,0){7}} +\put(0,-1.5){\line(0,1){3}} +\put(0,-1.5){\line(0,-1){0}} +\multiput(1.570796,-0.1)(1.570796,0){4}{\line(0,1){0.2}} +\multiput(-0.1,-1)(0,1){3}{\line(1,0){0.2}} + +\qbezier(0,0)(1,1)(1.570796,1) +\qbezier(1.570796,1)(2.141593,1)(3.141593,0) +\qbezier(3.141593,0)(4.141593,-1)(4.712389,-1) +\qbezier(4.712389,-1)(5.283185,-1)(6.283185,0) + +\put(-1.570796,0){% + \qbezier(1.570796,1)(2.141593,1)(3.141593,0) + \qbezier(3.141593,0)(4.141593,-1)(4.712389,-1) + \qbezier(4.712389,-1)(5.283185,-1)(6.283185,0)} +\put(4.712389,0){\qbezier(0,0)(1,1)(1.570796,1)} + +\put(2.356194,0.707107){$\sin x$} +\put(6.283185,1){$\cos x$} +\put(-0.15,-1){\makebox(0,0)[r]{$-1$}} +\put(-0.15,0){\makebox(0,0)[r]{$0$}} +\put(-0.15,1){\makebox(0,0)[r]{$1$}} +\put(1.570796,-0.15){\makebox(0,0)[t]{$\pi/2$}} +\put(3.141593,-0.15){\makebox(0,0)[t]{$\pi$}} +\put(4.712389,-0.15){\makebox(0,0)[t]{$3\pi/2$}} +\put(6.283185,-0.15){\makebox(0,0)[t]{$2\pi$}} +\end{picture} +\end{center} + +Note that, regarding labels along the $x$ axis, instead of aligning them to a +fixed distance of this axis, there would be better to align the baselines +($\pi$ and $2\pi$ should go down); +some of these labels should +move slightly to the right or to the left to avoid that it cut the graph. +Finally, the tag ``$\cos x$'' should be vertically centered +(with respect to the curve) and slightly moved to the right. +\medskip + +Using the \package{xpicture} package we construct this picture +in the following way: +\begin{Exemple} +\MULTIPLY{3}{\numberQUARTERPI}{\numberTQPI} +\SIN{\numberTQPI}{\sinTQPI} + +\begin{center} +\setlength{\unitlength}{2cm} +\begin{Picture}(-0.5,-1.5)(6.5,1.5) +{\referencesystem(0,0)(\numberHALFPI,0)(0,1) +\makenolabels +\renewcommand{\Pictlabelsep}{0.1} +\highestlabel{$-3\pi/2$} +\cartesianaxes(0,-1.5)(4.25,1.5) + +\rPut{l}(0,-1){$-1$} % put the y-axis labels at left +\rPut{l}(0,0){$0$} +\rPut{l}(0,1){$1$} +\rPut*{bbl}(1,0){$\pi/2$} % put "\pi/2" at bbl +\rPut*{b}(2,0){$\pi$} % put "\pi" at bottom +\rPut*{bbr}(3,0){$3\pi/2$} % put "3\pi/2" at bbr +\rPut*{b}(4,0){$2\pi$} % put "2\pi" at bottom + +\rPut*{b}(0,0){\pictcolor{gray}\xLINE(0.75,0)(4.25,0)}} % \baseline of x-labels + +\PlotFunction[8]{\COSfunction}{0}{\numberTWOPI} +\PlotFunction[8]{\SINfunction}{0}{\numberTWOPI} + +\Put[NE](\numberTQPI,\sinTQPI){$\sin x$} % put "\sin x" at NorthEast +\Put[E](\numberTWOPI,1){$\cos x$} % put "\cos x" at East +\end{Picture} +\end{center} +\end{Exemple} +Here we used several tools to draw the graphs of the functions. +But aside from this, commands \cs{Put}, \cs{rPut} and \cs{rPut*} have allowed +we to determine the logical position of objects in a much more +reasonable way.\footnote{Regarding to labels on coordinated axes +a better choice would be to use other specific commands, +as \cs{printxlabels}. Here we have chosen \cs{rPut} because we are +illustrating this instruction.} + +Argument \TTT{\TIT{position}} supports multiple values: +\begin{description} +\item[An integer or decimal number,] determining the angle (in degrees) +where \TTT{\TIT{object}} is placed, + with respect to the reference point \TTT{(\TIT{x},\TIT{y})}. +\end{description} + +\begin{Exemple} +\begin{center} +\setlength{\unitlength}{1cm} +\begin{Picture}(0,-1)(9,1) +\makenolabels +\renewcommand{\axescolor}{lightgray}\renewcommand{\ticscolor}{lightgray} +\cartesiangrid(0,-1)(8,1) +\pictcolor{blue} +\Put[0](0,0){0} +\Put[45](1,0){45} +\Put[90](2,0){90} +\Put[135](3,0){135} +\Put[180](4,0){180} +\Put[225](5,0){225} +\Put[270](6,0){270} +\Put[315](7,0){315} +\Put[360](8,0){360} +\end{Picture} +\end{center} +\end{Exemple} +\begin{description} +\item[Letter \TTT{c}] (from \emph{center}), +which places the center of \TTT{\TIT{object}} at point +\verb+(+\TTT{\TIT{x}}\verb+,+\TTT{\TIT{y}}\verb+)+. +\end{description} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{2cm} +\begin{Picture}(-1,-1)(1,1) +\cartesianaxes(-1,-1)(1,1) +\pictcolor{blue} +\Put[c](0,0){A CENTERED BOX} +\end{Picture} +\end{center} +\end{exemple} +Note that this option is not equivalent to the suppression of the optional +argument, because in that case +the reference point of \TTT{\TIT{object}} is located +in \verb+(+\TTT{\TIT{x}}\verb+,+\TTT{\TIT{y}}\verb+)+. +\begin{exemple} +\begin{center} +\setlength{\unitlength}{2cm} +\begin{Picture}(-1,-1)(1,1) +\cartesianaxes(-1,-1)(1,1) +\pictcolor{blue} +\Put(0,0){A NONCENTERED BOX} +\end{Picture} +\end{center} +\end{exemple} +\begin{description} +\item[Letters or letter combinations \TTT N, \TTT E, \TTT S, \TTT W, +\TTT{NE}, \TTT{SE}, \TTT{SW}, \TTT{NW}, +\TTT{NNE}, \TTT{ENE}, \TTT{ESE}, \TTT{SSE}, \TTT{SSW}, \TTT{WSW}, \TTT{WNW}, +\TTT{NNW}]\mbox{} + +Abbreviation of \emph{North}, \emph{East}\ldots, \emph{North-East}\ldots, +\emph{North-North-East}\ldots + +For example, the +\begin{Verbatim} +\Put[NE](0,0){A} +\end{Verbatim} +instruction writes ``\verb+A+'' \emph{at north-east} of point \verb+(0,0)+. +\item[Letters o letter combinations \TTT t, \TTT r, \TTT b, \TTT l, + \TTT{tr}, \TTT{br}, \TTT{bl}, \TTT{tl}, + \TTT{ttr}, \TTT{rtr}, \TTT{rbr}, \TTT{bbr}, \TTT{bbl}, \TTT{lbl}, \TTT{ltl}, + \TTT{ttl}]\mbox{} + +Abbreviation of \emph{top}, \emph{right}\ldots, \emph{top-right}\ldots, +\emph{top-top-right}\ldots + +For example, +\begin{Verbatim} +\Put[tr](0,0){A} +\end{Verbatim} +writes ``\verb+A+'' \emph{at top and right} of point \verb+(0,0)+. + +Parameter \cs{Pictlabelsep} determines the distance between the graphical +object and the given point. +In the following examples we have made this argument very big to clearly +appreciate the positioning of objects. +\end{description} +\begin{exemple} +\renewcommand{\Pictlabelsep}{1} +\begin{center} +\setlength{\unitlength}{2.5cm}% + +\begin{Picture}(-1.5,-1.5)(1.5,1.5) +\Put[N](0,0){N} +\Put[S](0,0){S} +\Put[E](0,0){E} +\Put[W](0,0){W} +\Put[NE](0,0){NE} +\Put[SE](0,0){SE} +\Put[SW](0,0){SW} +\Put[NW](0,0){NW} +% +\Put[NNE](0,0){NNE} +\Put[ENE](0,0){ENE} +\Put[ESE](0,0){ESE} +\Put[SSE](0,0){SSE} +\Put[SSW](0,0){SSW} +\Put[WSW](0,0){WSW} +\Put[WNW](0,0){WNW} +\Put[NNW](0,0){NNW} +\Put(0,0){\Circle{1}} +\xLINE(-1,0)(1,0) +\xLINE(0,-1)(0,1) +\end{Picture} +\end{center} +\end{exemple} +\begin{exemple} +\renewcommand{\Pictlabelsep}{1} +\begin{center} +\setlength{\unitlength}{2.5cm}% + +\begin{Picture}(-1.5,-1.5)(1.5,1.5) +\Put[t](0,0){t} +\Put[r](0,0){r} +\Put[b](0,0){b} +\Put[l](0,0){l} +\Put[tr](0,0){tr} +\Put[br](0,0){br} +\Put[bl](0,0){bl} +\Put[tl](0,0){tl} +\Put[ttr](0,0){ttr} +\Put[rtr](0,0){rtr} +\Put[rbr](0,0){rbr} +\Put[bbr](0,0){bbr} +\Put[bbl](0,0){bbl} +\Put[lbl](0,0){lbl} +\Put[ltl](0,0){ltl} +\Put[ttl](0,0){ttl} +\Put(0,0){% + \regularPolygon[45]{\numberSQRTTWO}{4}} +\xLINE(-1,0)(1,0) +\xLINE(0,-1)(0,1) +\end{Picture} +\end{center} +\end{exemple} +\end{description} +\paragraph{Rectangular o circular distance?} +Commands \cs{rPut} and \cs{cPut} differ only in the criterion they use +to determine the distance between the reference point and the graphical object. +Command \cs{rPut} places the object (outside of) +the square centered at the reference point and side \verb+2\Pictlabelsep+, +while \cs{cPut} places it in the cercle of radius \verb+\Pictlabelsep+ +(letters \verb+r+ and \verb+c+ mean, respectively, +a \emph{rectangular} and \emph{circular} layout).% +\footnote{For the mathematicians: command \cs{cPut} uses the euclidean norm +(or 2-norm), while \cs{rPut} uses the infinite norm.} +Although, for small values of the \cs{Pictlabelsep} parameter, +the difference is subtle and usually not very significant, it is generally best +to use the circular version (because it corresponds to the natural concept of +distance) and reserve the rectangular version +to objects that are placed on horizontal or vertical lines. +\begin{Exemple} +\begin{center} +\setlength{\unitlength}{1.5cm} +\renewcommand{\Pictlabelsep}{1} + +\begin{Picture}(-1.5,-1.5)(2,1.5) +\regularPolygon[45]{\numberSQRTTWO}{4} +\Put(0,0){\circle*{0.1}} +\rPut{45}(0,0){r} +\xLINE(0,0)(0,-1) +\thicklines +\renewcommand{\Pictlabelsep}{0.1} +\xLINE(0,0)(1,1) +\xLINE(0,0)(1,0) +\xtrivVECTOR(0,-1)(1,-1) +\xtrivVECTOR(1,-1)(0,-1) +\rPut{b}(0.5,-1){\footnotesize\textbackslash Pictlabelsep} +\xtrivVECTOR(1,-1)(1,0) +\xtrivVECTOR(1,0)(1,-1) +\rPut{r}(1,-0.5){\footnotesize\textbackslash Pictlabelsep} +\polarreference\degreesangles +\xArc{0.3}{0}{45} +\degreesangles +\Put[22.5](0.3,22.5){$45^{\mathrm o}$} +\end{Picture} +\begin{Picture}(-1.5,-1.5)(2,1.5) +\Put(0,0){\circle*{0.1}} +\cPut{45}(0,0){c} +\Circle{1} +\thicklines +\xLINE(0,0)(\numberCOSXLV,\numberCOSXLV) +\xLINE(0,0)(1,0) +\xtrivVECTOR(0,0)(0,-1) +\xtrivVECTOR(0,-1)(0,0) +\renewcommand{\Pictlabelsep}{0.1} +\rPut{r}(0,-0.5){\footnotesize\textbackslash Pictlabelsep} +\polarreference\degreesangles +\xArc{0.3}{0}{45} +\degreesangles +\Put[22.5](0.3,22.5){$45^{\mathrm o}$} +\end{Picture} +\end{center} +\end{Exemple} + +Note that if the commands we use are \cs{rPut} or \cs{cPut}, then the +positioners +\verb+t, r, tr+\ldots are equivalent to the corresponding \verb+N, E, NE+\ldots +However, the \cs{Put} command choose between rectangular or circular layout +following this criteria: +\begin{itemize} + \item Positioners of \emph{compass} type (like \verb+NE+) use the circular +layout. + \item Positioners \verb+t, tr+, et cetera use the rectangular layout. + \item If the positioner is an angle (a number), it uses a default position +which is set using the \cs{defaultPut} declaration: +\verb+\defaultPut{c}+ +determines a circular distance, while +\verb+\defaultPut{r}+ +determines the rectangular alternative. +\end{itemize} +\begin{exemple} +\renewcommand{\Pictlabelsep}{1} +\begin{center} +\setlength{\unitlength}{2.5cm}% + +\begin{Picture}(-1.5,-1.5)(1.5,1.5) +\defaultPut{c} +\Put[45](0,0){c} +\defaultPut{r} +\Put[45](0,0){r} +\regularPolygon[45]{\numberSQRTTWO}{4} +\Put(0,0){\Circle{1}} +\xLINE(-1,0)(1,0) +\xLINE(0,-1)(0,1) +\end{Picture} +\end{center} +\end{exemple} +\paragraph{Alignment by the baseline} +Starred versions \cs{Put*} and \cs{rPut*} allow us to align by the baseline +objects positioned below the reference point. +To use these commands, user must decide which is the higher object to be +positioned, and introduce it as an argument of +the \csdef{highestlabel} declaration. For example, typing +\begin{Verbatim} +\highestlabel{\Huge A} +\end{Verbatim} +we reserve a sufficient vertical space to write the character {\Huge A}. + +It should be noted that starred versions behave differently +only when the position of the object stands +under the reference point, with positioners +\verb+bbl+, \verb+b+ or \verb+bbr+, or with an appropiate angle +(as \verb+-90+ or \verb+300+); otherwise (including +\verb$S$, \verb$SSW$, et cetera), +the \cs{Put*} and \cs{rPut*} commands are equivalent +to the non-starred commands + \cs{Put} and \cs{rPut}. +\begin{exemple} +\begin{center} +\setlength{\unitlength}{1cm} + +\begin{Picture}(-3.5,-1.5)(3.5,1.5) +\xLINE(-3.5,0)(3.5,0) +\multiPut(-3,-0.1)(1,0){7}{\xLINE(0,0)(0,0.2)} +\highestlabel{\Huge A} +\renewcommand{\Pictlabelsep}{0.2} +\Put*[bbl](-3,0){\small A} +\Put*[b](-2,0){\normalsize A} +\Put*[-100](-1,0){\large A} +\Put*[-90](0,0){\Large A} +\Put*[270](1,0){\LARGE A} +\Put*[300](2,0){\huge A} +\Put*[bbr](3,0){\Huge A} +\Put*[bbl](-3.5,0){% + \pictcolor{gray}\xLINE(0,0)(7,0)} +\end{Picture} +\end{center} +\end{exemple} + + +When a \environ{Picture} environment starts, +highest label is set to \verb+\normalfont\normalsize$1$+ +(i.e., the high of a \emph{normal} $1$). +\subsection{Alternatives to the \cs{multiput} command} +The \package{xpicture} package introduces two families of commands +to generalize the \cs{multiput} command: +\begin{enumerate} + \item The natural generalization, with all versions, + \ttslashindex{multiPut}\ttslashindex{multicPut}\ttslashindex{multirPut} +\begin{Verbatim}[commandchars=\|\{\},commentchar=\%] +\multiPut[|TIT{position}](|TIT{x0},|TIT{y0})(|TIT{|(|Delta|)x},% +|TIT{|(|Delta|)y})|{|TIT{n}|}|{|TIT{object}|} +\multiPut*[|TIT{position}](|TIT{x0},|TIT{y0})(|TIT{|(|Delta|)x}% +,|TIT{|(|Delta|)y})|{|TIT{n}|}|{|TIT{object}|} +\multicPut|{|TIT{position}|}(|TIT{x0},|TIT{y0})(|TIT{|(|Delta|)x}% +,|TIT{|(|Delta|)y})|{|TIT{n}|}|{|TIT{object}|} +\multirPut|{|TIT{position}|}(|TIT{x0},|TIT{y0})(|TIT{|(|Delta|)x}% +,|TIT{|(|Delta|)y})|{|TIT{n}|}|{|TIT{object}|} +\multirPut*|{|TIT{position}|}(|TIT{x0},|TIT{y0})(|TIT{|(|Delta|)x}% +,|TIT{|(|Delta|)y})|{|TIT{n}|}|{|TIT{object}|} +\end{Verbatim} +These commands compose \TIT{n} copies of \TTT{\TIT{object}} +in $(\TIT{x0},\TIT{y0})$, $(\TIT{x0}+\Delta x,\TIT{y0}+\Delta y)$, + $(\TIT{x0}+2\Delta x,\TIT{y0}+2\Delta y)$,\ldots, + $(\TIT{x0}+(\TIT n-1)\Delta x,\TIT{y0}+(\TIT n-1)\Delta y)$. +\item A new command group, +\ttslashindex{multiPlot}\ttslashindex{multicPlot}\ttslashindex{multirPlot} +\begin{Verbatim}[commandchars=\|\{\},commentchar=\%] +\multiPlot[|TIT{position}]|{|TIT{object}|}(|TIT{x0},|TIT{y0})(|TIT{x1},% +|TIT{y1})...(|TIT{xn},|TIT{yn}) +\multiPlot*[|TIT{position}]|{|TIT{object}|}(|TIT{x0},|TIT{y0})(|TIT{x1},% +|TIT{y1})...(|TIT{xn},|TIT{yn}) +\multicPlot|{|TIT{position}|}|{|TIT{object}|}(|TIT{x0},|TIT{y0})(|TIT{x1},% +|TIT{y1})...(|TIT{xn},|TIT{yn}) +\multirPlot|{|TIT{position}|}|{|TIT{object}|}(|TIT{x0},|TIT{y0})(|TIT{x1},% +|TIT{y1})...(|TIT{xn},|TIT{yn}) +\multirPlot*|{|TIT{position}|}|{|TIT{object}|}(|TIT{x0},|TIT{y0})(|TIT{x1},% +|TIT{y1})...(|TIT{xn},|TIT{yn}) +\end{Verbatim} +These commands compose the done object in several positions, that are freely +entered as a list of coordinate pairs. +\end{enumerate} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{1cm} +\referencesystem(0,0)(1,-1)(1,1) +\begin{Picture}(-2.5,-2.5)(2.5,2.5) +\cartesiangrid(-2,-2)(2,2) +\pictcolor{blue} +\multiPut(-2,-2)(1,1){5}{\circle*{0.25}} +\pictcolor{red} +\multiPlot{\circle*{0.25}}(-1,-2)(2,1)(-2,2) +\end{Picture} +\end{center} +\end{exemple} +\begin{exemple} +\begin{center} +\setlength{\unitlength}{1cm} +\referencesystem(0,0)(1,-1)(1,1) +\begin{Picture}(-2.5,-2.5)(2.5,2.5) +\cartesiangrid(-2,-2)(2,2) +\pictcolor{blue} +\multiPut[b](-2,-2)(1,1){5}{\circle*{0.25}} +\pictcolor{red} +\multiPlot[NE]{\circle*{0.25}}(-1,-2)(2,1)(-2,2) +\end{Picture} +\end{center} +\end{exemple} +\subsection{Alternatives to \cs{line} and \cs{vector}} +\begin{description} +\item[\csdef{xLINE}] This command draws line segments: +\begin{Verbatim}[commandchars=\|\[\]] +\xLINE(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1]) +\end{Verbatim} +draws the line segment between the two points +\verb+(+\TIT{x0}\verb+,+\TIT{y0}\verb+)+ and +\verb+(+\TIT{x1}\verb+,+\TIT{y1}\verb+)+ +(Cartesian or polar coordinates, in the active reference system). +This allows us to draw any segment in any direction. +\item[\csdef{xVECTOR}, \csdef{xtrivVECTOR}] plot arrows: +\begin{Verbatim}[commandchars=\|\[\]] +\xVECTOR(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1]) +\xtrivVECTOR(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1]) +\end{Verbatim} +draw an arrow between points +\verb+(+\TIT{x0}\verb+,+\TIT{y0}\verb+)+ and +\verb+(+\TIT{x1}\verb+,+\TIT{y1}\verb+)+. +The \cs{xtrivVECTOR} command draw an arrow +the end of which simply consists of a pair of segments +(\setlength{\unitlength}{1cm}% +\begin{Picture}(0,-0.1)(0.5,0.1)\xtrivVECTOR(0,0)(0.5,0)\end{Picture}). +length and aperture of the end of arrow are controled by the instruction +\ttslashindex{arrowsize} +\begin{Verbatim}[commandchars=\|\[\]] +\arrowsize{|TIT[xlen]}{|TIT[ylen]} +\end{Verbatim} +where the two parameters are non-negative numbers: +the first one for the length (in points); second +for the half of the aperture. Default is +\begin{Verbatim} +\arrowsize{5}{2} +\end{Verbatim} +\begin{exemple} +\setlength{\unitlength}{0.75cm} +\referencesystem(0,0)(1,0)(0.25,0.75) +\begin{Picture}(-4.5,-4.5)(4.5,4.5) +\cartesiangrid(-4,-4)(4,4) +\thicklines +\pictcolor{blue} +\xLINE(-4,0)(1,4) +\Put(1,-3){\xLINE(0,0)(3,2)} +\pictcolor{red} +\xtrivVECTOR(0,0)(2,3) +\xtrivVECTOR(0,0)(2,0) +\arrowsize{10}{4} +\xtrivVECTOR(0,0)(-2,-1) + +\pictcolor{magenta} +\xVECTOR(-3,-3)(-3,3) +\xVECTOR(-3,-3)(-2,-2) +\end{Picture} +\end{exemple} +\item[\csdef{xline}, \csdef{xvector}, \csdef{xtrivvector}] +draw lines and vectors using the standard \LaTeX{} syntax +(but without any restriction in allowed parameters, +that can be integer or decimal numbers, positive, negative or zero). +\begin{Verbatim}[commandchars=\|\[\]] +\xline(|TIT[x],|TIT[y]){|TIT[size]} +\xvector(|TIT[x],|TIT[y]){|TIT[size]} +\xtrivvector(|TIT[x],|TIT[y]){|TIT[size]} +\end{Verbatim} +\begin{exemple} +\setlength{\unitlength}{0.75cm} +\referencesystem(0,0)(1,0)(0.25,0.75) +\begin{Picture}(-4.5,-4.5)(4.5,4.5) +\cartesiangrid(-4,-4)(4,4) +\thicklines +\pictcolor{blue} +\Put(-4,0){\xline(5,4){5}} +\Put(1,-3){\xline(3,2){3}} +\pictcolor{red} +\Put(0,0){\xtrivvector(2,3){2}} +\xtrivvector(1,0){2} +\arrowsize{10}{4} +\Put(0,0){\xtrivvector(2,1){-2}} + +\pictcolor{magenta} +\Put(-3,-3){\xvector(0,1){6}} +\Put(-3,-3){\xvector(1,1){1}} +\end{Picture} +\end{exemple} + +If you want to draw only an arrowhead (without any line) +you can use either the +\csdef{zerovector}/\csdef{zerotrivvector} +or \cs{xvector}/\cs{xtrivvector} commands: +\begin{Verbatim}[commandchars=\|\[\]] +\zerovector(|TIT[x],|TIT[y]) +\zerotrivvector(|TIT[x],|TIT[y]) +\xvector(|TIT[x],|TIT[y]){0} +\xtrivvector(|TIT[x],|TIT[y]){0} +\end{Verbatim} +\end{description} +\subsection{Polygons anf polygonal lines} +The \package{pict2e} and \package{curve2e} packages include +specific instructions for drawing polygonal lines and polygons. +We introduce new versions of these +commands in order to refer to the active reference system. +\begin{description} +\item[\csdef{Polyline}] draws polygonal lines. +Logically, we must pass the list of vertices: +\begin{Verbatim}[commandchars=\|\[\]] +\Polyline(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1])...(|TIT[xn],|TIT[yn]) +\end{Verbatim} +\item[\csdef{Polygon}] plots polygons, ie, closed polygonal lines: +\begin{Verbatim}[commandchars=\|\[\]] +\Polygon(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1])...(|TIT[xn],|TIT[yn]) +\end{Verbatim} +is equivalent to +\begin{Verbatim}[commandchars=\|\[\],commentchar=\%] +\Polyline(|TIT[x0],|TIT[y0])(|TIT[x1],|TIT[y1])...(|TIT[xn],|TIT[yn])% +(|TIT[x0],|TIT[y0]) +\end{Verbatim} + +\begin{exemple} +\setlength{\unitlength}{0.75cm} +\referencesystem(0,0)(1,0)(0.25,0.75) +\begin{Picture}(-4.5,-4.5)(4.5,4.5) +\externalaxes +\cartesiangrid(-4,-4)(4,4) +\linethickness{1pt} +\pictcolor{blue} +\Polyline(-2,2)(-3,-1)(0,0)(2,3)(2,2) +\pictcolor{red} +\Polygon(0,0)(1,1)(3,1)(1,-1) +\end{Picture} +\end{exemple} +\item[\csdef{regularPolygon}] draws regular polygons: +\begin{Verbatim}[commandchars=\|\(\)] +\regularPolygon[|TIT(initial angle)]{|TIT(radius)}{|TIT(sides)} +\end{Verbatim} +makes the regular polygon with the given radius and sides. +The optional argument (zero, by default) determines +the slope of the first vertex, always measured in degrees. +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.5cm} +\begin{Picture}(-7.5,-7.5)(7.5,7.5) +\externalaxes +\cartesiangrid(-7,-7)(7,7) +\pictcolor{blue} +\regularPolygon{1}{5} +\Put(-4,0){\regularPolygon{2}{6}} +\Put(3,3){\regularPolygon{2}{4}} +\Put(-4,-4){\regularPolygon[45]{2}{4}} +\Put(4,-4){\regularPolygon[90]{2.5}{11}} +\Put(-4,4){\regularPolygon[90]{3}{3}} +\end{Picture} +\end{center} +\end{exemple} + +\end{description} +\section{Drawing curves} +This section highlights the true potentiality of the \package{xpicture} +package. +We will describe the instructions that can be used to easily (and effectively) +represent +several interesting curves: Firstly, conic sections and arcs. +Then, any piecewise regular curve +(including graphs of real variable functions, in rectangular or polar +coordinates, +and ---in a more general way--- curves defined by parametric equations). +\subsection{Conic sections} +The \package{xpicture} package defines new commands to draw conic sections: + ellipses, circles, hyperbolas and parabolas. +\subsubsection{Circles} +We can draw the circle of implicit equation $x^2+y^2=r^2$ typing +\ttslashindex{Circle} +\begin{Verbatim}[commandchars=\|\[\]] +\Circle{|TIT[r]} +\end{Verbatim} +Note than the standard command \cs{circle} +requeres the diameter as mandatory argument, while here we must insert the +radius. +\subsubsection{Ellipses} +To draw the ellipse $\displaystyle\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$ enter the +following instruction:\ttslashindex{Ellipse} +\begin{Verbatim}[commandchars=\|\[\]] +\Ellipse{|TIT[a]}{|TIT[b]} +\end{Verbatim} +\begin{exemple} +\setlength{\unitlength}{0.5cm} +\renewcommand{\axeslabelsize}{\footnotesize} +\begin{Picture}(-5.5,-4.5)(5.5,4.5) +\cartesiangrid(-5,-4)(5,4) +\pictcolor{blue} +\Ellipse{4}{3} +\Circle{2} +\end{Picture} + +\referencesystem(0,0)(1,0)(0.5,0.5) +\begin{Picture}(-5.5,-4.5)(5.5,4.5) +\cartesiangrid(-5,-4)(5,4) +\pictcolor{blue} +\Ellipse{4}{3} +\Circle{2} +\end{Picture} +\end{exemple} +\subsubsection{Hyperbolas} +Since the hyperbolas and parabolas are not bounded curves, to define the +portion of the curve that we want to draw we need to specify the +maximum values for the $x$ and $y$ variables.\ttslashindex{Hyperbola} +\begin{Verbatim}[commandchars=\|\[\]] +\Hyperbola{|TIT[a]}{|TIT[b]}{|TIT[xmax]}{|TIT[ymax]} +\end{Verbatim} +draws the hyperbola +$\displaystyle\frac{x^2}{a^2}-\frac{y^2}{b^2}=1$, +where variables $x$ and $y$ are limited, respectively, +to the $\TTT{[-\TIT{xmax}}, \TTT{\TIT{xmax}]}$ and +$\TTT{[-\TIT{ymax}}, \TTT{\TIT{ymax}]}$ intervals. +This curve is well defined if the parameter \TTT{\TIT{xmax}} +is greater than \TTT{\TIT{a}}. Otherwise, \package{xpicture} returns an error +message and does not draw any curve. + +In the following example, we show the hyperbola +$\displaystyle\frac{x^2}{5^2}-\frac{y^2}{2^2}=1$ +and its asymptotes, +using the \cs{xLINE} command (these asymptotes are lines $2x=\pm5y$, +passing through $(\pm16,\pm6.4)$). +\begin{Exemple} +\begin{center} +\setlength{\unitlength}{0.5cm} +\begin{Picture}(-17,-9)(17,9) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesiangrid(-16,-8)(16,8) +\pictcolor{blue} +\Hyperbola{5}{2}{16}{8} +\pictcolor{orange} +\xLINE(16,6.4)(-16,-6.4) +\xLINE(-16,6.4)(16,-6.4) +\end{Picture} +\end{center} +\end{Exemple} + +Instructions \csdef{lHyperbola} and \csdef{rHyperbola} draw, respectively, +only the \emph{left} or only the \emph{right} branch of the given hyperbola +(here, is interpreted as \emph{right} branch this one that belongs to positive +values of variable $x$). +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.5cm} +\begin{Picture}(-5.5,-5.5)(5.5,5.5) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesiangrid(-5,-5)(5,5) +\pictcolor{red} +\lHyperbola{2}{3}{5}{5} +\pictcolor{blue} +\rHyperbola{2}{3}{5}{5} +\end{Picture} +\end{center} +\end{exemple} +\subsubsection{Parabolas} +Instruction\ttslashindex{Parabola} +\begin{Verbatim}[commandchars=\|\[\]] +\Parabola{|TIT[a]}{|TIT[xmax]}{|TIT[ymax]} +\end{Verbatim} +draw the parabola $x=ay^2$, varying $x$, at most, in the interval +$[0,\TTT{\TIT{xmax}}]$ +(if \TTT{\TIT{a}} is positive) or in $[-\TTT{\TIT{xmax}},0]$ +(for negative values of \TTT{\TIT{a}}), +and $y$ in $[-\TTT{\TIT{ymax}},\TTT{\TIT{ymax}}]$. +Parameters \TTT{\TIT{xmax}} and \TTT{\TIT{ymax}} +must be positive. +\begin{exemple} +\begin{center} +\setlength{\unitlength}{0.5cm} +\begin{Picture}(-5.5,-5.5)(5.5,5.5) +\cartesiangrid(-5,-5)(5,5) +\pictcolor{blue} +\Parabola{2}{5}{5} +\Parabola{0.2}{5}{5} +\pictcolor{orange} +\Parabola{-2}{5}{5} +\Parabola{-0.2}{5}{5} +\end{Picture} +\end{center} +\end{exemple} +\medskip + +All commands drawing conic sections or arcs divide the curve in +\csdef{defaultplotdivs} pieces (8, by default). To obtain a greather +accuracy, you can redefine this parameter. + +\medskip + +Note that all these commands draw conic sections centered +at the coordinate origin, so that their +principal axes coincide with the coordinate axes. If we +want to move his +center to any other point, we can do it moving in advance +the origin of coordinates or simply +including the command as an argument of the \cs{Put} command. +\begin{Exemple} +\begin{center} +\setlength{\unitlength}{0.5cm} +\begin{Picture}(-11,-8)(11,8) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesiangrid(-10,-7)(11,7) +\pictcolor{blue} +\Put(2,3){\Ellipse{4}{3}} +\Put(2,3){\Circle{0.25}} +\pictcolor{orange} +\Put(2,-3){\Hyperbola{5}{2}{9}{3}} +\Put(2,-3){\Circle{0.25}} +\pictcolor{green} +\translateorigin(-10,2) +\Parabola{0.5}{21}{5} +\Circle{0.25} +\end{Picture} +\end{center} +\end{Exemple} +But, if the symmetry axes of our curve are not parallel to the coordinate +axes,\footnote{That is, in mathematical terms, +if the eigenvectors of the underlying quadratic form are not the canonical +vectors.} +then we will need a rotation of axes. +\begin{Exemple} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-10.5,-7.5)(10.5,7.5) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesiangrid(-10,-7)(10,7) +{% +\pictcolor{blue} +\translateorigin(5,3) +\rotateaxes{\numberSIXTHPI} +\Ellipse{4}{3} +\xLINE(-4,0)(4,0) +\xLINE(0,-3)(0,3) +} +\degreesangles +{% +\pictcolor{orange} +\translateorigin(-3,0) +\rotateaxes{110} +\Hyperbola{3}{2}{6}{4} +\xLINE(-6,-4)(6,4) +\xLINE(6,-4)(-6,4) +} +\pictcolor{green} +\translateorigin(5,-6) +\rotateaxes{72} +\Parabola{1}{4}{3} +\xLINE(0,-2)(0,2) +\xLINE(0,0)(4,0) +\end{Picture} +\end{center} +\end{Exemple} +Note that we made a couple of changes of local reference system (one for each +curve) within the drawing. +We can use the recourse to the change of coordinates also to +draw the hyperbola $\displaystyle\frac{y^2}{a^2}-\frac{x^2}{b^2}=1$ and the +parabola $y=ax^2$. +Note than \verb+\referencesystem(0,0)(0,1)(1,0)+ +(or \verb+\symmetrize{\numberQUARTERPI}+) +makes vertical the $x$ axis and horizontal the +$y$ axis.\footnote{We will use this trick later +to plot inverse functions.} +\begin{exemple} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-5.5,-5.5)(5.5,5,5) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesiangrid(-5,-5)(5,5) +\referencesystem(0,0)(0,1)(1,0) +\pictcolor{blue} +\Parabola{0.22}{5}{5} +\pictcolor{red} +\Hyperbola{2}{3}{5}{5} +\end{Picture} +\end{center} +\end{exemple} + +\subsection{Arcs (of conic sections)} +The instructions described above allow us to draw whole circles, ellipses +hyperbolas and parabolas. More generally, we can represent any portion of +these curves, ie, circular, elliptic, hyperbolic and parabolic arcs. +\ttslashindex{xArc}\ttslashindex{circularArc} +\begin{Verbatim}[commandchars=\|\[\]] +\xArc{|TIT[r]}{|TIT[angle1]}{|TIT[angle2]} +\circularArc{|TIT[r]}{|TIT[angle1]}{|TIT[angle2]} +\end{Verbatim} +These two instructions are equivalent. +They draw the arc of the circle centered at $(0,0)$ +with radius $\TIT{r}$ +and limited by the $\TTT{\TIT{angle1}}$ and $\TTT{\TIT{angle2}}$ +angles. +\begin{exemple} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-5.5,-5.5)(5.5,5,5) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesianaxes(-5,-5)(5,5) +\pictcolor{gray} +\circularArc{3}{\numberPI}{\numberTWOPI} +\pictcolor{red} +\xLINE(-2,2)(-2,5) +\xLINE(-2,2)(-5,2) +\degreesangles +\Put(-2,2){\circularArc{1}{90}{180}} +\pictcolor{blue} +\polarreference +\Put(1,30){\xLINE(0,0)(4,30)} +\Put(1,30){\xLINE(0,0)(4,60)} +\Put(1,30){\circularArc{2}{30}{60}} +\end{Picture} +\end{center} +\end{exemple} +\begin{exemple} +\SUBTRACT{\numberGOLD}{1}{\midaB} +\COPY{1}{\midaA} +\ADD{\midaA}{\midaB}{\Mida} +\setlength{\unitlength}{5cm} +\newcommand{\espiral}{% + \Put(0,0){\begin{Picture}(0,0)(0,0) + \translateorigin(\midaA,0) + \pictcolor{red} + \circularArc{\midaA}{\numberHALFPI}{\numberPI} + \pictcolor{blue} + \xLINE(0,0)(0,\midaA) + \end{Picture} + } + \COPY{\midaA}{\Mida} + \COPY{\midaB}{\midaA} + \SUBTRACT{\Mida}{\midaA}{\midaB} + \translateorigin(\Mida,\midaB) + \changereferencesystem(0,\midaA)(0,-1)(1,0) +} +\renewcommand{\defaultplotdivs}{2} + +\begin{center} +\begin{Picture}(0,0)(\numberGOLD,1) + \Polygon(0,0)(\Mida,0)(\Mida,1)(0,1) + % Plot 8 circular arcs + \espiral\espiral\espiral\espiral + \espiral\espiral\espiral\espiral +\end{Picture} + +Golden rectangles and spiral +\end{center} +\end{exemple} +\ttslashindex{ellipticArc} +\begin{Verbatim}[commandchars=\|\[\]] +\ellipticArc{|TIT[a]}{|TIT[b]}{|TIT[angle1]}{|TIT[angle2]} +\end{Verbatim} +This instruction draws the arc of the ellipse centered at + $(0,0)$ with semiaxes $\TIT{a}$ +and $\TIT{b}$, $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$, +limited by angles $\TTT{\TIT{angle1}}$ and $\TTT{\TIT{angle2}}$. +\begin{exemple} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-0.5,-3.5)(5.5,3.5) +\degreesangles +\ellipticArc{2}{3}{-90}{90} +\ellipticArc{5}{3}{-90}{90} +\end{Picture} +\end{center} +\end{exemple} +\ttslashindex{lhyperbolicArc}\ttslashindex{rhyperbolicArc} +\begin{Verbatim}[commandchars=\|\[\]] +\rhyperbolicArc{|TIT[a]}{|TIT[b]}{|TIT[y1]}{|TIT[y2]} +\lhyperbolicArc{|TIT[a]}{|TIT[b]}{|TIT[y1]}{|TIT[y2]} +\end{Verbatim} +Draw the arc (of the right or left branch, respectively) +of the hyperbola + $\frac{x^2}{a^2}-\frac{y^2}{b^2}=1$ included between $y=\TTT{\TIT{y1}}$ and + $y=\TTT{\TIT{y2}}$. +\begin{exemple} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-5.5,-5.5)(5.5,5,5) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesianaxes(-5,-5)(5,5) +\pictcolor{red} +\lhyperbolicArc{2}{3}{-4}{0} +\pictcolor{blue} +\rhyperbolicArc{2}{3}{-2}{5} +\end{Picture} +\end{center} +\end{exemple} +\ttslashindex{parabolicArc} +\begin{Verbatim}[commandchars=\|\[\]] +\parabolicArc{|TIT[a]}{|TIT[y1]}{|TIT[y2]} +\end{Verbatim} +Draw the arc of the parabola + $x=ay^2$ included between $y=\TTT{\TIT{y1}}$ and $y=\TTT{\TIT{y2}}$. +\begin{exemple} +\setlength{\unitlength}{1cm} +\begin{center} +\begin{Picture}(-2.5,-2.5)(2.5,2,5) +\renewcommand{\axeslabelsize}{\footnotesize} +\cartesianaxes(-2,-2)(2,2) +\pictcolor{red} +\parabolicArc{-2}{-1}{0} +\pictcolor{blue} +\parabolicArc{0.5}{0}{2} +\end{Picture} +\end{center} +\end{exemple} +\subsection{Real variable functions}\label{subsec:real} +The \package{xpicture} package provides us two commands +to draw the graph of a function: +\csdef{PlotFunction} and \csdef{PlotPointsOfFunction}. +\begin{Verbatim}[commandchars=\|\(\)] +\PlotFunction[|TIT(n)]{\|TIT(functionname)}{\|TIT(tzero)}{\|TIT(tone)} +\PlotPointsOfFunction{|TIT(n)}{\|TIT(functionname)}{\|TIT(tzero)}{\|TIT(tone)} +\end{Verbatim} +Note that the parameter $\TTT{\TIT{n}}$ is optional in one of these +instructions and mandatory in the other one. +In the case of \csdef{PlotFunction}, +if we do not use this optional parameter, +a quadratic approximation of the function +\cs{\TIT{functionname}} +in the $[\cs{\TIT{tzero}},\cs{\TIT{tone}}]$ interval is drawn. +\begin{exemple} +\setlength{\unitlength}{1cm} +\begin{Picture}(-2.5,-0.5)(3.5,4.5) +\cartesianaxes(-2,0)(2,4) +\pictcolor{blue} +\PlotFunction{\SQUAREfunction}{-2}{2} +\Put[E](2,4){$f(t)=t^2$} +\end{Picture} +\end{exemple} +Now, this almost never provides a right graphic. +To draw curves with a greater accuracy we should use the parameter, +\TTT{\TIT{n}}, +dividing the interval in \TTT{\TIT{n}} subintervals. +\begin{exemple} +\setlength{\unitlength}{1cm} +\CUBE{1.5}{\mymax} +\begin{Picture}(-2,-4)(2,4) +\cartesianaxes(-1.5,-\mymax)(1.5,\mymax) +\pictcolor{blue} +\PlotFunction[8]{\CUBEfunction}{-1.5}{1.5} +\Put[E](1.5,\mymax){$f(t)=t^3$} +\end{Picture} +\end{exemple} + +On the other hand, the \csdef{PlotPointsOfFunction} command +plots $\TTT{\TIT{n}}+1$ \emph{points}, uniformly distributed +about the $x$-axis. +\begin{exemple} +\setlength{\unitlength}{1cm} +\CUBE{1.5}{\mymax} +\begin{Picture}(-2,-4)(2,4) +\cartesianaxes(-1.5,-\mymax)(1.5,\mymax) +\pictcolor{blue} +\PlotPointsOfFunction{24}{\CUBEfunction}{-1.5}{1.5} +\Put[E](1.5,\mymax){$f(t)=t^3$} +\end{Picture} +\end{exemple} + +By default, \cs{PlotPointsOfFunction} plot \emph{points} as a filled circle +of diameter \verb+0.1\unitlength+. But you can modifie this diameter, by +redefining the \csdef{pointmarkdiam} parameter. +\begin{exemple} +\setlength{\unitlength}{1cm} +\CUBE{1.5}{\mymax} +\renewcommand{\pointmarkdiam}{0.3} +\begin{Picture}(-2,-4)(2,4) +\cartesianaxes(-1.5,-\mymax)(1.5,\mymax) +\pictcolor{blue} +\PlotPointsOfFunction{24}{\CUBEfunction}{-1.5}{1.5} +\Put[E](1.5,\mymax){$f(t)=t^3$} +\end{Picture} +\end{exemple} + +Moreover, you can select another symbol for these points, redefining +\csdef{pointmark}. +\begin{exemple} +\setlength{\unitlength}{1cm} +\CUBE{1.5}{\mymax} +\renewcommand{\pointmark}{$\diamond$} +\begin{Picture}(-2,-4)(2,4) +\cartesianaxes(-1.5,-\mymax)(1.5,\mymax) +\pictcolor{blue} +\PlotPointsOfFunction{24}{\CUBEfunction}{-1.5}{1.5} +\Put[E](1.5,\mymax){$f(t)=t^3$} +\end{Picture} +\end{exemple} + +Naturally, in order to apply these commands the function must be defined. +\package{xpicture} +loads the \packagedef{calculus} package, which +predefines some of the most common elementary functions +and includes several tools to build new ones. +The predefined functions are the following: +\begin{center} +\begin{tabular}{l>{$}l<{$}>{\qquad}l>{$}l<{$}} + \csdef{ZEROfunction} & f(t)=0 & + \csdef{ONEfunction} & f(t)=1 \\ + \csdef{IDENTITYfunction} & f(t)=t & + \csdef{RECIPROCALfunction} & f(t)=1/t \\ + \csdef{SQUAREfunction} & f(t)=t^2 & + \csdef{CUBEfunction} & f(t)=t^3 \\ + \csdef{SQRTfunction} & f(t)=\sqrt t \\ + \csdef{EXPfunction} & f(t)=\exp t & + \csdef{LOGfunction} & f(t)=\log t \\ + \csdef{COSfunction} & f(t)=\cos t & + \csdef{SINfunction} & f(t)=\sin t \\ + \csdef{TANfunction} & f(t)=\tan t & + \csdef{COTfunction} & f(t)=\cot t \\ + \csdef{COSHfunction} & f(t)=\cosh t & + \csdef{SINHfunction} & f(t)=\sinh t \\ + \csdef{TANHfunction} & f(t)=\tanh t & + \csdef{COTHfunction} & f(t)=\coth t \\ + \csdef{HEAVISIDEfunction} & f(t)=\begin{cases} + 0 & \text{si $t<0$} \\ + 1 & \text{si $t\geq0$} + \end{cases} +\end{tabular} +\end{center} + +\begin{Exemple} +\setlength{\unitlength}{1cm} +\linethickness{1.5pt} +\centering +\begin{Picture}(-5,-5)(6,5) +\externalaxes\makenotics +\cartesiangrid(-4.5,-4.5)(4.5,4.5) +\pictcolor{red} +\PlotFunction{\IDENTITYfunction}{-4.5}{4.5} +\Put[tr](4.5,4.5){$y=x$} + +\DIVIDE{1}{4.5}{\minx} +\pictcolor{magenta} +\PlotFunction[10]{\RECIPROCALfunction}{\minx}{4.5} +\PlotFunction[10]{\RECIPROCALfunction}{-\minx}{-4.5} +\Put[r](4.5,\minx){$y=1/x$} + +\SQRT{4.5}{\maxx} +\pictcolor{cyan} +\PlotFunction[10]{\SQUAREfunction}{-\maxx}{\maxx} +\Put[tr](\maxx,4.5){$y=x^2$} + +\pictcolor{blue} +\PlotFunction[10]{\CUBEfunction}{-1.6509}{1.6509} +\Put[t](1.6509,4.5){$y=x^3$} +\end{Picture} +\end{Exemple} + +\begin{Exemple} +\setlength{\unitlength}{1cm} +\linethickness{1.5pt} +\centering +\begin{Picture}(-7,-4.5)(7,4.5) +{\makenolabels +\changereferencesystem(0,0)(\numberHALFPI,0)(0,1) +\cartesiangrid(-4,-4)(4,4) +\highestlabel{$2\pi$} +\printylabels{-4}{1}{4} +\printxlabel{-4}{-2\pi} +\printxlabel{-2}{-\pi} +\printxlabel{2}{\pi} +\printxlabel{4}{2\pi}} +\pictcolor{red} +\PlotFunction[16]{\COSfunction}{-\numberTWOPI}{\numberTWOPI} +\pictcolor{blue} +\PlotFunction[16]{\SINfunction}{-\numberTWOPI}{\numberTWOPI} +\pictcolor{magenta} +\PlotFunction[6]{\TANfunction}{-1.3258}{1.3258} +\end{Picture} +\end{Exemple} + +From these basic functions we can define many others, +using the following \emph{operations}: +\newcommand{\functoper}{% + \{\cs{\TIT{function1}}\}\{\cs{\TIT{function2}}\}\{\cs{\TIT{newfunction}}\}} +\begin{description} +\item[Constant function:]\mbox{} + +\csdef{CONSTANTfunction}\{\TIT{k}\}\{\cs{\TIT{newfunction}}\} + + Example: defining the $F(t)=5$ function: + +\cs{CONSTANTfunction}\{5\}\{\cs{F}\} + +\item[Sum function:]\mbox{} + +\csdef{SUMfunction}\functoper + + +Example: defining the $F(t)=t^2+t^3$ function: + +\cs{SUMfunction}\{\cs{SQUAREfunction}\}\{\cs{CUBEfunction}\}\{\cs{F}\} + +\item[Difference function:]\mbox{} + +\csdef{SUBTRACTfunction}\functoper + +Example: defining the $F(t)=t^2-t^3$ function: + +\cs{SUBTRACTfunction}\cs{SQUAREfunction}\cs{CUBEfunction}\{\cs{F}\} + +\item[Product function:]\mbox{} + +\csdef{PRODUCTfunction}\functoper + +Example: defining the $F(t)=\mathrm e^t\cos t$ function: + +\cs{PRODUCTfunction}\cs{EXPfunction}\cs{COSfunction}\{\cs{F}\} + +\item[Quotient function:]\mbox{} + +\csdef{QUOTIENTfunction}\functoper + +Example: defining the $F(t)=\mathrm e^t/\cos t$ function: + +\cs{QUOTIENTfunction}\cs{EXPfunction}\cs{COSfunction}\{\cs{F}\} + +\item[Composition of two functions:]\mbox{} + +\csdef{COMPOSITIONfunction}\functoper + +Example: defining the $F(t)=\mathrm e^{\cos t}$ function: + +\cs{COMPOSITIONfunction}\cs{EXPfunction}\cs{COSfunction}\{\cs{F}\} + +\item[Scaled function:]\mbox{} + +\csdef{SCALEfunction}\{\TIT{k}\}\{\cs{\TIT{function}}\}% + \{\cs{\TIT{newfunction}}\} + +Example: defining the $F(t)=3{\cos t}$ function: + +\cs{SCALEfunction}\{3\}\cs{COSfunction}\{\cs{F}\} + +\item[Scaled variable:]\mbox{} + +\csdef{SCALEVARIABLEfunction}\{\TIT{k}\}\{\cs{\TIT{function}}\}% + \{\cs{\TIT{newfunction}}\} + +Example: defining the $F(t)=\cos 3t$ function: + +\cs{SCALEVARIABLEfunction}\{3\}\cs{COSfunction}\{\cs{F}\} + +\item[Power function:] (exponent enter positiu)\mbox{} + +\csdef{POWERfunction}\{\cs{\TIT{function}}\}\{\TIT{n}\}% + \{\cs{\TIT{newfunction}}\} + +Example: defining the $F(t)=t^5$ function: + +\cs{POWERfunction}\cs{IDENTITYfunction}\{5\}\{\cs{F}\} + +\item[Linear combination:]\mbox{} + +\csdef{LINEARCOMBINATIONfunction}\{\TIT{a}\}\{\cs{\TIT{function1}}\}% + \{\TIT{b}\}\{\cs{\TIT{function2}}\}\{\cs{\TIT{newfunction}}\} + +Example: defining the $F(t)=2t-3\cos t$ function: + +\cs{LINEARCOMBINATIONfunction}\{2\}\cs{IDENTITYfunction}\{-3\}% + \cs{COSfunction}\{\cs{F}\} +\end{description} + +By combining properly these operations, we can draw graphs of many functions. +Some examples are shown in next pages. +\newpage + +First, we will draw the function $f(t)=t^3-2t$, +dividing the interval $[-2,2]$ in ten subintervals. +The simplest way to construct this function is as a linear combination of +$f_1(t)=t^3$ and $f_2(t)=t$. + +\begin{exemple} +\LINEARCOMBINATIONfunction + {1}{\CUBEfunction} + {-2}{\IDENTITYfunction} + {\Ffunction} +\begin{center} +\setlength{\unitlength}{1cm} +\begin{Picture}(-2.5,-4.5)(2.5,4.5) +\cartesianaxes(-2,-4)(2,4) +\pictcolor{blue} +\PlotFunction[10]{\Ffunction}{-2}{2} +\Put[rbr](2,4){$f(t)=t^3-2t$} +\end{Picture} +\end{center} +\end{exemple} +\newpage + +Graph of $g(t)=t\cos t$. We multiply the identity and the cosine functions: + +\begin{Exemple} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-11,-11)(11,11) +\cartesianaxes(-10,-10)(10,10) +\PRODUCTfunction{\IDENTITYfunction}{\COSfunction}{\Gfunction} +\pictcolor{red} +\PlotFunction[30]{\Gfunction}{-10}{10} +\end{Picture} +\end{center} +\end{Exemple} +\newpage + +Graph of $f(t)=(\cos t)^3$. + +\begin{Exemple} +\setlength{\unitlength}{1cm} +\begin{center} +\begin{Picture}(-7,-3)(7,3) +\cartesianaxes(-\numberTWOPI,-2)(\numberTWOPI,2) +\POWERfunction{\COSfunction}{3}{\Ffunction} +\pictcolor{blue} +\PlotFunction[50]{\Ffunction}{-\numberTWOPI}{\numberTWOPI} +\end{Picture} +\end{center} +\end{Exemple} +\newpage + +Graph of $g(t)=t\cos t\sin t$. +Note that in this case we have two operations: +First, we define the $f(t)=t \cos t$, multiplying the identity and cosine +functions; then, we multiply by the sine function. +\begin{Exemple} +\begin{center} +\setlength{\unitlength}{0.75cm} + \begin{Picture}(-11,-6)(11,6) +\cartesianaxes(-10,-5)(10,5) +\PRODUCTfunction{\IDENTITYfunction}{\COSfunction}{% + \Ffunction} +\PRODUCTfunction{\Ffunction}{\SINfunction}{\Gfunction} +\pictcolor{red} +\PlotFunction[40]{\Gfunction}{-10}{10} +\end{Picture} +\end{center} +\end{Exemple} + +Graph of $g(t)=\arcsin t$. The \package{calculus} package +not support, for now, the inverse trigonometric functions; but we can plot +these functions (or any other inverse function) +swapping coordinated axes. + +\begin{exemple} +\begin{center} +\setlength{\unitlength}{2cm} +\begin{Picture}(-1.5,-2)(1.5,2) +\makenolabels\makenotics +\cartesianaxes + (-1,-\numberHALFPI)(1,\numberHALFPI) +\printxticslabels{-1}{0.5}{1} +\printyticlabel{-\numberHALFPI}{-\pi/2} +\printyticlabel{-\numberQUARTERPI}{-\pi/4} +\printyticlabel{\numberQUARTERPI}{\pi/4} +\printyticlabel{\numberHALFPI}{\pi/2} +\pictcolor{red} +\symmetrize{\numberQUARTERPI} +\PlotFunction[4]{\SINfunction} + {-\numberHALFPI}{\numberHALFPI} +\end{Picture} +\end{center} +\end{exemple} +\subsubsection{Polynomial functions} +Although polynomial functions can be easily defined as +linear combinations of power functions, +to facilitate our work, the \package{calculus} package predefines +polynomials of +1, 2, and 3 degrees by these commands: +\cs{newlpoly} (new \emph{linear} polynomial), \cs{newqpoly} +(new \emph{quadratic} polynomial), +and \cs{newcpoly} (new \emph{cubic} polynomial): +\begin{description} +\item[\csdef{newlpoly}\{\cs{\TIT{newfunction}}\}\{\TIT a\}\{\TIT b\}] +stores the +$p(t)=\TTT{\TIT{a}}+\TTT{\TIT{b}}t$ +function in the + \cs{\TIT{newfunction}} command. +\item[\csdef{newqpoly}% + \{\cs{\TIT{newfunction}}\}\{\TIT a\}\{\TIT b\}\{\TIT c\}] +stores the +$p(t)=\TTT{\TIT{a}}+\TTT{\TIT{b}}t+\TTT{\TIT{c}}t^2$ +function in the +\cs{\TIT{newfunction}} command. +\item[\csdef{newcpoly}% +\{\cs{\TIT{newfunction}}\}\{\TIT a\}\{\TIT b\}\{\TIT c\}\{\TIT d\}] +stores the +$p(t)=\TTT{\TIT{a}}+\TTT{\TIT{b}}t+\TTT{\TIT{c}}t^2+\TTT{\TIT{d}}t^3$ +function in the +\cs{\TIT{newfunction}} command. +\end{description} +\begin{exemple} +% F(t)=-1+2t + \newlpoly{\poliF}{-1}{2} +% G(t)=-1+2t+t^2 + \newqpoly{\poliG}{-1}{2}{1} +% H(t)=-1+2t+t^2-0,5t^3 + \newcpoly{\poliH}{-1}{2}{1}{-0.5} + +\setlength{\unitlength}{1cm} +\begin{Picture}(-4.5,-5.5)(4.5,5.5) +\cartesianaxes(-4,-5)(4,5) +\pictcolor{blue} +\PlotFunction{\poliF}{-2}{3} +\pictcolor{red} +\PlotFunction{\poliG}{-3.5}{1.5} +\pictcolor{orange} +\PlotFunction[10]{\poliH}{-2}{3.5} +\end{Picture} +\end{exemple} + +\subsubsection{Possible errors} +In many cases you get a fairly accurate graph dividing the domain into several +subintervals. +But an indiscriminate use of this method can produce erroneous results. +For example, if inside a subinterval there is +a discontinuity or a point where the function is not differentiable. +Look at the following example. +\medskip + +\begin{exemple} +\SUBTRACTfunction{\SQUAREfunction}{\ONEfunction} + {\Ffunction} +\QUOTIENTfunction{\IDENTITYfunction}{\Ffunction} + {\Gfunction} + +\setlength{\unitlength}{0.5cm} + +\begin{Picture}(-8,-6)(8,6) +\def\xunitdivisions{2} +\def\yunitdivisions{2} +\renewcommand{\axeslabelsize}{\scriptsize} +\cartesianaxes(-7,-5)(7,5) +\Put(3,3){% + $\boxed{\displaystyle g(t)=\frac{t}{t^ 2-1}}$} +\pictcolor{red} +\PlotFunction[10]{\Gfunction}{-7}{7} +\end{Picture} +\end{exemple} + +Where is the problem? +Our function is $g(t)=t/(t^2-1)$; +this function has a pair of vertical asymptotes +at $t=\pm1$ (the two zeros of denominator). + +We made 10 subdivisions of the $[-7,7]$ interval. +Do, we compute the function in points $-7+(14/10)k=-7+(7/5)k$, +$0\leq k\leq10$, ie, +\[ + -7\quad -\frac{28}{5}\quad -\frac{21}{5}\quad -\frac{14}{5}\quad + -\frac{7}{5}\quad 0\quad \frac{7}{5}\quad \frac{14}{5}\quad + \frac{21}{5}\quad \frac{28}{5}\quad 7 +\] + +Singularities are between $-7/5$ and $0$, and between $0$ and $7/5$, +So, the graph is not correct in these intervals. +\medskip + +To avoid this problem, we will +draw the function in three intervals, excluding the points where it is +undefined: +\medskip +\begin{exemple} +\SUBTRACTfunction{\SQUAREfunction}{\ONEfunction} + {\Ffunction} +\QUOTIENTfunction{\IDENTITYfunction}{\Ffunction} + {\Gfunction} +\renewcommand{\axeslabelsize}{\scriptsize} +\setlength{\unitlength}{0.5cm} +\begin{Picture}(-8,-6)(8,6) +\def\xunitdivisions{2} +\def\yunitdivisions{2} +\cartesianaxes(-7,-5)(7,5) +\pictcolor{red} +\PlotFunction[5]{\Gfunction}{-7}{-1.105} +\PlotFunction[5]{\Gfunction}{-0.905}{0} +\PlotFunction[5]{\Gfunction}{0}{0.905} +\PlotFunction[5]{\Gfunction}{1.105}{7} +\end{Picture} +\end{exemple} + +(To determine the ends of the ranges of variation +$\pm1.105$ and $\pm0.905$, we solved the equation +$g(t)=5$, to ensure that asymtotic branches are interrupted +at the border of the drawing area). + +\subsubsection{Accurate graphs} +In general, to obtain fairly reliable results we must make + a careful analysis of the behavior of the function, +determining the points where it is undefined or not differentiable, + the intervals where it is increasing, its extreme values, +points where graph cuts the coordinate axes and, in general, + all points where the behavior of +function is significant. +From this information, we can chose the appropriate +drawing intervals. +A careful choice of the partition +subintervals in the domain ensures us +that the graph accurately reflects the behavior of the function. + +We will see a couple of examples. +First, we draw the sine function in $[-\pi,\pi]$. +This function ant its derivative have no discontinuities, +but it is convenient to choose a number of partitions +being multiple of $4$, to carefully draw +function at the +$k\pi/2$ points. +In fact, a good choice are 24 subdivisions, +to ensure also the well known values of this function +for angles +multiple of $\pi/6$ and $\pi/4$. +\begin{Exemple} +\setlength{\unitlength}{2cm}% + +\highestlabel{\normalfont\normalsize$3\pi/2$} +\begin{center} +\begin{Picture}(-3.5,-1.5)(3.5,1.5) +{\referencesystem(0,0)(\numberHALFPI,0)(0,1) +\makenolabels +\cartesianaxes(-2.2,-1.2)(2.2,1.2)} +\printylabels{-1}{1}{1} +\printxlabel{-\numberPI}{-\pi} +\printxlabel{-\numberHALFPI}{-\pi/2} +\printxlabel{\numberHALFPI}{\pi/2} +\printxlabel{\numberPI}{\pi} +\pictcolor{red} + \PlotFunction[24]{\SINfunction}{-\numberPI}{\numberPI} +\renewcommand{\axeslabelcolor}{red} +\printxlabel{\numberSIXTHPI}{\pi/6} +\printylabel{0.5}{1/2} +\Polyline(\numberSIXTHPI,0)(\numberSIXTHPI,0.5)(0,0.5) +\end{Picture} +\end{center} +\end{Exemple} + +Our second example is more complex. Let's graph the function +\[ +f(t)=(t^3/3-t^2/2-2t+3)/3 +\] + +This function has three roots, at +$t=3/2$ and $t=\pm\sqrt{6}$. +Its derivative, $f'(t)=(t^2-t-2)/3$, equals zero at +$t=-1$ and $t=2$, where the function has, respectively, +a relative maximum and a relative minimum. + The second derivative, $f''(t)=(2t-1)/3$, + is zero at $t=1/2$, which is an inflexion point. +Interesting points are, then, the following: +\[ + -\sqrt{6},-1,0,1/2,3/2,2,\sqrt{6} +\] + +We will plot this function in the + $[-3,4]$ interval (because it includes all these points), + but we divide it as +\[ + [-3,-\sqrt{6}]\cup + [-\sqrt{6},-1]\cup + [-1,0]\cup + [0,1/2]\cup + [1/2,3/2]\cup + [3/2,2]\cup + [2,\sqrt{6}]\cup + [\sqrt{6},4] +\] +\begin{Exemple} +\SQRT{6}{\SQRTSIX} +\newcpoly{\functionf}{1}{-0.66667}{-0.16667}{0.11111} +\setlength{\unitlength}{2cm} +\begin{center} + \begin{Picture}(-3.5,-2.5)(4.5,3.5) +\renewcommand{\xunitdivisions}{10} +\renewcommand{\yunitdivisions}{10} +\cartesiangrid(-3,-2)(4,3) +\pictcolor{red} +\PlotFunction{\functionf}{-3}{-\SQRTSIX} +\PlotFunction[4]{\functionf}{-\SQRTSIX}{-1} +\PlotFunction[4]{\functionf}{-1}{0} +\PlotFunction[4]{\functionf}{0}{0.5} +\PlotFunction[4]{\functionf}{0.5}{1.5} +\PlotFunction[4]{\functionf}{1.5}{2} +\PlotFunction[4]{\functionf}{2}{\SQRTSIX} +\PlotFunction{\functionf}{\SQRTSIX}{4} +\functionf{-1}{\tempf}{\tempDf} +\xLINE(-1,0)(-1,\tempf) +\functionf{2}{\tempf}{\tempDf} +\xLINE(2,0)(2,\tempf) +\functionf{0.5}{\tempf}{\tempDf} +\xLINE(0.5,0)(0.5,\tempf) +\end{Picture} +\end{center} +\end{Exemple} + +\subsection{Polar coordinates curves} +To draw a curve defined in polar form as $\rho =f(t)$, we must +declare it as a polar curve, using the \csdef{POLARfunction} +declaration: writing +\begin{Verbatim}[commandchars=\|\[\]] +\POLARfunction{\|TIT[functionname]}{\|TIT[polarfunction]} +\end{Verbatim} +we declare the new polar curve \cs{\TIT{polarfunction}} +$\rho=\cs{\TIT{functionname}}(t)$. +For example, the \emph{cardioide} curve, $\rho=1+\cos t$, +can be defined in the following way: +\begin{Verbatim} +\SUMfunction{\ONEfunction}{\COSfunction}{\ffunction} % (y=1 + cos t) +\POLARfunction{\ffunction}{\cardioide} +\end{Verbatim} + +Curves defined in such a way can be plotted using the +\csdef{PlotParametricFunction} command, +which syntax is analogous to that of \cs{PlotFunction}. + +\begin{exemple} +% Cardioide: r = 1+cos t +\SUMfunction{\ONEfunction}{\COSfunction} + {\ffunction} +\POLARfunction{\ffunction}{\cardioide} +\begin{center} +\def\runitdivisions{2} +\setlength{\unitlength}{1.5cm} +\begin{Picture}(-2.5,-2.5)(2.5,2.5) +\polargrid{2}{24} +\pictcolor{blue}\linethickness{1pt} + \PlotParametricFunction[20]{% + \cardioide}{0}{\numberTWOPI} +\end{Picture} +$\rho=1+\cos\phi$ +\end{center} +\end{exemple} + +\begin{exemple} +% Eight petal rose: r = cos(4t) +\SCALEVARIABLEfunction{4}{\COSfunction} + {\ffunction} +\POLARfunction{\ffunction}{\rose} +\begin{center} +\def\runitdivisions{3} +\MULTIPLY{2}{\numberTWOPI}{\numberFOURPI} +\setlength{\unitlength}{2.5cm} + +\begin{Picture}(-1.5,-1.5)(1.5,1.5) +\polargrid{1}{16} +\pictcolor{red}\linethickness{1pt} +\PlotParametricFunction[16]\rose{0}{\numberTWOPI} +\end{Picture} +$\rho=\cos 4\phi$ +\end{center} +\end{exemple} + +\begin{exemple} +% Archimedean spiral: r=0,5t +\SCALEfunction{0.5}{\IDENTITYfunction}{\ffunction} +\POLARfunction{\ffunction}{\archimedes} + +\MULTIPLY{2}{\numberTWOPI}{\numberFOURPI} +\setlength{\unitlength}{0.5cm} +\begin{center} +\begin{Picture}(-7,-7)(7,7) +\pictcolor{red} +\PlotParametricFunction[16]{% + \archimedes}{0}{\numberFOURPI} +\end{Picture} +$2\rho=\phi$ +\end{center} +\end{exemple} + +\begin{exemple} +\SCALEVARIABLEfunction{3.2}{\SINfunction}{\ffunction} +\SCALEfunction{0.2}{\ffunction}{\gfunction} +\SUMfunction{\ONEfunction}{\gfunction}{\myfunction} +\POLARfunction{\myfunction}{\Rfunction} +\MULTIPLY{10}{\numberPI}{\numberTENPI} +\setlength{\unitlength}{3cm} +\linethickness{2pt} +\begin{center} +\begin{Picture}(-1.2,-1.2)(1.2,1.2) +\pictcolor{orange} +\PlotParametricFunction[120]\Rfunction{0}{\numberTENPI} +\end{Picture} +$\rho=1+2\sin 3.2\phi$ +\end{center} +\end{exemple} +\subsection{Parametrically defined curves}\label{subsec:param} +Polar curves are a particular case of parametrically defined curves, +$x=f(t), y=g(t)$. These curves are declared by the + \csdef{PARAMETRICfunction} command: +\begin{Verbatim}[commandchars=\|\[\],commentchar=\%] +\PARAMETRICfunction{\|TIT[Xfunction]}{\|TIT[Yfunction]}% +{\|TIT[parametricfunction]} +\end{Verbatim} + +Once we have defined it, +to draw this curve, we use the \csdef{PlotParametricFunction} as described +above. +\begin{Exemple} +\POWERfunction{\IDENTITYfunction}{5}{\xfunction} +\PARAMETRICfunction{\xfunction}{\CUBEfunction}{\myparfunction} +\centering +\setlength{\unitlength}{0.75cm} +\begin{Picture}(-11,-6)(11,6) +\cartesiangrid(-10,-5)(10,5) +\pictcolor{blue} +\PlotParametricFunction[10]{\myparfunction}{-1.5849}{0} +\PlotParametricFunction[10]{\myparfunction}{0}{1.5849} +\Put[E](10,4){$\begin{matrix}x=t^5\\y=t^3\end{matrix}$} +\end{Picture} +\end{Exemple} +\begin{exemple} +% A Lissanjous curve: x=sin 3t, y=sin 4t +\SCALEVARIABLEfunction{3}{\SINfunction}{\ffunction} +\SCALEVARIABLEfunction{4}{\SINfunction}{\gfunction} +\PARAMETRICfunction{\ffunction}{\gfunction}{\myfunction} +\MULTIPLY{10}{\numberPI}{\numberTENPI} +\setlength{\unitlength}{3cm} +\linethickness{2pt} +\begin{center} +\begin{Picture}(-1.2,-1.2)(1.2,1.2) +\pictcolor{red} +\PlotParametricFunction[24]\myfunction{0}{\numberTWOPI} +\end{Picture} + +$x=\sin 3t,\ y=\sin 4t$ +\end{center} +\end{exemple} + +Here, we should also take into account the characteristics of the curve +in order to choose appropriate intervals for +the parameter (typically, the points where the function is not defined, +singularities, cuts with axes, +points where some of the derivatives $x',x'',\ldots$ or $y',y''\ldots$) is +zero\ldots +In the following example, to represent the curve $x=t^2-1$, $y=t^3-t$, +we see that $x$ or $y$ equals zero when $t$ is +$0$, $1$ or $-1$; the first derivatives $x'=2t$, $y'=3t^2-1$, +in $t=0$ and $t=\pm\sqrt3/3$, and second derivative of $y$ in $t=0$. +Thus, we choose an interval containing these values of $t$, such $[-2.2]$, +and this partition of it: +\[ + [-2,2]=[-2,-1]\cup[-1,-\sqrt3/3]\cup[-\sqrt3/3,0]\cup[0,\sqrt3/3]\cup[\sqrt3/3,1]\cup[1,2] +\] + +This same curve was depicted with a single instruction +\cs{PlotParametricFunction} dividing +the interval $[-2.2]$ into five subintervals. +Note that the obtained picture is almost identical, but the fact that +partition not includes zero +conceals the fact that the vertical tangent occurs at the point + $(-1,0)$. +So, one of the most significant features of the curve is not correctly +displayed. +\begin{Exemple} +\SUBTRACTfunction{\SQUAREfunction}{\ONEfunction}{\Xpart} +\SUBTRACTfunction{\CUBEfunction}{\IDENTITYfunction}{\Ypart} +\PARAMETRICfunction{\Xpart}{\Ypart}{\myparfunction} +\centering +\setlength{\unitlength}{1cm} +\begin{Picture}(-3.5,-6.5)(3.5,6.5) +\cartesiangrid(-3,-6)(3,6) +\pictcolor{blue} +\PlotParametricFunction\myparfunction{-2}{-1} +\PlotParametricFunction\myparfunction{-1}{-0.57735} +\PlotParametricFunction\myparfunction{-0.57735}{0} +\PlotParametricFunction\myparfunction{0}{0.57735} +\PlotParametricFunction\myparfunction{0.57735}{1} +\PlotParametricFunction\myparfunction{1}{2} +\Put[E](3,6){$\begin{matrix}x=t^2-1\\y=t^3-t\end{matrix}$} +\end{Picture} +\qquad +\begin{Picture}(-3.5,-6.5)(3.5,6.5) +\cartesiangrid(-3,-6)(3,6) +\pictcolor{orange} +\PlotParametricFunction[5]\myparfunction{-2}{2} +\Put[E](3,6){$\begin{matrix}x=t^2-1\\y=t^3-t\end{matrix}$} +\end{Picture} +\end{Exemple} +\subsubsection{The curve of the front page} +To conclude this section we will study in detail the example +of the front page of this manual. +This example shows the power, +while the simplicity of the package \package{xpicture}. + +It is the transcendent curve named \emph{butterfly}, +\begin{gather*} + x=\sin t \left(\mathrm e^{\cos t} - 2 \cos 4t + + \sin^5\left(\frac t{12}\right)\right) \\ + y=\cos t \left(\mathrm e^{\cos t} - 2 \cos 4t + + \sin^5\left(\frac t{12}\right)\right) +\end{gather*} + +We analyze step by step the code we used: +\begin{itemize} +\item First, we calculated some numbers we'll use later: +\begin{inparaenum}[(a)] +\item $1/12$, that appears in the definition of functions $x$ and $y$; +\item $12\times2\pi$, to plot the curve in $[0,24\pi]$ (twelve laps); and +\item$12\times64$, the number of subdivisions we will use +(64 subintervals for each lap). +\VerbatimInput[numbers=left,firstline=3,lastline=5]{xpicture1.tex} +\end{inparaenum} +\item In the next block we do the important work: +the curve is defined step by step. + +\begin{compactitem} +\item Define the function $A(t)=\mathrm e^{\cos t}$ +\VerbatimInput[numbers=left,firstline=7,lastline=7]{xpicture1.tex} +\item Define $B(t)=\cos 4t$ +\VerbatimInput[numbers=left,firstline=8,lastline=8]{xpicture1.tex} +\item Define $c(t)=\sin t/12$ +\VerbatimInput[numbers=left,firstline=9,lastline=9]{xpicture1.tex} +\item Define $C(t)=\sin^5 t/12$ +\VerbatimInput[numbers=left,firstline=10,lastline=10]{xpicture1.tex} +\item Define $AB(t)=\mathrm e^{\cos t}-2\cos 4t$ +\VerbatimInput[numbers=left,firstline=11,lastline=11]{xpicture1.tex} +\item Define $ABC(t)=\mathrm e^{\cos t}-2\cos 4t+\sin^5 t/12$ +\VerbatimInput[numbers=left,firstline=12,lastline=12]{xpicture1.tex} +\item Define the $x$ and $y$ functions +\VerbatimInput[numbers=left,firstline=13,lastline=16]{xpicture1.tex} +\item And, finally, we declare the parametric curve: +\VerbatimInput[numbers=left,firstline=17,lastline=17]{xpicture1.tex} +\end{compactitem} + +\item Now, the picture composition is trivial +(note the use of constants +\cs{divisions} and \cs{phione} we previously calculated): +\VerbatimInput[numbers=left,firstline=19,lastline=21]{xpicture1.tex} +\end{itemize} + +\subsection{Drawing curves from a table of values} +All instructions to draw curves described here use the +\csdef{qCurve} command, which draws quadratic B\'ezier curves: +\begin{Verbatim}[commandchars=\|\[\],commentchar=\%] +\qCurve(|TIT[x0],|TIT[y0])(|TIT[u0],|TIT[v0])(|TIT[x1],|TIT[y1])(|TIT[u1],% +|TIT[v1]) +\end{Verbatim} +draw a smooth curve between the points $(\TTT{\TIT{x0}},\TTT{\TIT{y0}})$ +and $(\TTT{\TIT{x1}},\TTT{\TIT{y1}})$, with tangent vectors +$(\TTT{\TIT{u0}},\TTT{\TIT{v0}})$ and $(\TTT{\TIT{u1}},\TTT{\TIT{v1}})$, +respectively. +\begin{exemple} +\setlength{\unitlength}{1cm} +\begin{Picture}(-0.5,-0.5)(5.5,5.5) +\cartesianaxes(0,0)(5,5) +\pictcolor{blue} +\qCurve(1,2)(1,2)(4,3)(-1,1) +\pictcolor{gray} +\Put(1,2){\xtrivVECTOR(0,0)(1,2)} +\Put(4,3){\xtrivVECTOR(0,0)(-1,1)} +\Polyline(1,0)(1,2)(0,2) +\Polyline(4,0)(4,3)(0,3) +\end{Picture} +\end{exemple} + +The \csdef{PlotQuadraticCurve} command generalizes \cs{qCurve} +to an arbitrary number of points. +\begin{exemple} +\setlength{\unitlength}{1cm} +\begin{Picture}(-0.5,-0.5)(5.5,3.5) +\cartesianaxes(0,0)(5,3) +\pictcolor{blue} +\PlotQuadraticCurve(0,0)(1,0)% + (1,1)(1,2)% + (3,2)(-1,1)% + (5,2)(0,-1) +\end{Picture} +\end{exemple} +This command supports two alternative syntaxes: +\begin{enumerate}[(a)] +\item +\begin{Verbatim}[commandchars=\|\[\],commentchar=\%] +\PlotQuadraticCurve(|TIT[x0],|TIT[y0])(|TIT[u0],|TIT[v0])(|TIT[x1],|TIT[y1])% +(|TIT[u1],|TIT[v1])...(|TIT[xn],|TIT[yn])(|TIT[un],|TIT[vn]) +\end{Verbatim} +draws a curve through the points +$(\TTT{\TIT{x0}},\TTT{\TIT{y0}})$, + $(\TTT{\TIT{x1}},\TTT{\TIT{y1}})$\ldots + $(\TTT{\TIT{xn}},\TTT{\TIT{yn}})$ +with tangent vectors +$(\TTT{\TIT{u0}},\TTT{\TIT{v0}})$, $(\TTT{\TIT{u1}},\TTT{\TIT{v1}})$\dots +$(\TTT{\TIT{un}},\TTT{\TIT{vn}})$.% +\footnote{This command draws a +quadratic curve between each pair of adjacent points. + +The \cs{Curve} command, introduced by the +\package{curve2e} package, does a similar job, +but using cubic approximations, instead of quadratic.} + +\begin{exemple} +\setlength{\unitlength}{2cm} +\begin{center} +\begin{Picture}(1,1)(-1,-1) +\pictcolor{red} +\PlotQuadraticCurve(1,0)(1,0)(0,1)(0,1)% + (-1,0)(-1,0)(0,-1)(0,-1)% + (1,0)(1,0) +\pictcolor{blue} +\referencesystem(0,0)% + (\numberCOSXLV,\numberCOSXLV)% + (-\numberCOSXLV,\numberCOSXLV) +\PlotQuadraticCurve(1,0)(1,0)(0,1)(0,1)% + (-1,0)(-1,0)(0,-1)(0,-1)% + (1,0)(1,0) +\end{Picture} +\end{center} +\end{exemple} +\item +\begin{Verbatim}[commandchars=\|\[\],commentchar=\%] +\PlotQuadraticCurve(|TIT[x0],|TIT[y0]){|TIT[angle0]}(|TIT[x1],|TIT[y1])% +{|TIT[angle1]}...(|TIT[xn],|TIT[yn]){|TIT[anglen]} +\end{Verbatim} +draws a curve through the points +$(\TTT{\TIT{x0}},\TTT{\TIT{y0}})$, + $(\TTT{\TIT{x1}},\TTT{\TIT{y1}})$\ldots + $(\TTT{\TIT{xn}},\TTT{\TIT{yn}})$ +the inclination angles of which, with respect to the $x$ axis, +are \TTT{\TIT{angle0}}, \TTT{\TIT{angle1}}\dots, + \TTT{\TIT{angle0}} (always measured in degrees). +\begin{exemple} +\setlength{\unitlength}{2cm} +\begin{center} +\begin{Picture}(1,1)(-1,-1) +\pictcolor{red} +\PlotQuadraticCurve(1,0){0}(0,1){90} + (-1,0){180}(0,-1){270} + (1,0){360} +\pictcolor{blue} +\referencesystem(0,0)% + (\numberCOSXLV,\numberCOSXLV)% + (-\numberCOSXLV,\numberCOSXLV) +\PlotQuadraticCurve(1,0){0}(0,1){90} + (-1,0){180}(0,-1){270} + (1,0){360} +\end{Picture} +\end{center} +\end{exemple} +\end{enumerate} +With the \cs{PlotQuadraticCurve} command you can approximate any smooth curve +passing through a list of points when you know the tangent vectors. +A particular case, particularly interesting (at least in a calculus course) +is the drawing of the graph a function of real variable knowing a table of +values of the function and its derivative. +To facilitate this work \package{xpicture} +includes the \csdef{PlotxyDyData} command: +\begin{Verbatim}[commandchars=\|\[\],commentchar=\%] +\PlotxyDyData(|TIT[x0],|TIT[y0],|TIT[Dy0])(|TIT[x1],|TIT[y1],|TIT[Dy1])...% +(|TIT[xn],|TIT[yn],|TIT[Dyn]) +\end{Verbatim} +plots the graph of a function $y=f(x)$ passing through points +$(\TTT{\TIT{x0}},\TTT{\TIT{y0}})$, +$(\TTT{\TIT{x1}},\TTT{\TIT{y1}})$\ldots +$(\TTT{\TIT{xn}},\TTT{\TIT{yn}})$ +with derivatives $\TTT{\TIT{Dy0}}$, $\TTT{\TIT{Dy1}}$\ldots +$\TTT{\TIT{Dyn}}$. +\begin{exemple} +\setlength{\unitlength}{1cm} +\begin{Picture}(-1,-1)(5.5,5.5) +\cartesianaxes(0,0)(5,5) +\pictcolor{blue} +\PlotxyDyData(0,0,2)(1,1,0)(2,2,3) + (3,4,0)(5,1,-2) +\pictcolor{gray} +\Put(0,0){\xtrivVECTOR(0,0)(1,2)} +\Put(1,1){\xtrivVECTOR(0,0)(1,0)} +\Put(2,2){\xtrivVECTOR(0,0)(1,3)} +\Put(3,4){\xtrivVECTOR(0,0)(1,0)} +\Put(5,1){\xtrivVECTOR(0,0)(1,-2)} +\end{Picture} +\end{exemple} +\section{Package options and configuration file} +This package is loaded as usual, using the instruction +\cs{usepackage\{\TIT{list of options}\}\{xpicture\}}. +Then, packages \packagedef{pict2e}, \packagedef{curve2e}, \packagedef{xcolor}, +\packagedef{calculator}, and \packagedef{calculus} are automatically loaded. +This package is compatible with any system that supports +\packagedef{xcolor} and \packagedef{pict2e} packages. + +The only specific option for this package is \optiondef{draft}, +which disables all the instructions defined in this package, +replacing each picture set in a \environ{Picture} environment +by a parallelogram circumscribed by a white rectangle (the box that shows +the area reserved for the picture).\footnote{This option is equivalent to +a global use of +the \texttt{\textbackslash draftPictures} declaration.} +This option is very useful throughout the production +of the document, +since the composition of the drawings slows considerably +the compilation time. + +All other options are passed directly to packages +\packagedef{pict2e}, \packagedef{curve2e}, and \packagedef{xcolor}. +The most interesting option (from package \package{pict2e}) +is \optiondef{pstarrows}; +if used, arrowheads in vectors are drawn in PSTricks style (instead of the +standard \LaTeX{} style). +Do not use the \optiondef{hide} or \optiondef{original} +options (from package \package{pict2e}). + +You can include your preferred values for configurable \package{xpicture} +parameters +(like axes or labels style, radians or degrees measure for angles, +radians or degrees labels in polar grids, et cetera) +using the file \texttt{xpicture.cfg}\ttindex{xpicture.cfg}, because, +if exists, this local configuration file is loaded. +If you want to use it, copy the file +\texttt{xpicture.cfgxmpl}\ttindex{xpicture.cfgxmpl} +(which is distributed along with package \package{xpicture}), +call your copy as \texttt{xpicture.cfg} and put it in your local +\texttt{texmf} tree. +Initially, this file contains the default values for all parameters, but +you edit it to modify everything agreed. +\section{Compatibility with related packages} +As mentioned earlier, this package loads packages +\packagedef{pict2e}, \packagedef{curve2e}, \packagedef{xcolor}, +\packagedef{calculator}, and \packagedef{calculus}. Every command defined in +these packages works fine within a \environ{Picture} environment. The only +restriction to take in account is that colors must be selected with the +\cs{pictcolor} command, because commands \cs{color} and \cs{textcolor} +may cause the appearance of unwanted spaces. Picture commands defined +in \packagedef{pict2e} and \packagedef{curve2e} can be freely used +(had in mind, however, that in this case coordinates +are interpreted as standard), +and you can use all the techniques for defining and manipulating colors +from \packagedef{color} and \packagedef{xcolor} packages. + +Although guidelines for defining and operating with functions +explained in subsections~\ref{subsec:real}--\ref{subsec:param} +may be enough to compose a lot of graphics, +in order to take full advantage of this package you must known +packages \packagedef{calculator} and \packagedef{calculus} +with certain depth. Package \package{calculator} +will set you free of many tedious calculations. +\medskip + +On the other hand, \package{xpicture} is widely compatible with other packages +related to the graphics inclusion, composition or modification. +This fact gives us a lot of flexibility when using them together. + +For example, a picture drawn by \package{xpicture} can include external images +loaded with packages \packagedef{graphics}/\packagedef{graphicx}, +and you can also manipulate the whole picture with the aid of these packages. +In a similar way, \texttt{pgf/tikz}\ttindex{pgf}\ttindex{tikz} +pictures can be included inside a +\package{xpicture} draw. If you use \LaTeX{} and \TTT{dvips} to compile your +document, you can combine \package{xpicture} with \packagedef{pstricks}. + +\printindex +\end{document} diff --git a/Master/texmf-dist/doc/latex/xpicture/xpicture.pdf b/Master/texmf-dist/doc/latex/xpicture/xpicture.pdf Binary files differnew file mode 100644 index 00000000000..eee47e12be5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xpicture/xpicture.pdf diff --git a/Master/texmf-dist/source/latex/xpicture/xpicture.dtx b/Master/texmf-dist/source/latex/xpicture/xpicture.dtx new file mode 100644 index 00000000000..65aab3c5fca --- /dev/null +++ b/Master/texmf-dist/source/latex/xpicture/xpicture.dtx @@ -0,0 +1,3570 @@ +% \iffalse meta-comment +%<*internal> +\begingroup +\input docstrip.tex +\keepsilent +\declarepreamble\packagepreamble +******************************************************************** +The xpicture package +Copyright (C) 2010, 2011, 2012 by Robert Fuster <rfuster@mat.upv.es> +All rights reserved + +This file may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + + http://www.latex-project.org/lppl.txt + +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. +******************************************************************** +\endpreamble +\declarepreamble\cfgpreamble +************************************************************************ +This is xpicture.cfgxmpl, part of the xpicture distribution +Copyright (C) 2010, 2011, 2012 by Robert Fuster <rfuster@mat.upv.es> +All rights reserved + + This is a model for the xpicture configuration file + +You should not modify this file. +To costumize your xpicture installation, make a copy of this file, +save it as 'xpicture.cfg' and modify this new file at your convenience. +************************************************************************ + +\endpreamble +\postamble +\endpostamble + +\askforoverwritefalse +\generate{\usepreamble\packagepreamble + \file{xpicture.sty}{\from{xpicture.dtx}{xpicture,defaults}} + \usepreamble\cfgpreamble + \file{xpicture.cfgxmpl}{\from{xpicture.dtx}{defaults,cfg}} + } + +\def\tmpa{plain} +\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi +\endgroup +%</internal> +% +% Copyright (C) 2010, 2011, 2012 by Robert Fuster <rfuster@mat.upv.es> +% +% This file may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% +% http://www.latex-project.org/lppl.txt +% +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% \fi +% \CheckSum{2978} +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\ProvidesFile{xpicture.dtx} + [2012/12/17 v.1.2a documented xpicture package] +\GetFileInfo{xpicture.dtx} +\usepackage[lmargin=5cm,rmargin=2cm]{geometry} + +\usepackage{xpicture} + +\newcommand{\environ}[1]{\textnormal{\texttt{#1}}} +\newcommand{\package}[1]{\textnormal{\texttt{#1}}} +\newcommand{\option}[1]{\textnormal{\texttt{#1}}} +\newcommand{\optionindex}[1]{% + \index{#1=\texttt{#1} (package option)|usage}% + \index{options:>#1=\texttt{#1}|usage}} + +\newcommand{\starred}{\textnormal{\texttt{*}}} +\newcommand{\Parg}[1]{\textnormal{\texttt(\textit{#1}\texttt)}} +\makeatletter +\newcommand{\myDescribeMacro}{\@ifstar + \xpct@myDescribeMacrostar + \xpct@myDescribeMacro + } +\newcommand{\xpct@myDescribeMacro}[1]{\smallskip\par\DescribeMacro{#1}} +\newcommand{\xpct@myDescribeMacrostar}[1]{\myDescribeMacro{#1}{ }} +\newcommand{\myDescribeEnv}[1]{\smallskip\par + \DescribeEnv{#1}{ }\cs{begin}\{\texttt{#1}\}} +\makeatother + +\def\fileversion{1.2a} +\def\filedate{2012/12/17} +\title{The \textsf{xpicture} package\thanks{This document + corresponds to \textsf{xpicture}~\fileversion, dated \filedate.}\\ + (\texttt{http://www.upv.es/\~{}rfuster/xpicture}) \\ + Several extensions of the \textsf{picture} standard environment\\ + Reference manual and documented source} +\author{Robert Fuster\\ + Universitat Polit\`ecnica de Val\`encia \\ + \texttt{rfuster@mat.upv.es}} +\date{\filedate} +\EnableCrossrefs +\CodelineIndex + +\begin{document} + \DocInput{xpicture.dtx} + \newpage + + \PrintIndex +\end{document} +%</driver> +% +% \fi +% +% +% \DoNotIndex{\NeedsTeXFormat} +% \DoNotIndex{\RequirePackage,\ProcessOptions,\ProvidesPackage} +% \DoNotIndex{\CurrentOption,\DeclareOption} +% \DoNotIndex{\MessageBreak,\PackageError,\PackageInfo,\PackageWarning} +% \DoNotIndex{\PassOptionsToPackage,\InputIfFileExists} +% \DoNotIndex{\begingroup,\endgroup,\begin,\end} +% \DoNotIndex{\def,\let,\edef,\xdef,\newcommand,\newenvironment} +% \DoNotIndex{\if,\ifx,\ifnum,\ifdim,\else,\fi,\@whilenum,\@whiledim,\value} +% \DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined,\@killglue,\do,\newif} +% \DoNotIndex{\undefined,\newcounter,\newdimen,\stepcounter} +% \DoNotIndex{\setcounter,\setlength,\unitlength,\settoheight,\settowidth} +% \DoNotIndex{\p@,\z@} +% \DoNotIndex{\noexpand,\ignorespaces} +% \DoNotIndex{\normalfont,\normalsize,\small} +% \DoNotIndex{\circle,\line,\linethickness,\makebox,\put,\multiput,\qbezier} +% \DoNotIndex{\ensuremath,\mathrm,\mathversion} +% \DoNotIndex{\scshape} +% \DoNotIndex{\color,\textcolor,\colorlet} +% \DoNotIndex{\moveto,\lineto,\closepath,\fillpath} +% \DoNotIndex{\LINE,\VECTOR,\segment} +% \DoNotIndex{\x,\Dx,\y,\Dy,\t,\Dt} +% \DoNotIndex{\Picture,\endPicture} +% \DoNotIndex{\ADD,\COPY,\GLOBALCOPY} +% \DoNotIndex{\COS,\RADtoDEG,\COSH,\COTAN,\COTANH,\CUBE,\DIVIDE,\EXP,\LOG} +% \DoNotIndex{\MULTIPLY,\POWER,\SIN,\SINH,\SQRT,\SQUARE,\SUBTRACT,\TAN,\TANH} +% \DoNotIndex{\ABSVALUE,\DEGREESCOS,\DEGREESSIN,\DEGREESTAN,\DEGREESCOT} +% \DoNotIndex{\COS,\SIN,\TAN,\COT,\pi} +% \DoNotIndex{\DETERMINANT,\MATRIXVECTORPRODUCT,\SCALARVECTORPRODUCT} +% \DoNotIndex{\MAX,\MIN,\ROUND,\TRUNCATE} +% \DoNotIndex{\FLOOR,\FRACTIONSIMPLIFY,\LENGTHDIVIDE,\SQUAREROOT} +% \DoNotIndex{\numberTWOPI,\newvectorfunction} +% \DoNotIndex{\UNITVECTOR,\VECTORADD,\VECTORCOPY,\VECTORNORM,\VECTORSUB} + +% \maketitle +% \begin{abstract} +% The \package{xpicture} package extends the graphic abilities +% of the \environ{picture} standard environment and packages \package{pict2e} +% and \package{curve2e}, adding the ability to work with arbitrary +% In addition to other utilities, +% the greater interest of \package{xpicture} +% lies in its capacity to draw function graphs, +% conic sections and arcs, and parametrically defined curves. + +% This is the technical documentation and reference manual +% of package \package{xpicture}, but not its user manual. +% User manual is on file \texttt{xpicture-doc.pdf}, +% distributed together with the package. +% \end{abstract} +% \tableofcontents +% \newpage +% +% \section{Introduction} +% The \package{xpicture} package introduces several new graphical +% instructions, +% and some enriched versions of standard +% instructions used inside the \environ{picture} environment. +% All these new instructions can be classified as follows: +% \begin{enumerate} +% \item Reference systems and coordinates: +% \begin{itemize} +% \item Declaration and use of different reference systems, +% with Cartesian or polar coordinates. +% \item Instructions to show Cartesian or polar reference systems. +% \end{itemize} +% \item An alternative to the \environ{picture} environment, +% compatible with the new reference systems. +% \item Alternative instructions or extensions of the standard +% \environ{picture} commands and those defined by the packages +% \package{pict2e} and \package{curve2e}: +% \begin{itemize} +% \item Enriched versions of marks \cs{put} and \cs{multiput}, +% providing an adequate control of the precise position +% in which objects are composed +% (this functionality is especially useful in the composition +% of not strictly graphical objects, such as formulas or labels). +% \item Instructions for drawing straight segments, vectors +% (in any direction and using any reference system), polylines, +% polygons, regular and arbitrary polygons . +% \end{itemize} +% \item Regular curves: +% \begin{itemize} +% \item Instructions for drawing conic sections (circles, ellipses, +% hyperbolas and parabolas) and arcs of these curves. +% \item Instructions to graph functions and parametrically defined curves +% (this is the most interesting feature of this package). +% \end{itemize} +% \end{enumerate} +% +% To enjoy this package you need to have an adequate knowledge of the commands +% defined in packages \package{calculator} and \package{calculus}, +% especially concerning to the definition of +% functions and operations with functions. +% +% +% \setlength{\marginparsep}{0pt} +% \setlength{\parindent}{0pt} +% \section{Usage} +% This package is loaded as usual, using the instruction +% \cs{usepackage}\oarg{list of options}|{xpicture}|. +% Then, packages \package{pict2e}, \package{curve2e}, \package{xcolor}, +% \package{calculator}, and \package{calculus} are automatically loaded. +% This package is compatible with any system that supports +% \package{xcolor} and \package{pict2e} packages.\footnote{% +% Earlier versions supports \option{dvi} option, +% which was compatible with a pure \texttt{dvi} output, +% but this possibility has been eliminated in version 2.1a, +% because it was too expensive and probably unhelpful.} +% +% Options are passed directly to packages +% \package{pict2e}, \package{curve2e}, and \package{xcolor}, excerpt option +% \option{draft}\optionindex{draft}, +% which disables all the instructions defined in this package, +% replacing each picture set in a \environ{Picture} environment +% by a blank rectangle.\footnote{If you use an instruction +% not directly defined by \package{xpicture}, +% this instruction may take effect.} +% Using this option is very convenient throughout the production +% of the document, +% since the composition of the drawings slows considerably +% the compilation time. +% The |\draftPictures| declaration performs a similar work, +% allowing the user to locally disable |Picture| commands. +% +% An interesting option (from package \package{pict2e}) is +% \option{pstarrows};\optionindex{pstarrows} +% if used, arrowheads in vectors are drawn in PSTricks style (instead of the +% standard \LaTeX{} style). +% +% If exists, the local configuration file \texttt{xpicture.cfg} is loaded. +% This file allows the user to customize all configurable +% \package{xpicture} parameters; +% if you want to use it, copy the file \texttt{xpicture.cfgxmpl}, +% which is distributed along with package \package{xpicture}, +% call your copy as \texttt{xpicture.cfg}, put it in your local +% \texttt{texmf} tree +% and edit this file to modify everything agreed. +% +% \section{The user interface} +% \subsection{Color selection} +% +% \myDescribeMacro\pictcolor\marg{color} +% select a color without spurious spaces. +% +% Example: |\pictcolor{blue}| +% +% \subsection{Reference systems} +% \myDescribeMacro\referencesystem\parg{x0,y0}\parg{x1,y1}\parg{x2,y2} +% selects the affine reference system with origin in point +% (\textit{x0},\textit{y0}) and coordinate vectors (\textit{x1},\textit{y1}) +% and (\textit{x2},\textit{y2}). +% +% Coordinates are refered to the standard reference system. +% +% Example: |\referencesystem(0,0)(1,-1)(1,1)| +% +% \myDescribeMacro\changereferencesystem\parg{x0,y0}\parg{x1,y1}\parg{x2,y2} +% selects the affine reference system with origin in point +% (\textit{x0},\textit{y0}) and coordinate vectors (\textit{x1},\textit{y1}) +% and (\textit{x2},\textit{y2}). +% +% Coordinates are refered to the active reference system. +% +% Example: |\changereferencesystem(0,0)(1,-1)(1,1)| +% +% \myDescribeMacro\translateorigin\parg{x0,y0} +% translates origin to the given point. +% +% Coordinates are refered to the active reference system. +% +% Example: |\translateorigin(2,-3)| +% +% \myDescribeMacro\rotateaxes\marg{angle} +% rotates the axes. +% The angle parameter is interpreted as the rotation angle in radians +% (if the \cs{radiansangles} declaration is active) +% or in sexagesimal degrees (if the \cs{degreesangles} declaration is active). +% +% Coordinates are refered to the active reference system. +% +% Example: |\rotateaxes{\numberQUARTERPI}| +% +% \myDescribeMacro\symmetrize\marg{angle} +% performs a symmetry, being \textit{angle} +% the angle between the symmetry axis and the $x$ axis. +% The \cs{radiansangles} and \cs{degreesangles} declarations determine +% if angles are interpreted as radians or degrees. +% +% Coordinates are refered to the active reference system. +% +% Example: |\symmetrize{\numberPI}| +% +% \myDescribeMacro*\radiansangles +% declares that angles are measured in radians (default). +% +% \myDescribeMacro*\degreesangles +% declares that angles are measured in degrees. +% +% \myDescribeMacro*\cartesianreference +% declares Cartesian coordinates (default). +% +% \myDescribeMacro*\polarreference +% declares polar coordinates. +% +% \myDescribeMacro\polarcoor\parg{radius,angle}\parg{x,y} +% changes from polar to Cartesian coordinates. +% +% \subsection{The \environ{Picture} environment} +% +% \myDescribeEnv{Picture}\oarg{color}\parg{x0,y0}\parg{x1,y1} +% starts a picture, refered to rectangle +% $[\textit{x0},\textit{y0}]\times[\textit{x1},\textit{y1}]$. +% If optional argument is present, background is colored with +% this \textit{color}. By default, background is not colored. +% +% Coordinates are refered to the active reference system and are always +% Cartesian coordinates. +% +% Example: |\begin{Picture}[black!10!white](-3.5,-4)(3.5,4)| +% +% \myDescribeEnv{xpicture} +% is an alias for \cs{begin\{Picture\}}. +% +% Example: |\begin{xpicture}[black!10!white](-3.5,-4)(3.5,4)| +% +% \myDescribeMacro*{\draftPictures} +% disables |Picture| commands, showing only the picture area. +% +% Example: |\begin{xpicture}[black!10!white](-3.5,-4)(3.5,4)| +% +% \subsection{Cartesian and polar coordinate axes and grids} +% +% \myDescribeMacro{\cartesianaxes}\parg{x0,y0}\parg{x1,y1} +% draws the coordinate axes corresponding to the +% $[\textit{x0},\textit{y0}]\times[\textit{x1},\textit{y1}]$ rectangle. +% +% Example: |\cartesianaxes(-3.25,-4.5)(3.25,4.25)| +% +% \myDescribeMacro{\cartesiangrid}\parg{x0,y0}\parg{x1,y1} +% draws a coordinate grid corresponding to the +% $[\textit{x0},\textit{y0}]\times[\textit{x1},\textit{y1}]$ rectangle. +% +% Example: |\cartesiangrid(-3.25,-4.5)(3.25,4.25)| +% +% \myDescribeMacro{\polargrid}\marg{radius}\marg{circledivs} +% draws a polar grid. |radius| is the radius of the circle and |circledivs| +% (an integer) the number of angular divisions. +% +% Example: |\polargrid{3.5}{16}| +% +% \subsubsection{The style of the axes} +% +% \myDescribeMacro*{\axescolor} User can change the axes color +% by redefining the \cs{axescolor} declaration. +% +% Example: |\renewcommand{\axescolor}{orange}| (default is \texttt{black}). +% +% \myDescribeMacro*{\axesthickness} Length determining the thickness of axes +% (default \verb+1 pt+). +% +% Example: |\setlength{\axesthickness}{1mm}| +% +% \myDescribeMacro*{\xunitdivisions} Number of subdivisions of +% the unit in the $x$ axis (must a positive integer). +% +% Example:|\renewcommand{\xunitdivisions}{5}| +% (default is \texttt{1}). +% +% \myDescribeMacro*{\yunitdivisions} Number of subdivisions of +% the unit in the $y$ axis (must a positive integer). +% +% Example:|\renewcommand{\yunitdivisions}{3}| +% (default is \texttt{1}). +% +% \myDescribeMacro*{\runitdivisions} Number of subdivisions of +% the unit in the polar axis (must a positive integer). +% +% Example:|\renewcommand{\runitdivisions}{3}| +% (default is \texttt{1}). +% +% \subsubsection{Axes position} +% +% \myDescribeMacro*{\internalaxes} +% Cartesian axes lies on $y=0$ and $x=0$ (default). +% +% \myDescribeMacro*{\externalaxes} +% Cartesian axes lies on $y=\textit{y0}$ and $x=\textit{x0}$. +% +% \subsubsection{Style of numerical labels} +% +% \myDescribeMacro*{\axeslabelcolor} +% User can change the color of labels by redefining the +% \cs{axeslabelcolor} declaration. +% +% Example: |\renewcommand{\axeslabelcolor}{red}| +% (default is equal to the axes color). +% +% \myDescribeMacro*{\axeslabelsize} +% User can change the size of labels by redefining the +% \cs{axeslabelsize} declaration. +% +% Example: |\renewcommand{\axeslabelsize}{\tiny}| +% (default is |\small|). +% +% \myDescribeMacro*{\axeslabelmathversion} +% User can change the mathversion of labels by redefining the +% \cs{axeslabelmathversion} declaration. +% +% Example: |\renewcommand{\axeslabelmathversion}{bold}| +% (default is |normal|). +% +% \myDescribeMacro*{\axeslabelmathalphabet} +% User can change the math alphabet of labels by redefining the +% \cs{axeslabelmathalphabet} declaration. +% +% Example: |\renewcommand{\axeslabelmathalphabet}{\mathsf}| +% (default is |\mathrm|). +% +% \myDescribeMacro*{\radianspolarlabels} +% when this declaration is active, angular labels in polar grids are printed +% in radians (default). +% +% \myDescribeMacro*{\degreespolarlabels} +% when this declaration is active, angular labels in polar grids are printed +% in degrees. +% +% \myDescribeMacro*{\axislabelsep} +% Distance between tags and cut marks, measured in \cs{unitlength} units; +% the distance between axes and tags equals \cs{ticssize}$+$\cs{axislabelsep}. +% (see description of \cs{makenotics}). +% +% Example: |\renewcommand{\axislabelsep}{0.3}| +% (default is |0.1|). +% +% \subsubsection{Position of numerical labels} +% +% \myDescribeMacro{\xlabelpos}\marg{position} +% Relative position of labels in $x$ axis. +% +% Example: |\xlabelpos{t}| +% (default is |-90|). +% +% \myDescribeMacro{\ylabelpos}\marg{position} +% Relative position of labels in $y$ axis. +% +% Example: |\ylabelpos{tl}| +% (default is |180|). +% +% \subsubsection{Style of cut marks} +% +% \myDescribeMacro*{\ticssize} +% half the length of main axes cuts. +% +% Example: |\setlength{\ticssize}{3mm}| +% (default is |4pt|) +% +% \myDescribeMacro*{\secundaryticssize} +% half the length of secundary axes cuts. +% +% Example: |\setlength{\secunadryticssize}{1mm}| +% (default is |2pt|) +% +% \myDescribeMacro*{\ticsthickness} +% thickness of the marks on axes. +% +% Example: |\setlength{\ticsthickness}{0.5pt}| +% (default is |1pt|) +% +% \myDescribeMacro*{\ticscolor} +% User can change the color of tics by redefining the +% \cs{ticscolor} declaration. +% +% Example: |\renewcommand{\ticscolor}{lightgray}| +% (default is |black|) +% +% \subsubsection{Grid style} +% +% \myDescribeMacro*{\gridthickness} +% thickness of the main grid lines. +% +% Example: |\setlength{\gridthickness}{1pt}| +% (default is |0.4pt|) +% +% \myDescribeMacro*{\secundarygridthickness} +% thickness of the secundary grid lines. +% +% Example: |\setlength{\gridthickness}{0.25pt}| +% (default is |0.2pt|) +% +% \myDescribeMacro*{\gridcolor} +% User can change the color of main grid lines by redefining the +% \cs{ticscolor} declaration. +% +% Example: |\renewcommand{\gridcolor}{blue}| +% (default is |gray|) +% +% \myDescribeMacro*{\secundarygridcolor} +% User can change the color of secundary grid lines by redefining the +% \cs{ticscolor} declaration. +% +% Example: |\renewcommand{\secundarygridcolor}{blue}| +% (default is |lightgray|) +% +% \subsubsection{Removing cut marks, labels and grids} +% \myDescribeMacro*{\maketics} +% when this declaration is active, divisions of axes are marked (default). +% +% \myDescribeMacro*{\makenotics} +% when this declaration is active, divisions of axes are not marked. +% +% In this case, the distance between axes and tags equals \cs{axislabelsep}. +% +% \myDescribeMacro*{\makelabels} +% when this declaration is active, numerical labels are printed (default). +% +% \myDescribeMacro*{\makenolabels} +% when this declaration is active, numerical labels are not printed. +% +% \myDescribeMacro*{\makenogrid} +% If the \cs{makenogrid} declaration is active, +% then \cs{cartesianaxes} plots only the axes (default). +% +% \myDescribeMacro*{\makegrid} +% If the \cs{makegrid} declaration is active, +% then \cs{cartesianaxes} plots a Cartesian grid. +% +% In this case, \cs{cartesianaxes} is equivalent to \cs{cartesiangrid}. +% +% \subsection{Directly printing cuts and labels} +% +% \myDescribeMacro{\plotxtic}\marg{x-coor} +% plot a tic for the given $x$ coordinate. +% +% \myDescribeMacro{\plotytic}\marg{y-coor} +% plot a tic for the given $y$ coordinate. +% +% \myDescribeMacro{\printxlabel}\marg{x-coor}\marg{label} +% print the required label at the given $x$ coordinate. +% +% \myDescribeMacro{\printylabel}\marg{y-coor}\marg{label} +% print the required label at the given $y$ coordinate. +% +% \myDescribeMacro{\printxticlabel}\marg{x-coor}\marg{label} +% print a tic and the required label at the given $x$ coordinate. +% +% \myDescribeMacro{\printyticlabel}\marg{y-coor}\marg{label} +% print a tic and the required label at the given $y$ coordinate. +% +% \myDescribeMacro{\plotxtics}\marg{firstcoor}\marg{incr}\marg{bound} +% plot several $x$ tics, from the initial coordinate \textit{firstcoor}; +% \textit{incr} is the distance between consecutive tics, +% and the last tic is not in a position greater than \textit{bound}. +% +% \myDescribeMacro{\plotytics}\marg{firstcoor}\marg{incr}\marg{bound} +% plot several $y$ tics, from the initial coordinate \textit{firstcoor}; +% \textit{incr} is the distance between consecutive tics, +% and the last tic is not in a position greater than \textit{bound}. +% +% \myDescribeMacro{\printxlabels}% +% \oarg{digits}\marg{firstcoor}\marg{incr}\marg{bound} +% print several $x$ labels, from the initial coordinate \textit{firstcoor}; +% \textit{incr} is the distance between consecutive label positions, +% and the last position is not greater than \textit{bound}. +% The optional argument \textit{digits} is the number of decimal +% digits to be printed +% (by default, numbers are printed with its natural number of decimals). +% \myDescribeMacro{\printylabels}% +% \oarg{digits}\marg{firstcoor}\marg{incr}\marg{bound} +% print several $x$ labels, from the initial coordinate \textit{firstcoor}; +% \textit{incr} is the distance between consecutive label positions, +% and the last position is not greater than \textit{bound}. +% The optional argument \textit{digits} is the number of decimal +% digits to be printed +% (by default, numbers are printed with its natural number of decimals). +% +% \myDescribeMacro{\printxticslabels}% +% \oarg{digits}\marg{firstcoor}\marg{incr}\marg{bound} +% print $x$ tics and labels simultaneously. +% +% \myDescribeMacro{\printyticslabels}% +% \oarg{digits}\marg{firstcoor}\marg{incr}\marg{bound} +% print $y$ tics and labels simultaneously. +% +% \subsection{\cs{put} and \cs{multiput} extensions} +% +% \myDescribeMacro{\cPut}\marg{position}\parg{x,y}\marg{object} +% \myDescribeMacro{\rPut}\starred\marg{position}\parg{x,y}\marg{object} +% \myDescribeMacro{\Put}\starred\oarg{position}\parg{x,y}\marg{object} +% +% draw \textit{object} in point \Parg{x,y}. +% Argument \textit{position} fixes the precise position of \textit{object} +% with respect \Parg{x,y}. +% +% In starred versions objects positioned below the reference point +% are aligned at a fixed vertical distance (normally, by the baseline). +% User must decide which is that amount (normally the higher object +% to be positioned), and introduce it as an argument of +% the \cs{highestlabel} declaration. +% +% Example: |\Put*[SSE](1,2){\Ellipse{2}{3}}| +% +% \medskip +% +% Argument \textit{position} supports the following values: +% \begin{description} +% \item[An integer or decimal number,] determining the angle (in degrees) +% where \textit{object} is placed, +% (with respect to the reference point \Parg{x,y}). +% \item[Letter \texttt{c}] +% which places the center of \textit{object} at +% \Parg{x,y}). +% \item[Letter or letter combinations \texttt N, \texttt E, \texttt S, +% \texttt W, +% \texttt{NE}, \texttt{SE}, \texttt{SW}, \texttt{NW}, +% \texttt{NNE}, \texttt{ENE}, \texttt{ESE}, \texttt{SSE}, \texttt{SSW},% +% \texttt{WSW}, \texttt{WNW}, +% \texttt{NNW}] +% Abbreviation of \emph{North}, \emph{East}\ldots, \emph{North-East}\ldots, +% \emph{North-North-East}\ldots +% \item[Letter o letter combinations \texttt t, \texttt r, \texttt b,% +% \texttt l, +% \texttt{tr}, \texttt{br}, \texttt{bl}, \texttt{tl}, +% \texttt{ttr}, \texttt{rtr}, \texttt{rbr}, \texttt{bbr}, \texttt{bbl},% +% \texttt{lbl}, \texttt{ltl}, +% \texttt{ttl}] +% Abbreviation of \emph{top}, \emph{right}\ldots, \emph{top-right}\ldots, +% \emph{top-top-right}\ldots +% +% \end{description} +% Without optional argument \textit{position} (in command \cs{Put}) +% the reference point of \textit{object} is placed at +% \Parg{x,y}) +% (in a similar way to the \cs{put} command). +% +% \myDescribeMacro*{\Pictlabelsep} +% determines the distance between the graphical object and the given point. +% User can redefine this declaration by typing +% \cs{renewcommand}\cs{Pictlabelsep}\marg{number}. +% This number is interpreted as an amount of |\unitlength|. +% +% Example: |\renewcommand{\Pictlabelsep}{1}| (default is |0.1|). +% +% This distance is understood either as the Euclidean (circular) distance, +% derived from the $2$-norm, +% or as the distance derived from the $\infty$-norm (rectangular distance), +% following these rules: +% \begin{itemize} +% \item If argument \textit{position} is a \textit{compass} argument +% (like \texttt N or \texttt{SSW}), then circular distance is used. +% \item If argument \textit{position} is like \texttt t, \texttt{bbl},\ldots +% then rectangular distance is used. +% In all other cases, |\cPut| uses circular distance, +% |\rPut| uses rectangular distance and |\Put| uses distance established +% by \cs{defaultPut}. +% \end{itemize} +% +% \myDescribeMacro{\defaultPut}\marg{position} +% fixes the default position for \cs{Put}, \cs{multiPut} and \cs{multiPlot} +% commands. Argument \textit{position} can be \texttt c or \texttt r. +% +% Example: |\defaultPut{r}| (default is \texttt c). +% +% \myDescribeMacro{\highestlabel}\marg{text} declares the highest label to be +% equal to height of \textit{text}. +% +% Example: |\highestlabel{\Huge A}| (default is |\normalfont\normalsize$1$|) +% +% \myDescribeMacro{\multicPut} +% \marg{position}\parg{x,y}\parg{$\Delta$x,$\Delta$y}\marg{n}\marg{object} +% \myDescribeMacro{\multirPut}\starred +% \marg{position}\parg{x,y}\parg{$\Delta$x,$\Delta$y}\marg{n}\marg{object} +% \myDescribeMacro{\multiPut}\starred +% \oarg{position}\parg{x,y}\parg{$\Delta$x,$\Delta$y}\marg{n}\marg{object} +% +% put \textit{n} copies of \textit{object} in \textit{position} +% at points +% $(\textit{x0},\textit{y0})$, $(\textit{x0}+\Delta x,\textit{y0}+\Delta y)$, +% $(\textit{x0}+2\Delta x,\textit{y0}+2\Delta y)$, \ldots, +% $(\textit{x0}+(\textit n-1)\Delta x,\textit{y0}+(\textit n-1)\Delta y)$. +% +% Example: |\multicPut{c}(1,2)(1,-1){4}{\xVECTOR(0,0)(1,1)}| +% +% \myDescribeMacro{\multicPlot} +% \marg{position}\marg{object}\parg{x0,y0}\parg{x1,y1}\ldots\parg{xn,yn} +% +% \myDescribeMacro{\multirPlot}\starred +% \marg{position}\marg{object}\parg{x0,y0}\parg{x1,y1}\ldots\parg{xn,yn} +% +% \myDescribeMacro{\multiPlot}\starred +% \oarg{position}\marg{object}\parg{x0,y0}\parg{x1,y1}\ldots\parg{xn,yn} +% +% put $\textit{n}+1$ copies of \textit{object} at points +% \Parg{x0,y0}, +% \Parg{x1,y1},\ldots, +% \Parg{xn,yn} +% +% Example: |\multirPlot{c}{\xVECTOR(0,0)(1,1)}(1,2)(2,1)(3,0)(4,-1)| +% +% \subsection{Drawing lines, vectors and polylines} +% +% \subsubsection{Lines and vectors} +% +% \myDescribeMacro{\xLINE}\parg{x0,y0}\parg{x1,y1} +% draws a stright line between points \Parg{x0,y0} +% and \Parg{x1,y1}. +% +% Example: |\xLINE(1,-2)(0,3)|. +% +% \myDescribeMacro{\xVECTOR}\parg{x0,y0}\parg{x1,y1} +% draws an arrow from point \Parg{x0,y0} +% to point \Parg{x1,y1}. +% +% Example: |\xVECTOR(1,-2)(0,3)|. +% +% \myDescribeMacro{\xtrivVECTOR}\parg{x0,y0}\parg{x1,y1} +% draws an arrow from point \Parg{x0,y0} +% to point \Parg{x1,y1}. +% The arrowhead consists of two lines, controled by the |\arrowsize| +% declaration. +% +% Example: |\xtrivVECTOR(1,-2)(0,3)|. +% +% \myDescribeMacro{\xline}\parg{x,y}\marg{size} +% \myDescribeMacro{\xvector}\parg{x,y}\marg{size} +% \myDescribeMacro{\xtrivvector}\parg{x,y}\marg{size} +% +% draw lines, vectors and triv vectors with the standard \LaTeX{} syntax, +% but without any restriction. +% +% Example: |\Put(1,-2){\xline(-1,5){1}}| +% +% \myDescribeMacro{\zerovector}\parg{x,y} +% \myDescribeMacro{\zerotrivvector}\parg{x,y} +% +% draw a zero-length vector (an arrowhead) in direction +% \Parg{x,y}. +% +% Example: |\Put(0,3){\zerovector(-1,5)}| +% +% \myDescribeMacro\arrowsize\marg{xlen}\marg{ylen} +% declares dimensions of triv arrowhead: |xlen|\,pt is its length, and +% |ylen|\,pt is half of its aperture. +% +% Example: |\arrowsize{4}{2}| (default is |xlen=5|, |ylen=2|) +% +% \subsubsection{Polylines and polygons} +% +% \myDescribeMacro{\Polyline}\parg{x0,y0}\parg{x1,y1}\ldots\parg{xn,yn} +% draws a polyline with vertices +% \Parg{x0,y0}\Parg{x1,y1}\ldots\Parg{xn,yn}. +% +% Example: |\Polyline(1,1)(2,0)(0,-1)| +% +% \myDescribeMacro{\Polygon}\parg{x0,y0}\parg{x1,y1}\ldots\parg{xn,yn} +% draws a polygon with vertices +% \Parg{x0,y0}\Parg{x1,y1}\ldots\Parg{xn,yn}. +% +% Example: |\Polygon(1,1)(2,0)(0,-1)| +% +% \myDescribeMacro{\regularPolygon}\oarg{angle}\marg{radius}\marg{sides} +% draws a regular polygon with the given \textit{radius} and \textit{sides}. +% The optional argument (zero, by default) determines the inclination angle +% of the first vertex, always measured in degrees. +% +% Example: |\regularPolygon[90]{4}{7}| +% +% \subsection{Drawing curves} +% \subsubsection{Conic sections and arcs} +% +% \myDescribeMacro{\Circle}\marg{r} +% draws the circle $x^2+y^2=\textit{r}^2$. +% +% Example: |\Circle{2.5}| +% +% \myDescribeMacro{\Ellipse}\marg{a}\marg{b} +% draws the ellipse +% $\displaystyle\frac{x^2}{\textit{a}^2}+\frac{y^2}{\textit{b}^2}=1$. +% +% Example: |\Ellipse{2}{3}| +% +% \myDescribeMacro{\Hyperbola}\marg{a}\marg{b}\marg{xmax}\marg{ymax} +% draws the hyperbola +% $\displaystyle\frac{x^2}{\textit{a}^2}-\frac{y^2}{\textit{b}^2}=1$. +% +% Variables $x$ and $y$ are limited, respectively, +% to the $[-\textit{xmax},\textit{xmax}]$ and +% $[-\textit{ymax},\textit{ymax}]$ intervals. +% This curve is well defined if the parameter \textit{xmax} +% is greater than \textit{a}. Otherwise, \package{xpicture} returns an error +% message and does not draw any curve. +% +% Example: |\Hyperbola{2}{3}{5}{5}| +% +% \myDescribeMacro{\rHyperbola}\marg{a}\marg{b}\marg{xmax}\marg{ymax} +% draws the \emph{right} branch of hyperbola +% $\displaystyle\frac{x^2}{\textit{a}^2}-\frac{y^2}{\textit{b}^2}=1$. +% +% (parameters are restricted as in |\Hyperbola|). +% +% Example: |\rHyperbola{2}{3}{5}{5}| +% +% \myDescribeMacro{\lHyperbola}\marg{a}\marg{b}\marg{xmax}\marg{ymax} +% draws the \emph{left} branch of hyperbola +% $\displaystyle\frac{x^2}{\textit{a}^2}-\frac{y^2}{\textit{b}^2}=1$. +% +% (parameters are restricted as in |\Hyperbola|). +% +% Example: |\rHyperbola{2}{3}{5}{5}| +% +% \myDescribeMacro{\Parabola}\marg{a}\marg{xmax}\marg{ymax} +% draws the parabola $x=ay^2$. +% +% Variable $x$ is limited, respectively, +% to the $[0,\textit{xmax}]$ (if \textit{a} is positive) +% or $[-\textit{xmax},0]$ (if negative) interval. +% $[-\textit{ymax},\textit{ymax}]$ intervals. +% +% Example: |\Parabola{2}{5}{5}| +% +% \myDescribeMacro{\circularArc}\marg{r}\marg{angle1}\marg{angle2} +% draws the arc of circle +% $x=r\cos t,y=r\sin t,\ t\in[\textit{angle1},\textit{angle2}]$ +% (the arc of the circle centered at $(0,0)$ with radius $\textit{r}$ +% and limited between $\textit{angle1}$ and $\textit{angle2}$). +% +% Example: |\circularArc{3}{0}{\numberSIXTHPI}| +% +% \myDescribeMacro*{\xArc} is an alias for \cs{circularArc}. +% +% Example: |\xArc{3}{0}{\numberSIXTHPI}| +% +% \myDescribeMacro{\ellipticArc}\marg{a}\marg{b}\marg{angle1}\marg{angle2} +% draws the arc of ellipse +% $x=a\cos t,y=b\sin t,\ t\in[\textit{angle1},\textit{angle2}]$ +% (the arc of the ellipse centered at $(0,0)$ with semiaxes +% $\textit{a}$ and $\textit{b}$ +% and limited between $\textit{angle1}$ and $\textit{angle2}$). +% +% Example: |\ellipticArc{2}{3}{-\numberSIXTHPI}{\numberSIXTHPI}| +% +% \myDescribeMacro{\rhyperbolicArc}\marg{a}\marg{b}\marg{y0}\marg{y1} +% draws the right arc of hyperbola +% $\displaystyle\frac{x^2}{\textit{a}^2}-\frac{y^2}{\textit{b}^2}=1$ +% included between +% $\textit{y}=\textit{y0}$ and $\textit{y}=\textit{y1}$. +% +% Example: |\rhyperbolicArc{2}{3}{-2}{2}| +% +% \myDescribeMacro{\lhyperbolicArc}\marg{a}\marg{b}\marg{y0}\marg{y1} +% draws the left arc of hyperbola +% $\displaystyle\frac{x^2}{\textit{a}^2}-\frac{y^2}{\textit{b}^2}=1$ +% included between $\textit{y}=\textit{y0}$ and $\textit{y}=\textit{y1}$. +% +% Example: |\lhyperbolicArc{2}{3}{-2}{2}| +% +% \myDescribeMacro{\parabolicArc}\marg{a}\marg{y0}\marg{y1} +% Draw the arc of the parabola $x=ay^2$ included between +% $\textit{y}=\textit{y0}$ and $\textit{y}=\textit{y1}$. +% +% Example: |\parabolicArc{2}{-2}{2}| +% +% \myDescribeMacro{\defaultplotdivs}\marg{divisions} +% declares the number of subintervals we divide the domain of curves +% when plotting conic arcs. +% +% Example: |\defaultplotdivs{16}| (default is |8|). +% +% \subsubsection{Real variable functions} +% +% \myDescribeMacro{\PlotFunction} +% \oarg{n}\marg{\textbackslash functionname}\marg{t0}\marg{t1} +% draws the graph of function \cs{functionname}$(t)$, +% $t\in[\textit{t0},\textit{t1}]$. +% This interval is partitioned in \textit{n} subintervals (default for +% \textit{n} is |2|). +% +% Example: |\PlotFunction[16]{\COSfunction}{-\numberTWOPI}{\numberTWOPI}| +% +% \myDescribeMacro{\PlotPointsOfFunction} +% \marg{n}\marg{\textbackslash functionname}\marg{t0}\marg{t1} +% draws $\textit{n}+1$ points of the graph of function \cs{functionname}$(t)$, +% $t\in[\textit{t0},\textit{t1}]$. +% +% Example: |\PlotPointsOfFunction{20}{\SQRTfunction}{0}{4}| +% +% \myDescribeMacro*{\pointmarkdiam} +% is the size of points printed by |\PlotPointsOfFunction|, measured in +% |\unitlength| units. It may be +% redefined with a |\renewcommand| declaration. +% +% Example: |\renewcommand{\pointmarkdiam}{0.3}| +% +% \myDescribeMacro*{\pointmark} +% is the symbol printed at every point by |\PlotPointsOfFunction|. It may be +% redefined with a |\renewcommand| declaration. +% +% Example: |\renewcommand{\pointmark}{$\diamond$}| +% +% \subsubsection{Parametrically defined curves} +% +% \myDescribeMacro{\PlotParametricFunction} +% \oarg{n}\marg{\textbackslash functionname}\marg{t0}\marg{t1} +% draws the graph of parametric curve \cs{functionname}$(t)$, +% $t\in[\textit{t0},\textit{t1}]$. +% This interval is partitioned in \textit{n} subintervals (default for +% \textit{n} is |2|). +% +% Example: |\ParametricFunction{\F}{\SQUAREfunction}{CUBEfunction}| +% \\ +% \phantom{Example:} |\PlotParametricFunction[15]{\F}{-2}{2}| +% +% \subsubsection{Drawing curves from a table of values} +% +% \myDescribeMacro{\qCurve}\parg{x0,y0}\parg{u0,v0}\parg{x1,y1}\parg{u1,v1} +% draws the quadratic curve between points \textit{x0,y0} and \textit{x1,y1} +% with tangent vectors \textit{u0,v0} nd \textit{u1,v1}. +% +% Example: |\qCurve(1,2)(1,2)(4,3)(-1,1)| +% +% \myDescribeMacro{\PlotQuadraticCurve} +% \parg{x0,y0}\parg{u0,v0}\parg{x1,y1}\parg{u1,v1}\ldots% +% \parg{xn,yn}\parg{un,vn} +% +% draws a curve through the points +% \parg{x0,y0}, \parg{x1,y1},\ldots, \parg{xn,yn} +% with tangent vectors +% \parg{u0,v0}, \parg{u1,v1},\ldots, \parg{un,vn}. +% +% Example: +% |\PlotQuadraticCurve(1,0)(1,0)(0,1)(0,1)(-1,0)(-1,0)(0,-1)(0,-1)| +% +% \myDescribeMacro{\PlotQuadraticCurve} +% \parg{x0,y0}\marg{angle0}\parg{x1,y1}\marg{angle1}\ldots +% \parg{xn,yn}\marg{anglen} +% +% draws a curve through the points +% \parg{x0,y0}, \parg{x1,y1},\ldots, \parg{xn,yn} +% the inclination angles of which, with respect to the $x$ axis, +% are \textit{{angle0}, \textit{angle1}}\dots, +% \textit{anglen} (always measured in degrees). +% +% Example: +% |\PlotQuadraticCurve(1,0){0}(0,1){90}(-1,0){180}(0,-1){270}}| +% \StopEventually{} +% +% \myDescribeMacro{\PlotxyDyData} +% \parg{x0,y0,Dy0}\parg{x1,y1,Dy1}\ldots\parg{xn,yn,Dyn} +% draws a curve through the points +% \parg{x0,y0}, \parg{x1,y1},\ldots, \parg{xn,yn} +% with derivatives \textit{Dy0}, \textit{Dy1}, \ldots, \textit{Dyn}. +% \section{Implementation} +% \begin{macrocode} +%<*xpicture> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{xpicture}[2012/12/17 v.1.2a picture environment extensions] +% \end{macrocode} +% \subsection{Package options} +% If the |draft| option is selected, +% |Picture| environments are shown +% as a rectangular frame and |xpicture| commands are ignored +% (Boolean |draft| controls whether this option has been selected). +% \begin{macrocode} +\newif\ifdraft\draftfalse +\DeclareOption{draft}{\drafttrue} +% \end{macrocode} +% All other options are passed to packages |curve2e| and |xcolor| +% (Old options |dvi|, |pict2e| and |curve2e| have been removed in +% version 1.2a). +% \begin{macrocode} +\DeclareOption*{% + \PassOptionsToPackage{\CurrentOption}{curve2e} + \PassOptionsToPackage{\CurrentOption}{xcolor}} +\ProcessOptions +% \end{macrocode} +% \subsection{Booleans for some command options} +% Booleans used by several declarations +% controlling the behavior of some |xpicture| commands. +% \begin{macro}{\ifpolar} +% True: polar coordinates. False: Cartesian coordinates. +% \begin{macrocode} +\newif\ifpolar\polarfalse +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifrputstar} +% True: |\rPut| starred. +% \begin{macrocode} +\newif\ifrputstar\rputstarfalse +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifdegrees} +% True: angles mesured in degrees. False: arcs mesured in radians. +% \begin{macrocode} +\newif\ifdegrees\degreesfalse +% \end{macrocode} +% \end{macro} +% \begin{macro}{\iftics} +% True: coordinate axes include tic marks. +% \begin{macrocode} +\newif\iftics\ticstrue +% \end{macrocode} +% \end{macro} +% \begin{macro}{\iflabels} +% True: coordinate axes include numeric labels. +% \begin{macrocode} +\newif\iflabels\labelstrue +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifgrid} +% True: Cartesian grids. +% \begin{macrocode} +\newif\ifgrid\gridfalse +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifticslabelsgrid} +% True: Tics, labels or grid must be printed. +% \begin{macrocode} +\newif\ifticslabelsgrid\ticslabelsgridfalse +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifinzeroaxes} +% True: Representation of axes passes through the origin (internal axes). +% False: external axes. +% \begin{macrocode} +\newif\ifinzeroaxes\inzeroaxestrue +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifbg} +% True: Background will be colored. +% \begin{macrocode} +\newif\ifbg\bgfalse +% \end{macrocode} +% \end{macro} +% \subsection{Required packages} +% \begin{macrocode} +\RequirePackage{curve2e} +\RequirePackage{xcolor} +\RequirePackage{calculus} +% \end{macrocode} +% \subsection{Error, Warning and Info messages} +% \begin{macrocode} +\def\xpct@Warnbadpos{% + \PackageWarning{xpicture}% + {Argument in \noexpand\defaultPut command must be either + 'c' or 'r'\MessageBreak + I will no change the default position for + \noexpand\Put commands}} +\def\xpct@Infopos#1{% + \PackageInfo{xpicture}% + {Default position for \noexpand\Put commands changed to #1}} +\def\xpct@WarnIncSys(#1,#2)(#3,#4){% + \PackageWarning{xpicture}{% + Incompatible linear system!\MessageBreak + Tangent lines are parallel}} +\def\xpct@ErrHypCons{% + \PackageError{xpicture}{% + Inconsistent parameters in \noexpand\Hyperbola command}{% + The first and second parameters in a \noexpand\Hyperbola + command\MessageBreak + must be, respectively, lesser than the third and + the fourth ones.}} +\def\xpct@Infocfg{\PackageInfo{xpicture}{% + Loading local configuration file xpicture.cfg}} +\def\xpct@Infonocfg{\PackageInfo{xpicture}{% + Local configuration file xpicture.cfg does not exists}} +% \end{macrocode} +% \subsection{Internal counters and lengths and a special number} +% Counters |xpct@counta| and |xpct@countb| will be used by several +% internal commands (mainly in |while| clauses). +% |xpct@step| is used when iterating functions plots, and +% |multiput| by commands extending the |\multiput| command. +% \begin{macrocode} +\newcounter{xpct@counta} +\newcounter{xpct@countb} +\newcounter{xpct@step} +\newcounter{multiput} +% \end{macrocode} +% \begin{macro}{\xpct@bxw} +% \begin{macro}{\xpct@bxh} +% Width and height of certain boxes. +% \begin{macrocode} +\newdimen\xpct@bxw +\newdimen\xpct@bxh +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@maxnum} +% The largest \TeX{} number. +% \begin{macrocode} +\def\xpct@maxnum{16383.99998} +% \end{macrocode} +% \end{macro} +% \subsection{Declarations and parameters controlling axes style} +% \begin{macro}{\makenotics} +% \begin{macro}{\maketics} +% \begin{macro}{\makenolabels} +% \begin{macro}{\makelabels} +% \begin{macro}{\makegrid} +% \begin{macro}{\makenogrid} +% \begin{macro}{\externalaxes} +% \begin{macro}{\internalaxes} +% Four pairs of alternative declarations, switching booleans +% |\iftics|, |\iflabels|, |\ifgrid|, and |\ifinzeroaxes|. +% Defaults are |\maketics|, |\makelabels|, |\makenogrid|, +% and |\internalaxes|. +% \begin{macrocode} +\def\makenotics{\ticsfalse} +\def\maketics{\ticstrue} +\def\makenolabels{\labelsfalse} +\def\makelabels{\labelstrue} +\def\makenogrid{\gridfalse} +\def\makegrid{\gridtrue} +\def\externalaxes{\inzeroaxesfalse} +\def\internalaxes{\inzeroaxestrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\axesthickness} +% Thickness of axes (it is a length). +% \begin{macrocode} +\newdimen\axesthickness +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@axeslabelattrib} +% Attributes of labels. It is a private declaration, because you can select +% attributes (size, color and mathversion) of labels independently. +% \begin{macrocode} +\def\xpct@axeslabelattrib{\axeslabelsize% + \pictcolor{\axeslabelcolor}% + \mathversion{\axeslabelmathversion}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ticsthickness} +% \begin{macro}{\ticssize} +% \begin{macro}{\secundaryticssize} +% \begin{macro}{\gridthickness} +% \begin{macro}{\secundarygridthickness} +% Thickness and size of tics and grid lines. +% \begin{macrocode} +\newdimen\ticsthickness +\newdimen\ticssize +\newdimen\secundaryticssize +\newdimen\gridthickness +\newdimen\secundarygridthickness +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \subsection{Color selection} +% \begin{macro}{\pictcolor} +% Declaration |\pictcolor| supresses spureus spaces when selecting color. +% \begin{macrocode} +\def\pictcolor{\@killglue\color} +% \end{macrocode} +% \end{macro} +% \subsection{Reference systems} +% \begin{macro}{\standardreferencesystem} +% Declaration to select the standard reference system. +% \begin{macrocode} +\def\standardreferencesystem{\referencesystem(0,0)(1,0)(0,1)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\referencesystem} +% \begin{macro}{\changereferencesystem} +% \begin{macro}{\xpct@xorigin} +% \begin{macro}{\xpct@yorigin} +% \begin{macro}{\xpct@xI} +% \begin{macro}{\xpct@yI} +% \begin{macro}{\xpct@xII} +% \begin{macro}{\xpct@yII} +% |\referencesystem| changes to the affine reference centered +% in P|(#1,#2)| with directions |(#3,#4)| and |(#5,#6)|. +% These six numbers are stored in +% |\xpct@xorigin|, |\xpct@yorigin|, +% |\xpct@xI|, |\xpct@yI|, |\xpct@xII|, and |\xpct@yII|. +% \begin{macrocode} +\def\referencesystem(#1,#2)(#3,#4)(#5,#6){% + \COPY{#1}\xpct@xorigin + \COPY{#2}\xpct@yorigin + \COPY{#3}\xpct@xI + \COPY{#4}\xpct@yI + \COPY{#5}\xpct@xII + \COPY{#6}\xpct@yII} +% \end{macrocode} +% The |\changereferencesystem| changes from the active reference system. +% \begin{macrocode} +\def\changereferencesystem(#1)(#2)(#3){% + \refsysPoint(#1)(\xpct@newx,\xpct@newy) + \refsysVector(#2)(\xpct@newux,\xpct@newuy) + \refsysVector(#3)(\xpct@newvx,\xpct@newvy) + \referencesystem(\xpct@newx,\xpct@newy)(\xpct@newux,\xpct@newuy)% + (\xpct@newvx,\xpct@newvy)} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\translateorigin} +% \begin{macro}{\rotateaxes} +% \begin{macro}{\symmetrize} +% Translations and orthogonal changes (rotations and symmetries) +% of reference system. +% \begin{macrocode} +\def\translateorigin(#1){\changereferencesystem(#1)(1,0)(0,1)} +\def\rotateaxes#1{% + \ifdegrees\DEGREESCOS{#1}\xpct@cosine\DEGREESSIN{#1}\xpct@sine + \else\COS{#1}\xpct@cosine\SIN{#1}\xpct@sine\fi + \changereferencesystem% + (0,0)(\xpct@cosine,\xpct@sine)(-\xpct@sine,\xpct@cosine)} +% \end{macrocode} +% \begin{macrocode} +\def\symmetrize#1{% + \MULTIPLY{2}{#1}{\xpct@sym} + \ifdegrees + \DEGREESCOS{\xpct@sym}\xpct@cosine\DEGREESSIN{\xpct@sym}\xpct@sine + \else + \COS{\xpct@sym}\xpct@cosine\SIN{\xpct@sym}\xpct@sine\fi + \changereferencesystem% + (0,0)(\xpct@cosine,\xpct@sine)(\xpct@sine,-\xpct@cosine)} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \subsection{Coordinates} +% \begin{macro}{\refsysxyVector} +% \begin{macro}{\refsysxyPoint} +% Canonical coordinates of a point or vector given in Cartesian coordinates +% (change from the active r.s. to the standard one). +% \begin{macrocode} +\def\refsysxyVector(#1)(#2,#3){% + \MATRIXVECTORPRODUCT% + (\xpct@xI,\xpct@xII;\xpct@yI,\xpct@yII)(#1)(#2,#3)} +\def\refsysxyPoint(#1)(#2,#3){% + \MATRIXVECTORPRODUCT(\xpct@xI,\xpct@xII;\xpct@yI,\xpct@yII)(#1)(#2,#3) + \VECTORADD(#2,#3)(\xpct@xorigin,\xpct@yorigin)(#2,#3)} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\refsyspVector} +% \begin{macro}{\refsyspPoint} +% Canonical coordinates of a point or vector given in polar coordinates. +% \begin{macrocode} +\def\refsyspVector(#1,#2)(#3,#4){% + \polarcoor(#1,#2)(\xpct@polarx,\xpct@polary) + \refsysxyVector(\xpct@polarx,\xpct@polary)(#3,#4)} +\def\refsyspPoint(#1,#2)(#3,#4){% + \polarcoor(#1,#2)(\xpct@polarx,\xpct@polary) + \refsysxyPoint(\xpct@polarx,\xpct@polary)(#3,#4)} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\cartesianreference} +% \begin{macro}{\polarreference} +% Alternative declarations to switch between Cartesian or polar coordinates. +% +% \noindent In fact, they define |\refsysVector|/|\refsysPoint| to be +% |\refsysxyVector|/|\refsysxyPoint| or |\refsyspVector|/|\refsyspPoint|. +% \begin{macrocode} +\def\cartesianreference{% + \def\refsysVector{\refsysxyVector}% + \def\refsysPoint{\refsysxyPoint}\polarfalse} +\def\polarreference{% + \def\refsysVector{\refsyspVector}% + \def\refsysPoint{\refsyspPoint}\polartrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\polarcoor} +% |\polarcoor| changes from polar to rectangular coordinates. +% \begin{macrocode} +\def\polarcoor(#1,#2)(#3,#4){% + \ifdegrees\DEGREESCOS{#2}{\xpct@Px}\DEGREESSIN{#2}{\xpct@Py} + \else\COS{#2}{\xpct@Px}\SIN{#2}{\xpct@Py}\fi + \MULTIPLY{\xpct@Px}{#1}{#3} + \MULTIPLY{\xpct@Py}{#1}{#4}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\degreesangles} +% \begin{macro}{\radiansangles} +% Switches to measure angles in degrees or radians. +% \begin{macrocode} +\def\degreesangles{\degreestrue} +\def\radiansangles{\degreesfalse} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \subsection{The \texttt{Picture} environment} +% \begin{environment}{Picture} +% |Picture| is an extension of |picture| to refer points to the +% active reference system. +% It can take an optional argument (background color). +% \begin{macrocode} +\def\Picture{\@ifnextchar[{\xpct@@Picture}{\xpct@Picture}} +% \end{macrocode} +% \end{environment} +% \begin{macro}{\xpct@Picture} +% Compute the surrounding box and call |picture| with the appropriate +% parameters. +% \begin{macrocode} +\def\xpct@Picture(#1,#2)(#3,#4){% +% \end{macrocode} +% First, we determine the standard coordinates of the four vertices +% \begin{macrocode} + \refsysxyPoint(#1,#2)(\xpct@xzero,\xpct@yzero) + \refsysxyPoint(#3,#4)(\xpct@xone,\xpct@yone) + \refsysxyPoint(#1,#4)(\xpct@xtwo,\xpct@ytwo) + \refsysxyPoint(#3,#2)(\xpct@xthree,\xpct@ythree) +% \end{macrocode} +% Now we calculate the maximum and minimum |x| and |y| coordinates. +% \begin{macrocode} + \MIN{\xpct@xzero}{\xpct@xone}{\xpct@xmin} + \MIN{\xpct@xmin}{\xpct@xtwo}{\xpct@xmin} + \MIN{\xpct@xmin}{\xpct@xthree}{\xpct@xmin} + \MIN{\xpct@yzero}{\xpct@yone}{\xpct@ymin} + \MIN{\xpct@ymin}{\xpct@ytwo}{\xpct@ymin} + \MIN{\xpct@ymin}{\xpct@ythree}{\xpct@ymin} + \MAX{\xpct@xzero}{\xpct@xone}{\xpct@xmax} + \MAX{\xpct@xmax}{\xpct@xtwo}{\xpct@xmax} + \MAX{\xpct@xmax}{\xpct@xthree}{\xpct@xmax} + \MAX{\xpct@yzero}{\xpct@yone}{\xpct@ymax} + \MAX{\xpct@ymax}{\xpct@ytwo}{\xpct@ymax} + \MAX{\xpct@ymax}{\xpct@ythree}{\xpct@ymax} +% \end{macrocode} +% Width and height (|xmax-xmin| and |ymax-ymin|) of the sorrounding box. +% \begin{macrocode} + \SUBTRACT{\xpct@xmax}{\xpct@xmin}{\xpct@pictwidth} + \SUBTRACT{\xpct@ymax}{\xpct@ymin}{\xpct@pictheight} +% \end{macrocode} +% Call |picture|. +% \begin{macrocode} + \begin{picture}(\xpct@pictwidth,\xpct@pictheight)(% + \xpct@xmin,\xpct@ymin) +% \end{macrocode} +% Fix highest label to normal 1. +% \begin{macrocode} + \highestlabel{\normalfont\normalsize$1$} +% \end{macrocode} +% If option |draft| was selected, background is colored, +% a surrounding rectangle is drawn and a centered label is printed. +% \begin{macrocode} + \ifdraft + \colorlet{backgroundcolor}{lightgray} + \xpct@backgrd + \put(\xpct@xmin,\xpct@ymin){\line(1,0){\xpct@pictwidth}} + \put(\xpct@xmin,\xpct@ymin){\line(0,1){\xpct@pictheight}} + \put(\xpct@xmin,\xpct@ymax){\line(1,0){\xpct@pictwidth}} + \put(\xpct@xmax,\xpct@ymin){\line(0,1){\xpct@pictheight}} + \VECTORADD(\xpct@xmax,\xpct@ymax)(\xpct@xmin,\xpct@ymin)(% + \xpct@xmed,\xpct@ymed) + \SCALARVECTORPRODUCT{0.5}(\xpct@xmed,\xpct@ymed)(% + \xpct@xmed,\xpct@ymed) + \put(\xpct@xmed,\xpct@ymed){\makebox(0,0){\scshape xpicture}} + \else +% \end{macrocode} +% Finally, if required, we color the background. +% \begin{macrocode} + \ifbg\xpct@backgrd\fi + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@@Picture} +% Set background color to |#1|, swich boolean |\ifbg| +% to true and call |\xpct@Picture|. +% \begin{macrocode} +\def\xpct@@Picture[#1](#2,#3)(#4,#5){% + \colorlet{backgroundcolor}{#1}% + \bgtrue\xpct@Picture(#2,#3)(#4,#5)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@backgrd} +% Fill background with |backgroundcolor|. We use |pict2e| path commands. +% \begin{macrocode} +\def\xpct@backgrd{\begingroup + \pictcolor{backgroundcolor} + \moveto(\xpct@xzero,\xpct@yzero) + \lineto(\xpct@xthree,\xpct@ythree) + \lineto(\xpct@xone,\xpct@yone) + \lineto(\xpct@xtwo,\xpct@ytwo) + \closepath\fillpath + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\endPicture} +% Close |picture| environment. +% \begin{macrocode} +\def\endPicture{\end{picture}} +% \end{macrocode} +% \end{macro} +% \begin{environment}{xpicture} +% |xpicture| is an alias for |Picture|. +% \begin{macrocode} +\newenvironment{xpicture}{\begin{Picture}}{\end{Picture}} +% \end{macrocode} +% \end{environment} +% \subsection{\cs{put} extensions} +% User's commands are |\cPut|, |\rPut|, and |\Put|. +% |\rPut| and |\Put| have starred versions. Related commands are +% |\highestlabel| and |\defaultPut|. +% \begin{macro}{\cPut} +% |\cPut| puts the |#4| object in the |(#2,#3)| point at the |#1| position +% (circular version). +% \begin{macrocode} +\def\cPut#1(#2,#3)#4{% +% \end{macrocode} +% Select circular trigonometry and call |\xpct@PUT|. +% \begin{macrocode} + \COPY{0}{\xpct@CorRput} + \xpct@PUT{#1}(#2,#3){#4}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\rPut} +% \begin{macro}{\rPut*} +% |\rPut| puts the |#4| object in the |(#2,#3)| point at the |#1| position +% (rectangular version). +% Call |\xpct@rPut| (ordinary) or |\xpct@rPutstar| (starred). +% \begin{macrocode} +\def\rPut{\@ifstar + \xpct@rPutstar% + \xpct@rPut% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\Put} +% \begin{macro}{\Put*} +% |\Put| is equivalent to |\cPut| or |\rPut|, and has a starred form. +% Call |\xpct@Put| (ordinary) or |\xpct@Putstar| (starred). +% \begin{macrocode} +\def\Put{\@ifstar + \xpct@Putstar% + \xpct@Put% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\defaultPut} +% \begin{macro}{\xpct@defaultPut} +% |\defaultPut| is a declaration to fix default position (|c| or |r|) +% for the |\Put| command. It defines |\xpct@defaultPut| to be +% |\rPut| or |\cPut|. +% \begin{macrocode} +\def\defaultPut#1{\def\xpct@tempa{#1}\def\xpct@tempb{r} + \ifx\xpct@tempa\xpct@tempb + \xpct@Infopos#1 + \def\xpct@defaultPut{\rPut} + \else + \xpct@Infopos#1 + \def\xpct@tempc{c} + \ifx\xpct@tempa\xpct@tempc + \def\xpct@defaultPut{\cPut} + \else + \xpct@Warnbadpos + \fi\fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\highestlabel} +% The highest label for the starred |\Put| and |\rPut| commands. +% First we mesure the label, then we convert this length to |\unitlength|. +% This number is stored in |\xpct@rputmxhg|. +% \begin{macrocode} +\def\highestlabel#1{\settoheight{\xpct@bxh}{#1}% + \LENGTHDIVIDE{\xpct@bxh}{\unitlength}{\xpct@rputmxhg}} +% \end{macrocode} +% \end{macro} +% Private commands. Main command is |\xpct@PUT|, all other commands are +% intended to select appropiate geometry. +% \begin{macro}{\xpct@rPut} +% \begin{macro}{\xpct@rPutstar} +% We give the appropriate value to boolean |\rputstar|, select rectangular +% trigonometry and call |\xpct@PUT|. +% \begin{macrocode} +\def\xpct@rPutstar{\rputstartrue\COPY{1}{\xpct@CorRput}\xpct@PUT} +\def\xpct@rPut{\rputstarfalse\COPY{1}{\xpct@CorRput}\xpct@PUT} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@Putstar} +% \begin{macro}{\xpct@Put} +% |\Put| can take an optional argument. +% \begin{macrocode} +\def\xpct@Putstar{\@ifnextchar[{\xpct@@Putstar}{\xpct@@Put}} +\def\xpct@Put{\@ifnextchar[{\xpct@@@Put}{\xpct@@Put}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@@Putstar} +% \begin{macro}{\xpct@@Put} +% \begin{macro}{\xpct@@@Put} +% |\Put[pos]| is |\rPut*{pos}| (for ``bl'' like pos), +% |\cPut{pos}| (for ``SW'' like pos) and +% |\defaultPut| pos otherwise. +% +% |\Put*[pos]| is |\rPut*{pos}| +% or |\cPut{pos}| (only for ``SW'' like pos). +% \begin{macrocode} +\def\xpct@@Put(#1){\refsysPoint(#1)(\xpct@abscoorx,\xpct@abscoory) + \put(\xpct@abscoorx,\xpct@abscoory)} +\def\xpct@@Putstar[#1](#2)#3{\xpct@convtoang{#1}{\xpct@putpos}{\xpct@CorR} + \if\xpct@CorR c + \cPut{#1}(#2){#3} + \else + \rPut*{#1}(#2){#3} + \fi} +\def\xpct@@@Put[#1](#2)#3{\xpct@convtoang{#1}{\xpct@putpos}{\xpct@CorR} + \if\xpct@CorR c + \cPut{#1}(#2){#3} + \else + \if\xpct@CorR r + \rPut{#1}(#2){#3} + \else + \xpct@defaultPut{#1}(#2){#3} + \fi\fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@PUT} +% This command puts object |#4| in |(#2,#3)| (active reference), +% according to |#1| position. +% \begin{macrocode} +\def\xpct@PUT#1(#2,#3)#4{% +% \end{macrocode} +% Call |\xpct@alphaput| to compute |(\xpct@xPictsep,\xpct@yPictsep)|, +% displacement of |\Pictlabelsep| units in direction |#1|. +% Then, apply |\refsysxyVector| to get |(\xpct@Posx,\xpct@Posy)|, +% standard coordinates of vector |(\xpct@xPictsep,\xpct@yPictsep)|. +% \begin{macrocode} + \xpct@alphaput{#1}{\xpct@CorRput} + \refsysxyVector(\xpct@xPictsep,\xpct@yPictsep)(\xpct@Posx,\xpct@Posy) +% \end{macrocode} +% Compute |(\xpct@posx,\xpct@posy)|, standard coordinates of point |(#2,#3)|. +% \begin{macrocode} + \refsysPoint(#2,#3)(\xpct@posx,\xpct@posy) +% \end{macrocode} +% Call |\xpct@alphamove| to adjust |(\xpct@Posx,\xpct@Posy)| +% according to dimensions of |#4|. +% Then add |(\xpct@posx,\xpct@posy)| to |(\xpct@Posx,\xpct@Posy)|. +% \begin{macrocode} + \xpct@alphamove{#4}{\xpct@CorRput} + \VECTORADD(\xpct@posx,\xpct@posy)(\xpct@Posx,\xpct@Posy)(% + \xpct@Posx,\xpct@Posy) +% \end{macrocode} +% Now |(\xpct@Posx,\xpct@Posy)| is the absolute position where |#4| +% must go. +% \begin{macrocode} + \put(\xpct@Posx,\xpct@Posy){#4}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@alphaput} +% Computes displacement vector required by |#1| and stores it in +% |(\xpct@xPictsep},\xpct@yPictsep)|. +% \begin{macrocode} +\def\xpct@alphaput#1#2{\def\xpct@tempa{#1}\def\xpct@tempb{c}% + \ifx\xpct@tempa\xpct@tempb +% \end{macrocode} +% If |#1=c|, no displacement is required: +%|(\xpct@xPictsep},\xpct@yPictsep)=(0,0)|. +% \begin{macrocode} + \COPY{0}{\xpct@xPictsep}\COPY{0}{\xpct@yPictsep} + \else +% \end{macrocode} +% Else, call |\xpct@convtoang| to translate |#1| to a number (of degrees), +% \begin{macrocode} + \xpct@convtoang{#1}{\xpct@putpos}{\xpct@CorR} +% \end{macrocode} +% and compute |(\xpct@xPictsep},\xpct@yPictsep)|. +% \begin{macrocode} + \ifnum #2=0 + \DEGREESCOS{\xpct@putpos}{\xpct@cosine} + \DEGREESSIN{\xpct@putpos}{\xpct@sine} + \else + \qCOS{\xpct@putpos}{\xpct@cosine} + \qSIN{\xpct@putpos}{\xpct@sine} + \fi + \MULTIPLY{\Pictlabelsep}{\xpct@cosine}{\xpct@xPictsep} + \MULTIPLY{\Pictlabelsep}{\xpct@sine}{\xpct@yPictsep} + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@alphamove} +% Adjust |(\xpct@Posx,\xpct@Posy)| to required position, according to +% |#1| dimensions. If |#2| equals |0|, it uses circular trigonometry, else +% it uses square trigonometry. +% \begin{macrocode} +\def\xpct@alphamove#1#2{% +% \end{macrocode} +% Computes half of dimensions of |#1|, +% \begin{macrocode} + \xpct@halfbox{#1}{\xpct@amplada}{\xpct@altura} + \ifx\xpct@tempa\xpct@tempb + \else +% \end{macrocode} +% If required position is not centered, move |(\xpct@Posx,\xpct@Posy)| +% (circular or square cases). First, compute a unitary vector in +% |(\xpct@Posx,\xpct@Posy)| direction. +% \begin{macrocode} + \ifnum #2=0 + \UNITVECTOR(\xpct@Posx,\xpct@Posy)(\xpct@xdir,\xpct@ydir) + \else + \qUNITVECTOR(\xpct@Posx,\xpct@Posy)(\xpct@xdir,\xpct@ydir) +% \end{macrocode} +% If starred, change height to half |\xpct@rputmxhg|. +% \begin{macrocode} + \ifrputstar + \ifdim\xpct@ydir\p@=-1\p@ + \DIVIDE{\xpct@rputmxhg}{2}{\xpct@altura} + \fi + \fi + \fi +% \end{macrocode} +% Adjust |(\xpct@xdir,\xpct@ydir)| to |#1| dimensions. +% \begin{macrocode} + \MULTIPLY{\xpct@ydir}{\xpct@altura}{\xpct@ydir} + \MULTIPLY{\xpct@xdir}{\xpct@amplada}{\xpct@xdir} + \VECTORADD(\xpct@Posx,\xpct@Posy)(\xpct@xdir,\xpct@ydir)% + (\xpct@Posx,\xpct@Posy) + \fi +% \end{macrocode} +% Move |(\xpct@Posx,\xpct@Posy)| according to |#1| dimensions. +% \begin{macrocode} + \VECTORSUB(\xpct@Posx,\xpct@Posy)(\xpct@amplada,\xpct@altura)(% + \xpct@Posx,\xpct@Posy)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@convtoang} +% Literal specifiers in |\Put|-like commands must be converted to angles. +% |c| or |r| (circular or rectangular) distance is also selected. +% \begin{macrocode} +\def\xpct@convtoang#1#2#3{% + \def\xpct@tempc{#1} + \def\xpct@tempd{r}\ifx\xpct@tempc\xpct@tempd\COPY{0}{#2}\def#3{r}\else + \def\xpct@tempd{tr}\ifx\xpct@tempc\xpct@tempd\COPY{45}{#2}\def#3{r}\else + \def\xpct@tempd{t}\ifx\xpct@tempc\xpct@tempd\COPY{90}{#2}\def#3{r}\else + \def\xpct@tempd{tl}\ifx\xpct@tempc\xpct@tempd\COPY{135}{#2}\def#3{r}\else + \def\xpct@tempd{l}\ifx\xpct@tempc\xpct@tempd\COPY{180}{#2}\def#3{r} + \else + \def\xpct@tempd{bl}\ifx\xpct@tempc\xpct@tempd\COPY{-135}{#2} + \def#3{r}\else + \def\xpct@tempd{b}\ifx\xpct@tempc\xpct@tempd\COPY{-90}{#2} + \def#3{r}\else + \def\xpct@tempd{br}\ifx\xpct@tempc\xpct@tempd\COPY{-45}{#2} + \def#3{r}\else + \def\xpct@tempd{rtr}\ifx\xpct@tempc\xpct@tempd\COPY{22.5}{#2} + \def#3{r}\else + \def\xpct@tempd{ttr}\ifx\xpct@tempc\xpct@tempd\COPY{67.5}{#2} + \def#3{r}\else + \def\xpct@tempd{ttl}\ifx\xpct@tempc\xpct@tempd\COPY{112.5}{#2} + \def#3{r}\else + \def\xpct@tempd{ltl}\ifx\xpct@tempc\xpct@tempd\COPY{157.5}{#2} + \def#3{r}\else + \def\xpct@tempd{lbl}\ifx\xpct@tempc\xpct@tempd\COPY{-157.5}{#2} + \def#3{r}\else + \def\xpct@tempd{bbl}\ifx\xpct@tempc\xpct@tempd\COPY{-112.5}{#2} + \def#3{r}\else + \def\xpct@tempd{bbr}\ifx\xpct@tempc\xpct@tempd\COPY{-67.5}{#2} + \def#3{r}\else + \def\xpct@tempd{rbr}\ifx\xpct@tempc\xpct@tempd\COPY{-22.5}{#2} + \def#3{r}\else + \def\xpct@tempd{E}\ifx\xpct@tempc\xpct@tempd\COPY{0}{#2}\def#3{c}\else + \def\xpct@tempd{NE}\ifx\xpct@tempc\xpct@tempd\COPY{45}{#2}\def#3{c}\else + \def\xpct@tempd{N}\ifx\xpct@tempc\xpct@tempd\COPY{90}{#2}\def#3{c}\else + \def\xpct@tempd{NW}\ifx\xpct@tempc\xpct@tempd\COPY{135}{#2}\def#3{c}\else + \def\xpct@tempd{W}\ifx\xpct@tempc\xpct@tempd\COPY{180}{#2}\def#3{c}\else + \def\xpct@tempd{SW}\ifx\xpct@tempc\xpct@tempd\COPY{-135}{#2} + \def#3{c}\else + \def\xpct@tempd{S}\ifx\xpct@tempc\xpct@tempd\COPY{-90}{#2}\def#3{c}\else + \def\xpct@tempd{SE}\ifx\xpct@tempc\xpct@tempd\COPY{-45}{#2}\def#3{c}\else + \def\xpct@tempd{ENE}\ifx\xpct@tempc\xpct@tempd\COPY{22.5}{#2} + \def#3{c}\else + \def\xpct@tempd{NNE}\ifx\xpct@tempc\xpct@tempd\COPY{67.5}{#2} + \def#3{c}\else + \def\xpct@tempd{NNW}\ifx\xpct@tempc\xpct@tempd\COPY{112.5}{#2} + \def#3{c}\else + \def\xpct@tempd{WNW}\ifx\xpct@tempc\xpct@tempd\COPY{157.5}{#2} + \def#3{c}\else + \def\xpct@tempd{WSW}\ifx\xpct@tempc\xpct@tempd\COPY{-157.5}{#2} + \def#3{c}\else + \def\xpct@tempd{SSW}\ifx\xpct@tempc\xpct@tempd\COPY{-112.5}{#2} + \def#3{c}\else + \def\xpct@tempd{SSE}\ifx\xpct@tempc\xpct@tempd\COPY{-67.5}{#2} + \def#3{c}\else + \def\xpct@tempd{ESE}\ifx\xpct@tempc\xpct@tempd\COPY{-22.5}{#2} + \def#3{c}\else + \def\xpct@tempd{c}\ifx\xpct@tempc\xpct@tempd\COPY{0}{#2}\def#3{c}\else + \COPY{#1}{#2}\def#3{a} +\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi +\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi +\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@halfbox} +% Half of dimensions of a box. +% \begin{macrocode} +\def\xpct@halfbox#1#2#3{% + \settowidth\xpct@bxw{#1}% + \settoheight\xpct@bxh{#1}% + \LENGTHDIVIDE{\xpct@bxw}{\unitlength}{#2} + \LENGTHDIVIDE{\xpct@bxh}{\unitlength}{#3} + \MULTIPLY{0.5}{#2}{#2} + \MULTIPLY{0.5}{#3}{#3}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\qCOS} +% \begin{macro}{\qSIN} +% \begin{macro}{\qUNITVECTOR} +% Square versions of |\DEGREESCOS|, |\DEGREESSIN| and |\UNITVECTOR|. +% \begin{macrocode} +\def\qCOS#1#2{% + \ifdim #1\p@<-135\p@ + \ADD{360}{#1}{\xpct@angles}\qCOS{\xpct@angles}{#2} + \else + \ifdim #1\p@>225\p@ \SUBTRACT{#1}{360}{\xpct@angles} + \qCOS{\xpct@angles}{#2} + \else + \ifdim #1\p@<-45\p@ \DEGREESCOT{#1}{#2}\MULTIPLY{-1}{#2}{#2} + \else + \ifdim #1\p@<45\p@ \COPY{1}{#2} + \else + \ifdim #1\p@<135\p@ \DEGREESCOT{#1}{#2} + \else + \COPY{-1}{#2} + \fi + \fi + \fi + \fi + \fi +} +\def\qSIN#1#2{% + \ifdim #1\p@<-135\p@ + \ADD{360}{#1}{\xpct@angles}\qSIN{\xpct@angles}{#2} + \else + \ifdim #1\p@>225\p@ \SUBTRACT{#1}{360}{\xpct@angles} + \qSIN{\xpct@angles}{#2} + \else + \ifdim #1\p@<-45\p@ \COPY{-1}{#2} + \else + \ifdim #1\p@<45\p@ \DEGREESTAN{#1}{#2} + \else + \ifdim #1\p@<135\p@ \COPY{1}{#2} + \else + \DEGREESTAN{#1}{#2}\MULTIPLY{-1}{#2}{#2} + \fi + \fi + \fi + \fi + \fi +} +\def\qUNITVECTOR(#1,#2)(#3,#4){% + \VECTORCOPY(#1,#2)(#3,#4) + \ABSVALUE{#4}{\xpct@Ydir} + \ifdim \xpct@Ydir\p@ < 0.00005\p@ + \COPY{\xpct@maxnum}{\xpct@tan} + \else + \DIVIDE{#3}{#4}{\xpct@tan} + \fi + \ifdim #3\p@ > 0\p@ + \ifdim #4\p@ > 0\p@ + \ifdim #3\p@ > #4\p@ + \COPY{1}{#3}\DIVIDE{#4}{\xpct@tan}{#4} + \else + \COPY{1}{#4}\COPY{\xpct@tan}{#3} + \fi + \else + \ifdim #3\p@ > -#4\p@ + \COPY{1}{#3}\DIVIDE{-#4}{\xpct@tan}{#4} + \else + \COPY{-1}{#4}\MULTIPLY{-1}{\xpct@tan}{#3} + \fi + \fi + \else + \ifdim #4\p@ > 0\p@ + \ifdim -#3\p@ > #4\p@ + \COPY{-1}{#3}\DIVIDE{-#4}{\xpct@tan}{#4} + \else + \COPY{1}{#4}\COPY{\xpct@tan}{#3} + \fi + \else + \ifdim #3\p@ > #4\p@ + \COPY{-1}{#4}\COPY{-\xpct@tan}{#3} + \else + \COPY{-1}{#3}\DIVIDE{#4}{\xpct@tan}{#4} + \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \subsection{\cs{multiput} extensions} +% User commands: |\multicPut|, |\multirPut|, |\multiPut|; +% |\multicPlot|, |\multirPlot|, |\multiPlot|. +% |\multirPut|, |\multiPut|, |\multirPlot|, and |\multiPlot| +% have starred versions. +% \begin{macro}{\multicPut} +% Define |\xpct@mPut| as |\cPut{#1}| and call |\xpct@@mPut|. +% \begin{macrocode} +\def\multicPut#1{\def\xpct@mPut{\cPut{#1}}\xpct@@mPut} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\multirPut} +% \begin{macro}{\multirPut*} +% Call |\xpct@multirPut| or |\xpct@multirPutstar| (if starred). +% \begin{macrocode} +\def\multirPut{\@ifstar + \xpct@multirPutstar% + \xpct@multirPut% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\multiPut} +% \begin{macro}{\multiPut*} +% Call |\xpct@multiPut| or |\xpct@multiPutstar| (if starred). +% \begin{macrocode} +\def\multiPut{\@ifstar + \xpct@multiPutstar% + \xpct@multiPut% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@multirPutstar} +% \begin{macro}{\xpct@multirPut} +% Define |\xpct@mPut| as |\rPut*{#1}| or |\rPut{#1}| and call |\xpct@@mPut|. +% \begin{macrocode} +\def\xpct@multirPutstar#1{\def\xpct@mPut{\rPut*{#1}}\xpct@@mPut} +\def\xpct@multirPut#1{\def\xpct@mPut{\rPut{#1}}\xpct@@mPut} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@multiPut} +% \begin{macro}{\xpct@multiPutstar} +% |\multiPut| can take an optional argument. +% \begin{macrocode} +\def\xpct@multiPut{\@ifnextchar[{\xpct@@@multiPut}{\xpct@@multiPut}} +\def\xpct@multiPutstar{\@ifnextchar[{\xpct@@@multiPutstar}{\xpct@@multiPutstar}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@@multiPut} +% \begin{macro}{\xpct@@multiPutstar} +% Define |\xpct@mPut| as |\Put| or |\Put*| and call |\xpct@@mPut|. +% \begin{macrocode} +\def\xpct@@multiPut{\def\xpct@mPut{\Put}\xpct@@mPut} +\def\xpct@@multiPutstar{\def\xpct@mPut{\Put*}\xpct@@mPut} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@@@multiPut} +% \begin{macro}{\xpct@@@multiPutstar} +% Define |\xpct@mPut| as |\Put[#1]| or |\Put*[#1]| and call |\xpct@@mPut|. +% \begin{macrocode} +\def\xpct@@@multiPut[#1]{\def\xpct@mPut{\Put[#1]}\xpct@@mPut} +\def\xpct@@@multiPutstar[#1]{\def\xpct@mPut{\Put*[#1]}\xpct@@mPut} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@@mPut} +% \begin{macro}{\xpct@mPut} +% |\xpct@@mPut| is the main macro about |\multiPut|-like commands. +% |\xpct@mPut| is already defined as the appropiate |\Put| command. +% \begin{macrocode} +\def\xpct@@mPut(#1,#2)(#3,#4)#5#6{% +% \end{macrocode} +% Use counter |multiput| to count iterations. +% |(\xpct@@abscoorx,\xpct@@abscoory)| is the point to be ploted in each +% iteration. +% \begin{macrocode} + \COPY{#1}\xpct@@abscoorx\COPY{#2}\xpct@@abscoory + \setcounter{multiput}{0}% + \@whilenum\value{multiput}<#5 \do +% \end{macrocode} +% Plot the point, translate it, and update conter. +% \begin{macrocode} + {\xpct@mPut(\xpct@@abscoorx,\xpct@@abscoory){#6} + \ADD{#3}\xpct@@abscoorx\xpct@@abscoorx + \ADD{#4}\xpct@@abscoory\xpct@@abscoory + \stepcounter{multiput}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\multicPlot} +% Execute |\cPut| and iterates itself while next character be |(|. +% \begin{macrocode} +\def\multicPlot#1#2(#3){\cPut{#1}(#3){#2}\@ifnextchar({\multicPlot{#1}{#2}}{}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\multirPlot} +% \begin{macro}{\multirPlot*} +% |\multirPlot| can take a starred form. Call |\xpct@multirPlot| or, +% if starred, |\xpct@multirPlotstar|. +% \begin{macrocode} +\def\multirPlot{\@ifstar + \xpct@multirPlotstar% + \xpct@multirPlot% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\multiPlot} +% \begin{macro}{\multiPlot*} +% |\multiPlot| can take a starred form. Call |\xpct@multiPlot| or, +% if starred, |\xpct@multiPlotstar|. +% \begin{macrocode} +\def\multiPlot{\@ifstar + \xpct@multiPlotstar% + \xpct@multiPlot% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@multirPlotstar} +% \begin{macro}{\xpct@multirPlot} +% Execute |\rPut*| or |\rPut| and iterates itself while next character be |(|. +% \begin{macrocode} +\def\xpct@multirPlotstar#1#2(#3){\rPut*{#1}(#3){#2} + \@ifnextchar({\xpct@multirPlotstar{#1}{#2}}{}} +\def\xpct@multirPlot#1#2(#3){\rPut{#1}(#3){#2} + \@ifnextchar({\xpct@multirPlot{#1}{#2}}{}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@multiPlotstar} +% \begin{macro}{\xpct@multiPlot} +% |\multiPlot| (and |\multiPlot*|) can take an optional argument. +% We have four cases: (starred or not) and (optional argument or not). +% \begin{macrocode} +\def\xpct@multiPlotstar{% + \@ifnextchar[{\xpct@@@multiPlotstar}{\xpct@@multiPlotstar}} +\def\xpct@multiPlot{\@ifnextchar[{\xpct@@@multiPlot}{\xpct@@multiPlot}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@@multiPlot} +% \begin{macro}{\xpct@@@multiPlot} +% \begin{macro}{\xpct@@multiPlotstar} +% \begin{macro}{\xpct@@@multiPlotstar} +% Execute |\Put| (or |\Put*|) and iterates itself while next character be |(|. +% \begin{macrocode} +\def\xpct@@multiPlot#1(#2){\Put(#2){#1}\@ifnextchar({\xpct@@multiPlot{#1}}{}} +\def\xpct@@@multiPlot[#1]#2(#3){\Put[#1](#3){#2} + \@ifnextchar({\xpct@@@multiPlot[#1]{#2}}{}} +\def\xpct@@multiPlotstar#1(#2){\Put*(#2){#1} + \@ifnextchar({\xpct@@multiPlotstar{#1}}{}} +\def\xpct@@@multiPlotstar[#1]#2(#3){\Put*[#1](#3){#2} + \@ifnextchar({\xpct@@@multiPlotstar[#1]{#2}}{}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \subsection{Strigth lines and vectors} +% \begin{macro}{\xLINE} +% \begin{macro}{\strline} +% Compute standard coordinates of two points and call |\xpct@strline| +% to plot a line. +% \begin{macrocode} +\def\xLINE(#1)(#2){% + \refsysPoint(#1)(\xpct@xzero,\xpct@yzero) + \refsysPoint(#2)(\xpct@xone,\xpct@yone) + \xpct@strline(\xpct@xzero,\xpct@yzero)(\xpct@xone,\xpct@yone)} +\let\strline\xLINE +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@strline} +% This command calls the |\segment| command from |curve2e| +% (or |\LINE|, for old versions of |curve2e|). +% \begin{macrocode} +\def\xpct@strline{\@killglue\@ifundefined{segment}{\LINE}{\segment}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xVECTOR} +% Compute standard coordinates of two points and call |\VECTOR| +% to plot a vector. +% \begin{macrocode} +\def\xVECTOR(#1)(#2){% + \refsysPoint(#1)(\xpct@xzero,\xpct@yzero) + \refsysPoint(#2)(\xpct@xone,\xpct@yone) + \VECTOR(\xpct@xzero,\xpct@yzero)(\xpct@xone,\xpct@yone)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xtrivVECTOR} +% Compute standard coordinates of two points and call |\xpct@xtrivVECTOR| +% to plot a `triv' vector. +% \begin{macrocode} +\def\xtrivVECTOR(#1)(#2){% + \refsysPoint(#1)(\xpct@xzeropoint,\xpct@yzeropoint) + \refsysPoint(#2)(\xpct@xonepoint,\xpct@yonepoint) + \xpct@xtrivVECTOR(\xpct@xzeropoint,\xpct@yzeropoint)(% + \xpct@xonepoint,\xpct@yonepoint)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\arrowsize} +% Store dimensions of triv arrows. +% to plot a vector. +% \begin{macrocode} +\def\arrowsize#1#2{\COPY{#1}{\xpct@xarrowlen} + \COPY{#2}{\xpct@yarrowlen}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@xtrivVECTOR} +% Plot a stright line, compute size of arrowhead and call |\xpct@arrow| +% to plot it. +% \begin{macrocode} +\def\xpct@xtrivVECTOR(#1)(#2){% + \xpct@strline(#1)(#2) + \VECTORSUB(#2)(#1)(\xpct@xarrow,\xpct@yarrow) + \VECTORNORM(\xpct@xarrow,\xpct@yarrow){\xpct@xarrowunit} + \DIVIDE{\xpct@xarrow}{\xpct@xarrowunit}{\xpct@xarrow} + \DIVIDE{\xpct@yarrow}{\xpct@xarrowunit}{\xpct@yarrow} + \xpct@arrow(#2){\xpct@xarrow}{\xpct@yarrow}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@arrow} +% Make an arrowhead as a small picture. +% \begin{macrocode} +\def\xpct@arrow(#1)#2#3{\begingroup% + \referencesystem(#1)(#2,#3)(-#3,#2) + \Put(0,0){\setlength{\unitlength}{1pt}% + \begin{Picture}(0,0)(0,0)\cartesianreference + \xLINE(-\xpct@xarrowlen,\xpct@yarrowlen)(0,0) + \xLINE(0,0)(-\xpct@xarrowlen,-\xpct@yarrowlen) + \end{Picture}}\endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\zerovector} +% \begin{macro}{\zerotrivvector} +% To have an arrowhead, draw a very short vector (of |0.01\unitlength|). +% \begin{macrocode} +\def\zerovector(#1){% + \UNITVECTOR(#1)(\xpct@dirx,\xpct@diry) + \SCALARVECTORPRODUCT{0.01}(\xpct@dirx,\xpct@diry)(\xpct@dirx,\xpct@diry) + \xVECTOR(0,0)(\xpct@dirx,\xpct@diry)} +\def\zerotrivvector(#1){% + \UNITVECTOR(#1)(\xpct@dirx,\xpct@diry) + \SCALARVECTORPRODUCT{0.01}(\xpct@dirx,\xpct@diry)(\xpct@dirx,\xpct@diry) + \xtrivVECTOR(0,0)(\xpct@dirx,\xpct@diry)} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xline} +% \begin{macro}{\xvector} +% \begin{macro}{\xtrivvector} +% Standard syntax strigth lines and vectors. +% Call |\xpct@xline| to compute adequate coordinates of line or vector ends. +% Then call |\xLINE|, |\xVECTOR| or |\xtrivVECTOR| command. +% \begin{macrocode} +\def\xline(#1,#2)#3{% + \xpct@xline(#1,#2){#3} + \xLINE(0,0)(\xpct@@xdir,\xpct@@ydir)} + +\def\xvector(#1,#2)#3{% + \ifdim #3 pt = 0 pt \zerovector(#1,#2) + \else + \xpct@xline(#1,#2){#3} + \xVECTOR(0,0)(\xpct@@xdir,\xpct@@ydir) + \fi} + +\def\xtrivvector(#1,#2)#3{% + \ifdim #3 pt = 0 pt \zerotrivvector(#1,#2) + \else + \xpct@xline(#1,#2){#3} + \xtrivVECTOR(0,0)(\xpct@@xdir,\xpct@@ydir) + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@xline} +% Calculate the coordinates of the endpoint of |\xline(#1,#2){#3}| and stores +% them in |(\xpct@@xdir,\xpct@@ydir)|. +% \begin{macrocode} +\def\xpct@xline(#1,#2)#3{% + \ABSVALUE{#1}{\xpct@modx} + \ifdim \xpct@modx pt < 0.0001 pt + \COPY{0}{\xpct@@xdir} + \ifdim #2\p@>\z@ \COPY{#3}{\xpct@@ydir} + \else \MULTIPLY{-1}{#3}{\xpct@@ydir} + \fi + \else + \DIVIDE{#1}{\xpct@modx}{\xpct@@xdir} + \DIVIDE{#2}{\xpct@modx}{\xpct@@ydir} + \SCALARVECTORPRODUCT{#3}(\xpct@@xdir,\xpct@@ydir)(% + \xpct@@xdir,\xpct@@ydir) + \fi} +% \end{macrocode} +% \end{macro} +% \subsection{Polygons and polylines} +% \begin{macro}{\Polyline} +% This command plots a line between the two first points and, if next +% character is |(|, supresses first point and iterates itself. +% \begin{macrocode} +\def\Polyline(#1)(#2){% + \xLINE(#1)(#2)\@ifnextchar({\Polyline(#2)}{}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\Polygon} +% Store the first point in |(\xpct@firstx,\xpct@firsty)| and call +% |\xpct@Polygon|. +% \begin{macrocode} +\def\Polygon(#1,#2)(#3){% + \COPY{#1}{\xpct@firstx}\COPY{#2}{\xpct@firsty} + \xpct@Polygon(#1,#2)(#3)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@Polygon} +% This command plots a line between the two first points and, if next +% character is |(|, supresses first point and iterates itself. +% When finished, adds a closing line to the previously stored first point. +% \begin{macrocode} +\def\xpct@Polygon(#1)(#2){% + \xLINE(#1)(#2)\@ifnextchar({\xpct@Polygon(#2)}{% + \xLINE(#2)(\xpct@firstx,\xpct@firsty)}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\regularPolygon} +% |\regularPolygon| can take an optional argument. +% \begin{macrocode} +\def\regularPolygon{% + \@ifnextchar[{\xpct@regPolygon}{\xpct@@regPolygon}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@@regPolygon} +% Default for optional argument is |0|. +% \begin{macrocode} +\def\xpct@@regPolygon#1#2{\xpct@regPolygon[0]{#1}{#2}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@regPolygon} +% |\xpct@regPolygon[#1]{#2}{#3}| uses the |xpct@counta| counter to +% plot |#3| lines, in polar coordinates with |#2| radius, +% startint with angle |#1| and using $360/|#3|$ to +% incrementing angle in each step. +% \begin{macrocode} +\def\xpct@regPolygon[#1]#2#3{\begingroup% + \polarreference\degreesangles + \setcounter{xpct@counta}{0}% + \setcounter{xpct@countb}{#3}% + \DIVIDE{360}{#3}{\xpct@angles} + \COPY{#1}{\xpct@anglea} + \@whilenum\value{xpct@counta}<\value{xpct@countb} \do {% + \ADD{\xpct@anglea}{\xpct@angles}{\xpct@angleb} + \xLINE(#2,\xpct@anglea)(#2,\xpct@angleb) + \COPY{\xpct@angleb}{\xpct@anglea}\stepcounter{xpct@counta}} + \endgroup} +% \end{macrocode} +% \end{macro} +% \subsection{Quadratic curves} +% \begin{macro}{\xpct@ctrlpoint} +% The main command in this section is |\xpct@ctrlpoint|. +% It computes the control point in a quadratic Bezier curve +% from the coordinates and direction vectors of ending points. +% \begin{macrocode} +\def\xpct@ctrlpoint(#1,#2)(#3,#4)(#5,#6)(#7,#8){% + \DETERMINANT(#3,#4;#7,#8)\xpct@detA + \DETERMINANT(#1,#2;#3,#4)\xpct@detB + \DETERMINANT(#5,#6;#7,#8)\xpct@detC + \DETERMINANT(#3,#7;\xpct@detB,\xpct@detC)\xpct@detD + \DETERMINANT(#4,#8;\xpct@detB,\xpct@detC)\xpct@detE + \ABSVALUE{\xpct@detA}{\xpct@@detA} + \ABSVALUE{\xpct@detD}{\xpct@@detD} + \ABSVALUE{\xpct@detE}{\xpct@@detE} + \ifdim \xpct@@detA pt<0.00005 pt +% \end{macrocode} +% If |\xpct@detA| approaches zero, matrix is singular or close to singular. +% Then tangent lines may be parallel or coincide. +% \begin{macrocode} + \ifdim \xpct@@detD pt<0.00005 pt %\xpct@detD pt=0 pt + \ifdim \xpct@@detE pt<0.00005 pt %\xpct@detE pt=0 pt +% \end{macrocode} +% Indeterminate system. The curve is a straight line. +% We take (as reference point) middle point between end points. +% \begin{macrocode} + \ADD{#1}{#5}{\xpct@solx}\DIVIDE{\xpct@solx}{2}{\xpct@solx} + \ADD{#2}{#6}{\xpct@soly}\DIVIDE{\xpct@soly}{2}{\xpct@soly} + \fi\else +% \end{macrocode} +% Inconsistent case. Return a warning and undefine control point. +% \begin{macrocode} + \xpct@WarnIncSys(#1,#2)(#5,#6) + \let\xpct@solx\undefined\let\xpct@soly\undefined + \fi + \else +% \end{macrocode} +% This is the regular case. +% \begin{macrocode} + \DIVIDE{\xpct@detD}{\xpct@detA}{\xpct@solx} + \DIVIDE{\xpct@detE}{\xpct@detA}{\xpct@soly} + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\qCurve} +% This macro accepts two alternative syntax (directions given by a vector +% or by an angle). +% \begin{macrocode} +\def\qCurve(#1){\@ifnextchar({\xpct@@qCurve(#1)}{\xpct@@@qCurve(#1)}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@@qCurve} +% Compute standard coordinates of points and vectors and call |\xpct@qCurve|. +% \begin{macrocode} +\def\xpct@@qCurve(#1)(#2)(#3)(#4){% + \refsysPoint(#1)(\xpct@@xzero,\xpct@@yzero) + \refsysPoint(#3)(\xpct@@xone,\xpct@@yone) + \refsysVector(#2)(\xpct@@dxzero,\xpct@@dyzero) + \refsysVector(#4)(\xpct@@dxone,\xpct@@dyone) + \xpct@qCurve(\xpct@@xzero,\xpct@@yzero)(\xpct@@dxzero,\xpct@@dyzero)(% + \xpct@@xone,\xpct@@yone)% + (\xpct@@dxone,\xpct@@dyone)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@@@qCurve} +% Translate direction angles to vectors and call |\qCurve|. +% \begin{macrocode} +\def\xpct@@@qCurve(#1)#2(#3)#4{% + \ifpolar + \qCurve(#1)(1,#2)(#3)(1,#4) + \else + \DEGREESCOS{#2}{\xpct@angxz} + \DEGREESSIN{#2}{\xpct@angyz} + \DEGREESCOS{#4}{\xpct@angxo} + \DEGREESSIN{#4}{\xpct@angyo} + \qCurve(#1)(\xpct@angxz,\xpct@angyz)(#3)% + (\xpct@angxo,\xpct@angyo)\fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@qCurve} +% Call |\xpct@ctrlpoint| to compute control point; then, use |\qbezier| +% to plot the curve. If the control point is undefined, nothing is drawn. +% \begin{macrocode} +\def\xpct@qCurve(#1)(#2)(#3)(#4){% + \xpct@ctrlpoint(#1)(#2)(#3)(#4) + \ifx\xpct@solx\undefined + \else + \qbezier(#1)(\xpct@solx,\xpct@soly)(#3)\fi\ignorespaces} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PlotQuadraticCurve} +% Try between the two alternative sintax. +% \begin{macrocode} +\def\PlotQuadraticCurve(#1){% + \@ifnextchar({\xpct@PlotQuadraticCurve(#1)}{% + \xpct@@PlotQuadraticCurve(#1)}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@PlotQuadraticCurve} +% \begin{macro}{\xpct@@PlotQuadraticCurve} +% Call |\qCurve| and iterate |\PlotQuadraticCurve|. +% \begin{macrocode} +\def\xpct@PlotQuadraticCurve(#1)(#2)(#3)(#4){% + \qCurve(#1)(#2)(#3)(#4) + \@ifnextchar({\PlotQuadraticCurve(#3)(#4)}{}} +\def\xpct@@PlotQuadraticCurve(#1)#2(#3)#4{% + \qCurve(#1){#2}(#3){#4} + \@ifnextchar({\PlotQuadraticCurve(#3){#4}}{}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \subsection{Conic sections and arcs} +% \begin{macro}{\xpct@circulararc} +% \begin{macro}{\xpct@hyperbolicarc} +% \begin{macro}{\xpct@parabolicarc} +% Parametric equations of circular, hyperbolic and parabolic arcs +% defined as vector functions. +% \begin{macrocode} +\newvectorfunction{\xpct@circulararc}{% +% \end{macrocode} +% Unit circle equation $x^2+y^2=1$ can be parameterized as +% $f(t)=(\cos t,\sin t)$. +% If the angles are measured in degrees, the derivative is not correct. +% Should be multiplied by $\pi/180$, but because what we want is the +% direction of the derivative, we will not do. +% \begin{macrocode} + \ifdegrees + \DEGREESCOS{\t}{\x} + \DEGREESSIN{\t}{\y} + \COPY{\x}{\Dy} + \MULTIPLY{-1}{\y}{\Dx} + \else + \COS{\t}{\x} + \SIN{\t}{\y} + \COPY{\x}{\Dy} + \MULTIPLY{-1}{\y}{\Dx} + \fi} +\newvectorfunction{\xpct@hyperbolicarc}{% +% \end{macrocode} +% Hyperbola $x^2-y^2=1$, parameterized as $f(t)=\frac12(t+1/t,t-1/t)$. +% This derivative is not correct. +% We should divide it by $t$, but that did not change direction. +% \begin{macrocode} + \DIVIDE{1}{\t}{\xpct@invt} + \ADD{\t}{\xpct@invt}{\x} + \SUBTRACT{\t}{\xpct@invt}{\y} + \MULTIPLY{0.5}{\x}{\x} + \MULTIPLY{0.5}{\y}{\y} + \COPY{\x}{\Dy} + \COPY{\y}{\Dx}} +% \end{macrocode} +% Parabola $x=y^2$ (or $f(t)=(t^2,t)$). +% \begin{macrocode} +\newvectorfunction{\xpct@parabolicarc}{% + \COPY{\t}{\y} + \COPY{1}{\Dy} + \SQUARE{\t}{\x} + \MULTIPLY{2}{\t}{\Dx}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\circularArc} +% \begin{macro}{\xArc} +% A circular arc is an elliptic arc with equal semiaxes. +% \begin{macrocode} +\def\circularArc#1#2#3{\ellipticArc{#1}{#1}{#2}{#3}} +\let\xArc\circularArc +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\ellipticArc} +% To draw an arc of ellipse of semiaxes |#1| and |#2|, +% scale the axes and draw a circular arc. +% |\defaultplotdivs| is the number of subintervals we divide |[#3,#4]|. +% \begin{macrocode} +\def\ellipticArc#1#2#3#4{% + \begingroup + \cartesianreference + \changereferencesystem(0,0)(#1,0)(0,#2) + \PlotParametricFunction[\defaultplotdivs]{\xpct@circulararc}{#3}{#4} + \endgroup\ignorespaces} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\Circle} +% \begin{macro}{\Ellipse} +% A circle (or ellipse) is a circular (elliptic) arc of amplitude $2\pi$. +% \begin{macrocode} +\def\Circle#1{\begingroup\radiansangles + \circularArc{#1}{0}{\numberTWOPI}\endgroup\ignorespaces} +\def\Ellipse#1#2{\begingroup\radiansangles + \ellipticArc{#1}{#2}{0}{\numberTWOPI} + \endgroup\ignorespaces} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\lhyperbolicArc} +% Change $x$-axis to $-x$, then draw a right hyperbolic arc. +% \begin{macrocode} +\def\lhyperbolicArc#1#2#3#4{% + \begingroup + \changereferencesystem(0,0)(-1,0)(0,1) + \rhyperbolicArc{#1}{#2}{#3}{#4} + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\rhyperbolicArc} +% Call |\xpct@hypluy| to compute extreme variables, then draw a +% normalized arc of hyperbola. +% \begin{macrocode} +\def\rhyperbolicArc#1#2#3#4{% + \xpct@hypluy{#2}{#3}{\xpct@uone} + \xpct@hypluy{#2}{#4}{\xpct@utwo} + \xpct@hyperbolicArc{#1}{#2}{\xpct@uone}{\xpct@utwo}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@hyperbolicArc} +% To draw an arc of (right branch of) hyperbola of semiaxes |#1| and |#2|, +% scale the axes and draw a normalized arc of hyperbola. +% |\defaultplotdivs| is the number of subintervals we divide |[#3,#4]|. +% \begin{macrocode} +\def\xpct@hyperbolicArc#1#2#3#4{% + \begingroup + \cartesianreference + \changereferencesystem(0,0)(#1,0)(0,#2) + \PlotParametricFunction[\defaultplotdivs]{\xpct@hyperbolicarc}{#3}{#4} + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\lHyperbola} +% Change $x$-axis to $-x$, then draw a right hyperbola branch. +% \begin{macrocode} +\def\lHyperbola#1#2#3#4{% + \begingroup + \changereferencesystem(0,0)(-1,0)(0,1) + \rHyperbola{#1}{#2}{#3}{#4} + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\rHyperbola} +% Use |\xpct@hypconsist| to ensure parameters consistency, +% call |\xpct@hyperbolalastu| to compute extreme variable, +% then plot the right hyperbola branch. +% Divide the curve into two arcs to ensure that +% it includes point |(#1,0)|. +% \begin{macrocode} +\def\rHyperbola#1#2#3#4{% + \def\xpct@hycons{}\xpct@hypconsist{#1}{#3}% + \ifx\xpct@hycons\undefined + \else + \xpct@hyperbolalastu{#1}{#2}{#3}{#4} + \DIVIDE{1}{\xpct@umax}{\xpct@umin} + \xpct@hyperbolicArc{#1}{#2}{\xpct@umin}{1} + \xpct@hyperbolicArc{#1}{#2}{1}{\xpct@umax} + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\Hyperbola} +% Use |\xpct@hypconsist| to ensure parameters consistency, +% call |\xpct@hyperbolalastu| to compute extreme variable, +% then plot the two branches. +% \begin{macrocode} +\def\Hyperbola#1#2#3#4{% + \begingroup + \def\xpct@hycons{}\xpct@hypconsist{#1}{#3}% + \ifx\xpct@hycons\undefined + \else + \xpct@hyperbolalastu{#1}{#2}{#3}{#4} + \DIVIDE{1}{\xpct@umax}{\xpct@umin} + \xpct@hyperbolicArc{#1}{#2}{\xpct@umin}{1} + \xpct@hyperbolicArc{#1}{#2}{1}{\xpct@umax} + \changereferencesystem(0,0)(-1,0)(0,1) + \xpct@hyperbolicArc{#1}{#2}{\xpct@umin}{1} + \xpct@hyperbolicArc{#1}{#2}{1}{\xpct@umax} + \fi\endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@hypconsist} +% Ensures consistency of parameters in |\Hyperbola|-like commands. +% This curve is not defined for $x<a$ values. +% \begin{macrocode} +\def\xpct@hypconsist#1#2{% + \ifnum #1<#2\else\xpct@ErrHypCons + \let\xpct@hycons\undefined\fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@hyperbolalastu} +% Compute the max value of parameter ensuring restrictions +% |x<#3| and |y<#4|. +% \begin{macrocode} +\def\xpct@hyperbolalastu#1#2#3#4{% + \xpct@hyplux{#1}{#3}{\xpct@umaxx} + \xpct@hypluy{#2}{#4}{\xpct@umaxy} + \MIN{\xpct@umaxx}{\xpct@umaxy}{\xpct@umax}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@hyplux} +% To compute the max value of parameter ensuring restriction +% |x<=#2|, solve equation |#2=(1/2)#1(u+1/u)| (|u=#3|). +% \begin{macrocode} +\def \xpct@hyplux#1#2#3{% + \DIVIDE{#2}{#1}{\xpct@xa} + \SQUARE{\xpct@xa}{#3} + \SUBTRACT{#3}{1}{#3} + \SQUAREROOT{#3}{\xpct@@umaxx} + \ADD{\xpct@xa}{\xpct@@umaxx}{#3}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@hypluy} +% To compute the max value of parameter ensuring restriction +% |y<#2|, solve equation |#2=(1/2)#1(u-1/u)| (|u=#3|). +% \begin{macrocode} +\def \xpct@hypluy#1#2#3{% + \DIVIDE{#2}{#1}{\xpct@xa} + \SQUARE{\xpct@xa}{#3} + \ADD{#3}{1}{#3} + \SQUAREROOT{#3}{\xpct@@umaxx} + \ADD{\xpct@xa}{\xpct@@umaxx}{#3}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\parabolicArc} +% To draw an arc of parabola +% scale the $x$-axis and draw a normalized arc of parabola. +% |\defaultplotdivs| is the number of subintervals we divide |[#2,#3]|. +% \begin{macrocode} +\def\parabolicArc#1#2#3{% + \begingroup + \changereferencesystem(0,0)(#1,0)(0,1) + \PlotParametricFunction[\defaultplotdivs]{\xpct@parabolicarc}{#2}{#3} + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\Parabola} +% Call |\xpct@parabolalasty| to compute extreme variable, then plot +% the parabola. Divide the curve into two arcs to +% ensure that it includes point |(0,0)|. +% \begin{macrocode} +\def\Parabola#1#2#3{% + \xpct@parabolalasty{#1}{#2}{#3} + \parabolicArc{#1}{-\xpct@maxy}{0} + \parabolicArc{#1}{0}{\xpct@maxy}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@parabolalasty} +% Ensure restrictions |x<=#2|, |y<=#3|: solve equation |#2=#1 y^2|. +% Then, |\xpct@maxy=min(y,#3)|. +% \begin{macrocode} +\def\xpct@parabolalasty#1#2#3{% + \ABSVALUE{#1}{\xpct@@maxy} + \DIVIDE{#2}{\xpct@@maxy}{\xpct@@maxy} + \SQUAREROOT{\xpct@@maxy}{\xpct@maxy} + \MIN{\xpct@maxy}{#3}{\xpct@maxy}} +% \end{macrocode} +% \end{macro} +% \subsection{Graphing functions} +% \begin{macro}{\PlotFunction} +% This command can take an optional argument. +% \begin{macrocode} +\def\PlotFunction{% + \@ifnextchar[{\xpct@iterateplotfunction}{\xpct@plotfunction}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@iterateplotfunction} +% Compute |\xpct@step| as |(#4-#3)/#1| and iterate |\xpct@plotfunction| +% |#1| times. +% \begin{macrocode} +\def\xpct@iterateplotfunction[#1]#2#3#4{% +\setcounter{xpct@step}{0}% +\COPY{#3}{\xpct@oldt} +\SUBTRACT{#4}{#3}{\xpct@step} +\DIVIDE{\xpct@step}{#1}{\xpct@step} +\@whilenum \value{xpct@step}<#1 \do + {\ADD{\xpct@oldt}{\xpct@step}{\xpct@newt} + \xpct@plotfunction{#2}{\xpct@oldt}{\xpct@newt} + \stepcounter{xpct@step}% + \COPY\xpct@newt\xpct@oldt +}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotfunction} +% Draw graph of |#1| function between |#2| and |#3|. +% \begin{macrocode} +\def\xpct@plotfunction#1#2#3{\@killglue% +% \end{macrocode} +% Compute $f$ and $f'$ in |#2| and |#3|, and apply |\PlotxyDyData|. +% \begin{macrocode} + #1{#2}{\yzero}{\Dyzero}% + #1{#3}{\yone}{\Dyone}% + \PlotxyDyData(#2,\yzero,\Dyzero)(#3,\yone,\Dyone) + \ifx\xpct@solx\undefined +% \end{macrocode} +% If tangent vectors are parallel, divide the interval into two halves +% and recall |\xpct@plotfunction|. +% \begin{macrocode} + \ADD{#2}{#3}{\xpct@middt} + \MULTIPLY{0.5}{\xpct@middt}{\xpct@middt} + \xpct@plotfunction{#1}{#2}{\xpct@middt} + \xpct@plotfunction{#1}{\xpct@middt}{#3} + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PlotPointsOfFunction} +% The |\PlotPointsOfFunction| command is essentialy equal to +% |\xpct@iterateplotfunction|, +% but instead of a curve between two adjacent points, +% plots a |\pointmark| (user can redefine |\pointmark|). +% \begin{macrocode} +\def\PlotPointsOfFunction#1#2#3#4{% + \setcounter{xpct@step}{0}% +\COPY{#3}{\xpct@oldt} +\SUBTRACT{#4}{#3}{\xpct@step} +\DIVIDE{\xpct@step}{#1}{\xpct@step} +\ADD{#1}{1}{\xpct@lastt} +\@whilenum \value{xpct@step}<\xpct@lastt \do + {\ADD{\xpct@oldt}{\xpct@step}{\xpct@newt} + #2{\xpct@oldt}{\xpct@oldy}{\xpct@oldDy} + \Put[c](\xpct@oldt,\xpct@oldy){\pointmark} + \stepcounter{xpct@step}% + \COPY\xpct@newt\xpct@oldt +}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PlotxyDyData} +% |\PlotxyDyData(x0,y0,y0')(x1,y1,y1')(x2,y2,y2')...| +% uses |\qCurve| to draw a curve between |(x0,y0)| and |(x1,y1)| +% with tangent vectors |(1,y0')| and |(1,y1')|, then iterates itself. +% \begin{macrocode} +\def\PlotxyDyData(#1,#2,#3)(#4,#5,#6){% + \qCurve(#1,#2)(1,#3)(#4,#5)(1,#6) + \@ifnextchar({\PlotxyDyData(#4,#5,#6)}{}} +% \end{macrocode} +% \end{macro} +% \subsection{Graphing parametric curves} +% \begin{macro}{\PlotParametricFunction} +% Plot vectorial function |#2| between the parameter values |#3| and |#4|. +% It can take an optional argument |#1|. +% \begin{macrocode} +\def\PlotParametricFunction{% + \@ifnextchar[{\xpct@iterateplotpfunction}{\xpct@plotpfunction}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@iterateplotpfunction} +% Divide |[#3,#4]| in |#1| pieces, then iterate |\xpct@plotpfunction| |#1| +% times. +% \begin{macrocode} +\def\xpct@iterateplotpfunction[#1]#2#3#4{% +\setcounter{xpct@step}{0}% +\COPY{#3}{\xpct@oldt} +\SUBTRACT{#4}{#3}{\xpct@step} +\DIVIDE{\xpct@step}{#1}{\xpct@step} +\@whilenum \value{xpct@step}<#1 \do + {\ADD{\xpct@oldt}{\xpct@step}{\xpct@newt} + \xpct@plotpfunction{#2}{\xpct@oldt}{\xpct@newt} + \stepcounter{xpct@step}% + \COPY\xpct@newt\xpct@oldt}\ignorespaces} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotpfunction} +% Compute function (and derivative of) |#1| in |#2| and |#3|, then +% call |\qCurve|. +% \begin{macrocode} +\def\xpct@plotpfunction#1#2#3{% + \begingroup + #1{#2}\xzero\Dxzero\yzero\Dyzero + #1{#3}\xone\Dxone\yone\Dyone + \cartesianreference + \qCurve(\xzero,\yzero)(\Dxzero,\Dyzero)(\xone,\yone)(\Dxone,\Dyone) + \endgroup\ignorespaces} +% \end{macrocode} +% \end{macro} +% \subsection{Cartesian axes and grids} +% Main commands: |\cartesianaxes| and |\cartesiangrid|. +% \begin{macro}{\cartesiangrid} +% Put |\ifgrid| to true, then call |\cartesianaxes|. +% \begin{macrocode} +\def\cartesiangrid(#1,#2)(#3,#4){% + \begingroup\gridtrue\cartesianaxes(#1,#2)(#3,#4)\endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\cartesianaxes} +% \begin{macro}{\xpct@XZero} +% \begin{macro}{\xpct@XOne} +% \begin{macro}{\xpct@YZero} +% \begin{macro}{\xpct@YOne} +% |\cartesianaxes| makes axes and, optionally, grid, tics, and/or labels. +% Cartesian rectangle limits are stored in +% |\xpct@XZero|, |\xpct@XOne|, |\xpct@YZero|, and |\xpct@YOne|. +% \begin{macrocode} +\def\cartesianaxes(#1,#2)(#3,#4){% +% \end{macrocode} +% In this command, coordinates are Cartesian. +% \begin{macrocode} + \begingroup\cartesianreference + \GLOBALCOPY{#1}{\xpct@XZero}\GLOBALCOPY{#2}{\xpct@YZero} + \GLOBALCOPY{#3}{\xpct@XOne}\GLOBALCOPY{#4}{\xpct@YOne} +% \end{macrocode} +% There shall be cuts, labels or grid? +% \begin{macrocode} + \iftics + \ticslabelsgridtrue + \else + \iflabels + \ticslabelsgridtrue + \else + \ifgrid + \ticslabelsgridtrue + \fi\fi\fi + \ifticslabelsgrid + \xpct@plotticslabels + \fi +% \end{macrocode} +% Call |\xpct@plotaxes| to plot axes. +% \begin{macrocode} + \xpct@plotaxes\endgroup} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\plotxtic} +% \begin{macro}{\plotytic} +% Put |\iftics| boolean to true, adjust tics lengths and position, +% and call |\xpct@printtic|. +% \begin{macrocode} +\def\plotxtic#1{% + \maketics + \xpct@adjticssize + \xpct@adjxorytics{#1}{0} + \xpct@printtic} +\def\plotytic#1{% + \maketics + \xpct@adjticssize + \xpct@adjxorytics{#1}{1} + \xpct@printtic} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\printxlabel} +% \begin{macro}{\printylabel} +% Adjust tics lengths and position, and call |\xpct@printlabel|. +% \begin{macrocode} +\def\printxlabel#1#2{% + \xpct@adjticssize + \xpct@adjxorytics{#1}{0} + \xpct@printlabel{0}{#2}} +\def\printylabel#1#2{% + \xpct@adjticssize + \xpct@adjxorytics{#1}{1} + \xpct@printlabel{1}{#2}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\printxticlabel} +% \begin{macro}{\printyticlabel} +% Print tic and label. +% \begin{macrocode} +\def\printxticlabel#1#2{\plotxtic{#1}\printxlabel{#1}{#2}} +\def\printyticlabel#1#2{\plotytic{#1}\printylabel{#1}{#2}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\plotxtics} +% \begin{macro}{\plotytics} +% Call |\xpct@plottics{0}}| or |\xpct@plottics{1}|. +% \begin{macrocode} +\def\plotxtics{\xpct@plottics{0}} +\def\plotytics{\xpct@plottics{1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\printxlabels} +% \begin{macro}{\printylabels} +% Call |\xpct@printlabels{0}| or |\xpct@printlabels{1}|. +% By default, optional argument must be |-1|. +% \begin{macrocode} +\def\printxlabels{% + \@ifnextchar[{\xpct@printlabels{0}}{\xpct@printlabels{0}[-1]}} +\def\printylabels{% + \@ifnextchar[{\xpct@printlabels{1}}{\xpct@printlabels{1}[-1]}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\printxticslabels} +% \begin{macro}{\printyticslabels} +% Call |\xpct@printxticslabels| or |\xpct@printyticslabels|. +% By default, optional argument must be |-1|. +% \begin{macrocode} +\def\printxticslabels{% + \@ifnextchar[{\xpct@printxticslabels}{\xpct@printxticslabels[-1]}} +\def\printyticslabels{% + \@ifnextchar[{\xpct@printyticslabels}{\xpct@printyticslabels[-1]}} +% \end{macrocode} +% \end{macro} +% \end{macro} + + + +% \begin{macro}{\xpct@plotaxes} +% Axes are simple lines, but its position depends on boolean |\inzeroaxes|. +% \begin{macrocode} +\def\xpct@plotaxes{\linethickness{\axesthickness}% + \pictcolor{\axescolor} + \ifinzeroaxes + \xLINE(\xpct@XZero,0)(\xpct@XOne,0) + \xLINE(0,\xpct@YZero)(0,\xpct@YOne) + \else + \xLINE(\xpct@XZero,\xpct@YZero)(\xpct@XOne,\xpct@YZero) + \xLINE(\xpct@XZero,\xpct@YZero)(\xpct@XZero,\xpct@YOne) + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotticslabels} +% Adjust tics sizes to axes lengths +% and call |\xpct@plotxticslabels| and |\xpct@plotyticslabels|. +% \begin{macrocode} +\def\xpct@plotticslabels{% + \xpct@adjticssize + \xpct@plotxticslabels\xpct@plotyticslabels} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotxticslabels} +% Grid, tics and labels on the |x| axis. +% If secundary divisions are required, this command iterates itself. +% \begin{macrocode} +\def\xpct@plotxticslabels{% +% \end{macrocode} +% If required, plot grid (in both directions, |x| and |y|). +% \begin{macrocode} + \ifgrid\xpct@plotgrid\fi + \begingroup + \ifnum\xunitdivisions=1 +% \end{macrocode} +% Call |\xpct@ticsinterval| to compute integer interval extremes +% and number of tics; +% then plot |x| tics. +% \begin{macrocode} + \xpct@ticsinterval{\xpct@XZero}{\xpct@XOne} + \xpct@plotxtics + \else +% \end{macrocode} +% Secundary tics. +% \begin{macrocode} + \begingroup +% \end{macrocode} +% Secundary tics. Change the reference system to the small unities, +% and ajust tics sizes, thickness and colors. +% \begin{macrocode} + \xpct@adjstics + \MULTIPLY{\secundaryyticssize}{\yunitdivisions}{\yticssize} +% \end{macrocode} +% At secundary level one must not print labels. +% \begin{macrocode} + \makenolabels +% \end{macrocode} +% Print secundary tics. +% \begin{macrocode} + \def\xunitdivisions{1} + \xpct@plotxticslabels + \endgroup +% \end{macrocode} +% Print primary tics and (perhaps) labels. +% \begin{macrocode} + \def\xunitdivisions{1} + \xpct@plotxticslabels + \fi + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotyticslabels} +% Tics and labels on the |y| axis. +% If secundary divisions are required, this command iterates itself. +% \begin{macrocode} +\def\xpct@plotyticslabels{% + \begingroup + \ifnum\yunitdivisions=1 +% \end{macrocode} +% Call |\xpct@ticsinterval| to compute integer interval extremes +% and number of tics; +% then plot |y| tics. +% \begin{macrocode} + \xpct@ticsinterval{\xpct@YZero}{\xpct@YOne} + \xpct@plotytics + \else +% \end{macrocode} +% Secundary tics. +% \begin{macrocode} + \begingroup +% \end{macrocode} +% Secundary tics. Change the reference system to the small unities, +% and ajust tics sizes, thickness and colors. +% \begin{macrocode} + \xpct@adjstics + \MULTIPLY{\secundaryxticssize}{\xunitdivisions}{\xticssize} +% \end{macrocode} +% At secundary level one must not print labels. +% \begin{macrocode} + \makenolabels +% \end{macrocode} +% Print secundary tics. +% \begin{macrocode} + \def\yunitdivisions{1} + \xpct@plotyticslabels + \endgroup +% \end{macrocode} +% Print primary tics and (perhaps) labels. +% \begin{macrocode} + \def\yunitdivisions{1} + \xpct@plotyticslabels + \fi + \endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@adjstics} +% Adjust length, color and thickness for secundary tics. +% \begin{macrocode} +\def\xpct@adjstics{% + \MULTIPLY{\xpct@XZero}{\xunitdivisions}{\xpct@XZero} + \MULTIPLY{\xpct@YZero}{\yunitdivisions}{\xpct@YZero} + \MULTIPLY{\xpct@XOne}{\xunitdivisions}{\xpct@XOne} + \MULTIPLY{\xpct@YOne}{\yunitdivisions}{\xpct@YOne} + \DIVIDE{1}{\xunitdivisions}{\xpct@xunit} + \DIVIDE{1}{\yunitdivisions}{\xpct@yunit} + \changereferencesystem(0,0)(\xpct@xunit,0)(0,\xpct@yunit) + \def\gridthickness{\secundarygridthickness} + \def\gridcolor{\secundarygridcolor}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotxtics} +% \begin{macro}{\xpct@plotytics} +% Call |\xpct@maketics| to make tics and/or labels (on |x| and |y| axes). +% \begin{macrocode} +\def\xpct@plotxtics{\xpct@maketics{\xpct@firstint}{\xpct@numtics}{0}} +\def\xpct@plotytics{\xpct@maketics{\xpct@firstint}{\xpct@numtics}{1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@maketics} +% Makes tics and/or labels (|#2| points, begining in |#1|; +% |#3=0| means |x| axis, |#3=1| means |y| axis). +% \begin{macrocode} +\def\xpct@maketics#1#2#3{% +% \end{macrocode} +% Call |\xpct@adjxorytics| to compute coordinates of extreme points of first +% tic and translation vector from one tic to the next one. +% \begin{macrocode} + \xpct@adjxorytics{#1}{#3} +% \end{macrocode} +% Use counter |xpct@counta| for tics and |xpct@countb| for labels +% (number to print in each label). +% \begin{macrocode} + \setcounter{xpct@counta}{0}% + \iflabels\setcounter{xpct@countb}{#1}\fi +% \end{macrocode} +% Main loop: |#2| steps, begining in |#1|. +% \begin{macrocode} + \@whilenum \value{xpct@counta}<#2 \do {% + \iftics +% \end{macrocode} +% If required, print tic. +% \begin{macrocode} + \xpct@printtic + \fi + \iflabels +% \end{macrocode} +% If labels are to be printed, adjust |\Pictlabelsep|; then print label +% and step label (|xpct@countb| counter). +% \begin{macrocode} + \highestlabel{\xpct@axeslabelattrib% + $\axeslabelmathalphabet{1}$}% + \xpct@printlabel{#3}{\thexpct@countb} + \stepcounter{xpct@countb}% + \fi +% \end{macrocode} +% Step tics counter and move coordinates to next point. +% \begin{macrocode} + \stepcounter{xpct@counta}% + \VECTORADD(\xpct@@xzero,\xpct@@yzero)(\xpct@@xincr,\xpct@@yincr)% + (\xpct@@xzero,\xpct@@yzero) + \VECTORADD(\xpct@@xone,\xpct@@yone)(\xpct@@xincr,\xpct@@yincr)% + (\xpct@@xone,\xpct@@yone) + }} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@adjxorytics} +% Compute coordinates of extreme points of first tic +% and translation vector from one tic to the next one. +% There are four cases: |x| or |y| axis, and external or internal axes. +% \begin{macrocode} +\def\xpct@adjxorytics#1#2{% + \ifnum #2=0 + \COPY{#1}{\xpct@@xzero} + \COPY{-\yticssize}{\xpct@@yzero} + \COPY{#1}{\xpct@@xone} + \COPY{\yticssize}{\xpct@@yone} + \COPY{1}{\xpct@@xincr} + \COPY{0}{\xpct@@yincr} + \ifinzeroaxes\else + \ADD{\xpct@YZero}{\xpct@@yzero}{\xpct@@yzero} + \ADD{\xpct@YZero}{\xpct@@yone}{\xpct@@yone} + \fi + \else + \COPY{#1}{\xpct@@yzero} + \COPY{-\xticssize}{\xpct@@xzero} + \COPY{#1}{\xpct@@yone} + \COPY{\xticssize}{\xpct@@xone} + \COPY{1}{\xpct@@yincr} + \COPY{0}{\xpct@@xincr} + \ifinzeroaxes\else + \ADD{\xpct@XZero}{\xpct@@xzero}{\xpct@@xzero} + \ADD{\xpct@XZero}{\xpct@@xone}{\xpct@@xone} + \fi + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@printtic} +% Plot a tic. +% \begin{macrocode} +\def\xpct@printtic{\pictcolor{\ticscolor} + \linethickness{\ticsthickness} + \xLINE(\xpct@@xzero,\xpct@@yzero)(\xpct@@xone,\xpct@@yone)} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@adjticssize} +% Adjust size of tics according to axes length. +% \begin{macrocode} +\def\xpct@adjticssize{% +% \end{macrocode} +% First, convert absolute lenghts |\ticssize| and |\secundaryticssize| to +% the |\unitlength| unity. +% \begin{macrocode} + \LENGTHDIVIDE{\ticssize}{\unitlength}{\xpct@ticssize} + \LENGTHDIVIDE{\secundaryticssize}{\unitlength}{\xpct@sticssize} +% \end{macrocode} +% Calculate the size of vector |(1,0)|, converting it to standard coordinates +% and computing its norm. +% Then we adjust |\xticssize| and |\secundaryxticssize|; this ensures +% the desired sizes. +% \begin{macrocode} + \refsysxyVector(1,0)(\xpct@a,\xpct@b) + \VECTORNORM(\xpct@a,\xpct@b){\xpct@norm} + \DIVIDE{\xpct@ticssize}{\xpct@norm}{\xticssize} + \DIVIDE{\xpct@sticssize}{\xpct@norm}{\secundaryxticssize} + \DIVIDE{\axislabelsep}{\xpct@norm}{\xpct@xaxislabelsep} +% \end{macrocode} +% Repeat calculations for vector $(0,1)$, +% adjusting |\yticssize| and |\secundaryyticssize|. +% \begin{macrocode} + \refsysxyVector(0,1)(\xpct@a,\xpct@b) + \VECTORNORM(\xpct@a,\xpct@b){\xpct@norm} + \DIVIDE{\xpct@ticssize}{\xpct@norm}{\yticssize} + \DIVIDE{\xpct@sticssize}{\xpct@norm}{\secundaryyticssize} + \DIVIDE{\axislabelsep}{\xpct@norm}{\xpct@yaxislabelsep}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@printlabel} +% Adjust highest label (for horizontal labels); +% then print value of |#2|. +% Four cases: |x| or |y|, external or internal. +% \begin{macrocode} +\def\xpct@printlabel#1#2{% + \iftics + \ifnum #1=0 + \ADD{\yticssize}{\xpct@yaxislabelsep}{\Pictlabelsep} + \else + \ADD{\xticssize}{\xpct@xaxislabelsep}{\Pictlabelsep} + \fi + \else + \ifnum #1=0 + \COPY{\xpct@yaxislabelsep}{\Pictlabelsep} + \else + \COPY{\xpct@xaxislabelsep}{\Pictlabelsep} + \fi + \fi + \ifinzeroaxes + \ifnum\thexpct@countb=0 + \else + \ifnum #1=0 + \rPut*{\xpct@xlblpos}(\xpct@@xzero,0){% + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet{#2}}} + \else + \rPut*{\xpct@ylblpos}(0,\xpct@@yzero){% + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet{#2}}} + \fi + \fi + \else + \ifnum #1=0 + \rPut*{\xpct@xlblpos}(\xpct@@xzero,\xpct@YZero){% + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet{#2}}} + \else + \rPut*{\xpct@ylblpos}(\xpct@XZero,\xpct@@yzero){% + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet{#2}}} + \fi + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xlabelpos} +% \begin{macro}{\ylabelpos} +% Default position for labels on axes. Call |\xpct@convtoang| to define +% |\xpct@xlblpos| or |\xpct@ylblpos|. +% \begin{macrocode} +\def\xlabelpos#1{\xpct@convtoang{#1}{\xpct@xlblpos}{\xpct@CorR}} +\def\ylabelpos#1{\xpct@convtoang{#1}{\xpct@ylblpos}{\xpct@CorR}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@printxticslabels} +% \begin{macro}{\xpct@printyticslabels} +% Print tics and labels. +% \begin{macrocode} +\def\xpct@printxticslabels[#1]#2#3#4{% + \plotxtics{#2}{#3}{#4}\printxlabels[#1]{#2}{#3}{#4}} +\def\xpct@printyticslabels[#1]#2#3#4{% + \plotytics{#2}{#3}{#4}\printylabels[#1]{#2}{#3}{#4}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@plottics} +% Plot |x| or |y| tics (if |#1| equals |0| or |1|), +% starting an |#2|. Distance between two consecutive tics is |#3|, and +% position of last tic is not greather than |#4|. +% \begin{macrocode} +\def\xpct@plottics#1#2#3#4{% + \COPY{#2}{\xpct@ticcoor} +% \end{macrocode} +% |\xpct@ticcoor| is the position of next tic. +% \begin{macrocode} + \@whiledim\xpct@ticcoor\p@<#4\p@ \do {% +% \end{macrocode} +% Make a tic while |\xpct@ticcoor<#4| +% \begin{macrocode} + \ifnum #1=0 + \plotxtic{\xpct@ticcoor} + \else + \plotytic{\xpct@ticcoor} + \fi + \ADD{#3}{\xpct@ticcoor}{\xpct@ticcoor} + } +% \end{macrocode} +% If |\xpct@ticcoor=#4| then this is the last tic position. +% \begin{macrocode} + \ifdim\xpct@ticcoor\p@>#4\p@ + \else + \ifnum #1=0 + \plotxtic{\xpct@ticcoor} + \else + \plotytic{\xpct@ticcoor} + \fi + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@printlabels} +% Print |x| or |y| labels (if |#1| equals |0| or |1|), +% starting an |#3|. Distance between two consecutive tics is |#4|, and +% position of last tic is not greather than |#5|. +% |#2| is the number of decimal digits to be printed +% (default is |#2=-1|, meaning no control of digits in number printing). +% \begin{macrocode} +\def\xpct@printlabels#1[#2]#3#4#5{% + \COPY{#3}{\xpct@ticcoor} +% \end{macrocode} +% |\xpct@ticcoor| is the position of next label. +% \begin{macrocode} + \@whiledim\xpct@ticcoor\p@<#5\p@ \do {% +% \end{macrocode} +% Print a label while |\xpct@ticcoor<#5| +% |\xpct@Ticcoor| is the label with adjusted number of digits. +% \begin{macrocode} + \ifnum #2=-1 + \COPY{\xpct@ticcoor}{\xpct@Ticcoor} + \else + \ROUND[#2]{\xpct@ticcoor}{\xpct@Ticcoor} + \fi + \xpct@prtlbl{#1} + \ADD{#4}{\xpct@ticcoor}{\xpct@ticcoor}} + \ifdim\xpct@ticcoor\p@>#5\p@ +% \end{macrocode} +% If |\xpct@ticcoor=#5| then this is the last label position. +% \begin{macrocode} + \else + \ifnum #2=-1 + \COPY{\xpct@ticcoor}{\xpct@Ticcoor} + \else + \ROUND[#2]{\xpct@ticcoor}{\xpct@Ticcoor} + \fi + \xpct@prtlbl{#1} + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@prtlbl} +% Print the |x| or |y| label (for |#1=0| or |1|) +% |\xpct@Ticcoor| at |\xpct@ticcoor|. +% When |\ifinzeroaxes| is true label at |0| position is not printed. +% \begin{macrocode} +\def\xpct@prtlbl#1{% + \ifinzeroaxes + \ifdim \xpct@ticcoor\p@=\z@\else + \xpct@adjticssize + \xpct@adjxorytics{\xpct@ticcoor}{#1} + \xpct@printlabel{#1}{\xpct@Ticcoor} + \fi + \else + \xpct@adjticssize + \xpct@adjxorytics{\xpct@ticcoor}{#1} + \xpct@printlabel{#1}{\xpct@Ticcoor}\fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@plotgrid} +% Plot a grid in a Cartesian rectangle. +% \begin{macrocode} +\def\xpct@plotgrid{% +% \end{macrocode} +% Call |\xpct@ticsinterval| to compute integer interval extremes +% and number of tics; +% then plot grid lines (for |x| axis). +% \begin{macrocode} + \xpct@ticsinterval{\xpct@XZero}{\xpct@XOne} + \begingroup\setcounter{xpct@counta}{0}% + \pictcolor{\gridcolor}\linethickness{\gridthickness} + \COPY{\xpct@firstint}{\xpct@grid} + \@whilenum\value{xpct@counta}<\xpct@numtics\do{ + \xLINE(\xpct@grid,\xpct@YZero)(\xpct@grid,\xpct@YOne) + \ADD{1}{\xpct@grid}{\xpct@grid} + \stepcounter{xpct@counta}}\endgroup +% \end{macrocode} +% Call |\xpct@ticsinterval| to compute integer interval extremes +% and number of tics; +% then plot grid lines (for |y| axis). +% \begin{macrocode} + \xpct@ticsinterval{\xpct@YZero}{\xpct@YOne} + \begingroup\setcounter{xpct@counta}{0}% + \pictcolor{\gridcolor}\linethickness{\gridthickness} + \COPY{\xpct@firstint}{\xpct@grid} + \@whilenum\value{xpct@counta}<\xpct@numtics\do{ + \xLINE(\xpct@XZero,\xpct@grid)(\xpct@XOne,\xpct@grid) + \ADD{1}{\xpct@grid}{\xpct@grid} + \stepcounter{xpct@counta}}\endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@ticsinterval} +% Truncate extremes to integers, then compute the number of tics +% (|\xpct@firstint-\xpct@lastint+1|). +% \begin{macrocode} +\def\xpct@ticsinterval#1#2{\TRUNCATE[0]{#1}{\xpct@firstint} + \TRUNCATE[0]{#2}{\xpct@lastint} + \SUBTRACT{\xpct@lastint}{\xpct@firstint}{\xpct@numtics} + \ADD{\xpct@numtics}{1}{\xpct@numtics}} +% \end{macrocode} +% \end{macro} +% \subsection{Polar grids} +% \begin{macro}{\polargrid} +% Plot a polar grid of radius |#1| and |#2| divisions of circle. +% \begin{macrocode} +\def\polargrid#1#2{% + \begingroup + \polarreference +% \end{macrocode} +% Compute integer part of radius, number of circles and distance +% between circles. +% \begin{macrocode} + \FLOOR{#1}{\xpct@rint} + \MULTIPLY{\xpct@rint}{\runitdivisions}{\xpct@rdivs} + \DIVIDE{1}{\runitdivisions}{\rincr} +% \end{macrocode} +% Use counter |xpct@counta| to control the number of printed circles +% and |\xpct@radius| as radius of the current circle. +% \begin{macrocode} + \COPY{0}{\xpct@radius} + \setcounter{xpct@counta}{1}% +% \end{macrocode} +% Plot |\xpct@rdivs| circles. +% \begin{macrocode} + \begingroup + \pictcolor{\gridcolor} + \linethickness{\gridthickness} + \@whilenum \value{xpct@counta}<\xpct@rdivs\do {% + \ADD{\rincr}{\xpct@radius}{\xpct@radius} + \Ellipse{\xpct@radius}{\xpct@radius} + \stepcounter{xpct@counta}}% +% \end{macrocode} +% Plot external circle. +% \begin{macrocode} + \pictcolor{\axescolor} + \linethickness{\axesthickness} + \Ellipse{\xpct@rint}{\xpct@rint} + \endgroup +% \end{macrocode} +% Use counter |xpct@counta| to control the number of printed lines and +% |\xpct@angle| as arc (in radians) of the current line. +% |\xpct@angincr| is the gap between two adjacent lines. +% \begin{macrocode} + \COPY{0}{\xpct@angle} + \DIVIDE{\numberTWOPI}{#2}{\xpct@angincr} + \setcounter{xpct@counta}{0}% +% \end{macrocode} +% Plot |#2| lines. +% \begin{macrocode} + \pictcolor{\gridcolor} + \linethickness{\gridthickness} + \@whilenum \value{xpct@counta}<#2 \do {% + \xLINE(0,0)(#1,\xpct@angle) +% \end{macrocode} +% If required, print angular label: evaluate the number |\xpct@arc| +% such that angle is |(\xpct@arc/#2) pi| and call |\xpct@polarlabel|. +% \begin{macrocode} + \iflabels + \COPY{\axislabelsep}{\Pictlabelsep} + \MULTIPLY{2}{\thexpct@counta}{\xpct@arc} + \xpct@polarlabel{#1}{\xpct@arc}{#2}\fi + \ADD{\xpct@angincr}{\xpct@angle}{\xpct@angle} + \stepcounter{xpct@counta}}% +% \end{macrocode} +% Plot the polar line. +% \begin{macrocode} + \pictcolor{\axescolor} + \linethickness{\axesthickness} + \xLINE(0,0)(#1,0) +% \end{macrocode} +% If required, print radial labels. +% \begin{macrocode} + \iflabels + \highestlabel{\xpct@axeslabelattrib$\axeslabelmathalphabet{1}$} + \multiPut*[\xpct@rlblpos](1,0)(1,0){\xpct@rint}{% + \ADD{\value{multiput}}{1}{\xpct@lbl} + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet{\xpct@lbl}}}% + \fi + \endgroup} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\rlabelpos} +% Default position for labels on polar axis. Call |\xpct@convtoang| to define +% |\xpct@rlblpos|. +% \begin{macrocode} +\def\rlabelpos#1{\xpct@convtoang{#1}{\xpct@rlblpos}{\xpct@CorR}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\degreespolarlabels} +% \begin{macro}{\radianspolarlabels} +% Define |\xpct@polarlabel| to be |\xpct@degreeslabel| or |\xpct@radianslabel| +% (print polar label as degrees or radians). +% \begin{macrocode} +\def\degreespolarlabels{\def\xpct@polarlabel{\xpct@degreeslabel}} +\def\radianspolarlabels{\def\xpct@polarlabel{\xpct@radianslabel}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\xpct@degreeslabel} +% Print the angle label |(#2/#3) pi| converted to degrees. +% \begin{macrocode} +\def\xpct@degreeslabel#1#2#3{% +% \end{macrocode} +% Adjust label position. +% \begin{macrocode} +% \end{macrocode} +% Simplify |#2/#3|. Then convert |(#2/#3) pi| to degrees +% (evaluate |(#2 180)/#3|). +% \begin{macrocode} + \FRACTIONSIMPLIFY{#2}{#3}\xpct@num\xpct@den + \MULTIPLY{\xpct@num}{180}{\xpct@degangle} + \DIVIDE{\xpct@degangle}{\xpct@den}{\xpct@degangle} +% \end{macrocode} +% Print label. +% \begin{macrocode} + \cPut{\xpct@degangle}(#1,\xpct@angle){% + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet{\xpct@degangle^\mathrm{o}}}}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@radianslabel} +% Print the angle label |(#2/#3) pi|. +% \begin{macrocode} +\def\xpct@radianslabel#1#2#3{% +% \end{macrocode} +% Adjust label position and call |\xpct@prtfracrad|. +% \begin{macrocode} + \RADtoDEG{\xpct@angle}{\xpct@angles} + \cPut{\xpct@angles}(#1,\xpct@angle){% + \xpct@axeslabelattrib% + \ensuremath{\axeslabelmathalphabet + {\xpct@prtfracrad{#2}{#3}}}}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xpct@prtfracrad} +% Pretty print |(#1/#2)pi| +% \begin{macrocode} +\def\xpct@prtfracrad#1#2{% + \FRACTIONSIMPLIFY{#1}{#2}\xpct@num\xpct@den + \ifnum \xpct@num = 0 0 + \else + \ifnum \xpct@num = 1 + \ifnum \xpct@den = 1 \pi + \else \pi/\xpct@den + \fi + \else \xpct@num\pi/\xpct@den + \fi + \fi} +% \end{macrocode} +% \end{macro} +% \subsection{Configurable parameters} +% These are the parameters the user can customize. +% Default values are written to |xpicture.sty| and |xpicture.cfgxmpl|. +% \begin{macrocode} +%</xpicture> +%<*defaults> +%<+cfg>%% +%<+cfg>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%<+cfg>% xpicture configurable parameters % +%<+cfg>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%<+cfg>%% +%<+cfg>%%%%% Cartesian and polar axes +%<+cfg> % Thickness and color of axes +\axesthickness=1pt +\def\axescolor{black} +%<+cfg> % Color, size, mathversion and mathalphabet of numeric labels +\def\axeslabelcolor{\axescolor} +\def\axeslabelsize{\small} +\def\axeslabelmathversion{normal} +\def\axeslabelmathalphabet{\mathrm} +%<+cfg> % Relative position of numeric labels on x- y- and r- axes +\xlabelpos{-90} +\ylabelpos{180} +\rlabelpos{bbr} +%<+cfg> % Distance between tags and cut marks, +%<+cfg> % is is a number (not a lenght) of \unitlength units +\def\axislabelsep{0.1} +%<+cfg> % Color, thickness and size of tics +\def\ticscolor{\axescolor} +\ticsthickness=1pt +\ticssize=4pt +%<+cfg> % Size of secundary tics +\secundaryticssize=2pt +%<+cfg> % Thickness and color of Cartesian or polar grid +\gridthickness=0.4pt +\def\gridcolor{gray} +%<+cfg> % Thickness and color of Cartesian or polar secundary grid +\secundarygridthickness=0.2pt +\def\secundarygridcolor{lightgray} +%<+cfg> % Number of divisions of unity in x- y- and r-axis +\def\xunitdivisions{1} +\def\yunitdivisions{1} +\def\runitdivisions{1} +%<+cfg> % Arc labels in radians (\xpct@radianslabel) +%<+cfg> % or degrees (\xpct@degreeslabel) +\def\xpct@polarlabel{\xpct@radianslabel} +%<+cfg>%%%%% \put and \multiput extensions +%<+cfg> % Distance from label to reference point, +%<+cfg> % is is a number (not a lenght) of \unitlength units +\def\Pictlabelsep{0.1} +%<+cfg> % Default layout for distance (\defaultPut{c} or \defaultPut{r}) +\defaultPut{c} +%<+cfg>%%%%% Reference systems +%<+cfg> % Default reference system +\referencesystem(0,0)(1,0)(0,1) +%<+cfg> % Cartesian or polar reference +\cartesianreference +%<+cfg>%%%%% Arrow size in \xtrivVECTOR +\arrowsize{5}{2} +%<+cfg>%%%%% Default interval divisions +%<+cfg> % (used when plotting conic sections and arcs) +\def\defaultplotdivs{8} +%<+cfg>%%%%% Size to be used by \pointmark +\def\pointmarkdiam{0.1} +%<+cfg>%%%%% Point mark used by \PlotPointsOfFunction +\def\pointmark{\circle*{\pointmarkdiam}} +%</defaults> +%<*xpicture> +% \end{macrocode} +% \subsection{Commands to be ignored if draft option or \cs{draftPicture} +% declaration is active} +% \begin{macro}{\draftPictures} +% This declaration allow user to locally disable |Picture| drawns. +% \begin{macrocode} +\def\draftPictures{% + \drafttrue + \def\cPut##1(##2,##3)##4{} + \def\xpct@@Put(##1)##2{} + \def\xpct@@Putstar[##1](##2)##3{} + \def\xpct@@@Put[##1](##2)##3{} + \def\defaultPut##1{\def\xpct@defaultPut{\cPut}} + \def\xpct@@mPut(##1,##2)(##3,##4)##5##6{} + \def\xpct@PUT##1(##2,##3)##4{} + \def\xLINE(##1)(##2){} + \def\xtrivVECTOR(##1)(##2){} + \def\xVECTOR(##1)(##2){} + \def\zerovector(##1){} + \def\zerotrivvector(##1){} + \def\xline(##1,##2)##3{} + \def\xvector(##1,##2)##3{} + \def\xtrivvector(##1,##2)##3{} + \def\xpct@regPolygon[##1]##2##3{} + \def\xpct@@qCurve(##1)(##2)(##3)(##4){} + \def\xpct@PlotQuadraticCurve(##1)(##2)(##3)(##4){% + \@ifnextchar({\PlotQuadraticCurve(##3)(##4)}{}} + \def\xpct@@PlotQuadraticCurve(##1)##2(##3)##4{% + \@ifnextchar({\PlotQuadraticCurve(##3){##4}}{}} + \def\circularArc##1##2##3{} + \def\ellipticArc##1##2##3##4{} + \def\Ellipse##1##2{} + \def\Circle##1{} + \def\xpct@hyperbolicArc##1##2##3##4{} + \def\lHyperbola##1##2##3##4{} + \def\rHyperbola##1##2##3##4{} + \def\Hyperbola##1##2##3##4{} + \def\rhyperbolicArc##1##2##3##4{} + \def\lhyperbolicArc##1##2##3##4{} + \def\parabolicArc##1##2##3{} + \def\Parabola##1##2##3{} + \def\PlotPointsOfFunction##1##2##3##4{} + \def\xpct@iterateplotfunction[##1]##2##3##4{} + \def\xpct@plotfunction##1##2##3{} + \def\xpct@iterateplotpfunction[##1]##2##3##4{} + \def\xpct@plotpfunction##1##2##3{} + \def\cartesianaxes(##1,##2)(##3,##4){} + \def\cartesiangrid(##1,##2)(##3,##4){} + \def\plotxtic##1{} + \def\plotytic##1{} + \def\printxlabel##1##2{} + \def\printylabel##1##2{} + \def\printxticlabel##1##2{} + \def\printyticlabel##1##2{} + \def\plotxtics##1##2##3{} + \def\plotytics##1##2##3{} + \def\xpct@printlabels##1[##2]##3##4##5{} + \def\polargrid##1##2{} +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ifdraft} +% If |draft| option is active |\draftPictures| is executed. +% Then all |Picture| commands are disabled. +% \begin{macrocode} +\ifdraft + \draftPictures +\fi +% \end{macrocode} +% \end{macro} +% Input local defaults (file |xpicture.cfg|). +% \begin{macrocode} +\InputIfFileExists{xpicture.cfg}{\xpct@Infocfg}{\xpct@Infonocfg} +%</xpicture> +% \end{macrocode} +% \section{Change history} +% \begin{description} +% \item[v1.2a] (2012/11/17) +% +% Documented source.\par +% Many internal c.s. renamed and/or rewrited.\par +% dvi/pict2e/curve2e options supressed.\par +% draft option added.\par +% Background color added to Picture environment.\par +% \cs{Pictlabelsep} is set to \verb+\normalfont\normalsize$1$+ +% when a \verb+Picture+ environment starts.\par +% New commands: \cs{draftPictures},\cs{symmetrize}, +% \cs{xlabelpos}, \cs{ylabelpos}, +% \cs{plotxtic}, \cs{plotytic}, \cs{plotxtics}, \cs{plotytics}, +% \cs{printxlabel}, \cs{printylabel}, \cs{printxlabels}, \cs{printylabels}, +% \cs{printxticlabel}, \cs{printyticlabel}, +% \cs{printxticslabels}, \cs{printyticslabels}, +% \cs{makegrid}, \cs{makenogrid}, +% \cs{PlotPointsOfFunction}, \cs{pointmark}, \cs{pointmarkdiam}. +% +% \item[v1.2] (2012/04/25) +% +% First public version. +% \end{description} +% \Finale +%
\ No newline at end of file diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index b2f7bef2d15..c41efa6deb8 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -462,7 +462,7 @@ my @TLP_working = qw( xetexref xfor xgreek xhfill xifthen xits xkeyval xlop xltxtra xmpincl xnewcommand - xoptarg xpatch xpeek xpinyin xpunctuate + xoptarg xpatch xpeek xpicture xpinyin xpunctuate xq xskak xstring xtab xunicode xwatermark xyling xypic xypic-tut-pt xytree yafoot yagusylo yannisgr yax ydoc yfonts york-thesis youngtab yplan ytableau diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc index 2ae31bc9efa..58a42b760a0 100644 --- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc @@ -99,5 +99,6 @@ depend tkz-tab depend tsemlines depend tufte-latex depend venndiagram +depend xpicture depend xypic depend collection-basic diff --git a/Master/tlpkg/tlpsrc/xpicture.tlpsrc b/Master/tlpkg/tlpsrc/xpicture.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/xpicture.tlpsrc |