| 1 |
%% $Id: pstricks-add-doc.tex 705 2023-04-17 18:32:58Z herbert $ |
| 2 |
%\RequirePackage{pdfmanagement-testphase} |
| 3 |
%\DeclareDocumentMetadata{} |
| 4 |
% |
| 5 |
\documentclass[11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small, |
| 6 |
headinclude=false,footinclude=false,oneside]{pst-doc} |
| 7 |
\listfiles |
| 8 |
\usepackage{biblatex} |
| 9 |
\addbibresource{pstricks-add-doc.bib} |
| 10 |
\makeatletter |
| 11 |
%\RequirePackage{ltxcmds}[2010/01/28] |
| 12 |
%\@ifpackagelater{ltxcmds}{2010/03/09}{}{% |
| 13 |
% \def\ltx@pkgextension{sty}% |
| 14 |
%} |
| 15 |
\makeatother |
| 16 |
|
| 17 |
\usepackage{siunitx,iftex} |
| 18 |
\sisetup{add-decimal-zero, |
| 19 |
round-mode=places, |
| 20 |
round-precision=2, |
| 21 |
output-decimal-marker={,}, |
| 22 |
detect-all} |
| 23 |
|
| 24 |
%\input{data/pstricks-add-doc.data} |
| 25 |
|
| 26 |
%\usepackage{pstricks-add} |
| 27 |
%\let\pstricksaddFV\fileversion |
| 28 |
\usepackage{pst-eucl,pst-fun,pst-func,multirow} |
| 29 |
\usepackage{pifont,pst-func} |
| 30 |
\let\belowcaptionskip\abovecaptionskip |
| 31 |
% |
| 32 |
\def\textat{\char064}% |
| 33 |
\newdimen\fullWidth |
| 34 |
\makeatletter |
| 35 |
\renewcommand*\l@section{\@dottedtocline{1}{2em}{2.3em}} |
| 36 |
\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}} |
| 37 |
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} |
| 38 |
\renewcommand*\l@paragraph{\@dottedtocline{4}{10em}{5em}} |
| 39 |
\makeatother |
| 40 |
\lstset{explpreset={pos=l,width=-99pt,overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,rframe={}}, |
| 41 |
escapechar=§} |
| 42 |
|
| 43 |
\def\bgImage{%\includegraphics{data/olympic} |
| 44 |
\begin{pspicture}(-4.5,-3)(4.5,1.5) |
| 45 |
\psOlympicRings[bgcolor=lightgray](0,0) |
| 46 |
\psOlympicRings[bgcolor=lightgray,psscale=0.2](1.5,-1.5) |
| 47 |
\psOlympicRings[bgcolor=lightgray,psscale=0.2](-1.5,-1.5) |
| 48 |
\psOlympicRings[bgcolor=lightgray,psscale=0.2](0,0.5) |
| 49 |
\end{pspicture}% |
| 50 |
} |
| 51 |
|
| 52 |
\iffalse |
| 53 |
\psset{unit=1.5} |
| 54 |
\begin{pspicture}(-3,-3.25)(3,3) |
| 55 |
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50, |
| 56 |
magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2} |
| 57 |
\psset{nodesepA=5pt,nodesepB=-10pt} |
| 58 |
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)} |
| 59 |
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)} |
| 60 |
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)} |
| 61 |
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)} |
| 62 |
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)} |
| 63 |
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)} |
| 64 |
\bfseries% |
| 65 |
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills} |
| 66 |
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food} |
| 67 |
\end{pspicture}} |
| 68 |
\fi |
| 69 |
|
| 70 |
|
| 71 |
\begin{document} |
| 72 |
\title{\texttt{pstricks-add}\\additionals Macros for \texttt{pstricks}\\ |
| 73 |
\small v.\pstricksaddFV} |
| 74 |
\docauthor{Herbert Voß} |
| 75 |
\author{Dominique Rodriguez\\Michael Sharpe\\Herbert Voß} |
| 76 |
\date{\today} |
| 77 |
|
| 78 |
\settitle |
| 79 |
|
| 80 |
\fullWidth=\linewidth |
| 81 |
\advance\fullWidth by \marginparsep |
| 82 |
\advance\fullWidth by \marginparwidth |
| 83 |
|
| 84 |
|
| 85 |
\begin{abstract} |
| 86 |
This version of \verb+pstricks-add+ needs \verb+pstricks.tex+ |
| 87 |
version >1.04 from June 2004, otherwise the additional macros may |
| 88 |
not work as expected. The ellipsis material and the option |
| 89 |
\verb+asolid+ (renamed to \verb+eofill+) are |
| 90 |
\index{fillstyle!eofill@\texttt{eofill}} now part of the new |
| 91 |
\verb+pstricks.tex+ package, available on CTAN. \LPack{pstricks-add} will for ever be |
| 92 |
an experimental and dynamical package, try it at your own risk. |
| 93 |
|
| 94 |
\begin{itemize} |
| 95 |
\item It is important to load \LPack{pstricks-add} as the \textbf{last} PSTricks related package, otherwise |
| 96 |
a lot of the macros won't work in the expected way. |
| 97 |
\item \LPack{pstricks-add} uses the extended version of the keyval package. So be sure that |
| 98 |
you have installed \LPack{pst-xkey} which is part of the |
| 99 |
\LPack{xkeyval}-package, and that all packages that use the old |
| 100 |
keyval interface are loaded \textbf{before} the |
| 101 |
\LPack{xkeyval}. |
| 102 |
\item the option \Lkeyword{tickstyle} from \LPack{pst-plot} is no longer supported; use \Lkeyword{ticksize} instead. |
| 103 |
\item the option \Lkeyword{xyLabel} is no longer supported; use the option \Lkeyword{labelFontSize} instead. |
| 104 |
\item if \LPack{pstricks-add} is loaded together with the package \LPack{pst-func} then \Lkeyword{InsideArrow} |
| 105 |
of the \Lcs{psbezier} macro doesn't work! |
| 106 |
\end{itemize} |
| 107 |
|
| 108 |
\vfill |
| 109 |
\noindent |
| 110 |
Thanks to: |
| 111 |
%Hendri Adriaens; |
| 112 |
Stefano Baroni; |
| 113 |
Martin Chicoine; |
| 114 |
Gerry Coombes; |
| 115 |
Ulrich Dirr; |
| 116 |
Christophe Fourey; |
| 117 |
Hubert G\"a\ss lein; |
| 118 |
J\"urgen Gilg; |
| 119 |
Denis Girou; |
| 120 |
Pablo Gonzáles Luengo; |
| 121 |
Peter Hutnick; |
| 122 |
Christophe Jorssen; |
| 123 |
Uwe Kern; |
| 124 |
Marcel Krüger; |
| 125 |
Friedrich Lenk; |
| 126 |
Manuel Luque; |
| 127 |
Jens-Uwe Morawski; |
| 128 |
Tobias N\"ahring; |
| 129 |
Rolf Niepraschk; |
| 130 |
Alan Ristow; |
| 131 |
Christine R\"omer; |
| 132 |
Arnaud Schmittbuhl; |
| 133 |
John Smith; |
| 134 |
Timothy Van Zandt |
| 135 |
\end{abstract} |
| 136 |
|
| 137 |
\clearpage |
| 138 |
\tableofcontents |
| 139 |
|
| 140 |
|
| 141 |
\clearpage |
| 142 |
|
| 143 |
\section{\nxLcs{psGetSlope} and \nxLcs{psGetDistance}} |
| 144 |
%-------------------------------------------------------------------------------------- |
| 145 |
|
| 146 |
\begin{BDef} |
| 147 |
\Lcs{psGetSlope}\coord1\coord2\Lcs{\Larga{macro}}\\ |
| 148 |
\Lcs{psGetDistance}\OptArg{\Larga{decimals}}\coord1\coord2\Lcs{\Larga{macro}} |
| 149 |
\end{BDef} |
| 150 |
|
| 151 |
\begin{LTXexample}[width=4cm] |
| 152 |
\psGetSlope(-2,1)(3,1)\SlopeVal \SlopeVal \quad |
| 153 |
\psGetDistance(-2,1)(3,1)\DVal \DVal\\ |
| 154 |
\psGetSlope(-2,1)(-3,-1)\SlopeVal \SlopeVal\quad |
| 155 |
\psGetDistance(-2,1)(-3,-1)\DVal \DVal\\ |
| 156 |
\psGetSlope(-2,0)(3,-1)\SlopeVal \SlopeVal\quad |
| 157 |
\psGetDistance(-2,0)(3,-1)\DVal \DVal\\ |
| 158 |
\psGetSlope(-2111,-12)(3,1)\SlopeVal \SlopeVal\quad |
| 159 |
%\psGetDistance(-2111,-12)(3,1)\DVal ==> Overflow! |
| 160 |
\end{LTXexample} |
| 161 |
|
| 162 |
\begin{LTXexample}[width=4cm] |
| 163 |
\psGetDistance(-2,1)(3,-1.5)\DVal \DVal\\ |
| 164 |
\psGetDistance[5](-2,1)(3,-1.5)\DVal \DVal\\ |
| 165 |
\psGetDistance[3](-2,1)(3,-1.5)\DVal \DVal\\ |
| 166 |
\psGetDistance[1](-2,1)(3,-1.5)\DVal \DVal |
| 167 |
\end{LTXexample} |
| 168 |
|
| 169 |
|
| 170 |
\clearpage |
| 171 |
|
| 172 |
%-------------------------------------------------------------------------------------- |
| 173 |
\section{"`Handmade"' lines :-)} |
| 174 |
%-------------------------------------------------------------------------------------- |
| 175 |
|
| 176 |
\begin{BDef} |
| 177 |
\Lcs{pslineByHand}\OptArgs\coord1\coord2\coord3 \ldots |
| 178 |
\end{BDef} |
| 179 |
|
| 180 |
\begin{LTXexample}[width=0.4\linewidth] |
| 181 |
\begin{pspicture}(4,6) |
| 182 |
\psset{unit=2cm} |
| 183 |
\pslineByHand[linecolor=red](0,0)(0,2)(2,2)(2,0)(0,0)(2,2)(1,3)(0,2)(2,0) |
| 184 |
\end{pspicture} |
| 185 |
\end{LTXexample} |
| 186 |
|
| 187 |
\iffalse |
| 188 |
\pslineByHand( 1.20, 1.50)( 1.20, 1.51)( 1.20, 1.53)( 1.20, 1.54)( 1.19, 1.55)( 1.19, 1.56) |
| 189 |
( 1.19, 1.57)( 1.18, 1.59)( 1.18, 1.60)( 1.17, 1.61)( 1.16, 1.62)( 1.15, 1.63)( 1.15, 1.64) |
| 190 |
( 1.14, 1.65)( 1.13, 1.65)( 1.12, 1.66)( 1.11, 1.67)( 1.10, 1.68)( 1.09, 1.68)( 1.07, 1.69) |
| 191 |
( 1.06, 1.69)( 1.05, 1.69)( 1.04, 1.70)( 1.03, 1.70)( 1.01, 1.70)( 1.00, 1.70)( 0.99, 1.70) |
| 192 |
( 0.97, 1.70)( 0.96, 1.70)( 0.95, 1.69)( 0.94, 1.69)( 0.93, 1.69)( 0.91, 1.68)( 0.90, 1.68) |
| 193 |
( 0.89, 1.67)( 0.88, 1.66)( 0.87, 1.65)( 0.86, 1.65)( 0.85, 1.64)( 0.85, 1.63)( 0.84, 1.62) |
| 194 |
( 0.83, 1.61)( 0.82, 1.60)( 0.82, 1.59)( 0.81, 1.57)( 0.81, 1.56)( 0.81, 1.55)( 0.80, 1.54) |
| 195 |
( 0.80, 1.53)( 0.80, 1.51)( 0.80, 1.50)( 0.80, 1.49)( 0.80, 1.47)( 0.80, 1.46)( 0.81, 1.45) |
| 196 |
( 0.81, 1.44)( 0.81, 1.43)( 0.82, 1.41)( 0.82, 1.40)( 0.83, 1.39)( 0.84, 1.38)( 0.85, 1.37) |
| 197 |
( 0.85, 1.36)( 0.86, 1.35)( 0.87, 1.35)( 0.88, 1.34)( 0.89, 1.33)( 0.90, 1.32)( 0.91, 1.32) |
| 198 |
( 0.93, 1.31)( 0.94, 1.31)( 0.95, 1.31)( 0.96, 1.30)( 0.97, 1.30)( 0.99, 1.30)( 1.00, 1.30) |
| 199 |
( 1.01, 1.30)( 1.03, 1.30)( 1.04, 1.30)( 1.05, 1.31)( 1.06, 1.31)( 1.07, 1.31)( 1.09, 1.32) |
| 200 |
( 1.10, 1.32)( 1.11, 1.33)( 1.12, 1.34)( 1.13, 1.35)( 1.14, 1.35)( 1.15, 1.36)( 1.15, 1.37) |
| 201 |
( 1.16, 1.38)( 1.17, 1.39)( 1.18, 1.40)( 1.18, 1.41)( 1.19, 1.43)( 1.19, 1.44)( 1.19, 1.45) |
| 202 |
( 1.20, 1.46)( 1.20, 1.47)( 1.20, 1.49)( 1.20, 1.50) |
| 203 |
\fi |
| 204 |
|
| 205 |
\begin{LTXexample}[pos=t] |
| 206 |
\begin{pspicture}(\linewidth,3) |
| 207 |
\multido{\rA=0.00+0.25}{12}{\pslineByHand[linecolor=blue](0,\rA)(\linewidth,\rA)} |
| 208 |
\end{pspicture} |
| 209 |
\end{LTXexample} |
| 210 |
|
| 211 |
The amplitude and the width can be changed by the optional arguments \Lkeyword{varsteptol} and |
| 212 |
\Lkeyword{VarStepEpsilon}. Both are preset to \verb+VarStepEpsilon=2,varsteptol=0.8+. |
| 213 |
|
| 214 |
|
| 215 |
\begin{LTXexample}[pos=t] |
| 216 |
\begin{pspicture}(\linewidth,3) |
| 217 |
\multido{\rA=0.00+0.25}{12}{% |
| 218 |
\pslineByHand[linecolor=blue,VarStepEpsilon=4,varsteptol=2](0,\rA)(\linewidth,\rA)} |
| 219 |
\end{pspicture} |
| 220 |
\end{LTXexample} |
| 221 |
|
| 222 |
|
| 223 |
\clearpage |
| 224 |
|
| 225 |
%-------------------------------------------------------------------------------------- |
| 226 |
\section{\nxLcs{rmultiput}: a multiple \nxLcs{rput}} |
| 227 |
%-------------------------------------------------------------------------------------- |
| 228 |
\verb+PSTricks+ already has a \Lcs{multirput}, which puts a box n |
| 229 |
times with a difference of $dx$ and $dy$ relative to each other. |
| 230 |
It is not possible to put it with a different distance from one |
| 231 |
point to the next. This is possible with \Lcs{rmultiput}: |
| 232 |
|
| 233 |
\begin{BDef} |
| 234 |
\LcsStar{rmultiput}\OptArgs\Largb{any material}\coord1\coord2\ldots\Largr{\coord{n}} |
| 235 |
\end{BDef} |
| 236 |
|
| 237 |
\begin{LTXexample}[width=6.2cm] |
| 238 |
\psset{unit=0.75} |
| 239 |
\begin{pspicture}(-4,-4)(4,4) |
| 240 |
\rmultiput[rot=45]{\red\psscalebox{3}{\ding{250}}}% |
| 241 |
(-2,-4)(-2,-3)(-3,-3)(-2,-1)(0,0)(1,2)(1.5,3)(3,3) |
| 242 |
\rmultiput[rot=90,ref=lC]{\blue\psscalebox{2}{\ding{253}}}% |
| 243 |
(-2,2.5)(-2,2.5)(-3,2.5)(-2,1)(1,-2)(1.5,-3)(3,-3) |
| 244 |
\psgrid[subgriddiv=0,gridcolor=lightgray] |
| 245 |
\end{pspicture} |
| 246 |
\end{LTXexample} |
| 247 |
|
| 248 |
\clearpage |
| 249 |
|
| 250 |
|
| 251 |
%-------------------------------------------------------------------------------------- |
| 252 |
\section{\nxLcs{psVector}: Drawing relative vector lines} |
| 253 |
%-------------------------------------------------------------------------------------- |
| 254 |
|
| 255 |
The new macros \Lcs{psStartPoint} and \Lcs{psVector} allow to draw a series of |
| 256 |
vectors which start point refers to the endpoint of the last drawn vector. The |
| 257 |
coordinates of the endpoint are \emph{always} interpreted relative to the last |
| 258 |
the vector. The first vector refers to the coordinates set by \Lcs{psStartPoint}. |
| 259 |
With the boolean argument one can draw the horizontal angle of the vector. |
| 260 |
|
| 261 |
\begin{BDef} |
| 262 |
\Lcs{psVector}\OptArgs\OptArg*{\texttt{<startpoint>}}\coord1\coord2\ldots\Largr{\coord{n}}\\ |
| 263 |
\Lcs{psStartPoint}\OptArg{node basename}\Largr{$x$,$y$} |
| 264 |
\end{BDef} |
| 265 |
|
| 266 |
If the optional argument in angle braces is given then it will be the start point |
| 267 |
for the current vector and the next ones, until a new start point is defined or a |
| 268 |
new optional argument is used. |
| 269 |
|
| 270 |
The style of the angle arc is saved in \Lkeyval{psMarkAngleStyle} and the style |
| 271 |
for the horizontal line in \Lkeyval{psMarkAngleLineStyle} and preset to |
| 272 |
|
| 273 |
\begin{lstlisting} |
| 274 |
\newpsstyle{psMarkAngleStyle}{arrows=->,arrowsize=4pt} |
| 275 |
\newpsstyle{psMarkAngleLineStyle}{linestyle=dotted} |
| 276 |
\end{lstlisting} |
| 277 |
|
| 278 |
|
| 279 |
\begin{pspicture}[showgrid](10,10) |
| 280 |
\psVector<1,1>(3;30)(4;60)\nbput{$V_2$} |
| 281 |
\psVector[linecolor=red](3;10)\nbput{$V_3$} |
| 282 |
\psVector[linestyle=dashed](4;110)\nbput{$V_4$} |
| 283 |
\psStartPoint(1,1)\psset{markAngle} |
| 284 |
\psVector[linestyle=dashed](4;110)\ncput*{$V_1$} |
| 285 |
\psVector[linecolor=red](3;10)\ncput*{$V_2$} |
| 286 |
\psVector(4;60)(3;30)\ncput*{$V_4$} |
| 287 |
\end{pspicture} |
| 288 |
|
| 289 |
\begin{lstlisting} |
| 290 |
\begin{pspicture}[showgrid](10,10) |
| 291 |
\psVector<1,1>(3;30)(4;60)\nbput{$V_2$} |
| 292 |
\psVector[linecolor=red](3;10)\nbput{$V_3$} |
| 293 |
\psVector[linestyle=dashed](4;110)\nbput{$V_4$} |
| 294 |
\psset{markAngle} |
| 295 |
\psVector[linestyle=dashed]<1,1>(4;110)\ncput*{$V_1$} |
| 296 |
\psVector[linecolor=red](3;10)\ncput*{$V_2$} |
| 297 |
\psVector(4;60)(3;30)\ncput*{$V_4$} |
| 298 |
\end{pspicture} |
| 299 |
\end{lstlisting} |
| 300 |
|
| 301 |
All end points of the vectors are saved in node names with the preset name \verb=Vector#=, |
| 302 |
where \# is the consecutive number of the nodes. \verb=Vector0= ist the starting point of |
| 303 |
the first \Lcs{psVector}. With the macro \Lcs{psStartPoint} one can set the starting point and |
| 304 |
with optional argument the name of the nodes. \verb=Vector3= is the default node name of |
| 305 |
the endpoint of the third vector or the name of the starting point of the forth vector. |
| 306 |
|
| 307 |
|
| 308 |
\begin{pspicture}[showgrid,linewidth=1pt](10,10.4) |
| 309 |
\psStartPoint[A](1,1)% nodes have the base name A |
| 310 |
\psVector(3;30)(4;60)\psVector[linecolor=red](3;10) |
| 311 |
\psVector[linestyle=dashed](4;110)\nbput{$V_3$} |
| 312 |
\psline{->}(A0)(A4) |
| 313 |
\psStartPoint[B](1,1)\psset{markAngle}% nodes have the base name B |
| 314 |
\psVector[linestyle=dashed](4;110)\naput{$V_1$} |
| 315 |
\psVector[linecolor=red](3;10)\ncput*{$V_2$} |
| 316 |
\psVector(4;60)(3;30) |
| 317 |
\psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=red](B2)(A2) |
| 318 |
\psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=blue](A3)(B3) |
| 319 |
\multido{\iA=0+1}{5}{\uput[0](A\iA){A\iA}\uput[180](B\iA){B\iA}} |
| 320 |
\end{pspicture} |
| 321 |
|
| 322 |
\begin{lstlisting} |
| 323 |
\begin{pspicture}[showgrid,linewidth=1pt](10,10.4) |
| 324 |
\psStartPoint[A](1,1)% nodes have the base name A |
| 325 |
\psVector(3;30)(4;60)\psVector[linecolor=red](3;10) |
| 326 |
\psVector[linestyle=dashed](4;110)\nbput{$V_3$} |
| 327 |
\psline{->}(A0)(A4) |
| 328 |
\psStartPoint[B](1,1)\psset{markAngle}% nodes have the base name B |
| 329 |
\psVector[linestyle=dashed](4;110)\naput{$V_1$} |
| 330 |
\psVector[linecolor=red](3;10)\ncput*{$V_2$} |
| 331 |
\psVector(4;60)(3;30) |
| 332 |
\psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=red](B2)(A2) |
| 333 |
\psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=blue](A3)(B3) |
| 334 |
\multido{\iA=0+1}{5}{\uput[0](A\iA){A\iA}\uput[180](B\iA){B\iA}} |
| 335 |
\end{pspicture} |
| 336 |
\end{lstlisting} |
| 337 |
|
| 338 |
\clearpage |
| 339 |
|
| 340 |
|
| 341 |
%-------------------------------------------------------------------------------------- |
| 342 |
\section{\nxLcs{psCircleTangents}: Calculating tangent lines of circles} |
| 343 |
%-------------------------------------------------------------------------------------- |
| 344 |
|
| 345 |
The macro calculates the points on a circle where tangent lines from another |
| 346 |
point or another circle are drawn. |
| 347 |
|
| 348 |
\begin{BDef} |
| 349 |
\Lcs{psCircleTangents}\Largr{$x1,y1$}\Largr{$x2,y2$}\Largb{Radius}\\ |
| 350 |
\Lcs{psCircleTangents}\Largr{$x1,y1$}\Largb{Radius}\Largr{$x2,y2$}\Largb{Radius} |
| 351 |
\end{BDef} |
| 352 |
|
| 353 |
In the first case the coordinates of a point and the center and the radius |
| 354 |
of a circle must be given. The names of the calculates node names are \verb=CircleT1= |
| 355 |
and \verb=CircleT2=. |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
\bigskip |
| 360 |
\begin{pspicture}[showgrid](0,3)(10,10) |
| 361 |
\psdot(2,4)\pscircle(7,7){2} |
| 362 |
\psCircleTangents(2,4)(7,7){2} |
| 363 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT1) |
| 364 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT2) |
| 365 |
\psdots(CircleT1)(CircleT2) |
| 366 |
\uput[-80](CircleT1){T1}\uput[115](CircleT2){T2} |
| 367 |
\end{pspicture} |
| 368 |
|
| 369 |
\begin{lstlisting} |
| 370 |
\begin{pspicture}[showgrid](0,3)(10,10) |
| 371 |
\psdot(2,4)\pscircle(7,7){2} |
| 372 |
\psCircleTangents(2,4)(7,7){2} |
| 373 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT1) |
| 374 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT2) |
| 375 |
\psdots(CircleT1)(CircleT2) |
| 376 |
\uput[-80](CircleT1){T1}\uput[115](CircleT2){T2} |
| 377 |
\end{pspicture} |
| 378 |
\end{lstlisting} |
| 379 |
|
| 380 |
\bigskip |
| 381 |
When using the other variant of the macro two circles must be given. The macro then defines |
| 382 |
ten nodes, named \verb=CircleTC1= and \verb=CircleTC2= for the two intersection points, |
| 383 |
\verb=CircleTO1=, \verb=CircleTO2=, \verb=CircleTO3=, and \verb=CircleTO4= for the four |
| 384 |
nodes of the outer tangent lines and |
| 385 |
\verb=CircleTI1=, \verb=CircleTI2=, \verb=CircleTI3=, and \verb=CircleTI4= for the |
| 386 |
four nodes of the inner tangent lines. |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
\bigskip |
| 392 |
\begin{pspicture}[showgrid](-2,-2)(10,10) |
| 393 |
\pscircle(1,1){1}\pscircle(7,7){3} |
| 394 |
\psCircleTangents(1,1){1}(7,7){3} |
| 395 |
\pcline[nodesep=-1cm,linecolor=blue](CircleTO1)(CircleTO2) |
| 396 |
\pcline[nodesep=-1cm,linecolor=blue](CircleTO3)(CircleTO4) |
| 397 |
\pcline[nodesep=-1cm,linecolor=red](CircleTI1)(CircleTI2) |
| 398 |
\pcline[nodesep=-1cm,linecolor=red](CircleTI3)(CircleTI4) |
| 399 |
\psdots(CircleTC1)(CircleTC2)% |
| 400 |
(CircleTO1)(CircleTO2)(CircleTO3)(CircleTO4)% |
| 401 |
(CircleTI1)(CircleTI2)(CircleTI3)(CircleTI4)% |
| 402 |
\uput[0](CircleTC1){TC1}\uput[0](CircleTC2){TC2} |
| 403 |
\uput[-80](CircleTI1){TI1}\uput[115](CircleTI2){TI2} |
| 404 |
\uput[150](CircleTI3){TI3}\uput[-45](CircleTI4){TI4} |
| 405 |
\uput[-80](CircleTO1){TO1}\uput[150](CircleTO2){TO2} |
| 406 |
\uput[150](CircleTO3){TO3}\uput[-45](CircleTO4){TO4} |
| 407 |
\end{pspicture} |
| 408 |
|
| 409 |
\bigskip |
| 410 |
\begin{lstlisting} |
| 411 |
\begin{pspicture}[showgrid](-2,-2)(10,10) |
| 412 |
\pscircle(1,1){1}\pscircle(7,7){3} |
| 413 |
\psCircleTangents(1,1){1}(7,7){3} |
| 414 |
\pcline[nodesep=-1cm,linecolor=blue](CircleTO1)(CircleTO2) |
| 415 |
\pcline[nodesep=-1cm,linecolor=blue](CircleTO3)(CircleTO4) |
| 416 |
\pcline[nodesep=-1cm,linecolor=red](CircleTI1)(CircleTI2) |
| 417 |
\pcline[nodesep=-1cm,linecolor=red](CircleTI3)(CircleTI4) |
| 418 |
\psdots(CircleTC1)\psdots(CircleTC2)% |
| 419 |
(CircleTO1)(CircleTO2)(CircleTO3)(CircleTO4)% |
| 420 |
(CircleTI1)(CircleTI2)(CircleTI3)(CircleTI4)% |
| 421 |
\uput[0](CircleTC1){TC1}\uput[0](CircleTC2){TC2} |
| 422 |
\uput[-80](CircleTI1){TI1}\uput[115](CircleTI2){TI2} |
| 423 |
\uput[150](CircleTI3){TI3}\uput[-45](CircleTI4){TI4} |
| 424 |
\uput[-80](CircleTO1){TO1}\uput[150](CircleTO2){TO2} |
| 425 |
\uput[150](CircleTO3){TO3}\uput[-45](CircleTO4){TO4} |
| 426 |
\end{pspicture} |
| 427 |
\end{lstlisting} |
| 428 |
|
| 429 |
|
| 430 |
\clearpage |
| 431 |
|
| 432 |
%-------------------------------------------------------------------------------------- |
| 433 |
\section{\nxLcs{psEllipseTangents}: Calculating tangent lines of an ellipse} |
| 434 |
%-------------------------------------------------------------------------------------- |
| 435 |
|
| 436 |
The macro calculates the two points on an ellipse where tangent lines from an outside point |
| 437 |
are drawn. |
| 438 |
|
| 439 |
\begin{BDef} |
| 440 |
\Lcs{psEllipseTangents}\Largr{$x_0,y_0$}\Largr{$a,b$}\Largr{$x_p,y_p$}\\ |
| 441 |
\end{BDef} |
| 442 |
|
| 443 |
The first two pairs of coordinates are the same as the ones for the default ellipse. |
| 444 |
The names of the calculates node names are \verb=EllipseT1= |
| 445 |
and \verb=EllipseT2=. |
| 446 |
|
| 447 |
\bigskip |
| 448 |
\begin{pspicture}[showgrid](0,3)(10,10) |
| 449 |
\psdot(2,4)\psellipse(7,7)(3,1.5) |
| 450 |
\psEllipseTangents(7,7)(3,1.5)(2,4) |
| 451 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT1) |
| 452 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT2) |
| 453 |
\psdots(EllipseT1)(EllipseT2) |
| 454 |
\uput[-80](EllipseT1){T1}\uput[115](EllipseT2){T2} |
| 455 |
\end{pspicture} |
| 456 |
|
| 457 |
|
| 458 |
\begin{lstlisting} |
| 459 |
\begin{pspicture}[showgrid](0,3)(10,10) |
| 460 |
\psdot(2,4)\psellipse(7,7)(3,1.5) |
| 461 |
\psEllipseTangents(7,7)(3,1.5)(2,4) |
| 462 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT1) |
| 463 |
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT2) |
| 464 |
\psdots(EllipseT1)(EllipseT2) |
| 465 |
\uput[-80](EllipseT1){T1}\uput[115](EllipseT2){T2} |
| 466 |
\end{pspicture} |
| 467 |
\end{lstlisting} |
| 468 |
|
| 469 |
|
| 470 |
\clearpage |
| 471 |
|
| 472 |
%-------------------------------------------------------------------------------------- |
| 473 |
\section{\nxLcs{psrotate}: Rotating objects} |
| 474 |
%-------------------------------------------------------------------------------------- |
| 475 |
\Lcs{rput} also has an optional argument for rotating objects, but |
| 476 |
it always depends on the \Lcs{rput} coordinates. With |
| 477 |
\Lcs{psrotate} the rotating center can be placed anywhere. The |
| 478 |
rotation is done with \verb+\pscustom+, all optional arguments are |
| 479 |
only valid if they are part of the \verb+\pscustom+ macro. |
| 480 |
|
| 481 |
\begin{BDef} |
| 482 |
\Lcs{psrotate}\OptArgs\Largr{$x,y$}\Largb{rot angle}\Largb{object} |
| 483 |
\end{BDef} |
| 484 |
|
| 485 |
\begin{LTXexample}[width=0.4\linewidth] |
| 486 |
\psset{unit=0.75} |
| 487 |
\begin{pspicture}(-0.5,-3.5)(8.5,4.5) |
| 488 |
\psaxes{->}(0,0)(-0.5,-3)(8.5,4.5) |
| 489 |
\psdots[linecolor=red,dotscale=1.5](2,1) |
| 490 |
\psarc[linecolor=red,linewidth=0.4pt,showpoints=true] |
| 491 |
{->}(2,1){3}{0}{60} |
| 492 |
\pspolygon[linecolor=green,linewidth=1pt](2,1)(5,1.1)(6,-1)(2,-2) |
| 493 |
\psrotate(2,1){60}{% |
| 494 |
\pspolygon[linecolor=blue,linewidth=1pt](2,1)(5,1.1)(6,-1)(2,-2)} |
| 495 |
\end{pspicture} |
| 496 |
\end{LTXexample} |
| 497 |
|
| 498 |
|
| 499 |
\begin{LTXexample}[width=6cm] |
| 500 |
\begin{pspicture}(-1,-1)(3,6) |
| 501 |
\def\canne{% Idea by Manuel Luque |
| 502 |
\psgrid[subgriddiv=0](-1,0)(1,5) |
| 503 |
\pscustom[linewidth=2mm]{\psline(0,4)\psarcn(0.3,4){0.3}{180}{360}}% |
| 504 |
\pscircle*(0.6,4){0.1}\pstriangle*(0,0)(0.2,-0.3)} |
| 505 |
\def\Object{} |
| 506 |
\canne |
| 507 |
\psrotate(0.3,4){45}{\psset{linecolor=red!50}\canne} |
| 508 |
\psrotate(0.3,4){90}{\psset{linecolor=blue!50}\canne} |
| 509 |
\psrotate(0.3,4){360}{\psset{linecolor=cyan!50}\canne} |
| 510 |
\psdot[linecolor=red](0.3,4) |
| 511 |
\end{pspicture} |
| 512 |
\end{LTXexample} |
| 513 |
|
| 514 |
|
| 515 |
\begin{LTXexample}[pos=t] |
| 516 |
\begin{pspicture}(0,-6)(15,5) |
| 517 |
\def\majorette{\psline[linewidth=0.5mm](0,2)% Idea by Manuel Luque |
| 518 |
\pscircle[fillstyle=solid]{0.1} |
| 519 |
\pscircle[fillstyle=solid](0,2){0.1}} |
| 520 |
\psaxes[linewidth=0.5pt]{->}(0,0)(0,-5)(15,5) |
| 521 |
\pstVerb{/V0 10 def /Alpha 45 def}% vitesse initiale, angle de lancement |
| 522 |
\multido{\nT=0.0+0.05,\iA=0+40}{41}{% |
| 523 |
\pstVerb{/nT \nT\space def}% |
| 524 |
\rput(!V0 Alpha cos mul nT mul -9.81 2 div nT dup mul mul V0 Alpha sin mul nT mul add){% |
| 525 |
\psrotate(0,1){\iA}{\majorette\psdot[linecolor=red](0,1)\psdot[linecolor=green](0,2)}}} |
| 526 |
\parametricplot[linecolor=red]{0}{2}{% trajectoire du milieu |
| 527 |
V0 Alpha cos mul t mul -9.81 2 div t dup mul mul V0 Alpha sin mul t mul add 1 add} |
| 528 |
\parametricplot[linecolor=green,plotpoints=360]{0}{2}{% d'une extremite |
| 529 |
V0 Alpha cos mul t mul 800 t mul sin sub % x(t) |
| 530 |
-9.81 2 div t dup mul mul V0 Alpha sin mul t mul add 1 add 800 t mul cos add }%y(t) |
| 531 |
\end{pspicture} |
| 532 |
\end{LTXexample} |
| 533 |
|
| 534 |
|
| 535 |
\clearpage |
| 536 |
|
| 537 |
%-------------------------------------------------------------------------------------- |
| 538 |
\section{\nxLcs{psComment}: comments to a graphic} |
| 539 |
%-------------------------------------------------------------------------------------- |
| 540 |
|
| 541 |
\begin{BDef} |
| 542 |
\LcsStar{psComment}\OptArgs\OptArg*{\Largb{arrows}}\coord0\coord1\Largb{Text}\OptArg{line macro}\OptArg{put macro} |
| 543 |
\end{BDef} |
| 544 |
|
| 545 |
By default the macro uses the \Lcs{ncline} macro to draw a line from the first to the |
| 546 |
second point, it can be changed with the first additional optional argument. The label is |
| 547 |
put by default with \Lcs{rput}, which can be changed with the last optional argument. |
| 548 |
If this is used, then the line macro has also be defined, eg \verb+\psComment(A)(B){text}[\ncarc][\ncput}+ |
| 549 |
At least, leave the argument empty. |
| 550 |
|
| 551 |
|
| 552 |
\begin{LTXexample}[pos=t,wide] |
| 553 |
\SpecialCoor\newpsstyle{weiss}{fillstyle=solid,fillcolor=white} |
| 554 |
\footnotesize\psset{unit=0.5cm,dimen=middle} |
| 555 |
\begin{pspicture}(-12,-4)(6,10) |
| 556 |
\psframe*[linecolor=black!20](-5,-3)(5,7) \psframe*[linecolor=black!40](-5,3)(5,6) |
| 557 |
\pscircle(-8.19,5.51){0.2} |
| 558 |
\psframe[fillcolor=white,fillstyle=solid](-5.8,3.6)(4.3,5.8) |
| 559 |
\psframe(-8.98,3.14)(-5.8,6.32) |
| 560 |
\multido{\rA=-4.1+1.3}{5}{\rput(\rA,-2.4){\psframe[style=weiss](1.1,6) |
| 561 |
\psline(0,0)(1.1,0.5)(0,1)(1.1,1.6)(0,2.2)(1.1,2.7)(0,3.2)(1.1,3.2)}} |
| 562 |
\pspolygon*(-4.1,3.7)(-4.1,3)(-3,3)(-3.01,3.7)(-3.54,4.19) |
| 563 |
\pspolygon*(1.09,3.7)(1.1,3)(2.2,3)(2.18,3.7)(1.65,4.24) |
| 564 |
\pspolygon*(-2.78,3.7)(-2.8,3)(-1.7,3)(-1.71,3.7)(-2.27,4.04) |
| 565 |
\pspolygon*(-1.51,3.7)(-1.5,3)(-0.4,3)(-0.41,3.7)(-1.02,4.17) |
| 566 |
\pspolygon*(-0.21,3.7)(-0.2,3)(0.9,3)(0.89,3.7)(0.3,4.04) |
| 567 |
\psline(-5,3.83)(-4.15,3.86)(-3.5,4.3)(-2.85,3.81)(-2.22,4.21)(-1.6,3.86)(-0.99,4.33) |
| 568 |
(-0.28,3.83)(0.35,4.19)(0.97,3.83)(1.65,4.39)(2.2,4.01)(3.57,4.89)(2.41,5.8) |
| 569 |
\psline(-5,5.8)(-5.78,5.8) \psline(-5.78,5.47)(2.85,5.47) |
| 570 |
\psline(-5.8,3.52)(-5,3.5) \psline(3.57,4.89)(-5.8,4.89) |
| 571 |
\psComment*[ref=r]{->}(-8.14,1.19)(-4.31,3.27){Mantelstift} |
| 572 |
\psComment*[ref=r]{->}(-8.17,-0.56)(-4.37,1.59){Kernstift}[\ncarc] |
| 573 |
\psComment*[ref=r]{->}(-7.91,-2.24)(-4.44,-0.23){Feder}[\ncarc] |
| 574 |
\psComment[npos=-0.1]{->}(-3.48,8.72)(-1.33,5.46){Nur f\"ur Profil} |
| 575 |
\end{pspicture} |
| 576 |
\end{LTXexample} |
| 577 |
|
| 578 |
\clearpage |
| 579 |
%-------------------------------------------------------------------------------------- |
| 580 |
\section{\nxLcs{psChart}: a pie chart} |
| 581 |
%-------------------------------------------------------------------------------------- |
| 582 |
|
| 583 |
\begin{BDef} |
| 584 |
\Lcs{psChart}\OptArgs\Largb{comma separated value list}\Largb{comma separated value list}\Largb{radius} |
| 585 |
\end{BDef} |
| 586 |
|
| 587 |
The special optional arguments for the \Lcs{psChart} macro are as follows: |
| 588 |
|
| 589 |
\noindent |
| 590 |
\begin{tabularx}{\linewidth}{@{}>{\ttfamily}lX>{\ttfamily}l@{}} |
| 591 |
\textrm{\emph{name}} & \textrm{\emph{description}} & \textrm{\emph{default}}\\\hline |
| 592 |
\Lkeyword{chartSep} & distance from the pie chart center to an outraged pie piece & 10pt\\ |
| 593 |
\Lkeyword{chartColor} & gray or colored pie (values are: \texttt{gray} or \texttt{color})& gray\\ |
| 594 |
\Lkeyword{userColor} & a comma separated list of user defined colors for the pie & \{\}\\ |
| 595 |
\Lkeyword{chartNodeI}& the position of the inner node, relative to the radius & 0.75\\ |
| 596 |
\Lkeyword{chartNodeO}& the position of the outer node, relative to the radius & 1.5 |
| 597 |
\end{tabularx} |
| 598 |
|
| 599 |
\bigskip |
| 600 |
The first mandatory argument is the list of the values and may not be empty. The second |
| 601 |
one is a list of outraged pieces, numbered consecutively from 1 to up the total number |
| 602 |
of values. The list of user defined colors must be enclosed in braces! |
| 603 |
|
| 604 |
The macro \Lcs{psChart} defines for every value three nodes at the half angle and |
| 605 |
in distances from 0.75, 1, and 1.25 times of the radius from the origin. The nodes |
| 606 |
are named as \verb+psChartI?+, \verb+psChart?+, and \verb+psChartO?+, where ? is the number of |
| 607 |
the pie. The letter I leads to the inner node and the letter O to the outer node. |
| 608 |
The distance can be changed with the optional arguments \Lkeyword{chartNodeI} and |
| 609 |
\Lkeyword{chartNodeO} in the usual way with \verb+\psset{chartNodeI=...,chartNodeO=...}+. |
| 610 |
|
| 611 |
The other one is the node on the circle line. |
| 612 |
The origin is by default \texttt{(0,0)}. Moving the pie to another position can be done as |
| 613 |
usual with the \Lcs{rput}-macro. The used colors are named internally as \Lkeyword{chartFillColor?} |
| 614 |
and can be used by the user for coloring lines or text. |
| 615 |
|
| 616 |
\begin{LTXexample}[width=6cm] |
| 617 |
\begin{pspicture}(-3,-3)(3,3) |
| 618 |
\psChart{ 23, 29, 3, 26, 28, 14 }{}{2} |
| 619 |
\multido{\iA=1+1}{6}{% |
| 620 |
\psdot(psChart\iA)\psdot(psChartI\iA)\psdot(psChartO\iA)% |
| 621 |
\psline[linestyle=dashed,linecolor=white](psChart\iA) |
| 622 |
\psline[linestyle=dashed](psChart\iA)(psChartO\iA)} |
| 623 |
\end{pspicture} |
| 624 |
\end{LTXexample} |
| 625 |
|
| 626 |
\begin{LTXexample}[width=6cm] |
| 627 |
\begin{pspicture}(-3,-3)(3,3) |
| 628 |
\psChart[chartColor=color]{45,90}{1}{2} |
| 629 |
\ncline[linecolor=-chartFillColor1, |
| 630 |
nodesepB=-20pt]{psChartO1}{psChart1} |
| 631 |
\rput[l](psChartO1){% |
| 632 |
\textcolor{chartFillColor1}{pie no 1}} |
| 633 |
\ncline[linecolor=-chartFillColor2, |
| 634 |
nodesepB=-20pt]{psChartO2}{psChart2} |
| 635 |
\rput[lt](psChartO2){% |
| 636 |
\textcolor{chartFillColor2}{pie no 2}} |
| 637 |
\end{pspicture} |
| 638 |
\end{LTXexample} |
| 639 |
|
| 640 |
\begin{LTXexample}[width=7.5cm] |
| 641 |
\psframebox[fillcolor=black!20, |
| 642 |
fillstyle=solid]{% |
| 643 |
\begin{pspicture}(-3.5,-3.5)(4.25,3.5) |
| 644 |
\psChart[chartColor=color]% |
| 645 |
{23, 29, 3, 26, 28, 14, 17, 4, 9}{}{2} |
| 646 |
\multido{\iA=1+1}{9}{% |
| 647 |
\ncline[linecolor=-chartFillColor\iA, |
| 648 |
nodesepB=-10pt]{psChartO\iA}{psChart\iA} |
| 649 |
\rput[l](psChartO\iA){% |
| 650 |
\textcolor{chartFillColor\iA}{pie no \iA}}} |
| 651 |
\end{pspicture}} |
| 652 |
\end{LTXexample} |
| 653 |
|
| 654 |
\begin{LTXexample}[width=6cm] |
| 655 |
\begin{pspicture}(-3,-3)(3,3) |
| 656 |
\psChart[userColor={red!30,green!30, |
| 657 |
blue!40,gray,magenta!60,cyan}]% |
| 658 |
{ 23, 29, 3, 26, 28, 14 }{1,4}{2} |
| 659 |
\end{pspicture} |
| 660 |
\end{LTXexample} |
| 661 |
|
| 662 |
\begin{LTXexample}[width=6cm] |
| 663 |
\begin{pspicture}(-3,-2.5)(3,2.5) |
| 664 |
\psChart{ 23, 29, 3, 26, 28, 14 }{}{2} |
| 665 |
\multido{\iA=1+1}{6}{\rput*(psChartI\iA){\iA}} |
| 666 |
\end{pspicture} |
| 667 |
\end{LTXexample} |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
%\begin{LTXexample}[pos=t] |
| 675 |
\psset{unit=1.5} |
| 676 |
\begin{pspicture}(-3,-3)(3,3) |
| 677 |
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50, |
| 678 |
magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2} |
| 679 |
\psset{nodesepA=5pt,nodesepB=-10pt} |
| 680 |
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)} |
| 681 |
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)} |
| 682 |
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)} |
| 683 |
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)} |
| 684 |
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)} |
| 685 |
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)} |
| 686 |
\bfseries% |
| 687 |
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills} |
| 688 |
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food} |
| 689 |
\end{pspicture} |
| 690 |
%\end{LTXexample} |
| 691 |
\psset{unit=1cm} |
| 692 |
|
| 693 |
\begin{lstlisting} |
| 694 |
\psset{unit=1.5} |
| 695 |
\begin{pspicture}(-3,-3)(3,3) |
| 696 |
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50, |
| 697 |
magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2} |
| 698 |
\psset{nodesepA=5pt,nodesepB=-10pt} |
| 699 |
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)} |
| 700 |
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)} |
| 701 |
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)} |
| 702 |
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)} |
| 703 |
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)} |
| 704 |
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)} |
| 705 |
\bfseries% |
| 706 |
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills} |
| 707 |
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food} |
| 708 |
\end{pspicture} |
| 709 |
\end{lstlisting} |
| 710 |
|
| 711 |
|
| 712 |
The linecolor of the pies is by default identical to the fillcolor. If you want another line color |
| 713 |
for all pies then use the optional argument \Lkeyword{uselinecolor}. In this case the current |
| 714 |
setting of \Lkeyword{linecolor} is taken into account: |
| 715 |
|
| 716 |
|
| 717 |
%\begin{LTXexample}[pos=t] |
| 718 |
\psset{unit=1.5} |
| 719 |
\begin{pspicture}(-3,-3)(3,3) |
| 720 |
\psChart[chartSep=30pt,shadow=true,shadowsize=5pt, |
| 721 |
uselinecolor,linecolor=black!20]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2} |
| 722 |
\psset{nodesepA=5pt,nodesepB=-10pt} |
| 723 |
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)} |
| 724 |
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)} |
| 725 |
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)} |
| 726 |
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)} |
| 727 |
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)} |
| 728 |
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)} |
| 729 |
\bfseries\color{white}% |
| 730 |
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills} |
| 731 |
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food} |
| 732 |
\end{pspicture} |
| 733 |
%\end{LTXexample} |
| 734 |
\psset{unit=1cm} |
| 735 |
|
| 736 |
\begin{lstlisting} |
| 737 |
\psset{unit=1.5} |
| 738 |
\begin{pspicture}(-3,-3)(3,3) |
| 739 |
\psChart[chartSep=30pt,shadow=true,shadowsize=5pt, |
| 740 |
uselinecolor,linecolor=black!20]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2} |
| 741 |
\psset{nodesepA=5pt,nodesepB=-10pt} |
| 742 |
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)} |
| 743 |
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)} |
| 744 |
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)} |
| 745 |
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)} |
| 746 |
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)} |
| 747 |
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)} |
| 748 |
\bfseries\color{white}% |
| 749 |
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills} |
| 750 |
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food} |
| 751 |
\end{pspicture} |
| 752 |
\end{lstlisting} |
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
Using a csv file for the data is possible with \Lcs{psreadDataColumn}. This macro deletes the commas in the csv file, but |
| 757 |
\Lcs{psChart} needs it as separator. With the option \Lkeyword{outDelimiter} it can be insert again: |
| 758 |
|
| 759 |
\begin{lstlisting} |
| 760 |
\begin{filecontents}[force]{Datitos.csv} |
| 761 |
%Dato Frecuencia |
| 762 |
1,4 |
| 763 |
2,7 |
| 764 |
3,5 |
| 765 |
4,1 |
| 766 |
5,4 |
| 767 |
6,6 |
| 768 |
\end{filecontents} |
| 769 |
|
| 770 |
\psreadDataColumn[ignoreLines=1,outDelimiter={,\space}]{2}{,}{\dada}{Datitos.csv} |
| 771 |
|
| 772 |
\begin{pspicture}(-4,-4)(4,4) |
| 773 |
\expandafter\psChart\expandafter{\dada}{}{4} |
| 774 |
\end{pspicture} |
| 775 |
\end{lstlisting} |
| 776 |
|
| 777 |
\begin{filecontents}[force]{Datitos.csv} |
| 778 |
%Dato Frecuencia |
| 779 |
1,4 |
| 780 |
2,7 |
| 781 |
3,5 |
| 782 |
4,1 |
| 783 |
5,4 |
| 784 |
6,6 |
| 785 |
\end{filecontents} |
| 786 |
|
| 787 |
\psreadDataColumn[ignoreLines=1,outDelimiter={, }]{2}{,}{\dada}{Datitos.csv} |
| 788 |
|
| 789 |
\begin{pspicture}(-4,-4)(4,4) |
| 790 |
\expandafter\psChart\expandafter{\dada}{}{4} |
| 791 |
\end{pspicture} |
| 792 |
|
| 793 |
\clearpage |
| 794 |
%-------------------------------------------------------------------------------------- |
| 795 |
\section{\nxLcs{psHomothetie}: central dilatation} |
| 796 |
%-------------------------------------------------------------------------------------- |
| 797 |
|
| 798 |
\begin{BDef} |
| 799 |
\Lcs{psHomothetie}\OptArgs\Largr{center}\Largb{factor}\Largb{object} |
| 800 |
\end{BDef} |
| 801 |
|
| 802 |
\begin{LTXexample}[width=9cm] |
| 803 |
\begin{pspicture}[showgrid=true](-5,-4)(4,8) |
| 804 |
\psBill% needs package pst-fun |
| 805 |
\psHomothetie[linecolor=blue](4,-3){2}{\psBill} |
| 806 |
\psdots[dotsize=3pt,linecolor=red](4,-3) |
| 807 |
\psplot[linestyle=dashed,linecolor=red]{-5}{4}% |
| 808 |
[ /m -3 -0.85 sub 4 0.6 sub div def ] |
| 809 |
{ m x mul m 4 mul sub 3 sub }% |
| 810 |
\psHomothetie[linecolor=green](4,-3){-0.2}{\psBill} |
| 811 |
\end{pspicture} |
| 812 |
\end{LTXexample} |
| 813 |
|
| 814 |
%\pstVerb{ /m -3 -0.85 sub 4 0.6 sub div def } |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
\clearpage |
| 821 |
|
| 822 |
%-------------------------------------------------------------------------------------- |
| 823 |
\section{\nxLcs{psbrace}} |
| 824 |
%-------------------------------------------------------------------------------------- |
| 825 |
\begin{BDef} |
| 826 |
\LcsStar{psbrace}\OptArgs\Largr{A}\Largr{B}\Largb{text} |
| 827 |
\end{BDef} |
| 828 |
|
| 829 |
Additional to all other available options from \LPack{pstricks} or the other |
| 830 |
related packages, there are two new option, named \Lkeyword{braceWidth} and |
| 831 |
\Lkeyword{bracePos}. All important ones are shown in the following graphics |
| 832 |
and table. |
| 833 |
|
| 834 |
\begin{center} |
| 835 |
\begin{pspicture}[showgrid=true](10,5) |
| 836 |
\psbrace[braceWidth=1cm,braceWidthInner=1cm, |
| 837 |
braceWidthOuter=1cm,bracePos=0.6,fillcolor=white, |
| 838 |
nodesepA=10mm,nodesepB=10mm](0,5)(10,5){\fbox{Label}} |
| 839 |
\pcline{<->}(3,3)(3,4)\ncput*{\footnotesize\ttfamily braceWidth} |
| 840 |
\pcline{<->}(3,4)(3,5)\ncput*{\footnotesize\ttfamily braceWidthInner} |
| 841 |
\pcline{<->}(3,2)(3,3)\ncput*{\footnotesize\ttfamily braceWidthOuter} |
| 842 |
\pcline{<->}(6,1)(6,2)\ncput{\footnotesize\ttfamily nodesepB} |
| 843 |
\pcline{<->}(6,1)(7,1)\ncput*{\footnotesize\ttfamily A} |
| 844 |
\pcline{<->}(0,0.5)(6,0.5)\ncput*{\footnotesize\ttfamily bracePos} |
| 845 |
\psdot[dotscale=2](0,5)\uput[0](0,5){\textbf{A}} |
| 846 |
\psdot[dotscale=2](10,5)\uput[180](10,5){\textbf{B}} |
| 847 |
\end{pspicture} |
| 848 |
\end{center} |
| 849 |
|
| 850 |
And with option \Lkeyword{singleline}: |
| 851 |
|
| 852 |
\begin{center} |
| 853 |
\begin{pspicture}[showgrid=true](0,1)(10,5) |
| 854 |
\psbrace[braceWidthInner=1cm,singleline, |
| 855 |
braceWidthOuter=1cm,bracePos=0.6,fillcolor=white, |
| 856 |
nodesepA=10mm,nodesepB=10mm](0,5)(10,5){\fbox{Label}} |
| 857 |
\pcline{<->}(3,4)(3,5)\ncput*{\footnotesize\ttfamily braceWidthInner} |
| 858 |
\pcline{<->}(3,3)(3,4)\ncput*{\footnotesize\ttfamily braceWidthOuter} |
| 859 |
\pcline{<->}(6,2)(6,3)\ncput{\footnotesize\ttfamily nodesepB} |
| 860 |
\pcline{<->}(6,2)(7,2)\ncput*{\footnotesize\ttfamily A} |
| 861 |
\pcline{<->}(0,1.5)(6,1.5)\ncput*{\footnotesize\ttfamily bracePos} |
| 862 |
\psdot[dotscale=2](0,5)\uput[0](0,5){\textbf{A}} |
| 863 |
\psdot[dotscale=2](10,5)\uput[180](10,5){\textbf{B}} |
| 864 |
\end{pspicture} |
| 865 |
\end{center} |
| 866 |
|
| 867 |
With the option \Lkeyword{singleline} one can choose also a different linestyle which makes no sense otherwise: |
| 868 |
|
| 869 |
\begin{LTXexample}[width=4.5cm] |
| 870 |
\begin{pspicture}[showgrid](4,4) |
| 871 |
\pnode(0,0){A} |
| 872 |
\pnode(4,4){B} |
| 873 |
\psbrace[singleline,linestyle=dashed,ref=lC](A)(B){Text I} |
| 874 |
\psbrace[singleline,linestyle=dotted,ref=lC](3,4)(0,1){Text II} |
| 875 |
\end{pspicture} |
| 876 |
\end{LTXexample} |
| 877 |
A positive value for \Lkeyword{nodesepA} and \Lkeyword{nodesepB} shifts the label to the upper right |
| 878 |
and a negative value to the lower left. This does not depends on |
| 879 |
the value for the rotating of the label! If both keywords have the same value, you can use \Lkeyword{nodesep} |
| 880 |
instead. It sets \Lkeyword{nodesepA} \emph{and} \Lkeyword{nodesepB} to the given value of \Lkeyword{nodesep}. |
| 881 |
|
| 882 |
\begin{center} |
| 883 |
\begin{tabular}{@{}l|l@{}} |
| 884 |
name & meaning\\\hline |
| 885 |
\Lkeyword{braceWidth} & default is \Lcs{pslinewidth}\\ |
| 886 |
\Lkeyword{braceWidthInner} & default is \verb+10\pslinewidth+\\ |
| 887 |
\Lkeyword{braceWidthOuter} & default is \verb+10\pslinewidth+\\ |
| 888 |
\Lkeyword{bracePos} & relative position (default is $0.5$)\\ |
| 889 |
\Lkeyword{nodesepA} & x-separation (default is $0pt$)\\ |
| 890 |
\Lkeyword{nodesepB} & y-separation (default is $0pt$)\\ |
| 891 |
\Lkeyword{nodesep} & x- and y-separation (default is $0pt$)\\ |
| 892 |
\Lkeyword{rot} & additional rotating for the text (default is $0$)\\ |
| 893 |
\Lkeyword{ref} & reference point for the text (default is c)\\ |
| 894 |
\Lkeyword{fillcolor} & default is black\\ |
| 895 |
\Lkeyword{singleline} & default is false |
| 896 |
\end{tabular} |
| 897 |
\end{center} |
| 898 |
|
| 899 |
|
| 900 |
\begin{LTXexample}[width=6.5cm] |
| 901 |
\begin{pspicture}[showgrid](-1,0)(4,5) |
| 902 |
\pnodes(0,1){A}(3,4){B}(-0.5,0.5){C}(3.5,4.5){D} |
| 903 |
\psdots(A)(B)(C)(D) |
| 904 |
\psbrace[singleline,linestyle=dashed,ref=lC, |
| 905 |
linewidth=1pt,nodesep=5mm](C)(D){Text I} |
| 906 |
\psbrace[singleline,linestyle=dotted,ref=lC, |
| 907 |
linewidth=1pt,nodesep=-10mm,rot=180](B)(A){Text II} |
| 908 |
\end{pspicture} |
| 909 |
\end{LTXexample} |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
By default the text is written perpendicular to the brace line and |
| 914 |
can be changed with the \LPack{pstricks} option \Lkeyword{rot}=\ldots\ The |
| 915 |
text parameter can take any object and may also be empty. The |
| 916 |
reference point can be any value of the combination of \Lkeyval{l} |
| 917 |
(left) or \Lkeyval{r} (right) and \Lkeyval{b} (bottom) or \Lkeyval{B} |
| 918 |
(Baseline) or \Lkeyval{C} (center) or \Lkeyval{t} (top), where the |
| 919 |
default is \Lkeyval{c}, the center of the object. |
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
\begin{LTXexample}[width=4.5cm] |
| 924 |
\begin{pspicture}(4,4) |
| 925 |
\psgrid[subgriddiv=0,griddots=10] |
| 926 |
\pnode(0,0){A} |
| 927 |
\pnode(4,4){B} |
| 928 |
\psbrace[linecolor=red,ref=lC](A)(B){Text I} |
| 929 |
\psbrace*[linecolor=blue,ref=lC](3,4)(0,1){Text II} |
| 930 |
\psbrace[fillcolor=white](3,0)(3,4){III} |
| 931 |
\end{pspicture} |
| 932 |
\end{LTXexample} |
| 933 |
|
| 934 |
\bigskip |
| 935 |
The option \Lcs{specialCoor} is enabled, so that all types of coordinates |
| 936 |
are possible, (nodename), ($x,y$), ($nodeA|nodeB$), \ldots |
| 937 |
The star version fills the inner of the \Index{brace} with the current linecolor. |
| 938 |
With the fillcolor \verb+white+ or any other background color the brace can |
| 939 |
be "`unfilled"'. |
| 940 |
|
| 941 |
\begin{LTXexample} |
| 942 |
\begin{pspicture}(8,2.5) |
| 943 |
\psbrace(0,0)(0,2){\fbox{Text}}% |
| 944 |
\psbrace[nodesepA=10pt](2,0)(2,2){\fbox{Text}} |
| 945 |
\psbrace[ref=lC](4,0)(4,2){\fbox{Text}} |
| 946 |
\psbrace[ref=lt,rot=90,nodesepB=-15pt](6,0)(6,2){\fbox{Text}} |
| 947 |
\psbrace[ref=lt,rot=90,nodesepA=-5pt,nodesepB=15pt](8,2)(8,0){\fbox{Text}} |
| 948 |
\end{pspicture} |
| 949 |
\end{LTXexample} |
| 950 |
|
| 951 |
|
| 952 |
\begin{LTXexample} |
| 953 |
\def\someMath{$\int\limits_1^{\infty}\frac{1}{x^2}\,dx=1$} |
| 954 |
\begin{pspicture}(8,2.5) |
| 955 |
\psbrace[ref=lC](0,0)(0,2){\someMath}% |
| 956 |
\psbrace[rot=90](2,0)(2,2){\someMath} |
| 957 |
\psbrace[ref=lC](4,0)(4,2){\someMath} |
| 958 |
\psbrace[ref=lt,rot=90,nodesepB=-30pt](6,0)(6,2){\someMath} |
| 959 |
\psbrace[ref=lt,rot=90,nodesepB=30pt](8,2)(8,0){\someMath} |
| 960 |
\end{pspicture} |
| 961 |
\end{LTXexample} |
| 962 |
|
| 963 |
%$ |
| 964 |
|
| 965 |
\begin{LTXexample} |
| 966 |
\begin{pspicture}(\linewidth,5) |
| 967 |
\psbrace(0,0.5)(\linewidth,0.5){\fbox{Text}}% |
| 968 |
\psbrace[bracePos=0.25,nodesepB=10pt,rot=90](0,2)(\linewidth,2){\fbox{Text}} |
| 969 |
\psbrace[ref=lC,nodesepA=-3.5cm,nodesepB=15pt,rot=90](0,4)(\linewidth,4){% |
| 970 |
\fbox{some very, very long wonderful Text}} |
| 971 |
\end{pspicture} |
| 972 |
\end{LTXexample} |
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
\begin{LTXexample}[width=8cm] |
| 977 |
\psset{unit=0.8} |
| 978 |
\begin{pspicture}(10,11) |
| 979 |
\psgrid[subgriddiv=0,griddots=10] |
| 980 |
\pnode(0,0){A} |
| 981 |
\pnode(4,6){B} |
| 982 |
\psbrace[ref=lC](A)(B){One} |
| 983 |
\psbrace[rot=180,nodesepA=-5pt,ref=rb](B)(A){Two} |
| 984 |
\psbrace[linecolor=blue,bracePos=0.25,ref=lB](8,1)(1,7){Three} |
| 985 |
\psbrace[braceWidth=-1mm,rot=180,ref=rB](8,1)(1,7){Four} |
| 986 |
\psbrace*[linearc=0.5,fillstyle=none,linewidth=1pt,braceWidth=1.5pt, |
| 987 |
bracePos=0.25,ref=lC](8,1)(8,9){A} |
| 988 |
\psbrace(4,9)(6,9){} |
| 989 |
\psbrace(6,9)(6,7){} |
| 990 |
\psbrace(6,7)(4,7){} |
| 991 |
\psbrace(4,7)(4,9){} |
| 992 |
\psset{linecolor=red} |
| 993 |
\psbrace*[ref=lb](7,10)(3,10){I} |
| 994 |
\psbrace*[ref=lb,bracePos=0.75](3,10)(3,6){II} |
| 995 |
\psbrace*[ref=lb](3,6)(7,6){III} |
| 996 |
\psbrace*[ref=lb](7,6)(7,10){IV} |
| 997 |
\end{pspicture} |
| 998 |
\end{LTXexample} |
| 999 |
|
| 1000 |
%$ |
| 1001 |
|
| 1002 |
\begin{LTXexample}[width=5cm] |
| 1003 |
\[ |
| 1004 |
\begin{pmatrix} |
| 1005 |
\Rnode[vref=2ex]{A}{~1} \\ |
| 1006 |
& \ddots \\ |
| 1007 |
&& \Rnode[href=2]{B}{1} \\ |
| 1008 |
&&& \Rnode[vref=2ex]{C}{0} \\ |
| 1009 |
&&&& \ddots \\ |
| 1010 |
&&&&& \Rnode[href=2]{D}{0}~ \\ |
| 1011 |
\end{pmatrix} |
| 1012 |
\] |
| 1013 |
\psbrace[rot=-90,nodesepB=-0.5,nodesepA=-0.2](B)(A){\small n times} |
| 1014 |
\psbrace[rot=-90,nodesepB=-0.5,nodesepA=-0.2](D)(C){\small n times} |
| 1015 |
\end{LTXexample} |
| 1016 |
|
| 1017 |
|
| 1018 |
\clearpage |
| 1019 |
It is also possible to put a vertical brace around a |
| 1020 |
default paragraph. This works by setting two invisible nodes at |
| 1021 |
the beginning and the end of the paragraph. Indentation is |
| 1022 |
possible with a minipage. |
| 1023 |
|
| 1024 |
\small |
| 1025 |
Some nonsense text, which is nothing more than nonsense. |
| 1026 |
Some nonsense text, which is nothing more than nonsense. |
| 1027 |
|
| 1028 |
\noindent\rnode{A}{} |
| 1029 |
|
| 1030 |
\vspace*{-1ex} |
| 1031 |
Some nonsense text, which is nothing more than nonsense. |
| 1032 |
Some nonsense text, which is nothing more than nonsense. |
| 1033 |
Some nonsense text, which is nothing more than nonsense. |
| 1034 |
Some nonsense text, which is nothing more than nonsense. |
| 1035 |
Some nonsense text, which is nothing more than nonsense. |
| 1036 |
Some nonsense text, which is nothing more than nonsense. |
| 1037 |
Some nonsense text, which is nothing more than nonsense. |
| 1038 |
Some nonsense text, which is nothing more than nonsense. |
| 1039 |
|
| 1040 |
\vspace*{-2ex}\noindent\rnode{B}{}\psbrace*[linecolor=red](A)(B){} |
| 1041 |
|
| 1042 |
Some nonsense text, which is nothing more than nonsense. |
| 1043 |
Some nonsense text, which is nothing more than nonsense. |
| 1044 |
|
| 1045 |
\medskip\hfill\begin{minipage}{0.95\linewidth} |
| 1046 |
\noindent\rnode{A}{} |
| 1047 |
|
| 1048 |
\vspace*{-1ex} |
| 1049 |
Some nonsense text, which is nothing more than nonsense. |
| 1050 |
Some nonsense text, which is nothing more than nonsense. |
| 1051 |
Some nonsense text, which is nothing more than nonsense. |
| 1052 |
Some nonsense text, which is nothing more than nonsense. |
| 1053 |
Some nonsense text, which is nothing more than nonsense. |
| 1054 |
Some nonsense text, which is nothing more than nonsense. |
| 1055 |
Some nonsense text, which is nothing more than nonsense. |
| 1056 |
Some nonsense text, which is nothing more than nonsense. |
| 1057 |
|
| 1058 |
\vspace*{-2ex} |
| 1059 |
\noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} |
| 1060 |
\end{minipage} |
| 1061 |
|
| 1062 |
\normalsize |
| 1063 |
|
| 1064 |
\begin{lstlisting} |
| 1065 |
Some nonsense text, which is nothing more than nonsense. |
| 1066 |
Some nonsense text, which is nothing more than nonsense. |
| 1067 |
|
| 1068 |
\noindent\rnode{A}{} |
| 1069 |
|
| 1070 |
\vspace*{-1ex} |
| 1071 |
Some nonsense text, which is nothing more than nonsense. |
| 1072 |
Some nonsense text, which is nothing more than nonsense. |
| 1073 |
Some nonsense text, which is nothing more than nonsense. |
| 1074 |
Some nonsense text, which is nothing more than nonsense. |
| 1075 |
Some nonsense text, which is nothing more than nonsense. |
| 1076 |
Some nonsense text, which is nothing more than nonsense. |
| 1077 |
Some nonsense text, which is nothing more than nonsense. |
| 1078 |
Some nonsense text, which is nothing more than nonsense. |
| 1079 |
|
| 1080 |
\vspace*{-2ex}\noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} |
| 1081 |
|
| 1082 |
Some nonsense text, which is nothing more than nonsense. |
| 1083 |
Some nonsense text, which is nothing more than nonsense. |
| 1084 |
|
| 1085 |
\medskip\hfill\begin{minipage}{0.95\linewidth} |
| 1086 |
\noindent\rnode{A}{} |
| 1087 |
|
| 1088 |
\vspace*{-1ex} |
| 1089 |
Some nonsense text, which is nothing more than nonsense. |
| 1090 |
Some nonsense text, which is nothing more than nonsense. |
| 1091 |
Some nonsense text, which is nothing more than nonsense. |
| 1092 |
Some nonsense text, which is nothing more than nonsense. |
| 1093 |
Some nonsense text, which is nothing more than nonsense. |
| 1094 |
Some nonsense text, which is nothing more than nonsense. |
| 1095 |
Some nonsense text, which is nothing more than nonsense. |
| 1096 |
Some nonsense text, which is nothing more than nonsense. |
| 1097 |
|
| 1098 |
\vspace*{-2ex}\noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} |
| 1099 |
\end{minipage} |
| 1100 |
\end{lstlisting} |
| 1101 |
|
| 1102 |
\clearpage |
| 1103 |
|
| 1104 |
|
| 1105 |
%-------------------------------------------------------------------------------------- |
| 1106 |
\section{Contour plots} |
| 1107 |
%-------------------------------------------------------------------------------------- |
| 1108 |
Contour plots are 2D-images but representing 3D data. The color is the representation of |
| 1109 |
the z coordinate. |
| 1110 |
It is only possible to plot data files which must have the following |
| 1111 |
structure: |
| 1112 |
\begin{verbatim} |
| 1113 |
/contourdata [[ |
| 1114 |
x y z |
| 1115 |
x y z |
| 1116 |
][ |
| 1117 |
x y z |
| 1118 |
... |
| 1119 |
][ |
| 1120 |
... |
| 1121 |
] def |
| 1122 |
\end{verbatim} |
| 1123 |
it is an PostScript array of array. The Perl script \url{http://tug.org/pstricks/pst-plot/3D/MakeData.pl} |
| 1124 |
allows to plot a file of the 3D-data of a mathematical function $z=f(x,y)$ and the Perl script |
| 1125 |
\url{http://tug.org/pstricks/pst-plot/3D/PrepareData.pl} prepares the data file |
| 1126 |
into the above structure for using it with the example file. |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
\begin{LTXexample}[pos=t] |
| 1131 |
\psset{unit=1.75cm} |
| 1132 |
\begin{pspicture}[showgrid](-3,-3)(3,3) |
| 1133 |
\pstContour[colored]{data/contourN.data} |
| 1134 |
\end{pspicture} |
| 1135 |
\end{LTXexample} |
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
\emph{Important} is the option \verb|-dNOSAFER| for the \texttt{ps2pdf} run, otherwise Ghostscript |
| 1143 |
didn't allow the run of external data files. Important optional arguments are |
| 1144 |
\Lkeyword{colored}, \Lkeyword{colorOffset}, and \Lkeyword{colSteps}. |
| 1145 |
|
| 1146 |
%-------------------------------------------------------------------------------------- |
| 1147 |
\section{Random dots} |
| 1148 |
%-------------------------------------------------------------------------------------- |
| 1149 |
The syntax of the new macro \Lcs{psRandom} is: |
| 1150 |
|
| 1151 |
\begin{BDef} |
| 1152 |
\Lcs{psRandom}\OptArgs\Largb{}\\ |
| 1153 |
\Lcs{psRandom}\OptArgs\OptArg*{\Largr{$x_{Min},y_{Min}$}}\OptArg*{\Largr{$x_{Max},y_{Max}$}}\Largb{clip path} %$ \\ |
| 1154 |
\Lcs{psRandomPointArea}\OptArgs\Largb{No dots}\Largb{function}\\ |
| 1155 |
%\psRandom[<option>](<xMax,yMax>){<clip path>} |
| 1156 |
%\psRandom[<option>](<xMin,yMin>)(<xMax,yMax>){<clip path>} |
| 1157 |
\end{BDef} |
| 1158 |
|
| 1159 |
|
| 1160 |
\subsection{Simple random dots} |
| 1161 |
|
| 1162 |
|
| 1163 |
If there is no area for the dots defined, then \verb+(0,0)(1,1)+ in the current |
| 1164 |
scale setting is used for placing the dots. If there is only one \Largr{$x_{Max},y_{Max}$} %$ |
| 1165 |
defined, then \verb+(0,0)+ is used for the other point. |
| 1166 |
This area should be greater than the clipping |
| 1167 |
path to be sure that the dots are placed over the full area. The clipping path can |
| 1168 |
be everything. If no clipping path is given, then the frame \verb+(0,0)(1,1)+ |
| 1169 |
in user coordinates is used. The new options are: |
| 1170 |
|
| 1171 |
\begin{center} |
| 1172 |
\begin{tabular}{@{}l|l|l@{}} |
| 1173 |
name & default\\\hline |
| 1174 |
\Lkeyword{randomPoints} & \verb|1000| & number of random dots\tabularnewline |
| 1175 |
\Lkeyword{randInit} & \verb|rrand| & initial value for the generator\tabularnewline |
| 1176 |
\Lkeyword{color} & \false & random color\tabularnewline |
| 1177 |
\end{tabular} |
| 1178 |
\end{center} |
| 1179 |
|
| 1180 |
|
| 1181 |
\begin{LTXexample}[width=0.3\linewidth] |
| 1182 |
\psset{unit=5cm} |
| 1183 |
\begin{pspicture}(1,1) |
| 1184 |
\psRandom[dotsize=1pt,fillstyle=solid](1,1){\pscircle(0.5,0.5){0.5}} |
| 1185 |
\end{pspicture} |
| 1186 |
\begin{pspicture}(1,1) |
| 1187 |
\psRandom[randInit=42,dotsize=2pt,randomPoints=5000,color,% |
| 1188 |
fillstyle=solid](1,1){\pscircle(0.5,0.5){0.5}} |
| 1189 |
\end{pspicture} |
| 1190 |
\end{LTXexample} |
| 1191 |
|
| 1192 |
\begin{LTXexample}[width=0.4\linewidth] |
| 1193 |
\psset{unit=5cm} |
| 1194 |
\begin{pspicture}(1,1) |
| 1195 |
\psRandom[randomPoints=200,dotsize=8pt,dotstyle=+]{} |
| 1196 |
\end{pspicture} |
| 1197 |
\begin{pspicture}(1.5,1) |
| 1198 |
\psRandom[dotsize=5pt,color](0,0)(1.5,0.8){\psellipse(0.75,0.4)(0.75,0.4)} |
| 1199 |
\end{pspicture} |
| 1200 |
\end{LTXexample} |
| 1201 |
|
| 1202 |
\begin{LTXexample} |
| 1203 |
\psset{unit=2.5cm} |
| 1204 |
\begin{pspicture}(0,-1)(3,1) |
| 1205 |
\psRandom[dotsize=4pt,dotstyle=o,linecolor=blue,fillcolor=red,% |
| 1206 |
fillstyle=solid,randomPoints=1000]% |
| 1207 |
(0,-1)(3,1){\psplot{0}{3.14}{ x 114 mul sin }} |
| 1208 |
\end{pspicture} |
| 1209 |
\end{LTXexample} |
| 1210 |
|
| 1211 |
\psset{unit=1cm} |
| 1212 |
|
| 1213 |
|
| 1214 |
\subsection{Simple random dots devided by a function} |
| 1215 |
|
| 1216 |
The predefined colors are blue (lower part) and red (upper part). |
| 1217 |
\begin{LTXexample}[pos=t] |
| 1218 |
\psset{unit=6cm} |
| 1219 |
\begin{pspicture}(-0.2,-0.1)(1.1,1.2) |
| 1220 |
\psaxes[linewidth=1.25pt,Dx=0.2,Dy=0.2, |
| 1221 |
labelFontSize=\scriptstyle,ticksize=0 1,subticks=2, |
| 1222 |
subticksize=1,tickwidth=1pt,tickcolor=black!30,subtickcolor=black!20](0,0)(1,1)% |
| 1223 |
\psRandomPointArea[radius=1.5pt,countDots,algebraic, |
| 1224 |
fillcolorA=black,fillcolorB=green]{30}{sqrt(1-x^2)}% |
| 1225 |
\psplot[plotpoints=200]{0}{1}{1 x dup mul sub sqrt} |
| 1226 |
\end{pspicture} |
| 1227 |
\end{LTXexample} |
| 1228 |
|
| 1229 |
\begin{LTXexample}[pos=t] |
| 1230 |
\psset{unit=6cm} |
| 1231 |
\begin{pspicture}(-0.2,-0.1)(1.1,1.2) |
| 1232 |
\psaxes[linewidth=1.25pt,Dx=0.2,Dy=0.2, |
| 1233 |
labelFontSize=\scriptstyle,ticksize=0 1,subticks=2, |
| 1234 |
subticksize=1,tickwidth=1pt,tickcolor=black!30,subtickcolor=black!20](0,0)(1,1)% |
| 1235 |
\psRandomPointArea[algebraic]{300}{-4*(x^2-x)}% |
| 1236 |
\psplot[plotpoints=200,algebraic]{0}{1}{-4*(x^2-x)} |
| 1237 |
\end{pspicture} |
| 1238 |
\end{LTXexample} |
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
\clearpage |
| 1245 |
%-------------------------------------------------------------------------------------- |
| 1246 |
\section{\nxLcs{psDice}} |
| 1247 |
%-------------------------------------------------------------------------------------- |
| 1248 |
\Lcs{psdice} creates the view of a dice. The number on the dice is the only parameter. |
| 1249 |
The optional parameters, like the color can be used as usual. The macro is a box of |
| 1250 |
dimension zero and is placed |
| 1251 |
at the current point. Use the \Lcs{rput} macro to place it anywhere. The optional |
| 1252 |
argument \Lkeyword{unit} can be used to scale the dice. the default size of |
| 1253 |
the dice $1\mathrm{cm}\times1\mathrm{cm}$. |
| 1254 |
|
| 1255 |
\begin{center} |
| 1256 |
\begin{pspicture}(-1,-1)(8,9) |
| 1257 |
\multido{\iA=1+1}{6}{% |
| 1258 |
\rput(\iA,7.5){\Huge\psdice[unit=0.75,linecolor=red!80]{\iA}} |
| 1259 |
\rput(! -0.5 7 \iA\space sub){\Huge\psdice[unit=0.75,linecolor=blue!70]{\iA}}% |
| 1260 |
\multido{\iB=1+1}{6}{% |
| 1261 |
\rput(! \iA\space 7 \iB\space sub){% |
| 1262 |
\rnode[c]{p\iA\iB}{\makebox[1em][l]{\strut\psPrintValue[fontscale=12]{\iA\space \iB\space add}}}% |
| 1263 |
}}} |
| 1264 |
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dotted]{p11}{p66} |
| 1265 |
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dashed]{p15}{p51} |
| 1266 |
\rput{90}(-1.5,3.5){1. dice} |
| 1267 |
\rput{0}(3.5,8.5){2. dice} |
| 1268 |
\psline[linewidth=1.5pt](0.25,0.5)(0.25,8) |
| 1269 |
\psline[linewidth=1.5pt](-1,6.75)(6.5,6.75) |
| 1270 |
\end{pspicture} |
| 1271 |
\end{center} |
| 1272 |
|
| 1273 |
\begin{lstlisting} |
| 1274 |
\begin{pspicture}(-1,-1)(8,8) |
| 1275 |
\multido{\iA=1+1}{6}{% |
| 1276 |
\rput(\iA,7.5){\Huge\psdice[unit=0.75,linecolor=red!80]{\iA}} |
| 1277 |
\rput(! -0.5 7 \iA\space sub){\Huge\psdice[unit=0.75,linecolor=blue!70]{\iA}}% |
| 1278 |
\multido{\iB=1+1}{6}{% |
| 1279 |
\rput(! \iA\space 7 \iB\space sub){% |
| 1280 |
\rnode[c]{p\iA\iB}{\makebox[1em][l]{\strut\psPrintValue[fontscale=12]{\iA\space \iB\space add}}}% |
| 1281 |
}}} |
| 1282 |
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dotted]{p11}{p66} |
| 1283 |
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dashed]{p15}{p51} |
| 1284 |
\rput{90}(-1.5,3.5){1. dice} |
| 1285 |
\rput{0}(3.5,8.5){2. dice} |
| 1286 |
\psline[linewidth=1.5pt](0.25,0.5)(0.25,8) |
| 1287 |
\psline[linewidth=1.5pt](-1,6.75)(6.5,6.75) |
| 1288 |
\end{pspicture} |
| 1289 |
\end{lstlisting} |
| 1290 |
|
| 1291 |
|
| 1292 |
\clearpage |
| 1293 |
\section{Olympic Rings} |
| 1294 |
The colors for the Rings are defined as \LColor{OlympicBlue}, \LColor{OlympicRed}, \LColor{OlympicGreen}, |
| 1295 |
and \LColor{OlympicYellow} and can be overwritten by the user. The only valid optional argument |
| 1296 |
is \Lkeyword{psscale} for scaling. |
| 1297 |
|
| 1298 |
\begin{BDef} |
| 1299 |
\Lcs{psOlympicRings}\OptArgs\coord1 |
| 1300 |
\end{BDef} |
| 1301 |
|
| 1302 |
\resetOptions |
| 1303 |
\psset{unit=1cm,doubleline=false,linearc=0,psscale=1} |
| 1304 |
|
| 1305 |
\includegraphics{data/olympic} |
| 1306 |
|
| 1307 |
\begin{lstlisting} |
| 1308 |
\begin{pspicture}(-4.5,-3)(4.5,1.5) |
| 1309 |
\psOlympicRings(0,0) |
| 1310 |
\psOlympicRings[psscale=0.2](1.5,-1.5) |
| 1311 |
\psOlympicRings[psscale=0.2](-1.5,-1.5) |
| 1312 |
\psOlympicRings[psscale=0.2](0,0.5) |
| 1313 |
\end{pspicture} |
| 1314 |
\end{lstlisting} |
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
\clearpage |
| 1319 |
%-------------------------------------------------------------------------------------- |
| 1320 |
\section{\nxLcs{psFormatInt}} |
| 1321 |
%-------------------------------------------------------------------------------------- |
| 1322 |
There exist some packages and a lot of code to format an integer like $1\,000\,000$ |
| 1323 |
or $1,234,567$ (in Europe $1.234.567$). But all packages expect a real number as |
| 1324 |
argument and cannot handle macros as an argument. For this case \LPack{pstricks-add} |
| 1325 |
has a macro \Lcs{psFormatInt} which can handle both: |
| 1326 |
|
| 1327 |
\begin{LTXexample}[width=3cm] |
| 1328 |
\psFormatInt{1234567}\\ |
| 1329 |
\psFormatInt[intSeparator={,}]{1234567}\\ |
| 1330 |
\psFormatInt[intSeparator=.]{1234567}\\ |
| 1331 |
\psFormatInt[intSeparator=$\cdot$]{1234567}\\ |
| 1332 |
\def\temp{965432} |
| 1333 |
\psFormatInt{\temp} |
| 1334 |
\end{LTXexample} |
| 1335 |
|
| 1336 |
With the option \Lkeyword{intSeparator} the symbol can be changed to any any non-number character. |
| 1337 |
|
| 1338 |
|
| 1339 |
\clearpage |
| 1340 |
|
| 1341 |
|
| 1342 |
%-------------------------------------------------------------------------------------- |
| 1343 |
\section{\nxLcs{psRelLine}} |
| 1344 |
%-------------------------------------------------------------------------------------- |
| 1345 |
With this macro it is possible to plot lines relative to a given one. Parameter are |
| 1346 |
the angle and the length factor: |
| 1347 |
|
| 1348 |
\begin{BDef} |
| 1349 |
\Lcs{psRelLine}\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{<end node name>}\\ |
| 1350 |
\Lcs{psRelLine}\OptArg{\Largb{arrows}}\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{end node name}\\ |
| 1351 |
\Lcs{psRelLine}\OptArgs\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{end node name}\\ |
| 1352 |
\Lcs{psRelLine}\OptArgs\OptArg{\Largb{arrows}}\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{end node name} |
| 1353 |
\end{BDef} |
| 1354 |
|
| 1355 |
The length factor relates to the distance $\overline{P_0P_1}$ and |
| 1356 |
the end node name must be a valid nodename and shouldn't contain |
| 1357 |
any of the special PostScript characters. There are two valid |
| 1358 |
options which are described in the foregoing section for |
| 1359 |
\Lcs{psRelNode}. |
| 1360 |
|
| 1361 |
The following two figures show the same, the first one with a scaling different to $1:1$, |
| 1362 |
this is the reason why the end points are on an ellipse and not on a circle like in the |
| 1363 |
second figure. |
| 1364 |
|
| 1365 |
\begin{LTXexample}[width=5cm] |
| 1366 |
\psset{yunit=2,xunit=1} |
| 1367 |
\begin{pspicture}(-2,-2)(3,2) |
| 1368 |
\psgrid[subgriddiv=2,subgriddots=10,gridcolor=lightgray] |
| 1369 |
\pnode(-1,0){A}\pnode(3,2){B} |
| 1370 |
\psline[linecolor=red](A)(B) |
| 1371 |
\psRelLine[linecolor=blue,angle=30](-1,0)(B){0.5}{EndNode} |
| 1372 |
\qdisk(EndNode){2pt} |
| 1373 |
\psRelLine[linecolor=blue,angle=-30](A)(B){0.5}{EndNode} |
| 1374 |
\qdisk(EndNode){2pt} |
| 1375 |
\psRelLine[linecolor=magenta,angle=90](-1,0)(3,2){0.5}{EndNode} |
| 1376 |
\qdisk(EndNode){2pt} |
| 1377 |
\psRelLine[linecolor=magenta,angle=-90](A)(B){0.5}{EndNode} |
| 1378 |
\qdisk(EndNode){2pt} |
| 1379 |
\end{pspicture} |
| 1380 |
\end{LTXexample} |
| 1381 |
|
| 1382 |
\begin{LTXexample}[width=5cm] |
| 1383 |
\begin{pspicture}(-2,-2)(3,2) |
| 1384 |
\psgrid[subgriddiv=2,subgriddots=10,gridcolor=lightgray] |
| 1385 |
\pnode(-1,0){A}\pnode(3,2){B} |
| 1386 |
\psline[linecolor=red](A)(B) |
| 1387 |
\psarc[linestyle=dashed](A){2.23}{-90}{135} |
| 1388 |
\psRelLine[linecolor=blue,angle=30](-1,0)(B){0.5}{EndNode} |
| 1389 |
\qdisk(EndNode){2pt} |
| 1390 |
\psRelLine[linecolor=blue,angle=-30](A)(B){0.5}{EndNode} |
| 1391 |
\qdisk(EndNode){2pt} |
| 1392 |
\psRelLine[linecolor=magenta,angle=90](-1,0)(3,2){0.5}{EndNode} |
| 1393 |
\qdisk(EndNode){2pt} |
| 1394 |
\psRelLine[linecolor=magenta,angle=-90](A)(B){0.5}{EndNode} |
| 1395 |
\qdisk(EndNode){2pt} |
| 1396 |
\end{pspicture} |
| 1397 |
\end{LTXexample} |
| 1398 |
|
| 1399 |
\medskip |
| 1400 |
The following figure has also a different scaling, but has set the |
| 1401 |
option \Lkeyword{trueAngle}, all angles refer to "what you see". |
| 1402 |
|
| 1403 |
\begin{LTXexample}[width=6.5cm] |
| 1404 |
\psset{yunit=2,xunit=1} |
| 1405 |
\begin{pspicture}(-3,-1)(3,2)\psgrid[subgridcolor=lightgray] |
| 1406 |
\pnode(-1,0){A}\pnode(3,2){B} |
| 1407 |
\psline[linecolor=red](A)(B) |
| 1408 |
\psarc(A){2.83}{-45}{135} |
| 1409 |
\psRelLine[linecolor=blue,angle=30,trueAngle](A)(B){0.5}{EndNode} |
| 1410 |
\qdisk(EndNode){2pt} |
| 1411 |
\psRelLine[linecolor=blue,angle=-30,trueAngle](A)(B){0.5}{EndNode} |
| 1412 |
\qdisk(EndNode){2pt} |
| 1413 |
\psRelLine[linecolor=magenta,angle=90,trueAngle](A)(B){0.5}{EndNode} |
| 1414 |
\qdisk(EndNode){2pt} |
| 1415 |
\psRelLine[linecolor=magenta,angle=-90,trueAngle](A)(B){0.5}{EndNode} |
| 1416 |
\qdisk(EndNode){2pt} |
| 1417 |
\end{pspicture} |
| 1418 |
\end{LTXexample} |
| 1419 |
|
| 1420 |
\medskip |
| 1421 |
Two examples using \verb+\multido+ to show the behaviour of the |
| 1422 |
options \verb+trueAngle+ and \verb+angle+. |
| 1423 |
|
| 1424 |
\medskip |
| 1425 |
\begin{LTXexample}[width=8cm] |
| 1426 |
\psset{yunit=4,xunit=2} |
| 1427 |
\begin{pspicture}(-1,0)(3,2)\psgrid[subgridcolor=lightgray] |
| 1428 |
\pnode(-1,0){A}\pnode(1,1){B} |
| 1429 |
\psline[linecolor=red](A)(3,2) |
| 1430 |
\multido{\iA=0+10}{36}{% |
| 1431 |
\psRelLine[linecolor=blue,angle=\iA](B)(A){-0.5}{EndNode} |
| 1432 |
\qdisk(EndNode){2pt} |
| 1433 |
} |
| 1434 |
\end{pspicture} |
| 1435 |
\end{LTXexample} |
| 1436 |
|
| 1437 |
\begin{LTXexample}[width=8cm] |
| 1438 |
\psset{yunit=4,xunit=2} |
| 1439 |
\begin{pspicture}(-1,0)(3,2)\psgrid[subgridcolor=lightgray] |
| 1440 |
\pnode(-1,0){A}\pnode(1,1){B} |
| 1441 |
\psline[linecolor=red](A)(3,2) |
| 1442 |
\multido{\iA=0+10}{36}{% |
| 1443 |
\psRelLine[linecolor=magenta,angle=\iA,trueAngle]{->}(B)(A){-0.5}{EndNode} |
| 1444 |
} |
| 1445 |
\end{pspicture} |
| 1446 |
\end{LTXexample} |
| 1447 |
|
| 1448 |
\begin{center} |
| 1449 |
\bgroup |
| 1450 |
\psset{xunit=0.75\linewidth,yunit=0.75\linewidth,trueAngle}% |
| 1451 |
\begin{pspicture}(1,0.6)%\psgrid |
| 1452 |
\pnode(.3,.35){Vk} \pnode(.375,.35){D} \pnode(0,.4){DST1} \pnode(1,.18){DST2} |
| 1453 |
\pnode(0,.1){A1} \pnode(1,.31){A1} |
| 1454 |
{ \psset{linewidth=.02,linestyle=dashed,linecolor=gray}% |
| 1455 |
\pcline(DST1)(DST2) % <- Druckseitentangente |
| 1456 |
\pcline(A2)(A1) % <- Anstr\"omrichtung |
| 1457 |
\lput*{:U}{\small Anstr\"omrichtung $v_{\infty}$} }% |
| 1458 |
\psIntersectionPoint(A1)(A2)(DST1)(DST2){Hk} |
| 1459 |
\pscurve(Hk)(.4,.38)(Vk)(.36,.33)(.5,.32)(Hk) |
| 1460 |
\psParallelLine[linecolor=red!75!green,arrows=->,arrowscale=2](Vk)(Hk)(D){.1}{FtE} |
| 1461 |
\psRelLine[linecolor=red!75!green,arrows=->,arrowscale=2,angle=90](D)(FtE){4}{Fn}% why "4"? |
| 1462 |
\psParallelLine[linestyle=dashed](D)(FtE)(Fn){.1}{Fnr1} |
| 1463 |
\psRelLine[linestyle=dashed,angle=90](FtE)(D){-4}{Fnr2} % why "-4"? |
| 1464 |
\psline[linewidth=1.5pt,arrows=->,arrowscale=2](D)(Fnr2) |
| 1465 |
\psIntersectionPoint(D)([nodesep=2]D)(Fnr1)([offset=-4]Fnr1){Fh} |
| 1466 |
\psIntersectionPoint(D)([offset=2]D)(Fnr1)([nodesep=4]Fnr1){Fv} |
| 1467 |
\psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fh) |
| 1468 |
\psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fv) |
| 1469 |
\psline[linestyle=dotted](Fh)(Fnr1) \psline[linestyle=dotted](Fv)(Fnr1) |
| 1470 |
\uput{.1}[0](Fh){\blue $F_{H}$} \uput{.1}[180](Fv){\blue $F_{V}$} |
| 1471 |
\uput{.1}[-45](Fnr1){$F_{R}$} \uput{.1}[90](Fn){\color{red!75!green}$F_{N}$} |
| 1472 |
\uput{.25}[-90](FtE){\color{red!75!green}$F_{T}$} |
| 1473 |
\end{pspicture} |
| 1474 |
\egroup |
| 1475 |
\end{center} |
| 1476 |
\begin{lstlisting} |
| 1477 |
\psset{xunit=0.75\linewidth,yunit=0.75\linewidth,trueAngle}% |
| 1478 |
\end{center} |
| 1479 |
\begin{pspicture}(1,0.6)%\psgrid |
| 1480 |
\pnode(.3,.35){Vk} \pnode(.375,.35){D} \pnode(0,.4){DST1} \pnode(1,.18){DST2} |
| 1481 |
\pnode(0,.1){A1} \pnode(1,.31){A1} |
| 1482 |
{ \psset{linewidth=.02,linestyle=dashed,linecolor=gray}% |
| 1483 |
\pcline(DST1)(DST2) % <- Druckseitentangente |
| 1484 |
\pcline(A2)(A1) % <- Anstr"omrichtung |
| 1485 |
\lput*{:U}{\small Anstr"omrichtung $v_{\infty}$} }% |
| 1486 |
\psIntersectionPoint(A1)(A2)(DST1)(DST2){Hk} |
| 1487 |
\pscurve(Hk)(.4,.38)(Vk)(.36,.33)(.5,.32)(Hk) |
| 1488 |
\psParallelLine[linecolor=red!75!green,arrows=->,arrowscale=2](Vk)(Hk)(D){.1}{FtE} |
| 1489 |
\psRelLine[linecolor=red!75!green,arrows=->,arrowscale=2,angle=90](D)(FtE){4}{Fn}% why "4"? |
| 1490 |
\psParallelLine[linestyle=dashed](D)(FtE)(Fn){.1}{Fnr1} |
| 1491 |
\psRelLine[linestyle=dashed,angle=90](FtE)(D){-4}{Fnr2} % why "-4"? |
| 1492 |
\psline[linewidth=1.5pt,arrows=->,arrowscale=2](D)(Fnr2) |
| 1493 |
\psIntersectionPoint(D)([nodesep=2]D)(Fnr1)([offset=-4]Fnr1){Fh} |
| 1494 |
\psIntersectionPoint(D)([offset=2]D)(Fnr1)([nodesep=4]Fnr1){Fv} |
| 1495 |
\psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fh) |
| 1496 |
\psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fv) |
| 1497 |
\psline[linestyle=dotted](Fh)(Fnr1) \psline[linestyle=dotted](Fv)(Fnr1) |
| 1498 |
\uput{.1}[0](Fh){\blue $F_{H}$} \uput{.1}[180](Fv){\blue $F_{V}$} |
| 1499 |
\uput{.1}[-45](Fnr1){$F_{R}$} \uput{.1}[90](Fn){\color{red!75!green}$F_{N}$} |
| 1500 |
\uput{.25}[-90](FtE){\color{red!75!green}$F_{T}$} |
| 1501 |
\end{pspicture} |
| 1502 |
\end{lstlisting} |
| 1503 |
|
| 1504 |
|
| 1505 |
%-------------------------------------------------------------------------------------- |
| 1506 |
\section{\nxLcs{psParallelLine}} |
| 1507 |
%-------------------------------------------------------------------------------------- |
| 1508 |
With this macro it is possible to plot lines relative to a given one, which is parallel. |
| 1509 |
There is no special parameter here. |
| 1510 |
|
| 1511 |
\begin{lstlisting}[style=syntax] |
| 1512 |
\psParallelLine(<P0>)(<P1>)(<P2>){<length>}{<end node name>} |
| 1513 |
\psParallelLine{<arrows>}(<P0>)(<P1>)(<P2>){<length>}{<end node name>} |
| 1514 |
\psParallelLine[<options>](<P0>)(<P1>)(<P2>){<length>}{<end node name>} |
| 1515 |
\psParallelLine[<options>]{<arrows>}(<P0>)(<P1>)(<P2>){<length>}{<end node name>} |
| 1516 |
\end{lstlisting} |
| 1517 |
|
| 1518 |
The line starts at $P_2$, is parallel to $\overline{P_0P_1}$ and |
| 1519 |
the length of this parallel line depends on the length factor. The |
| 1520 |
end node name must be a valid nodename and shouldn't contain any |
| 1521 |
of the special PostScript characters. |
| 1522 |
|
| 1523 |
\begin{LTXexample} |
| 1524 |
\begin{pspicture*}(-5,-4)(5,3.5) |
| 1525 |
\psgrid[subgriddiv=0,griddots=5] |
| 1526 |
\pnode(2,-2){FF}\qdisk(FF){1.5pt} |
| 1527 |
\pnode(-5,5){A}\pnode(0,0){O} |
| 1528 |
\multido{\nCountA=-2.4+0.4}{9}{% |
| 1529 |
\psParallelLine[linecolor=red](O)(A)(0,\nCountA){9}{P1} |
| 1530 |
\psline[linecolor=red](0,\nCountA)(FF) |
| 1531 |
\psRelLine[linecolor=red](0,\nCountA)(FF){9}{P2} |
| 1532 |
} |
| 1533 |
\psline[linecolor=blue](A)(FF) |
| 1534 |
\psRelLine[linecolor=blue](A)(FF){5}{END1} |
| 1535 |
\psline[linewidth=2pt,arrows=->](2,0)(FF) |
| 1536 |
\end{pspicture*} |
| 1537 |
\end{LTXexample} |
| 1538 |
|
| 1539 |
the following example was created by Patrice Mégret. |
| 1540 |
|
| 1541 |
\psset{unit=1cm} |
| 1542 |
\newcommand\pmsc[1]{\ensuremath{\underline{#1}}} |
| 1543 |
\newcommand\pmIc{\pmsc{I}} |
| 1544 |
\newcommand\pmUc{\pmsc{U}} |
| 1545 |
\newcommand\pmEc{\pmsc{E}} |
| 1546 |
\begin{pspicture}[showgrid=true](-5,-2)(3,8) |
| 1547 |
\psStartPoint[I](0,0) |
| 1548 |
\psVector[linewidth=1.5pt,linecolor=red](1.5;235)\ncput*{$\pmIc_2$}%I_2 |
| 1549 |
\psStartPoint[U](0,0) |
| 1550 |
\psVector[linewidth=1.5pt](2;90)\ncput*{$\pmUc_2$}%U_2 |
| 1551 |
\psParallelLine[linewidth=1.5pt,arrows=->](0,0)(I1)(U1){-0.3}{NUa}\nbput{\tiny $-R_2\pmIc_2$}%-R_2.I_2 |
| 1552 |
\psRelLine[linewidth=1.5pt,arrows=->,angle=90](NUa)(U1){-5}{NUb}\nbput{\tiny $-j\omega L_{\sigma2}\pmIc_2$} %$ |
| 1553 |
\pcline[linewidth=3.5pt,arrows=->](0,0)(NUb)\naput{$\pmEc_2$}%E_2 |
| 1554 |
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUb)(0,0){1.428}{NUc}\nbput[npos=0.8]{$\pmEc_1$}%E_1 (m=0.7) |
| 1555 |
\psRelLine[linewidth=1.5pt,arrows=->,angle=-85,linecolor=orange](0,0)(NUc){0.2}{NIm1}\nbput{\tiny $\pmIc_{m1}$}%I_m1 |
| 1556 |
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(I1)(NIm1){-0.7}{NI1}\nbput{\tiny $-m\pmIc_2$}%m.I_2 |
| 1557 |
\pcline[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(NI1)\naput{\tiny $\pmIc_{1}$}%I_1 |
| 1558 |
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NI1)(NUc){0.2}{NUd}\nbput{\tiny $R_1\pmIc_1$}%R_1 I_1 |
| 1559 |
\psRelLine[linewidth=1.5pt,arrows=->,angle=90,linecolor=blue](NUd)(NUc){-5}{NUe}\nbput{\tiny $j\omega L_{\sigma1}\pmIc_1$}%-j\omega I_2 |
| 1560 |
\pcline[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUe)\naput{$\pmUc_{1}$}%I_1 |
| 1561 |
\end{pspicture} |
| 1562 |
|
| 1563 |
%$ |
| 1564 |
|
| 1565 |
|
| 1566 |
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily] |
| 1567 |
\newcommand\pmsc[1]{\ensuremath{\underline{#1}}} |
| 1568 |
\newcommand\pmIc{\pmsc{I}} |
| 1569 |
\newcommand\pmUc{\pmsc{U}} |
| 1570 |
\newcommand\pmEc{\pmsc{E}} |
| 1571 |
\begin{pspicture}[showgrid=true](-5,-2)(3,8) |
| 1572 |
\psStartPoint[I](0,0) |
| 1573 |
\psVector[linewidth=1.5pt,linecolor=red](1.5;235)\ncput*{$\pmIc_2$}%I_2 |
| 1574 |
\psStartPoint[U](0,0) |
| 1575 |
\psVector[linewidth=1.5pt](2;90)\ncput*{$\pmUc_2$}%U_2 |
| 1576 |
\psParallelLine[linewidth=1.5pt,arrows=->](0,0)(I1)(U1){-0.3}{NUa}\nbput{\tiny $-R_2\pmIc_2$} |
| 1577 |
\psRelLine[linewidth=1.5pt,arrows=->,angle=90](NUa)(U1){-5}{NUb}% |
| 1578 |
\nbput{\tiny $-j\omega L_{\sigma2}\pmIc_2$}%-j\omega I_2 |
| 1579 |
\pcline[linewidth=3.5pt,arrows=->](0,0)(NUb)\naput{$\pmEc_2$}%E_2 |
| 1580 |
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUb)(0,0){1.428}{NUc}% |
| 1581 |
\nbput[npos=0.8]{$\pmEc_1$}%E_1 (m=0.7) |
| 1582 |
\psRelLine[linewidth=1.5pt,arrows=->,angle=-85,linecolor=orange](0,0)(NUc){0.2}{NIm1} |
| 1583 |
\nbput{\tiny $\pmIc_{m1}$}%I_m1 |
| 1584 |
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(I1)(NIm1){-0.7}{NI1} |
| 1585 |
\nbput{\tiny $-m\pmIc_2$}%m.I_2 |
| 1586 |
\pcline[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(NI1)\naput{\tiny $\pmIc_{1}$}%I_1 |
| 1587 |
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NI1)(NUc){0.2}{NUd} |
| 1588 |
\nbput{\tiny $R_1\pmIc_1$}%R_1 I_1 |
| 1589 |
\psRelLine[linewidth=1.5pt,arrows=->,angle=90,linecolor=blue](NUd)(NUc){-5}{NUe} |
| 1590 |
\nbput{\tiny $j\omega L_{\sigma1}\pmIc_1$}%-j\omega I_2 |
| 1591 |
\pcline[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUe)\naput{$\pmUc_{1}$}%I_1 |
| 1592 |
\end{pspicture} |
| 1593 |
\end{lstlisting} |
| 1594 |
|
| 1595 |
%$ |
| 1596 |
|
| 1597 |
\clearpage |
| 1598 |
|
| 1599 |
%-------------------------------------------------------------------------------------- |
| 1600 |
\section{\nxLcs{psColorLine}} |
| 1601 |
%-------------------------------------------------------------------------------------- |
| 1602 |
This macro plots a streight line between two given points and two colors. |
| 1603 |
\begin{lstlisting}[style=syntax] |
| 1604 |
\psColorLine[<OptArgs>](<P0>)(<P1>) |
| 1605 |
\end{lstlisting} |
| 1606 |
|
| 1607 |
\begin{LTXexample}[width=5.5cm] |
| 1608 |
\begin{pspicture}[linewidth=12pt,showgrid](-2.5,-2.5)(2.5,2.5) |
| 1609 |
\psColorLine(0,-2.5)(0,2.5) |
| 1610 |
\psColorLine[startColor=cyan,endColor=magenta](-2.5,0)(2.5,0) |
| 1611 |
\psColorLine[startColor=blue,endColor=green]{->}(-2.5,2.5)(2.5,-2.5) |
| 1612 |
\psColorLine[startColor=red,endColor=blue]{<->}(-2.5,-2.5)(2.5,2.5) |
| 1613 |
\end{pspicture} |
| 1614 |
\end{LTXexample} |
| 1615 |
|
| 1616 |
|
| 1617 |
\begin{LTXexample}[width=5.5cm] |
| 1618 |
\begin{pspicture}[linewidth=12pt,showgrid,colorsteps=5, |
| 1619 |
strokeopacity=0.5](-2.5,-2.5)(2.5,2.5) |
| 1620 |
\psColorLine(0,-2.5)(0,2.5) |
| 1621 |
\psColorLine[startColor=cyan,endColor=magenta](-2.5,0)(2.5,0) |
| 1622 |
\psColorLine[startColor=blue,endColor=green]{->}(-2.5,2.5)(2.5,-2.5) |
| 1623 |
\psColorLine[startColor=red,endColor=blue]{<->}(-2.5,-2.5)(2.5,2.5) |
| 1624 |
\end{pspicture} |
| 1625 |
\end{LTXexample} |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
\clearpage |
| 1633 |
|
| 1634 |
%-------------------------------------------------------------------------------------- |
| 1635 |
\section{\nxLcs{psIntersectionPoint}} |
| 1636 |
%-------------------------------------------------------------------------------------- |
| 1637 |
This macro calculates the intersection point of two lines, given by the four coordinates. |
| 1638 |
There is no special parameter here. |
| 1639 |
\begin{lstlisting}[style=syntax] |
| 1640 |
\psIntersectionPoint(<P0>)(<P1>)(<P2>)(<P3>){<node name>} |
| 1641 |
\end{lstlisting} |
| 1642 |
|
| 1643 |
\begin{LTXexample}[width=5.5cm] |
| 1644 |
\psset{unit=0.5cm} |
| 1645 |
\begin{pspicture}(-5,-4)(5,5) |
| 1646 |
\psaxes[labelFontSize=\scriptstyle, |
| 1647 |
dx=2,Dx=2,dy=2,Dy=2]{->}(0,0)(-5,-4)(5,5) |
| 1648 |
\psline[linecolor=red,linewidth=2pt](-5,-1)(5,5) |
| 1649 |
\psline[linecolor=blue,linewidth=2pt](-5,3)(5,-4) |
| 1650 |
\qdisk(-5,-1){2pt}\uput[-90](-5,-1){A} |
| 1651 |
\qdisk(5,5){2pt}\uput[-90](5,5){B} |
| 1652 |
\qdisk(-5,3){2pt}\uput[-90](-5,3){C} |
| 1653 |
\qdisk(5,-4){2pt}\uput[-90](5,-4){D} |
| 1654 |
\psIntersectionPoint(-5,-1)(5,5)(-5,3)(5,-4){IP} |
| 1655 |
\qdisk(IP){3pt}\uput{0.3}[90](IP){IP} |
| 1656 |
\psline[linestyle=dashed](IP|0,0)(IP)(0,0|IP) |
| 1657 |
\end{pspicture} |
| 1658 |
\end{LTXexample} |
| 1659 |
|
| 1660 |
\clearpage |
| 1661 |
|
| 1662 |
%-------------------------------------------------------------------------------------- |
| 1663 |
\section[\nxLcs{psCancel}]{\nxLcs{psCancel}\footnotemark} |
| 1664 |
%-------------------------------------------------------------------------------------- |
| 1665 |
\footnotetext{Thanks to by Stefano Baroni} This macro works like |
| 1666 |
the \Lcs{cancel} macro from the package of the same name but it |
| 1667 |
allows as argument any contents, not only letters but also a |
| 1668 |
complex graphic. |
| 1669 |
|
| 1670 |
\begin{BDef} |
| 1671 |
\LcsStar{psCancel}\OptArgs\Largb{contents}% |
| 1672 |
\end{BDef} |
| 1673 |
|
| 1674 |
All optional arguments for lines and boxes are valid and can be |
| 1675 |
used in the usual way. The star option fills the underlying box |
| 1676 |
rectangle with the linecolor. This can be transparent if |
| 1677 |
\Lkeyword{opacity} is set to a value less than 1. This can be used |
| 1678 |
in presentation to strike out words, equations, and graphic |
| 1679 |
objects. Lines can also be transparent when the option |
| 1680 |
\Lkeyword{strokeopacity} is used. |
| 1681 |
|
| 1682 |
\begingroup |
| 1683 |
\psCancel{A} \psCancel[linecolor=red]{Tikz :-)} \quad |
| 1684 |
\psCancel[linecolor=blue,doubleline=true]{% |
| 1685 |
\readdata{\data}{data/demo1.data} |
| 1686 |
\psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-13mm,lly=-7mm, |
| 1687 |
xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}} |
| 1688 |
\pstScalePoints(1,0.00000001){}{} |
| 1689 |
\begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1, |
| 1690 |
ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm} |
| 1691 |
\listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data} |
| 1692 |
\end{psgraph}} \qquad% end of Cancel |
| 1693 |
\psCancel[linewidth=3pt,linecolor=red, |
| 1694 |
strokeopacity=0.5]{\tabular[b]{c}first line\\second line\endtabular}\quad |
| 1695 |
\psCancel*[linecolor=red!50,opacity=0.5]{\tabular[b]{c}first line\\second line\endtabular} |
| 1696 |
|
| 1697 |
|
| 1698 |
\psCancel*[linecolor=blue!30,opacity=0.5]{% |
| 1699 |
\readdata{\data}{data/demo1.data} |
| 1700 |
\psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-15mm,lly=-7mm,urx=1mm, |
| 1701 |
xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}} |
| 1702 |
\pstScalePoints(1,0.00000001){}{} |
| 1703 |
\begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1, |
| 1704 |
ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm} |
| 1705 |
\listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data} |
| 1706 |
\end{psgraph}} \quad% end of Cancel |
| 1707 |
\psCancel[linewidth=4pt,strokeopacity=0.5]{\parbox{8cm}{\[ |
| 1708 |
\binom{x_R}{y_R} = \underbrace{r\vphantom{\binom{A}{B}}}_{\text{Scaling}}\cdot |
| 1709 |
\underbrace{\begin{pmatrix} |
| 1710 |
\sin\gamma & -\cos\gamma \\ |
| 1711 |
\cos \gamma & \sin \gamma \\ |
| 1712 |
\end{pmatrix}}_{\text{Rotation}} \binom{x_K}{y_K} + |
| 1713 |
\underbrace{\binom{t_x}{t_y}}_{\text{Translation}} \]} }% end of psCancel |
| 1714 |
\endgroup |
| 1715 |
|
| 1716 |
\bigskip |
| 1717 |
\begin{lstlisting} |
| 1718 |
\psCancel{A} \psCancel[linecolor=red]{Tikz :-)} \quad |
| 1719 |
\psCancel[linecolor=blue,doubleline=true]{% |
| 1720 |
\readdata{\data}{data/demo1.data} |
| 1721 |
\psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-13mm,lly=-7mm, |
| 1722 |
xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}} |
| 1723 |
\pstScalePoints(1,0.00000001){}{} |
| 1724 |
\begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1, |
| 1725 |
ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm} |
| 1726 |
\listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data} |
| 1727 |
\end{psgraph}} \qquad% end of Cancel |
| 1728 |
\psCancel[linewidth=3pt,linecolor=red, |
| 1729 |
strokeopacity=0.5]{\tabular[b]{c}first line\\second line\endtabular}\quad |
| 1730 |
\psCancel*[linecolor=red!50,opacity=0.5]{\tabular[b]{c}first line\\second line\endtabular} |
| 1731 |
\quad |
| 1732 |
\psCancel*[linecolor=blue!30,opacity=0.5]{% |
| 1733 |
\readdata{\data}{data/demo1.data} |
| 1734 |
\psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-15mm,lly=-7mm,urx=1mm, |
| 1735 |
xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}} |
| 1736 |
\pstScalePoints(1,0.00000001){}{} |
| 1737 |
\begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1, |
| 1738 |
ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm} |
| 1739 |
\listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data} |
| 1740 |
\end{psgraph}} \quad% end of Cancel |
| 1741 |
\psCancel[linewidth=4pt,strokeopacity=0.5]{\parbox{8cm}{\[ |
| 1742 |
\binom{x_R}{y_R} = \underbrace{r\vphantom{\binom{A}{B}}}_{\text{Scaling}}\cdot |
| 1743 |
\underbrace{\begin{pmatrix} |
| 1744 |
\sin\gamma & -\cos\gamma \\ |
| 1745 |
\cos \gamma & \sin \gamma \\ |
| 1746 |
\end{pmatrix}}_{\text{Rotation}} \binom{x_K}{y_K} + |
| 1747 |
\underbrace{\binom{t_x}{t_y}}_{\text{Translation}} \]} }% end of psCancel |
| 1748 |
\end{lstlisting} |
| 1749 |
|
| 1750 |
The optional argument \Lkeyword{cancelType} allows to define the lines for the non star version. |
| 1751 |
Possible values are \Lkeyval{x} for a cross, \Lkeyval{s} for a slash, and \Lkeyval{b} |
| 1752 |
for a backslash. It is also possible to use the long words for the \Lkeyval{slash} and the \Lkeyval{backslash}. |
| 1753 |
An empty value is always assumed as a \Lkeyval{x}. The uppercase keys maybe used in presentations where it make sense |
| 1754 |
to have thesame box size before ander after something is cancelled by lines. |
| 1755 |
|
| 1756 |
\begin{LTXexample}[pos=t,wide] |
| 1757 |
\psset{linewidth=3pt,strokeopacity=0.4} |
| 1758 |
\psCancel{\tabular[b]{c}first line\\second line\endtabular} \quad |
| 1759 |
\psCancel[cancelType=x]{\tabular[b]{c}first line\\second line\endtabular}\quad |
| 1760 |
\psCancel[cancelType=s]{\tabular[b]{c}first line\\second line\endtabular}\quad |
| 1761 |
\psCancel[cancelType=b]{\tabular[b]{c}first line\\second line\endtabular}\\ |
| 1762 |
\psCancel[cancelType=X]{\tabular[b]{@{}c@{}}first line\\second line\endtabular}\quad |
| 1763 |
\psCancel[cancelType=S]{\tabular[b]{@{}c@{}}first line\\second line\endtabular}\quad |
| 1764 |
\psCancel[cancelType=B]{\tabular[b]{@{}c@{}}first line\\second line\endtabular} |
| 1765 |
\end{LTXexample} |
| 1766 |
|
| 1767 |
\clearpage |
| 1768 |
%-------------------------------------------------------------------------------------- |
| 1769 |
\section{\nxLcs{psStep}} |
| 1770 |
%-------------------------------------------------------------------------------------- |
| 1771 |
\Lcs{psStep} calculates a step function for the upper or lower |
| 1772 |
sum or the max/min of the \Index{Riemann} integral definition of a given |
| 1773 |
function. The available option is |
| 1774 |
|
| 1775 |
\Lkeyset{StepType=lower}|\Lkeyval{upper}|\Lkeyval{Riemann}|\Lkeyval{infimum}|\Lkeyval{supremum} or alternative |
| 1776 |
\Lkeyset{StepType=l}|\Lkeyval{u}|\Lkeyval{R}|\Lkeyval{i}|\Lkeyval{s} |
| 1777 |
|
| 1778 |
with \Lkeyword{lower} as the default setting. The syntax of the function is |
| 1779 |
|
| 1780 |
\begin{BDef} |
| 1781 |
\Lcs{psStep}\OptArgs\Largr{$x1,x2$}\Largb{n}\Largb{function} |
| 1782 |
\end{BDef} |
| 1783 |
|
| 1784 |
%$ |
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
(x1,x2) is the given interval for the step wise calculated |
| 1791 |
function, n is the number of the rectangles and \Larg{function} is |
| 1792 |
the mathematical function in postfix or algebraic notation (with |
| 1793 |
\Lkeyword{algebraic}). |
| 1794 |
|
| 1795 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1796 |
\begin{pspicture}(-0.5,-0.5)(10,3) |
| 1797 |
\psaxes[labelFontSize=\scriptstyle]{->}(10,3) |
| 1798 |
\psplot[plotpoints=100,linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)} |
| 1799 |
\psStep[linecolor=magenta,StepType=upper,fillstyle=hlines](0,9){9}{x sqrt} |
| 1800 |
\psStep[linecolor=blue,fillstyle=vlines](0,9){9}{x sqrt } |
| 1801 |
\end{pspicture} |
| 1802 |
\end{LTXexample} |
| 1803 |
|
| 1804 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1805 |
\psset{plotpoints=200} |
| 1806 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 1807 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3) |
| 1808 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)} |
| 1809 |
\psStep[algebraic,linecolor=magenta,StepType=upper](0,9){20}{sqrt(x)*sin(x)} |
| 1810 |
\psStep[linecolor=blue,linestyle=dashed](0,9){20}{x sqrt x RadtoDeg sin mul} |
| 1811 |
\end{pspicture} |
| 1812 |
\end{LTXexample} |
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1818 |
\psset{yunit=1.25cm,plotpoints=200} |
| 1819 |
\begin{pspicture}(-0.5,-1.5)(10,1.5) |
| 1820 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5) |
| 1821 |
\psStep[algebraic,StepType=Riemann,fillstyle=solid,fillcolor=black!10](0,10){50}% |
| 1822 |
{sqrt(x)*cos(x)*sin(x)} |
| 1823 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)} |
| 1824 |
\end{pspicture} |
| 1825 |
\end{LTXexample} |
| 1826 |
|
| 1827 |
|
| 1828 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1829 |
\psset{yunit=1.25cm,plotpoints=200} |
| 1830 |
\begin{pspicture}(-0.5,-1.5)(10,1.5) |
| 1831 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5) |
| 1832 |
\psStep[algebraic,StepType=infimum,fillstyle=solid,fillcolor=black!10](0,10){50}% |
| 1833 |
{sqrt(x)*cos(x)*sin(x)} |
| 1834 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)} |
| 1835 |
\end{pspicture} |
| 1836 |
\end{LTXexample} |
| 1837 |
|
| 1838 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1839 |
\psset{yunit=1.25cm,plotpoints=200} |
| 1840 |
\begin{pspicture}(-0.5,-1.5)(10,1.5) |
| 1841 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5) |
| 1842 |
\psStep[algebraic,StepType=supremum,fillstyle=solid,fillcolor=black!10](0,10){50}% |
| 1843 |
{sqrt(x)*cos(x)*sin(x)} |
| 1844 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)} |
| 1845 |
\end{pspicture} |
| 1846 |
\end{LTXexample} |
| 1847 |
|
| 1848 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1849 |
\psset{unit=1.5cm,plotpoints=200} |
| 1850 |
\begin{pspicture}[plotpoints=200](-0.5,-3)(10,2.5) |
| 1851 |
\psStep[algebraic,fillstyle=solid,fillcolor=yellow](0.001,9.5){40}{2*sqrt(x)*cos(ln(x))*sin(x)} |
| 1852 |
\psStep[algebraic,StepType=Riemann,fillstyle=solid,fillcolor=blue](0.001,9.5){40}{2*sqrt(x)*cos(ln(x))*sin(x)} |
| 1853 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.75)(10,2.5) |
| 1854 |
\psplot[algebraic,linecolor=white]{0.001}{9.75}{2*sqrt(x)*cos(ln(x))*sin(x)} |
| 1855 |
\uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$} |
| 1856 |
\end{pspicture} |
| 1857 |
\end{LTXexample} |
| 1858 |
|
| 1859 |
|
| 1860 |
There is also an optional argument \Lkeyword{noVerticalLines} which suppresses all |
| 1861 |
vertical lines of the step function in the output. |
| 1862 |
|
| 1863 |
\iffalse |
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
\definecolor{BeigeTS}{rgb}{0.98,0.95,0.87} |
| 1868 |
\definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93} |
| 1869 |
\definecolor{SandBraun}{rgb}{0.96,0.64,0.38} |
| 1870 |
|
| 1871 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 1872 |
\psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,NodeCoorPrefix=n,PrintCoord} |
| 1873 |
\def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)} |
| 1874 |
\begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,dotscale=0.7](-0.5,-3)(10,2.5) |
| 1875 |
\psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,linecolor=SandBraun!50](0.001,9.5){40}{\funkf} |
| 1876 |
\psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,linecolor=CornBlauTS,linewidth=0.3pt]% |
| 1877 |
(0.001,9.5){40}{\funkf} |
| 1878 |
\psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5) |
| 1879 |
\psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf} |
| 1880 |
\psplotTangent[linecolor=blue, Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf} |
| 1881 |
\uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$} |
| 1882 |
\psZero[xShift=-0.2,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={1},Newton](0.5,1){\funkf}{0}{N1} |
| 1883 |
\psZero[xShift=-0.05,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={2}](2,4){\funkf}{0}{N2} |
| 1884 |
\psZero[xShift=-0.45,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={3}](4,6){\funkf}{0}{N3} |
| 1885 |
\psZero[xShift=-0.45,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={4}](6,7){\funkf}{0}{N4} |
| 1886 |
\psZero[xShift=-0.45,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={5}](9,11){\funkf}{0}{N5} |
| 1887 |
\psZero[xShift=-1.15,yShift=0,linecolor=blue!50!black!90,PtName={M},postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}{\funkf}{M} |
| 1888 |
\pcline{->}(0.5,-1)(M) |
| 1889 |
\nbput[nrot=:U,labelsep=0.01]{\scriptsize Steigung ist hier \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round=true,fontscale=7]{nMx,{Derive(1,\funkf)}}} |
| 1890 |
%\psdot[linecolor=green,strokeopacity=0.8](*{nMx} {\funkf}) |
| 1891 |
\uput[90](*{nMx} {\funkf}){$m=$\psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round=true,fontscale=8]{nMx,{Derive(1,\funkf)}}} |
| 1892 |
\end{pspicture} |
| 1893 |
\end{LTXexample} |
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
\begin{pspicture}(-0.5,-1.5)(10.2,1.5) |
| 1900 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10.2,1.5) |
| 1901 |
\psplot[linewidth=.6pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)} |
| 1902 |
\psStep[algebraic,StepType=infimum,fillstyle=solid,opacity=0.3,fillcolor=green!50!black!30,linecolor=green,linewidth=0.1pt,strokeopacity=0.8](0,10){50}% |
| 1903 |
{sqrt(x)*cos(x)*sin(x)} |
| 1904 |
\end{pspicture} |
| 1905 |
|
| 1906 |
|
| 1907 |
\psset{yunit=1.25cm,plotpoints=500} |
| 1908 |
\begin{pspicture}(-0.5,-1.5)(10,1.5) |
| 1909 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5) |
| 1910 |
\psStep[algebraic,StepType=supremum,fillstyle=solid,opacity=0.3,fillcolor=green!50!black!30,linecolor=green,linewidth=0.1pt](0,10){50}% |
| 1911 |
{sqrt(x)*cos(x)*sin(x)} |
| 1912 |
\psplot[linewidth=.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)} |
| 1913 |
\end{pspicture} |
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
\begin{pspicture}(-0.5,-0.5)(10,3) |
| 1918 |
\psaxes[labelFontSize=\scriptstyle]{->}(10,3) |
| 1919 |
\psplot[plotpoints=500,linewidth=.5pt,algebraic]{0}{10}{sqrt(x)} |
| 1920 |
\psStep[linecolor=green,StepType=upper,fillstyle=solid,opacity=0.3,fillcolor=green!50!black!60,linewidth=0.3pt](0,9){9}{x sqrt} |
| 1921 |
\psStep[linecolor=BeigeTS,StepType=lower,fillstyle=hlines,hatchcolor=BeigeTS,hatchwidth=0.3pt,hatchsep=1.2pt,linewidth=0.3pt](0,9){9}{x sqrt } |
| 1922 |
\end{pspicture} |
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
\psset{plotpoints=500} |
| 1927 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 1928 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3) |
| 1929 |
\psplot[linewidth=0.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)} |
| 1930 |
\psStep[algebraic,linecolor=SandBraun,linewidth=0.4pt,StepType=upper](0,9){20}{sqrt(x)*sin(x)} |
| 1931 |
\psStep[linecolor=CornBlauTS,linewidth=0.4pt,linestyle=dashed,dash=1.6pt 1.6pt](0,9){20}{x sqrt x RadtoDeg sin mul} |
| 1932 |
\end{pspicture} |
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
\psset{yunit=1.25cm,plotpoints=500} |
| 1937 |
\begin{pspicture}(-0.5,-1.5)(10,1.5) |
| 1938 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5) |
| 1939 |
\psStep[algebraic,StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,linecolor=CornBlauTS,linewidth=0.2pt](0,10){50}% |
| 1940 |
{sqrt(x)*cos(x)*sin(x)} |
| 1941 |
\psplot[linewidth=.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)} |
| 1942 |
\end{pspicture} |
| 1943 |
|
| 1944 |
\fi |
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
With setting the optional argument \Lkeyword{saveSumValue} |
| 1950 |
it is possible to calculate the area under the rectangles. The value is calculated on PostScript level and then |
| 1951 |
later saved in a macro \Lcs{pstAreaA}, |
| 1952 |
for the next call of \Lcs{psStep} in the macro \Lcs{pstAreaB} and so on. The values are calculated |
| 1953 |
on PostScript level, the reason why two \LaTeX\ runs are needed. for every \Lcs{psStep} there will |
| 1954 |
be an external file \verb|\jobname-area#.tex| which has the definition of the macros \nxLcs{pstArea?}. |
| 1955 |
In this documentation the following \Lcs{psStep} is the 10th call of this function, the reason |
| 1956 |
why we have to choose \Lcs{pstAreaJ} and so on: |
| 1957 |
|
| 1958 |
\clearpage |
| 1959 |
|
| 1960 |
%\begin{LTXexample}[pos=t,preset=\centering] |
| 1961 |
\psset{plotpoints=200}% |
| 1962 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 1963 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)% |
| 1964 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}% |
| 1965 |
\psset{linewidth=0.5pt}% |
| 1966 |
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){20}{sqrt(x)*sin(x)}% |
| 1967 |
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaJ}}% |
| 1968 |
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){20}{sqrt(x)*sin(x)}% |
| 1969 |
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaK}}% |
| 1970 |
\end{pspicture} |
| 1971 |
%\end{LTXexample} |
| 1972 |
|
| 1973 |
\begin{lstlisting} |
| 1974 |
\psset{plotpoints=200}% |
| 1975 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 1976 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)% |
| 1977 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}% |
| 1978 |
\psset{linewidth=0.5pt}% |
| 1979 |
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){20}{sqrt(x)*sin(x)}% |
| 1980 |
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaJ}}% |
| 1981 |
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){20}{sqrt(x)*sin(x)}% |
| 1982 |
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaK}}% |
| 1983 |
\end{pspicture} |
| 1984 |
\end{lstlisting} |
| 1985 |
|
| 1986 |
|
| 1987 |
%\begin{LTXexample}[pos=t,preset=\centering] |
| 1988 |
\psset{plotpoints=200}% |
| 1989 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 1990 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)% |
| 1991 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}% |
| 1992 |
\psset{linewidth=0.1pt}% |
| 1993 |
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){100}{sqrt(x)*sin(x)}% |
| 1994 |
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaL}}% |
| 1995 |
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){100}{sqrt(x)*sin(x)}% |
| 1996 |
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaM}}% |
| 1997 |
\end{pspicture} |
| 1998 |
%\end{LTXexample} |
| 1999 |
|
| 2000 |
\begin{lstlisting} |
| 2001 |
\psset{plotpoints=200}% |
| 2002 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 2003 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)% |
| 2004 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}% |
| 2005 |
\psset{linewidth=0.1pt}% |
| 2006 |
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){100}{sqrt(x)*sin(x)}% |
| 2007 |
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaL}}% |
| 2008 |
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){100}{sqrt(x)*sin(x)}% |
| 2009 |
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaM}}% |
| 2010 |
\end{pspicture} |
| 2011 |
\end{lstlisting} |
| 2012 |
%-------------------------------------------------------------------------------------- |
| 2013 |
|
| 2014 |
|
| 2015 |
The values for the Riemann sum can also be calculatet on \LaTeX\ level, but it needs |
| 2016 |
the package xparse and fp from the new \LaTeX3 kernel. It is not available for running \TeX. |
| 2017 |
|
| 2018 |
\begin{BDef} |
| 2019 |
\Lcs{psRiemannSum}\Largr{$x_0,x_1$}\Largb{n}\Largb{f(\#1)} |
| 2020 |
\end{BDef} |
| 2021 |
|
| 2022 |
The variable name in the last argument must be \#1! |
| 2023 |
After using the above macro the following four macros are defined: |
| 2024 |
|
| 2025 |
\begin{BDef} |
| 2026 |
\Lcs{psLeftSumValue}\\ |
| 2027 |
\Lcs{psRightSumValue}\\ |
| 2028 |
\Lcs{psMiddleSumValue}\\ |
| 2029 |
\Lcs{psDiffSumValue} |
| 2030 |
\end{BDef} |
| 2031 |
|
| 2032 |
They all sum up the Riemann sum for the rectangle of width $dx$ and the height of the left, right |
| 2033 |
or middle value of the function $f(x)$. \Lcs{psDiffSumValue} sums up the absolute value of rextangles |
| 2034 |
in difference to the other three macros which takes a negative area into account. |
| 2035 |
|
| 2036 |
%\begin{LTXexample}[pos=t,preset=\centering] |
| 2037 |
\psset{plotpoints=200}% |
| 2038 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 2039 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)% |
| 2040 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}% |
| 2041 |
\psset{linewidth=0.5pt}% |
| 2042 |
\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)} |
| 2043 |
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){18}{sqrt(x)*sin(x)}% |
| 2044 |
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \psRightSumValue}}% |
| 2045 |
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){18}{sqrt(x)*sin(x)}% |
| 2046 |
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \psLeftSumValue}}% |
| 2047 |
\end{pspicture} |
| 2048 |
%\end{LTXexample} |
| 2049 |
|
| 2050 |
\begin{lstlisting} |
| 2051 |
\psset{plotpoints=200}% |
| 2052 |
\begin{pspicture}(-0.5,-2.25)(10,3) |
| 2053 |
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)% |
| 2054 |
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}% |
| 2055 |
\psset{linewidth=0.5pt}% |
| 2056 |
\psRiemannSum(0,9){18} |
| 2057 |
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){18}{sqrt(x)*sin(x)}% |
| 2058 |
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \psRightSumValue}}% |
| 2059 |
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){18}{sqrt(x)*sin(x)}% |
| 2060 |
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \psLeftSumValue}}% |
| 2061 |
\end{pspicture} |
| 2062 |
\end{lstlisting} |
| 2063 |
|
| 2064 |
|
| 2065 |
With package \texttt{siunitx} it is possible to round the values: |
| 2066 |
|
| 2067 |
\begin{lstlisting} |
| 2068 |
\usepackage{siunitx} |
| 2069 |
\sisetup{add-decimal-zero, |
| 2070 |
round-mode=places, |
| 2071 |
round-precision=2, |
| 2072 |
output-decimal-marker={,}, |
| 2073 |
detect-all} |
| 2074 |
[...] |
| 2075 |
\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}% |
| 2076 |
\num{\psLeftSumValue}\\ |
| 2077 |
\num{\psRightSumValue}\\ |
| 2078 |
\num{\psMiddleSumValue}\\ |
| 2079 |
\num{\psDiffSumValue} |
| 2080 |
\end{lstlisting} |
| 2081 |
|
| 2082 |
\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}% |
| 2083 |
\num{\psLeftSumValue}\\ |
| 2084 |
\num{\psRightSumValue}\\ |
| 2085 |
\num{\psMiddleSumValue}\\ |
| 2086 |
\num{\psDiffSumValue} |
| 2087 |
|
| 2088 |
|
| 2089 |
\clearpage |
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
\section{Tangent lines} |
| 2097 |
There are two macros for plotting a tangent line or the tangent normal line. |
| 2098 |
The first one is \Lcs{psTangentLine} which expects three pairs of coordinates, |
| 2099 |
a $x$ and a $dx$ value. The second one is \Lcs{psplotTangent} which expects |
| 2100 |
a function for the curve. \xLkeyword{Tnormal} |
| 2101 |
|
| 2102 |
\subsection{\nxLcs{psTangentLine} and option \nxLkeyword{Tnormal}} |
| 2103 |
|
| 2104 |
\begin{BDef} |
| 2105 |
\Lcs{psTangentLine}\OptArgs\coord1\coord2\coord3\Largb{x}\Largb{dx} |
| 2106 |
\end{BDef} |
| 2107 |
|
| 2108 |
\begin{LTXexample}[width=0.45\linewidth,wide] |
| 2109 |
\psset{unit=2cm} |
| 2110 |
\begin{pspicture}[showgrid=true](1,-1)(4,1) |
| 2111 |
\pscurve[showpoints=true] |
| 2112 |
(2.1,-0.2)(2.5,0.2)(3.2,0.235)(3.8,-0.2) |
| 2113 |
\psTangentLine[Tnormal,arrows=->, |
| 2114 |
linecolor=red](2.5,0.2)(3.2,0.235)% |
| 2115 |
(3.8,-0.2){3}{0.1} |
| 2116 |
\psTangentLine[arrows=<->, |
| 2117 |
linecolor=blue](2.5,0.2)(3.2,0.235)% |
| 2118 |
(3.8,-0.2){3}{0.5} |
| 2119 |
\end{pspicture} |
| 2120 |
\end{LTXexample} |
| 2121 |
|
| 2122 |
In special cases one has to use \Lkeyword{curvature}\verb+=1 1 1+ for the macro \Lcs{pscurve} |
| 2123 |
to get the same equation for the curve as \Lcs{psplotTangentLine} does. |
| 2124 |
|
| 2125 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 2126 |
\psset{unit=2cm} |
| 2127 |
\begin{pspicture}[showgrid=true](2,-1)(6,2) |
| 2128 |
\pscurve[showpoints=true, |
| 2129 |
curvature=1 1 1](2.1,-0.2)(2.5,0.2)(3.2,0.235)(5.8,2) |
| 2130 |
\pscurve[showpoints=true,linecolor=green, |
| 2131 |
curvature=1 1 1](2.5,0.2)(3.2,0.235)(5.8,2) |
| 2132 |
\psTangentLine[Tnormal,arrows=->,linecolor=red](2.5,0.2)(3.2,0.235)(5.8,2){4.6}{0.6} |
| 2133 |
\psTangentLine[arrows=<->,linecolor=blue](2.5,0.2)(3.2,0.235)(5.8,2){4.5}{0.6} |
| 2134 |
\end{pspicture} |
| 2135 |
\end{LTXexample} |
| 2136 |
|
| 2137 |
|
| 2138 |
The end points are saved as nodes \verb=OCurve=, \verb=ETangent=, and \verb=ENormal=. They can |
| 2139 |
be used in the default ways for nodes: |
| 2140 |
|
| 2141 |
\begin{LTXexample}[pos=t,preset=\centering,wide] |
| 2142 |
\psset{yunit=4cm,xunit=2cm,arrowscale=2} |
| 2143 |
\begin{pspicture}(0.1,-0.3)(4,1) |
| 2144 |
\pscurve[showpoints=true](2.1,-0.2)(2.5,0.2)(3.2,0.4)(3.8,-0.2) |
| 2145 |
\psTangentLine[Tnormal,arrows=->,linecolor=red](2.5,0.2)(3.2,0.4)(3.8,-0.2){3.5}{0.5} |
| 2146 |
\psTangentLine[arrows=->,linecolor=blue](2.5,0.2)(3.2,0.4)(3.8,-0.2){3.5}{0.5} |
| 2147 |
\pcline[linestyle=dashed]{->}(OCurve)(ETangent|OCurve)\naput{$v_x$} |
| 2148 |
\pcline[linestyle=dashed]{->}(ETangent|OCurve)(ETangent)\naput{$v_y$}% double coordinate (x,y|x,y) |
| 2149 |
\end{pspicture} |
| 2150 |
\end{LTXexample} |
| 2151 |
|
| 2152 |
|
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
\subsection{\nxLcs{psplotTangent} and option \nxLkeyword{Tnormal}} |
| 2157 |
%-------------------------------------------------------------------------------------- |
| 2158 |
There is an additional option, named \Lkeyword{Derive} for an |
| 2159 |
alternative function (see following example) to calculate the |
| 2160 |
slope of the tangent. This will be in general the first |
| 2161 |
derivative, but can also be any other function. If this option is |
| 2162 |
different to to the default value \Lkeyset{Derive=default}, then this |
| 2163 |
function is taken to calculate the slope. For the other cases, |
| 2164 |
\LPack{pstricks-add} builds a secant with -0.00005<x<0.00005, |
| 2165 |
calculates the slope and takes this for the tangent. This may be |
| 2166 |
problematic in some cases of special functions or $x$ values, then |
| 2167 |
it may be appropriate to use the Derive option. |
| 2168 |
|
| 2169 |
\begin{BDef} |
| 2170 |
\LcsStar{psplotTangent}\OptArgs\Largb{x}\Largb{dx}\Largb{function} |
| 2171 |
\end{BDef} |
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
The macro expects three parameters: |
| 2176 |
|
| 2177 |
\begin{description} |
| 2178 |
\item[$x$]: the $x$ value of the function for which the tangent should be calculated |
| 2179 |
\item[$dx$]: the $dx$ to both sides of the $x$ value |
| 2180 |
\item[$f(x)$]: the function in infix (with option \Lkeyword{algebraic}) or the default |
| 2181 |
postfix (PostScript) notation |
| 2182 |
\end{description} |
| 2183 |
|
| 2184 |
The following examples show the use of the algebraic option together with the Derive option. |
| 2185 |
Remember that using the \Lkeyword{algebraic} option implies that the angles have to be in the |
| 2186 |
radian unit! |
| 2187 |
|
| 2188 |
\begin{center} |
| 2189 |
\bgroup |
| 2190 |
\def\F{x RadtoDeg dup dup cos exch 2 mul cos add exch 3 mul cos add} |
| 2191 |
\def\Fp{x RadtoDeg dup dup sin exch 2 mul sin 2 mul add exch 3 mul sin 3 mul add neg} |
| 2192 |
\psset{plotpoints=1001} |
| 2193 |
\begin{pspicture}(-7.5,-2.5)(7.5,4)%X\psgrid |
| 2194 |
\psaxes{->}(0,0)(-7.5,-2)(7.5,3.5) |
| 2195 |
\psplot[linewidth=3\pslinewidth]{-7}{7}{\F} |
| 2196 |
\psset{linecolor=red, arrows=<->, arrowscale=2} |
| 2197 |
\multido{\n=-7+1}{8}{\psplotTangent{\n}{1}{\F}} |
| 2198 |
\psset{linecolor=magenta, arrows=<->, arrowscale=2}% |
| 2199 |
\multido{\n=0+1}{8}{\psplotTangent[linecolor=blue, Derive=\Fp]{\n}{1}{\F}} |
| 2200 |
\end{pspicture} |
| 2201 |
\egroup |
| 2202 |
\end{center} |
| 2203 |
|
| 2204 |
|
| 2205 |
\begin{lstlisting} |
| 2206 |
\def\F{x RadtoDeg dup dup cos exch 2 mul cos add exch 3 mul cos add} |
| 2207 |
\def\Fp{x RadtoDeg dup dup sin exch 2 mul sin 2 mul add exch 3 mul sin 3 mul add neg} |
| 2208 |
\psset{plotpoints=1001} |
| 2209 |
\begin{pspicture}(-7.5,-2.5)(7.5,4)%X\psgrid |
| 2210 |
\psaxes{->}(0,0)(-7.5,-2)(7.5,3.5) |
| 2211 |
\psplot[linewidth=3\pslinewidth]{-7}{7}{\F} |
| 2212 |
\psset{linecolor=red, arrows=<->, arrowscale=2} |
| 2213 |
\multido{\n=-7+1}{8}{\psplotTangent{\n}{1}{\F}} |
| 2214 |
\psset{linecolor=magenta, arrows=<->, arrowscale=2}% |
| 2215 |
\multido{\n=0+1}{8}{\psplotTangent[linecolor=blue, §\ON§Derive=\Fp§\OFF§]{\n}{1}{\F}} |
| 2216 |
\end{pspicture} |
| 2217 |
\end{lstlisting} |
| 2218 |
|
| 2219 |
The star version plots only the tangent line in the positive $x$-direction: |
| 2220 |
|
| 2221 |
\begin{center} |
| 2222 |
\bgroup |
| 2223 |
\def\Falg{cos(x)+cos(2*x)+cos(3*x)} \def\Fpalg{-sin(x)-2*sin(2*x)-3*sin(3*x)} |
| 2224 |
\begin{pspicture}(-7.5,-2.5)(7.5,4)%\psgrid |
| 2225 |
\psaxes{->}(0,0)(-7.5,-2)(7.5,3.5) |
| 2226 |
\psplot[linewidth=1.5pt,algebraic,plotpoints=500]{-7.5}{7.5}{\Falg} |
| 2227 |
\multido{\n=-7+1}{8}{\psplotTangent*[linecolor=red,arrows=->,arrowscale=2,algebraic]{\n}{1}{\Falg}} |
| 2228 |
\multido{\n=0+1}{8}{\psplotTangent*[linecolor=magenta,% |
| 2229 |
arrows=->,arrowscale=2,algebraic,Derive={\Fpalg}]{\n}{1}{\Falg}} |
| 2230 |
\end{pspicture} |
| 2231 |
\egroup |
| 2232 |
\end{center} |
| 2233 |
|
| 2234 |
\begin{lstlisting} |
| 2235 |
\def\Falg{cos(x)+cos(2*x)+cos(3*x)} \def\Fpalg{-sin(x)-2*sin(2*x)-3*sin(3*x)} |
| 2236 |
\begin{pspicture}(-7.5,-2.5)(7.5,4)%\psgrid |
| 2237 |
\psaxes{->}(0,0)(-7.5,-2)(7.5,3.5) |
| 2238 |
\psplot[linewidth=1.5pt,algebraic,plotpoints=500]{-7.5}{7.5}{\Falg} |
| 2239 |
\multido{\n=-7+1}{8}{\psplotTangent*[linecolor=red,arrows=->,arrowscale=2,algebraic]{\n}{1}{\Falg}} |
| 2240 |
\multido{\n=0+1}{8}{\psplotTangent*[linecolor=magenta,% |
| 2241 |
arrows=->,arrowscale=2,algebraic,Derive={\Fpalg}]{\n}{1}{\Falg}} |
| 2242 |
\end{pspicture} |
| 2243 |
\end{lstlisting} |
| 2244 |
|
| 2245 |
The next example shows the use of the \Lkeyword{Derive} option to draw |
| 2246 |
the perpendicular line to the tangent. |
| 2247 |
|
| 2248 |
\begin{LTXexample}[width=8cm,wide] |
| 2249 |
\begin{pspicture}(-0.5,-0.5)(7.25,7.25) |
| 2250 |
\def\Func{10 x div} |
| 2251 |
\psaxes[arrowscale=1.5]{->}(7,7) |
| 2252 |
\psplot[linewidth=2pt,algebraic]{1.5}{5}{10/x} |
| 2253 |
\psplotTangent[linewidth=.5\pslinewidth,linecolor=red,algebraic]{3}{2}{10/x} |
| 2254 |
\psplotTangent[linewidth=.5\pslinewidth,linecolor=blue,algebraic,Derive=(x*x)/10]{3}{2}{10/x} |
| 2255 |
\psline[linestyle=dashed](!0 /x 3 def \Func)(!3 /x 3 def \Func)(3,0) |
| 2256 |
\end{pspicture} |
| 2257 |
\end{LTXexample} |
| 2258 |
|
| 2259 |
By setting the optional argument \Lkeyword{Tnormal} one can plot the |
| 2260 |
normal of the tangent line. It always starts at the given point. |
| 2261 |
|
| 2262 |
\begin{LTXexample}[width=8cm,wide] |
| 2263 |
\begin{pspicture}(-0.5,-0.5)(7.25,7.25) |
| 2264 |
\def\Func{10 x div} |
| 2265 |
\psaxes[arrowscale=1.5]{->}(7,7) |
| 2266 |
\psplot[linewidth=2pt]{1.5}{5}{\Func} |
| 2267 |
\psplotTangent[linewidth=1.5\pslinewidth,linecolor=red]{3}{2}{\Func} |
| 2268 |
\psplotTangent[linewidth=1.5\pslinewidth,linecolor=blue,Tnormal]{3}{2}{\Func} |
| 2269 |
\psline[linestyle=dashed](!0 /x 3 def \Func)(!3 /x 3 def \Func)(3,0) |
| 2270 |
\end{pspicture} |
| 2271 |
\end{LTXexample} |
| 2272 |
|
| 2273 |
|
| 2274 |
Let's work with the classical \Index{cardioid}: $r=2(1+\cos(\theta))$ and |
| 2275 |
$\displaystyle \frac{d r}{d\theta}=-2\sin(\theta)$. The \Lkeyword{Derive} |
| 2276 |
option always expects the $\frac{d r}{d\theta}$ value and uses |
| 2277 |
internally the equation for the derivative of implicitly defined |
| 2278 |
functions: |
| 2279 |
|
| 2280 |
\[ |
| 2281 |
\frac{dy}{dx}=\frac{r^\prime\cdot\sin\theta + x}{r^\prime\cdot\cos\theta - y} |
| 2282 |
\] |
| 2283 |
where $x=r\cdot\cos\theta$ and $y=r\cdot\sin\theta$ |
| 2284 |
|
| 2285 |
|
| 2286 |
\begin{LTXexample}[width=6cm,wide] |
| 2287 |
\begin{pspicture}(-1,-3)(5,3)%\psgrid[subgridcolor=lightgray] |
| 2288 |
\psaxes{->}(0,0)(-1,-3)(5,3) |
| 2289 |
\psplot[polarplot,linewidth=3\pslinewidth,linecolor=blue,% |
| 2290 |
plotpoints=500]{0}{360}{1 x cos add 2 mul} |
| 2291 |
\end{pspicture} |
| 2292 |
\end{LTXexample} |
| 2293 |
|
| 2294 |
\psset{algebraic=false} |
| 2295 |
\begin{LTXexample}[width=6cm,wide] |
| 2296 |
\begin{pspicture}(-1,-3)(5,3)%\psgrid[subgridcolor=lightgray] |
| 2297 |
\psaxes{->}(0,0)(-1,-3)(5,3) |
| 2298 |
\psplot[polarplot,linewidth=3\pslinewidth,linecolor=blue,plotpoints=500]{0}{360}{1 x cos add 2 mul} |
| 2299 |
\multido{\n=0+36}{10}{% |
| 2300 |
\psplotTangent[polarplot,linecolor=red,arrows=<->]{\n}{1.5}{1 x cos add 2 mul} } |
| 2301 |
\end{pspicture} |
| 2302 |
\end{LTXexample} |
| 2303 |
|
| 2304 |
\begin{LTXexample}[width=6cm,wide] |
| 2305 |
\begin{pspicture}(-1,-3)(5,3)%\psgrid[subgridcolor=lightgray] |
| 2306 |
\psaxes{->}(0,0)(-1,-3)(5,3) |
| 2307 |
\psplot[polarplot,linewidth=3\pslinewidth,linecolor=blue,algebraic,plotpoints=500]{0}{6.289}{2*(1+cos(x))} |
| 2308 |
\multido{\r=0.000+0.314}{21}{% |
| 2309 |
\psplotTangent[polarplot,Derive=-2*sin(x),algebraic,linecolor=red,arrows=<->]{\r}{1.5}{2*(1+cos(x))} } |
| 2310 |
\end{pspicture} |
| 2311 |
\end{LTXexample} |
| 2312 |
|
| 2313 |
|
| 2314 |
Let's work with a \Index{Lissajou curve}: |
| 2315 |
$\displaystyle\left\{\begin{array}{l}x=3.5\cos(2t)\\y=3.5\sin(6t)\end{array}\right.$ |
| 2316 |
whose derivative is : |
| 2317 |
$\displaystyle\left\{\begin{array}{l}x=-7\sin(2t)\\y=21\cos(6t)\end{array}\right.$ |
| 2318 |
|
| 2319 |
The parameter must be the letter $t$ instead of $x$ and when using |
| 2320 |
the \Lkeyword{algebraic} option you must separate the two equations by |
| 2321 |
a \nxLnotation{|} (see example). |
| 2322 |
|
| 2323 |
\begin{LTXexample}[pos=t,wide] |
| 2324 |
\def\Lissa{t dup 2 RadtoDeg mul cos 3.5 mul exch 6 mul RadtoDeg sin 3.5 mul}% |
| 2325 |
\psset{yunit=0.6} |
| 2326 |
\begin{pspicture}(-4,-4)(4,6) |
| 2327 |
\parametricplot[plotpoints=500,linewidth=3\pslinewidth]{0}{3.141592}{\Lissa} |
| 2328 |
\multido{\r=0.000+0.314}{11}{% |
| 2329 |
\psplotTangent[linecolor=red,arrows=<->]{\r}{1.5}{\Lissa} } |
| 2330 |
\multido{\r=0.157+0.314}{11}{% |
| 2331 |
\psplotTangent[linecolor=blue,arrows=<->]{\r}{1.5}{\Lissa} } |
| 2332 |
\end{pspicture}\hfill% |
| 2333 |
\def\LissaAlg{3.5*cos(2*t)|3.5*sin(6*t)} \def\LissaAlgDer{-7*sin(2*t)|21*cos(6*t)}% |
| 2334 |
\begin{pspicture}(-4,-4)(4,6) |
| 2335 |
\parametricplot[algebraic,plotpoints=500,linewidth=3\pslinewidth]{0}{3.141592}{\LissaAlg} |
| 2336 |
\multido{\r=0.000+0.314}{11}{% |
| 2337 |
\psplotTangent[algebraic,linecolor=red,arrows=<->]{\r}{1.5}{\LissaAlg}} |
| 2338 |
\multido{\r=0.157+0.314}{11}{% |
| 2339 |
\psplotTangent[algebraic,linecolor=blue,arrows=<->, |
| 2340 |
Derive=\LissaAlgDer]{\r}{1.5}{\LissaAlg} } |
| 2341 |
\end{pspicture} |
| 2342 |
\end{LTXexample} |
| 2343 |
|
| 2344 |
\iffalse |
| 2345 |
\begin{LTXexample}[pos=t,wide] |
| 2346 |
\psset{yunit=2cm,xunit=1.2cm,plotpoints=500,arrowinset=0.02,arrowlength=2,algebraic} |
| 2347 |
\def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)} |
| 2348 |
\begin{pspicture}[showgrid](-1,-3)(10,3.2) |
| 2349 |
\psaxes[labelFontSize=\scriptstyle,subticks=5,ticksize=-0.1 0,labelsep=0.07]{->}(0,0)(0,-2.75)(10,2.5) |
| 2350 |
\psplot{0.001}{9.75}{\funkf} |
| 2351 |
\psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)}, |
| 2352 |
showpoints,nodesep=0]{0.35}{1.5}{\funkf} |
| 2353 |
\psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)},Tnormal, |
| 2354 |
nodesepA=-3,nodesepB=0,strokeopacity=0.4]{0.35}{1.5}{\funkf} |
| 2355 |
\psdot[linecolor=cyan](ENormal) |
| 2356 |
\psdot[linecolor=cyan](ENormalE) |
| 2357 |
\psdot[linecolor=red](OCurve) |
| 2358 |
\psdot[linecolor=green](ETangent) |
| 2359 |
\psdot[linecolor=green](ETangentE) |
| 2360 |
\end{pspicture} |
| 2361 |
\end{LTXexample} |
| 2362 |
\fi |
| 2363 |
|
| 2364 |
\clearpage |
| 2365 |
\section{Successive derivatives of a function} |
| 2366 |
|
| 2367 |
The new PostScript function \Lps{Derive} has been added for |
| 2368 |
plotting successive derivatives of a function. It must be used |
| 2369 |
with the \Lkeyword{algebraic} option. This function has two arguments: |
| 2370 |
|
| 2371 |
\begin{enumerate} |
| 2372 |
\item a positive integer which defines the order of the derivative; obviously $0$ means the |
| 2373 |
function itself! |
| 2374 |
\item a function of variable $x$ which can be any function using common operators, |
| 2375 |
\end{enumerate} |
| 2376 |
|
| 2377 |
Do not think that the derivative is approximated, the internal PostScript engine will |
| 2378 |
compute the real derivative using a formal derivative engine. |
| 2379 |
|
| 2380 |
The following diagram contains the plot of the polynomial: |
| 2381 |
|
| 2382 |
\[ f(x)=\sum_{i=0}^{14}\frac{(-1)^{i}x^{2i}}{i!}=1-\frac{x^2}{2}+\frac{x^4}{4!}-\frac{x^6}{6!}+\frac{x^8}{8!}- |
| 2383 |
\frac{x^{10}}{10!}+\frac{x^{12}}{12!}-\frac{x^{14}}{14!}\] |
| 2384 |
|
| 2385 |
and of its first 15 derivatives. It is the sequence definition of |
| 2386 |
the cosine. |
| 2387 |
|
| 2388 |
|
| 2389 |
\begin{LTXexample}[pos=t,wide,preset=\centering] |
| 2390 |
\psset{unit=2} |
| 2391 |
\def\getColor#1{\ifcase#1 Tan\or RedOrange\or magenta\or yellow\or green\or Orange\or blue\or |
| 2392 |
DarkOrchid\or BrickRed\or Rhodamine\or OliveGreen\or Goldenrod\or Mahogany\or |
| 2393 |
OrangeRed\or CarnationPink\or RoyalPurple\or Lavender\fi} |
| 2394 |
\begin{pspicture}[showgrid=true](0,-1.2)(7,1.5) |
| 2395 |
\psclip{\psframe[linestyle=none](0,-1.1)(7,1.1)} |
| 2396 |
\multido{\i=0+1}{16}{% |
| 2397 |
\psplot[linewidth=1pt,algebraic,linecolor=\getColor{\i}]{0}{7} |
| 2398 |
{Derive(\i,1-x^2/2+x^4/24-x^6/720+x^8/40320-x^10/3628800+x^12/479001600-x^14/87178291200)}} |
| 2399 |
\endpsclip |
| 2400 |
\end{pspicture} |
| 2401 |
\end{LTXexample} |
| 2402 |
|
| 2403 |
\begin{LTXexample}[width=3.5cm] |
| 2404 |
\begin{pspicture}[shift=-2.5,showgrid=true,linewidth=1pt](0,-2)(3,3) |
| 2405 |
\psplot[algebraic]{.001}{3}{x*ln(x)} % f(x) |
| 2406 |
\psplot[algebraic,linecolor=red]{.05}{3}{Derive(1,x*ln(x))} % f'(x)=1+ln(x) |
| 2407 |
\end{pspicture} |
| 2408 |
\end{LTXexample} |
| 2409 |
|
| 2410 |
|
| 2411 |
\clearpage |
| 2412 |
\section{Variable step for plotting a curve} |
| 2413 |
\subsection{Theory} |
| 2414 |
|
| 2415 |
As you know with the \Lcs{psplot} macro, the curve is plotted |
| 2416 |
using a piece-wise linear curve. The step is given by the |
| 2417 |
parameter \Lkeyword{plotpoints}. For each step between $x_i$ and |
| 2418 |
$x_{i+1}$, the area defined between the curve and its |
| 2419 |
approximation (a segment) is majored by this formula : |
| 2420 |
|
| 2421 |
\begin{minipage}[m]{.5\linewidth} |
| 2422 |
\[|\varepsilon|\le\frac{M_2(f)(x_{i+1}-x_i)^3}{12}\] |
| 2423 |
|
| 2424 |
$M_2(f)$ is a majorant of the second derivative of $f$ in the interval $[x_i;x_{i+1}]$. |
| 2425 |
\end{minipage} |
| 2426 |
{\psset{unit=1cm, showpoints=false} |
| 2427 |
\begin{pspicture}[shift=-2,showgrid=true](0,-1)(6,3) |
| 2428 |
\pscurve(0,0)(1,1)(3,2.2)(5,2)(6,1)\psline(1,1)(5,2) |
| 2429 |
\psline(.5,0)(5.5,0)\psline(1,0)(1,1)\psline(5,0)(5,2) |
| 2430 |
\rput[t](1,-.1){$x_n$}\rput[t](5,-.1){$x_{n+1}$} |
| 2431 |
\psclip{\pscustom{\psecurve(0,0)(1,1)(3,2.2)(5,2)(6,1)\psline(5,2)}} |
| 2432 |
\psframe[fillstyle=solid, fillcolor=gray](0,0)(5,5) |
| 2433 |
\endpsclip |
| 2434 |
\rput*(3,1.8){$\varepsilon$} |
| 2435 |
\end{pspicture}} |
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
The parameter \Lkeyword{VarStep} (\false\ by default) activates |
| 2440 |
the variable step algorithm. It is set to a tolerance defined by |
| 2441 |
the parameter \Lkeyword{VarStepEpsilon} (\Lkeyval{default} by default, |
| 2442 |
accept real value). If this parameter is not set by the user, then |
| 2443 |
it is automatically computed using the default first step given by |
| 2444 |
the parameter \Lkeyword{plotpoints}. Then, for each step, $f''(x_n)$ |
| 2445 |
and $f''(x_{n+1})$ are computed and the smaller is used as |
| 2446 |
$M_2(f)$, and then the step is approximated. This means that the |
| 2447 |
step is constant for second order polynomials. |
| 2448 |
|
| 2449 |
\subsection{The cosine} |
| 2450 |
|
| 2451 |
Different value for the tolerance from $0.01$ to $0.000\,1$, a factor $10$ between |
| 2452 |
each of them. In black, there is the classic \Lcs{psplot} behavior, and in |
| 2453 |
magenta the default variable step behavior. |
| 2454 |
|
| 2455 |
\begin{center} |
| 2456 |
\bgroup |
| 2457 |
\psset{algebraic, VarStep=true, unit=2, showpoints=true, linecolor=red} |
| 2458 |
\begin{pspicture}(-0,-1)(3.14,2)\psgrid |
| 2459 |
\psplot[VarStepEpsilon=.01]{0}{3.14}{cos(x)} |
| 2460 |
\psplot[VarStepEpsilon=.001]{0}{3.14}{cos(x)+.15} |
| 2461 |
\psplot[VarStepEpsilon=.0001]{0}{3.14}{cos(x)+.3} |
| 2462 |
\psplot[linecolor=magenta]{0}{3.14}{cos(x)+.45} |
| 2463 |
\psplot[VarStep=false, linewidth=2\pslinewidth, linecolor=black]{-0}{3.14}{cos(x)+.6} |
| 2464 |
\end{pspicture} |
| 2465 |
\egroup |
| 2466 |
\end{center} |
| 2467 |
|
| 2468 |
\begin{lstlisting} |
| 2469 |
\psset{algebraic, VarStep=true, unit=2, showpoints=true, linecolor=red} |
| 2470 |
\begin{pspicture}[showgrid=true](-0,-1)(3.14,2) |
| 2471 |
\psplot[VarStepEpsilon=.01]{0}{3.14}{cos(x)} |
| 2472 |
\psplot[VarStepEpsilon=.001]{0}{3.14}{cos(x)+.15} |
| 2473 |
\psplot[VarStepEpsilon=.0001]{0}{3.14}{cos(x)+.3} |
| 2474 |
\psplot[linecolor=magenta]{0}{3.14}{cos(x)+.45} |
| 2475 |
\psplot[VarStep=false,linewidth=1pt,linecolor=black]{-0}{3.14}{cos(x)+.6} |
| 2476 |
\end{pspicture} |
| 2477 |
\end{lstlisting} |
| 2478 |
|
| 2479 |
|
| 2480 |
\subsection{The Napierian Logarithm} |
| 2481 |
|
| 2482 |
A really classic example which gives a bad beginning, the tolerance is set to $0.001$. |
| 2483 |
|
| 2484 |
\begin{center} |
| 2485 |
\bgroup |
| 2486 |
\psset{algebraic, VarStep=true, linecolor=red, showpoints=true} |
| 2487 |
\begin{pspicture}[showgrid=true](0,-5)(16,4) |
| 2488 |
\psplot[VarStep=false, linecolor=black]{.01}{16}{ln(x)+1} |
| 2489 |
\psplot[linecolor=magenta]{.51}{16}{ln(x-1/2)+1/2} |
| 2490 |
\psplot[VarStepEpsilon=.001]{1.01}{16}{ln(x-1)} |
| 2491 |
\psplot[VarStepEpsilon=.01]{1.51}{16}{ln(x-1.5)-100/200} |
| 2492 |
\end{pspicture} |
| 2493 |
\egroup |
| 2494 |
\end{center} |
| 2495 |
|
| 2496 |
\begin{lstlisting} |
| 2497 |
\psset{algebraic, VarStep=true, linecolor=red, showpoints=true} |
| 2498 |
\begin{pspicture}[showgrid=true](0,-5)(16,4) |
| 2499 |
\psplot[VarStep=false, linecolor=black]{.01}{16}{ln(x)+1} |
| 2500 |
\psplot[linecolor=magenta]{.51}{16}{ln(x-1/2)+1/2} |
| 2501 |
\psplot[VarStepEpsilon=.001]{1.01}{16}{ln(x-1)} |
| 2502 |
\psplot[VarStepEpsilon=.01]{1.51}{16}{ln(x-1.5)-100/200} |
| 2503 |
\end{pspicture} |
| 2504 |
\end{lstlisting} |
| 2505 |
|
| 2506 |
|
| 2507 |
\clearpage |
| 2508 |
\subsection{Sine of the inverse of $x$} |
| 2509 |
Impossible to draw, but let's try! |
| 2510 |
|
| 2511 |
\begin{center} |
| 2512 |
\bgroup |
| 2513 |
\psset{xunit=64,algebraic,VarStep,linecolor=red,showpoints=true,linewidth=1pt,dotscale=0.5} |
| 2514 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2515 |
\psplot[VarStepEpsilon=.0001]{.01}{.25}{sin(1/x)} |
| 2516 |
\end{pspicture}\\ |
| 2517 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2518 |
\psplot[VarStepEpsilon=.00001]{.01}{.25}{sin(1/x)} |
| 2519 |
\end{pspicture}\\ |
| 2520 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2521 |
\psplot[VarStepEpsilon=.000001]{.01}{.25}{sin(1/x)} |
| 2522 |
\end{pspicture}\\ |
| 2523 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2524 |
\psplot[VarStep=false, linecolor=black]{.01}{.25}{sin(1/x)} |
| 2525 |
\end{pspicture} |
| 2526 |
\egroup |
| 2527 |
\end{center} |
| 2528 |
|
| 2529 |
\begin{lstlisting} |
| 2530 |
\psset{xunit=64,algebraic,VarStep,linecolor=red,showpoints=true,linewidth=1pt,dotscale=0.5} |
| 2531 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2532 |
\psplot[VarStepEpsilon=.0001]{.01}{.25}{sin(1/x)} |
| 2533 |
\end{pspicture}\\ |
| 2534 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2535 |
\psplot[VarStepEpsilon=.00001]{.01}{.25}{sin(1/x)} |
| 2536 |
\end{pspicture}\\ |
| 2537 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2538 |
\psplot[VarStepEpsilon=.000001]{.01}{.25}{sin(1/x)} |
| 2539 |
\end{pspicture}\\ |
| 2540 |
\begin{pspicture}[showgrid=true](0,-1)(.5,1) |
| 2541 |
\psplot[VarStep=false, linecolor=black]{.01}{.25}{sin(1/x)} |
| 2542 |
\end{pspicture} |
| 2543 |
\end{lstlisting} |
| 2544 |
|
| 2545 |
|
| 2546 |
|
| 2547 |
|
| 2548 |
|
| 2549 |
\clearpage |
| 2550 |
\subsection{A really complicated function} |
| 2551 |
|
| 2552 |
Just appreciate the difference between the normal behavior and the plotting with the |
| 2553 |
\Lkeyword{varStep} option. The function is: |
| 2554 |
|
| 2555 |
\[f(x)=x-\frac{x^2}{10}+\ln(x)+\cos(2x)+\sin(x^2)-1\] |
| 2556 |
|
| 2557 |
\begin{center} |
| 2558 |
\bgroup |
| 2559 |
\psset{xunit=3, algebraic, VarStep, showpoints=true} |
| 2560 |
\begin{pspicture}[showgrid=true](0,-2)(5,6) |
| 2561 |
\psplot[VarStepEpsilon=.0005, linecolor=red]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)} |
| 2562 |
\psplot[linecolor=magenta]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)+.5} |
| 2563 |
\psplot[VarStep=false]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)-1} |
| 2564 |
\end{pspicture} |
| 2565 |
\egroup |
| 2566 |
\end{center} |
| 2567 |
|
| 2568 |
\begin{lstlisting} |
| 2569 |
\psset{xunit=3, algebraic, VarStep, showpoints=true} |
| 2570 |
\begin{pspicture}[showgrid=true](0,-2)(5,6) |
| 2571 |
\psplot[VarStepEpsilon=.0005, linecolor=red]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)} |
| 2572 |
\psplot[linecolor=magenta]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)+.5} |
| 2573 |
\psplot[VarStep=false]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)-1} |
| 2574 |
\end{pspicture} |
| 2575 |
\end{lstlisting} |
| 2576 |
|
| 2577 |
|
| 2578 |
\clearpage |
| 2579 |
\subsection{A hyperbola} |
| 2580 |
|
| 2581 |
\begin{center} |
| 2582 |
\bgroup |
| 2583 |
\psset{algebraic, showpoints=true, unit=0.75} |
| 2584 |
\begin{pspicture}(-5,-4)(9,6) |
| 2585 |
\psplot[linecolor=black]{-5}{1.8}{(x-1)/(x-2)} |
| 2586 |
\psplot[VarStep=true, VarStepEpsilon=.001, linecolor=red]{2.2}{9}{(x-1)/(x-2)} |
| 2587 |
\psaxes{->}(0,0)(-5,-4)(9,6) |
| 2588 |
\end{pspicture} |
| 2589 |
\egroup |
| 2590 |
\end{center} |
| 2591 |
|
| 2592 |
\begin{lstlisting} |
| 2593 |
\psset{algebraic, showpoints=true, unit=0.75} |
| 2594 |
\begin{pspicture}(-5,-4)(9,6) |
| 2595 |
\psplot[linecolor=black]{-5}{1.8}{(x-1)/(x-2)} |
| 2596 |
\psplot[VarStep=true, VarStepEpsilon=.001, linecolor=red]{2.2}{9}{(x-1)/(x-2)} |
| 2597 |
\psaxes{->}(0,0)(-5,-4)(9,6) |
| 2598 |
\end{pspicture} |
| 2599 |
\end{lstlisting} |
| 2600 |
|
| 2601 |
|
| 2602 |
|
| 2603 |
\clearpage |
| 2604 |
\subsection{Using \nxLcs{psparametricplot}} |
| 2605 |
|
| 2606 |
\begin{BDef} |
| 2607 |
\Lcs{parametricplot}\OptArgs\Largb{t0}\Largb{t1}\OptArg{PS commands}\Largb{x(t) y(t)} |
| 2608 |
\end{BDef} |
| 2609 |
|
| 2610 |
\begin{center} |
| 2611 |
\bgroup |
| 2612 |
\psset{unit=2.5} |
| 2613 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2614 |
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true, |
| 2615 |
VarStepEpsilon=.0001] |
| 2616 |
{-3.14}{3.14}{cos(3*t)|sin(2*t)} |
| 2617 |
\end{pspicture} |
| 2618 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2619 |
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false, |
| 2620 |
VarStepEpsilon=.0001] |
| 2621 |
{-3.14}{3.14}{cos(3*t)|sin(2*t)} |
| 2622 |
\end{pspicture} |
| 2623 |
\egroup |
| 2624 |
\end{center} |
| 2625 |
|
| 2626 |
\begin{lstlisting} |
| 2627 |
\psset{unit=3} |
| 2628 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2629 |
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true, |
| 2630 |
VarStepEpsilon=.0001] |
| 2631 |
{-3.14}{3.14}{cos(3*t)|sin(2*t)} |
| 2632 |
\end{pspicture} |
| 2633 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2634 |
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false, |
| 2635 |
VarStepEpsilon=.0001] |
| 2636 |
{-3.14}{3.14}{cos(3*t)|sin(2*t)} |
| 2637 |
\end{pspicture} |
| 2638 |
\end{lstlisting} |
| 2639 |
|
| 2640 |
|
| 2641 |
\begin{center} |
| 2642 |
\bgroup |
| 2643 |
\psset{unit=2.5} |
| 2644 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2645 |
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true, |
| 2646 |
VarStepEpsilon=.0001] |
| 2647 |
{0}{47.115}{cos(5*t)|sin(3*t)} |
| 2648 |
\end{pspicture} |
| 2649 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2650 |
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false, |
| 2651 |
VarStepEpsilon=.0001] |
| 2652 |
{0}{47.115}{cos(5*t)|sin(3*t)} |
| 2653 |
\end{pspicture} |
| 2654 |
\egroup |
| 2655 |
\end{center} |
| 2656 |
|
| 2657 |
\begin{lstlisting} |
| 2658 |
\psset{unit=2.5} |
| 2659 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2660 |
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true, |
| 2661 |
VarStepEpsilon=.0001] |
| 2662 |
{0}{47.115}{cos(5*t)|sin(3*t)} |
| 2663 |
\end{pspicture} |
| 2664 |
\begin{pspicture}[showgrid=true](-1,-1)(1,1) |
| 2665 |
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false, |
| 2666 |
VarStepEpsilon=.0001] |
| 2667 |
{0}{47.115}{cos(5*t)|sin(3*t)} |
| 2668 |
\end{pspicture} |
| 2669 |
\end{lstlisting} |
| 2670 |
|
| 2671 |
|
| 2672 |
\begin{center} |
| 2673 |
\bgroup |
| 2674 |
\psset{xunit=.5} |
| 2675 |
\begin{pspicture}[showgrid=true](0,0)(12.566,2) |
| 2676 |
\parametricplot[algebraic,linecolor=red,VarStep, showpoints=true, |
| 2677 |
VarStepEpsilon=.01]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)} |
| 2678 |
\end{pspicture} |
| 2679 |
% |
| 2680 |
\begin{pspicture}[showgrid=true](0,0)(12.566,2) |
| 2681 |
\parametricplot[algebraic,linecolor=blue,VarStep, showpoints=false, |
| 2682 |
VarStepEpsilon=.001]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)} |
| 2683 |
\end{pspicture} |
| 2684 |
\egroup |
| 2685 |
\end{center} |
| 2686 |
|
| 2687 |
\begin{lstlisting} |
| 2688 |
\psset{xunit=.5} |
| 2689 |
\begin{pspicture}[showgrid=true](0,0)(12.566,2) |
| 2690 |
\parametricplot[algebraic,linecolor=red,VarStep, showpoints=true, |
| 2691 |
VarStepEpsilon=.01]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)} |
| 2692 |
\end{pspicture} |
| 2693 |
% |
| 2694 |
\begin{pspicture}[showgrid=true](0,0)(12.566,2) |
| 2695 |
\parametricplot[algebraic,linecolor=blue,VarStep, showpoints=false, |
| 2696 |
VarStepEpsilon=.001]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)} |
| 2697 |
\end{pspicture} |
| 2698 |
\end{lstlisting} |
| 2699 |
|
| 2700 |
|
| 2701 |
\section{New math functions and their derivatives} |
| 2702 |
|
| 2703 |
\subsection{The inverse sine and its derivative} |
| 2704 |
|
| 2705 |
\begin{center} |
| 2706 |
\bgroup |
| 2707 |
\psset{unit=1.5} |
| 2708 |
\begin{pspicture}[showgrid=true](-1,-2)(1,2) |
| 2709 |
\psplot[linecolor=blue,algebraic]{-1}{1}{asin(x)} |
| 2710 |
\end{pspicture} |
| 2711 |
\hspace{1em} |
| 2712 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2713 |
\begin{pspicture}[showgrid=true](-1,-2)(1,2) |
| 2714 |
\psplot[linecolor=blue]{-.999}{.999}{asin(x)} |
| 2715 |
\end{pspicture} |
| 2716 |
\hspace{1em} |
| 2717 |
\begin{pspicture}[showgrid=true](-1,0)(1,4) |
| 2718 |
\psplot[linecolor=blue]{-.97}{.97}{Derive(1,asin(x))} |
| 2719 |
\end{pspicture} |
| 2720 |
\hspace{1em} |
| 2721 |
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true} |
| 2722 |
\begin{pspicture}[showgrid=true](-1,0)(1,4) |
| 2723 |
\psplot[linecolor=blue]{-.97}{.97}{Derive(1,asin(x))} |
| 2724 |
\end{pspicture} |
| 2725 |
\egroup |
| 2726 |
\end{center} |
| 2727 |
|
| 2728 |
\begin{lstlisting} |
| 2729 |
\psset{unit=1.5} |
| 2730 |
\begin{pspicture}[showgrid=true](-1,-2)(1,2) |
| 2731 |
\psplot[linecolor=blue,algebraic]{-1}{1}{asin(x)} |
| 2732 |
\end{pspicture} |
| 2733 |
\hspace{1em} |
| 2734 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2735 |
\begin{pspicture}[showgrid=true](-1,-2)(1,2) |
| 2736 |
\psplot[linecolor=blue]{-.999}{.999}{asin(x)} |
| 2737 |
\end{pspicture} |
| 2738 |
\hspace{1em} |
| 2739 |
\begin{pspicture}[showgrid=true](-1,0)(1,4) |
| 2740 |
\psplot[linecolor=red]{-.97}{.97}{Derive(1,asin(x))} |
| 2741 |
\end{pspicture} |
| 2742 |
\hspace{1em} |
| 2743 |
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true} |
| 2744 |
\begin{pspicture}[showgrid=true](-1,0)(1,4) |
| 2745 |
\psplot[linecolor=red]{-.97}{.97}{Derive(1,asin(x))} |
| 2746 |
\end{pspicture} |
| 2747 |
\end{lstlisting} |
| 2748 |
|
| 2749 |
|
| 2750 |
\subsection{The inverse cosine and its derivative} |
| 2751 |
|
| 2752 |
\begin{center} |
| 2753 |
\bgroup |
| 2754 |
\psset{unit=1.5} |
| 2755 |
\begin{pspicture}[showgrid=true](-1,0)(1,3) |
| 2756 |
\psplot[linecolor=blue,algebraic]{-1}{1}{acos(x)} |
| 2757 |
\end{pspicture} |
| 2758 |
\hspace{1em} |
| 2759 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2760 |
\begin{pspicture}[showgrid=true](-1,0)(1,3) |
| 2761 |
\psplot[linecolor=blue]{-.999}{.999}{acos(x)} |
| 2762 |
\end{pspicture} |
| 2763 |
\hspace{1em} |
| 2764 |
\begin{pspicture}[showgrid=true](-1,-4)(1,-1) |
| 2765 |
\psplot[linecolor=blue]{-.97}{.97}{Derive(1,acos(x))} |
| 2766 |
\end{pspicture} |
| 2767 |
\hspace{1em} |
| 2768 |
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true} |
| 2769 |
\begin{pspicture}[showgrid=true](-1,-4)(1,-1) |
| 2770 |
\psplot[linecolor=blue]{-.97}{.97}{Derive(1,acos(x))} |
| 2771 |
\end{pspicture} |
| 2772 |
\egroup |
| 2773 |
\end{center} |
| 2774 |
|
| 2775 |
\begin{lstlisting} |
| 2776 |
\psset{unit=1.5} |
| 2777 |
\begin{pspicture}[showgrid=true](-1,0)(1,3) |
| 2778 |
\psplot[linecolor=blue,algebraic]{-1}{1}{acos(x)} |
| 2779 |
\end{pspicture} |
| 2780 |
\hspace{1em} |
| 2781 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2782 |
\begin{pspicture}[showgrid=true](-1,0)(1,3) |
| 2783 |
\psplot[linecolor=blue]{-.999}{.999}{acos(x)} |
| 2784 |
\end{pspicture} |
| 2785 |
\hspace{1em} |
| 2786 |
\begin{pspicture}[showgrid=true](-1,-4)(1,-1) |
| 2787 |
\psplot[linecolor=red]{-.97}{.97}{Derive(1,acos(x))} |
| 2788 |
\end{pspicture} |
| 2789 |
\hspace{1em} |
| 2790 |
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true} |
| 2791 |
\begin{pspicture}[showgrid=true](-1,-4)(1,-1) |
| 2792 |
\psplot[linecolor=red]{-.97}{.97}{Derive(1,acos(x))} |
| 2793 |
\end{pspicture} |
| 2794 |
\end{lstlisting} |
| 2795 |
|
| 2796 |
|
| 2797 |
|
| 2798 |
\subsection{The inverse tangent and its derivative} |
| 2799 |
|
| 2800 |
\begin{center} |
| 2801 |
\bgroup |
| 2802 |
\begin{pspicture}[showgrid=true](-4,-2)(4,2) |
| 2803 |
\psset{algebraic} |
| 2804 |
\psplot[linecolor=blue,linewidth=1pt]{-4}{4}{atg(x)} |
| 2805 |
\psplot[linecolor=red,VarStep, VarStepEpsilon=.0001, showpoints=true]{-4}{4}{Derive(1,atg(x))} |
| 2806 |
\end{pspicture} |
| 2807 |
\hspace{1em} |
| 2808 |
\begin{pspicture}[showgrid=true](-4,-2)(4,2) |
| 2809 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2810 |
\psplot[linecolor=blue]{-4}{4}{atg(x)} |
| 2811 |
\psplot[linecolor=red]{-4}{4}{Derive(1,atg(x))} |
| 2812 |
\end{pspicture} |
| 2813 |
\egroup |
| 2814 |
\end{center} |
| 2815 |
|
| 2816 |
|
| 2817 |
|
| 2818 |
|
| 2819 |
|
| 2820 |
|
| 2821 |
|
| 2822 |
\begin{lstlisting} |
| 2823 |
\begin{pspicture}[showgrid=true](-4,-2)(4,2) |
| 2824 |
\psset{algebraic} |
| 2825 |
\psplot[linecolor=blue,linewidth=1pt]{-4}{4}{atg(x)} |
| 2826 |
\psplot[linecolor=red,VarStep, VarStepEpsilon=.0001, showpoints=true]{-4}{4}{Derive(1,atg(x))} |
| 2827 |
\end{pspicture} |
| 2828 |
\hspace{1em} |
| 2829 |
\begin{pspicture}[showgrid=true](-4,-2)(4,2) |
| 2830 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2831 |
\psplot[linecolor=blue]{-4}{4}{atg(x)} |
| 2832 |
\psplot[linecolor=red]{-4}{4}{Derive(1,atg(x))} |
| 2833 |
\end{pspicture} |
| 2834 |
\end{lstlisting} |
| 2835 |
|
| 2836 |
\subsection{Hyperbolic functions} |
| 2837 |
|
| 2838 |
\begin{center} |
| 2839 |
\bgroup |
| 2840 |
\begin{pspicture}(-3,-4)(3,4) |
| 2841 |
\psset{algebraic} |
| 2842 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)} |
| 2843 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)} |
| 2844 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)} |
| 2845 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2846 |
\end{pspicture} |
| 2847 |
\hspace{1em} |
| 2848 |
\begin{pspicture}(-3,-4)(3,4) |
| 2849 |
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true} |
| 2850 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)} |
| 2851 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)} |
| 2852 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)} |
| 2853 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2854 |
\end{pspicture} |
| 2855 |
\egroup |
| 2856 |
\end{center} |
| 2857 |
|
| 2858 |
\begin{lstlisting} |
| 2859 |
\begin{pspicture}(-3,-4)(3,4) |
| 2860 |
\psset{algebraic} |
| 2861 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)} |
| 2862 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)} |
| 2863 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)} |
| 2864 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2865 |
\end{pspicture} |
| 2866 |
\hspace{1em} |
| 2867 |
\begin{pspicture}(-3,-4)(3,4) |
| 2868 |
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true} |
| 2869 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)} |
| 2870 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)} |
| 2871 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)} |
| 2872 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2873 |
\end{pspicture} |
| 2874 |
\end{lstlisting} |
| 2875 |
|
| 2876 |
|
| 2877 |
|
| 2878 |
\begin{center} |
| 2879 |
\bgroup |
| 2880 |
\begin{pspicture}(-3,-4)(3,4) |
| 2881 |
\psset{algebraic} |
| 2882 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))} |
| 2883 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))} |
| 2884 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))} |
| 2885 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2886 |
\end{pspicture} |
| 2887 |
\hspace{1em} |
| 2888 |
\begin{pspicture}(-3,-4)(3,4) |
| 2889 |
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true} |
| 2890 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))} |
| 2891 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))} |
| 2892 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))} |
| 2893 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2894 |
\end{pspicture} |
| 2895 |
\egroup |
| 2896 |
\end{center} |
| 2897 |
|
| 2898 |
\begin{lstlisting} |
| 2899 |
\begin{pspicture}(-3,-4)(3,4) |
| 2900 |
\psset{algebraic,linewidth=1pt} |
| 2901 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))} |
| 2902 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))} |
| 2903 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))} |
| 2904 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2905 |
\end{pspicture} |
| 2906 |
\hspace{1em} |
| 2907 |
\begin{pspicture}(-3,-4)(3,4) |
| 2908 |
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true} |
| 2909 |
\psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))} |
| 2910 |
\psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))} |
| 2911 |
\psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))} |
| 2912 |
\psaxes{->}(0,0)(-3,-4)(3,4) |
| 2913 |
\end{pspicture} |
| 2914 |
\end{lstlisting} |
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
\begin{center} |
| 2919 |
\bgroup |
| 2920 |
\begin{pspicture}(-7,-3)(7,3) |
| 2921 |
\psset{algebraic} |
| 2922 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)} |
| 2923 |
\psplot[linecolor=blue,linewidth=1pt]{1}{7}{Argch(x)} |
| 2924 |
\psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)} |
| 2925 |
\psaxes{->}(0,0)(-7,-3)(7,3) |
| 2926 |
\end{pspicture}\\[\baselineskip] |
| 2927 |
\begin{pspicture}(-7,-3)(7,3) |
| 2928 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2929 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)} |
| 2930 |
\psplot[linecolor=blue,linewidth=1pt]{1.001}{7}{Argch(x)} |
| 2931 |
\psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)} |
| 2932 |
\psaxes{->}(0,0)(-7,-3)(7,3) |
| 2933 |
\end{pspicture} |
| 2934 |
\egroup |
| 2935 |
\end{center} |
| 2936 |
|
| 2937 |
\begin{lstlisting} |
| 2938 |
\begin{pspicture}(-7,-3)(7,3) |
| 2939 |
\psset{algebraic} |
| 2940 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)} |
| 2941 |
\psplot[linecolor=blue,linewidth=1pt]{1}{7}{Argch(x)} |
| 2942 |
\psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)} |
| 2943 |
\psaxes{->}(0,0)(-7,-3)(7,3) |
| 2944 |
\end{pspicture}\\[\baselineskip] |
| 2945 |
\begin{pspicture}(-7,-3)(7,3) |
| 2946 |
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true} |
| 2947 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)} |
| 2948 |
\psplot[linecolor=blue,linewidth=1pt]{1.001}{7}{Argch(x)} |
| 2949 |
\psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)} |
| 2950 |
\psaxes{->}(0,0)(-7,-3)(7,3) |
| 2951 |
\end{pspicture} |
| 2952 |
\end{lstlisting} |
| 2953 |
|
| 2954 |
|
| 2955 |
|
| 2956 |
\begin{center} |
| 2957 |
\bgroup |
| 2958 |
\begin{pspicture}(-7,-0.5)(7,6) |
| 2959 |
\psset{algebraic} |
| 2960 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))} |
| 2961 |
\psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))} |
| 2962 |
\psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))} |
| 2963 |
\psaxes{->}(0,0)(-7,0)(7,6) |
| 2964 |
\end{pspicture}\\[\baselineskip] |
| 2965 |
\begin{pspicture}(-7,-0.5)(7,6) |
| 2966 |
\psset{algebraic} |
| 2967 |
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true} |
| 2968 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))} |
| 2969 |
\psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))} |
| 2970 |
\psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))} |
| 2971 |
\psaxes{->}(0,0)(-7,0)(7,6) |
| 2972 |
\end{pspicture} |
| 2973 |
\egroup |
| 2974 |
\end{center} |
| 2975 |
|
| 2976 |
\begin{lstlisting} |
| 2977 |
\begin{pspicture}(-7,-0.5)(7,6) |
| 2978 |
\psset{algebraic} |
| 2979 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))} |
| 2980 |
\psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))} |
| 2981 |
\psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))} |
| 2982 |
\psaxes{->}(0,0)(-7,0)(7,6) |
| 2983 |
\end{pspicture}\\[\baselineskip] |
| 2984 |
\begin{pspicture}(-7,-0.5)(7,6) |
| 2985 |
\psset{algebraic} |
| 2986 |
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true} |
| 2987 |
\psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))} |
| 2988 |
\psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))} |
| 2989 |
\psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))} |
| 2990 |
\psaxes{->}(0,0)(-7,0)(7,6) |
| 2991 |
\end{pspicture} |
| 2992 |
\end{lstlisting} |
| 2993 |
|
| 2994 |
|
| 2995 |
\clearpage |
| 2996 |
%-------------------------------------------------------------------------------------- |
| 2997 |
\section[\nxLcs{psplotDiffEqn} -- solving diffential equations]% |
| 2998 |
{\nxLcs{psplotDiffEqn} -- solving diffential equations} |
| 2999 |
%-------------------------------------------------------------------------------------- |
| 3000 |
|
| 3001 |
|
| 3002 |
A differential equation of first order is like |
| 3003 |
|
| 3004 |
\begin{align} y^\prime=f(x,y,y^\prime) \end{align} |
| 3005 |
|
| 3006 |
|
| 3007 |
where $y$ is a function of $x$. We define some vectors $Y=[y, y', |
| 3008 |
\cdots , y^{(n-1)}]$ and $Y^\prime=[y^\prime, y^{\prime\prime}, |
| 3009 |
\cdots , y^{n}]$, depending on the order $n$. The syntax of the |
| 3010 |
macro is |
| 3011 |
|
| 3012 |
\begin{BDef} |
| 3013 |
\Lcs{psplotDiffEqn}\OptArgs\Largb{x0}\Largb{x1}\Largb{y0}\Largb{f(x,y,y',...)} |
| 3014 |
\end{BDef} |
| 3015 |
|
| 3016 |
\begin{itemize}\setlength\itemsep{0pt}\setlength\parsep{0pt}\setlength\parskip{0pt} |
| 3017 |
\item \verb+options+: the \verb+\psplotDiffEqn+ specific options and all other of PSTricks, which |
| 3018 |
make sense; |
| 3019 |
\item $x_0$: the start value; |
| 3020 |
\item $x_1$: the end value of the definition interval; |
| 3021 |
\item $y_0$: the initial values for $y(x_0)\ y'(x_0)\ \ldots$; |
| 3022 |
\item $f(x,y,y',...)$: the differential equation, depending to the number of initial values, e.g.: |
| 3023 |
\verb+{0 1}+ for $y_0$ are two initial values, so that we have a differential equation of |
| 3024 |
second order $f(x,y,y')$ and the macro leaves $y\ y'$ on the stack. |
| 3025 |
\end{itemize} |
| 3026 |
|
| 3027 |
The new options are: |
| 3028 |
|
| 3029 |
|
| 3030 |
\begin{itemize}\setlength\itemsep{0pt}\setlength\parsep{0pt}\setlength\parskip{0pt} |
| 3031 |
\item \Lkeyword{method}: integration method (\verb+euler+ for order 1 euler method, \verb+rk4+ for |
| 3032 |
4\textsuperscript{th} order Runge-Kutta method); |
| 3033 |
\item \Lkeyword{whichabs}: select the abscissa for plotting the graph, by default it is |
| 3034 |
$x$, but you can specify a number which represent a position in the vector $y$; |
| 3035 |
\item \Lkeyword{whichord}: same as precedent for the ordinate, by default $y(0)$; |
| 3036 |
\item \Lkeyword{plotfuncx}: describe a ps function for the abscissa, parameter |
| 3037 |
\Lkeyword{whichabs} becomes useless; |
| 3038 |
\item \Lkeyword{plotfuncy}: idem for the ordinate; |
| 3039 |
\item \Lkeyword{buildvector}: boolean parameter for specifying the input-output of the |
| 3040 |
$f$ description: |
| 3041 |
\begin{description} |
| 3042 |
\item[\texttt{true}] (default): $y$ is put on the stack element by element, $y'$ |
| 3043 |
must be given in the same way; |
| 3044 |
\item[\texttt{false}]: $y$ is put on the stack as a vector, $y'$ must be returned |
| 3045 |
in the same way; |
| 3046 |
\end{description} |
| 3047 |
|
| 3048 |
\item \Lkeyword{algebraic}: algebraic description for $f$, \Lkeyword{buildvector} |
| 3049 |
parameter is useless when activating this option. |
| 3050 |
\end{itemize} |
| 3051 |
|
| 3052 |
|
| 3053 |
|
| 3054 |
\clearpage |
| 3055 |
\subsection{Variable step for differential equations} |
| 3056 |
|
| 3057 |
A new algorithm has been added for adjusting the step according to the variations of |
| 3058 |
the curve. The parameter \Lkeyword{method} has a new possible value : \Lkeyword{varrkiv} to |
| 3059 |
activate the \Index{Runge-Kutta} method with variable step, then the parameter |
| 3060 |
\Lkeyword{varsteptol} (real value; \verb+.01+ by default) can control the tolerance of |
| 3061 |
the algortihm. |
| 3062 |
|
| 3063 |
\begin{center} |
| 3064 |
\bgroup |
| 3065 |
\def\Funct{neg}\def\FunctAlg{-y[0]} |
| 3066 |
\psset{xunit=1.5, yunit=8, showpoints=true} |
| 3067 |
\begin{pspicture}[showgrid=true](0,0)(10,1.2) |
| 3068 |
\psplot[linewidth=6\pslinewidth, linecolor=green, showpoints=false]{0}{10}{Euler x neg exp} |
| 3069 |
\psplotDiffEqn[linecolor=magenta, method=varrkiv, varsteptol=.1, plotpoints=2]{0}{10}{1}{\Funct} |
| 3070 |
\rput(0,.0){\psplotDiffEqn[linecolor=blue, method=varrkiv, varsteptol=.01, plotpoints=2]{0}{10}{1}{\Funct}} |
| 3071 |
\rput(0,.1){\psplotDiffEqn[linecolor=Orange, method=varrkiv, varsteptol=.001, plotpoints=2]{0}{10}{1}{\Funct}} |
| 3072 |
\rput(0,.2){\psplotDiffEqn[linecolor=red, method=varrkiv, varsteptol=.0001, plotpoints=2]{0}{10}{1}{\Funct}} |
| 3073 |
\psset{linewidth=4\pslinewidth,showpoints=false} |
| 3074 |
\rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)} |
| 3075 |
\rput*[l](3.3,.9){\small RK ordre 4 : $\varepsilon<10^{-1}$} |
| 3076 |
\rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)} |
| 3077 |
\rput*[l](3.3,.8){\small RK ordre 4 : $\varepsilon<10^{-2}$} |
| 3078 |
\rput*(3.3,.7){\psline[linecolor=Orange](-.75cm,0)} |
| 3079 |
\rput*[l](3.3,.7){\small RK ordre 4 : $\varepsilon<10^{-3}$} |
| 3080 |
\rput*(3.3,.6){\psline[linecolor=red](-.75cm,0)} |
| 3081 |
\rput*[l](3.3,.6){\small RK ordre 4 : $\varepsilon<10^{-4}$} |
| 3082 |
\rput*(3.3,.5){\psline[linecolor=green](-.75cm,0)} |
| 3083 |
\rput*[l](3.3,.5){\small solution exacte} |
| 3084 |
\end{pspicture} |
| 3085 |
{\captionof{figure}{Equation $y'=-y$ with $y_0=1$.}\label{fig:minusexpvarstep}} |
| 3086 |
\egroup |
| 3087 |
\end{center} |
| 3088 |
|
| 3089 |
|
| 3090 |
\begin{lstlisting}[wide=true] |
| 3091 |
\def\Funct{neg}\def\FunctAlg{-y[0]} |
| 3092 |
\psset{xunit=1.5, yunit=8, showpoints=true} |
| 3093 |
\begin{pspicture}[showgrid=true](0,0)(10,1.2) |
| 3094 |
\psplot[linewidth=6\pslinewidth, linecolor=green, showpoints=false]{0}{10}{Euler x neg exp} |
| 3095 |
\psplotDiffEqn[linecolor=magenta, method=varrkiv, varsteptol=.1, plotpoints=2]{0}{10}{1}{\Funct} |
| 3096 |
\rput(0,.0){\psplotDiffEqn[linecolor=blue, method=varrkiv, varsteptol=.01, plotpoints=2]{0}{10}{1}{\Funct}} |
| 3097 |
\rput(0,.1){\psplotDiffEqn[linecolor=Orange, method=varrkiv, varsteptol=.001, plotpoints=2]{0}{10}{1}{\Funct}} |
| 3098 |
\rput(0,.2){\psplotDiffEqn[linecolor=red, method=varrkiv, varsteptol=.0001, plotpoints=2]{0}{10}{1}{\Funct}} |
| 3099 |
\psset{linewidth=4\pslinewidth,showpoints=false} |
| 3100 |
\rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)} |
| 3101 |
\rput*[l](3.3,.9){\small RK ordre 4 : $\varepsilon<10^{-1}$} |
| 3102 |
\rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)} |
| 3103 |
\rput*[l](3.3,.8){\small RK ordre 4 : $\varepsilon<10^{-2}$} |
| 3104 |
\rput*(3.3,.7){\psline[linecolor=Orange](-.75cm,0)} |
| 3105 |
\rput*[l](3.3,.7){\small RK ordre 4 : $\varepsilon<10^{-3}$} |
| 3106 |
\rput*(3.3,.6){\psline[linecolor=red](-.75cm,0)} |
| 3107 |
\rput*[l](3.3,.6){\small RK ordre 4 : $\varepsilon<10^{-4}$} |
| 3108 |
\rput*(3.3,.5){\psline[linecolor=green](-.75cm,0)} |
| 3109 |
\rput*[l](3.3,.5){\small solution exacte} |
| 3110 |
\end{pspicture} |
| 3111 |
\end{lstlisting} |
| 3112 |
|
| 3113 |
|
| 3114 |
|
| 3115 |
\begin{center} |
| 3116 |
\bgroup |
| 3117 |
\def\Funct{exch neg} |
| 3118 |
\psset{xunit=1.5, yunit=5, method=varrkiv, showpoints=true}%% |
| 3119 |
\def\quatrepi{12.5663706144} |
| 3120 |
\begin{pspicture}(0,-1)(10,1.3) |
| 3121 |
\psaxes{->}(0,0)(0,-1)(10,1.3) |
| 3122 |
\psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{10}{cos(x)} |
| 3123 |
\rput(0,.0){\psplotDiffEqn[linecolor=magenta, plotpoints=7, varsteptol=.1]{0}{10}{1 0}{\Funct}} |
| 3124 |
\rput(0,.0){\psplotDiffEqn[linecolor=blue, plotpoints=201, varsteptol=.01]{0}{10}{1 0}{\Funct}} |
| 3125 |
\rput(0,.1){\psplotDiffEqn[linewidth=2\pslinewidth, linecolor=red, varsteptol=.001]{0}{10}{1 0}{\Funct}} |
| 3126 |
\rput(0,.2){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{10}{1 0}{\Funct}} |
| 3127 |
\rput(0,.3){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{10}{1 0}{\Funct}} |
| 3128 |
\psset{linewidth=4\pslinewidth,showpoints=false} |
| 3129 |
\rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)} |
| 3130 |
\rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$} |
| 3131 |
\rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)} |
| 3132 |
\rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$} |
| 3133 |
\rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)} |
| 3134 |
\rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$} |
| 3135 |
\rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)} |
| 3136 |
\rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$} |
| 3137 |
\rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)} |
| 3138 |
\rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$} |
| 3139 |
\rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)} |
| 3140 |
\rput*[l](2.3,.4){\small solution exacte} |
| 3141 |
\end{pspicture} |
| 3142 |
{\captionof{figure}{Equation $y''=-y$}\label{fig:trigfunc}} |
| 3143 |
\egroup |
| 3144 |
\end{center} |
| 3145 |
|
| 3146 |
\begin{lstlisting}[wide=true] |
| 3147 |
\def\Funct{exch neg} |
| 3148 |
\psset{xunit=1.5, yunit=5, method=varrkiv, showpoints=true}%% |
| 3149 |
\def\quatrepi{12.5663706144} |
| 3150 |
\begin{pspicture}(0,-1)(10,1.3) |
| 3151 |
\psaxes{->}(0,0)(0,-1)(10,1.3) |
| 3152 |
\psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{10}{cos(x)} |
| 3153 |
\rput(0,.0){\psplotDiffEqn[linecolor=magenta, plotpoints=7, varsteptol=.1]{0}{10}{1 0}{\Funct}} |
| 3154 |
\rput(0,.0){\psplotDiffEqn[linecolor=blue, plotpoints=201, varsteptol=.01]{0}{10}{1 0}{\Funct}} |
| 3155 |
\rput(0,.1){\psplotDiffEqn[linewidth=2\pslinewidth, linecolor=red, varsteptol=.001]{0}{10}{1 0}{\Funct}} |
| 3156 |
\rput(0,.2){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{10}{1 0}{\Funct}} |
| 3157 |
\rput(0,.3){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{10}{1 0}{\Funct}} |
| 3158 |
\psset{linewidth=4\pslinewidth,showpoints=false} |
| 3159 |
\rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)} |
| 3160 |
\rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$} |
| 3161 |
\rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)} |
| 3162 |
\rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$} |
| 3163 |
\rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)} |
| 3164 |
\rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$} |
| 3165 |
\rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)} |
| 3166 |
\rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$} |
| 3167 |
\rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)} |
| 3168 |
\rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$} |
| 3169 |
\rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)} |
| 3170 |
\rput*[l](2.3,.4){\small solution exacte} |
| 3171 |
\end{pspicture} |
| 3172 |
\end{lstlisting} |
| 3173 |
|
| 3174 |
|
| 3175 |
|
| 3176 |
|
| 3177 |
\begin{center} |
| 3178 |
\bgroup |
| 3179 |
\def\Funct{exch} |
| 3180 |
\psset{xunit=4, yunit=1, method=varrkiv, showpoints=true}%% |
| 3181 |
\def\quatrepi{12.5663706144} |
| 3182 |
\begin{pspicture}(0,-0.5)(3,11) |
| 3183 |
\psaxes{->}(0,0)(3,11) |
| 3184 |
\psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{3}{ch(x)} |
| 3185 |
\rput(0,.0){\psplotDiffEqn[linecolor=magenta, varsteptol=.1]{0}{3}{1 0}{\Funct}} |
| 3186 |
\rput(0,.3){\psplotDiffEqn[linecolor=blue, varsteptol=.01]{0}{3}{1 0}{\Funct}} |
| 3187 |
\rput(0,.6){\psplotDiffEqn[linecolor=red, varsteptol=.001]{0}{3}{1 0}{\Funct}} |
| 3188 |
\rput(0,.9){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{3}{1 0}{\Funct}} |
| 3189 |
\rput(0,1.2){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{3}{1 0}{\Funct}} |
| 3190 |
\psset{linewidth=4\pslinewidth,showpoints=false} |
| 3191 |
\rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)} |
| 3192 |
\rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$} |
| 3193 |
\rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)} |
| 3194 |
\rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$} |
| 3195 |
\rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)} |
| 3196 |
\rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$} |
| 3197 |
\rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)} |
| 3198 |
\rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$} |
| 3199 |
\rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)} |
| 3200 |
\rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$} |
| 3201 |
\rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)} |
| 3202 |
\rput*[l](2.3,.4){\small solution exacte} |
| 3203 |
\end{pspicture} |
| 3204 |
\captionof{figure}{Equation $y''=y$} |
| 3205 |
\egroup |
| 3206 |
\end{center} |
| 3207 |
|
| 3208 |
\begin{lstlisting}[wide=true] |
| 3209 |
\def\Funct{exch} |
| 3210 |
\psset{xunit=4, yunit=1, method=varrkiv, showpoints=true}%% |
| 3211 |
\def\quatrepi{12.5663706144} |
| 3212 |
\begin{pspicture}(0,-0.5)(3,11) |
| 3213 |
\psaxes{->}(0,0)(3,11) |
| 3214 |
\psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{3}{ch(x)} |
| 3215 |
\rput(0,.0){\psplotDiffEqn[linecolor=magenta, varsteptol=.1]{0}{3}{1 0}{\Funct}} |
| 3216 |
\rput(0,.3){\psplotDiffEqn[linecolor=blue, varsteptol=.01]{0}{3}{1 0}{\Funct}} |
| 3217 |
\rput(0,.6){\psplotDiffEqn[linecolor=red, varsteptol=.001]{0}{3}{1 0}{\Funct}} |
| 3218 |
\rput(0,.9){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{3}{1 0}{\Funct}} |
| 3219 |
\rput(0,1.2){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{3}{1 0}{\Funct}} |
| 3220 |
\psset{linewidth=4\pslinewidth,showpoints=false} |
| 3221 |
\rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)} |
| 3222 |
\rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$} |
| 3223 |
\rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)} |
| 3224 |
\rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$} |
| 3225 |
\rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)} |
| 3226 |
\rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$} |
| 3227 |
\rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)} |
| 3228 |
\rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$} |
| 3229 |
\rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)} |
| 3230 |
\rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$} |
| 3231 |
\rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)} |
| 3232 |
\rput*[l](2.3,.4){\small solution exacte} |
| 3233 |
\end{pspicture} |
| 3234 |
\end{lstlisting} |
| 3235 |
|
| 3236 |
|
| 3237 |
|
| 3238 |
|
| 3239 |
\clearpage |
| 3240 |
\subsection{Equation of second order} |
| 3241 |
|
| 3242 |
Here is the traditional simulation of two stars attracting each |
| 3243 |
other according to the classical gravitation law in |
| 3244 |
$\displaystyle\frac{1}{r^2}$. In 2-Dimensions, the system to be |
| 3245 |
solved is composed of four second order differential equations. In |
| 3246 |
order to be described, each of them gives two first order |
| 3247 |
equations, then we obtain a 8 sized vectorial equation. In the |
| 3248 |
following example the masses of the stars are 1 and 20. |
| 3249 |
|
| 3250 |
\[ |
| 3251 |
\left\{ |
| 3252 |
\begin{array}[m]{l} |
| 3253 |
x''_1=\displaystyle\frac{M_2}{r^2}\cos(\theta)\\ |
| 3254 |
y''_1=\displaystyle\frac{M_2}{r^2}\sin(\theta)\\ |
| 3255 |
x''_2=\displaystyle\frac{M_1}{r^2}\cos(\theta)\\ |
| 3256 |
y''_2=\displaystyle\frac{M_1}{r^2}\sin(\theta)\\ |
| 3257 |
\end{array} |
| 3258 |
\right. |
| 3259 |
\mbox{ avec } |
| 3260 |
\left\{ |
| 3261 |
\begin{array}[m]{l} |
| 3262 |
r^2=(x_1-x_2)^2+(y_1-y_2)^2\\ |
| 3263 |
\cos(\theta)=\displaystyle\frac{(x_1-x_2)}{r}\\ |
| 3264 |
\sin(\theta)=\displaystyle\frac{(y_1-y_2)}{r}\\ |
| 3265 |
\end{array} |
| 3266 |
\right. |
| 3267 |
\mbox{% |
| 3268 |
\begin{pspicture}[shift=-2](5,4)\psset{arrowscale=2} |
| 3269 |
\psframe[linewidth=.75\pslinewidth](5,4) |
| 3270 |
\pstGeonode[PosAngle={-90,90}](1,1){M_1}(4,3){M_2} |
| 3271 |
\pstHomO[HomCoef=.33, PointSymbol=none]{M_1}{M_2}[F_1] |
| 3272 |
\psline[arrows=->](M_1)(F_1) |
| 3273 |
\pstHomO[HomCoef=.33, PointSymbol=none]{M_2}{M_1}[F_2] |
| 3274 |
\psline[arrows=->, arrowscale=2](M_2)(F_2) |
| 3275 |
\pstGeonode[PointSymbol=none, PointName=none](M_2|M_1){A} |
| 3276 |
\psline[linewidth=.5\pslinewidth](M_1)(A) |
| 3277 |
\pstMarkAngle{A}{M_1}{M_2}{$\theta$} |
| 3278 |
\ncline[linewidth=.5\pslinewidth, offset=.5, arrows=<->]{M_1}{M_2} |
| 3279 |
\ncput*{$r$} |
| 3280 |
\end{pspicture}} |
| 3281 |
\] |
| 3282 |
|
| 3283 |
\begin{table}[!htbp] |
| 3284 |
\centering\small |
| 3285 |
\begin{tabular}{|l@{}>{\ttfamily}l@{}>{ \ttfamily \%\% }l|} |
| 3286 |
\hline |
| 3287 |
&& x1 y1 x'1 y'1 x2 y2 x'2 y'2\\ |
| 3288 |
&/yp2 exch def /xp2 exch def /ay2 exch def /ax2 exch def&mise en variables\\ |
| 3289 |
&/yp1 exch def /xp1 exch def /ay1 exch def /ax1 exch def&mise en variables\\ |
| 3290 |
&/ro2 ax2 ax1 sub dup mul ay2 ay1 sub dup mul add def&calcul de r*r\\ |
| 3291 |
&xp1 yp1&\\ |
| 3292 |
&ax2 ax1 sub ro2 sqrt div ro2 div&calcul de x''1\\ |
| 3293 |
&ay2 ay1 sub ro2 sqrt div ro2 div&calcul de y''1\\ |
| 3294 |
&xp2 yp2&\\ |
| 3295 |
&3 index -20 mul&calcul de x''2=-20x''1\\ |
| 3296 |
&3 index -20 mul&calcul de y''2=-20y''1\\ |
| 3297 |
\hline |
| 3298 |
\end{tabular} |
| 3299 |
\caption{\PS source code for the gravitational interaction}\label{intgravcode} |
| 3300 |
\end{table} |
| 3301 |
|
| 3302 |
\begin{table}[!htbp] |
| 3303 |
\centering |
| 3304 |
\small\newcommand{\POW}{\symbol{'136}} |
| 3305 |
\begin{tabular}{|l@{}>{\ttfamily}l@{}>{ \ttfamily \%\% }l|} |
| 3306 |
\hline |
| 3307 |
&y[2]|&y'[0]\\ |
| 3308 |
&y[3]|&y'[1]\\ |
| 3309 |
&(y[4]-y[0])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5|&y'[2]=y''[0]\\ |
| 3310 |
&(y[5]-y[1])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5|&y'[3]=y''[1]\\ |
| 3311 |
&y[6]|&y'[4]\\ |
| 3312 |
&y[7]|&y'[5]\\ |
| 3313 |
&20*(y[0]-y[4])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5|&y'[6]=y''[4]\\ |
| 3314 |
&20*(y[1]-y[5])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5&y'[7]=y''[5]\\ |
| 3315 |
\hline |
| 3316 |
\end{tabular} |
| 3317 |
\caption{Algebraic description for the gravitational interaction}\label{intgravalgcode} |
| 3318 |
\end{table} |
| 3319 |
|
| 3320 |
\newcommand\Grav{% |
| 3321 |
/yp2 exch def /xp2 exch def /ay2 exch def /ax2 exch def |
| 3322 |
/yp1 exch def /xp1 exch def /ay1 exch def /ax1 exch def |
| 3323 |
/ro2 ax2 ax1 sub dup mul ay2 ay1 sub dup mul add def |
| 3324 |
xp1 yp1 |
| 3325 |
ax2 ax1 sub ro2 sqrt div ro2 div |
| 3326 |
ay2 ay1 sub ro2 sqrt div ro2 div |
| 3327 |
xp2 yp2 |
| 3328 |
3 index -20 mul |
| 3329 |
3 index -20 mul} |
| 3330 |
\newcommand\GravAlg{% |
| 3331 |
y[2]|y[3]|% |
| 3332 |
(y[4]-y[0])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5|% |
| 3333 |
(y[5]-y[1])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5|% |
| 3334 |
y[6]|y[7]|% |
| 3335 |
20*(y[0]-y[4])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5|% |
| 3336 |
20*(y[1]-y[5])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5} |
| 3337 |
%% 0 1 2 3 4 5 6 7 |
| 3338 |
%% x1 y1 x'1 y'1 x2 y2 x'2 y'2 |
| 3339 |
|
| 3340 |
|
| 3341 |
\begin{LTXexample}[width=5cm,wide] |
| 3342 |
\def\InitCond{ 1 1 .1 0 -1 -1 -2 0} |
| 3343 |
\begin{pspicture}[shift=-2,showgrid=true](-3,-1.75)(2,1.5) |
| 3344 |
\psplotDiffEqn[whichabs=0, whichord=1, linecolor=blue, method=rk4, plotpoints=100]{0}{3.95}{\InitCond}{\Grav} |
| 3345 |
\psset{showpoints=true,whichabs=4, whichord=5} |
| 3346 |
\psplotDiffEqn[linecolor=black, method=varrkiv, varsteptol=.0001, plotpoints=200]{0}{3.9}{\InitCond}{\Grav} |
| 3347 |
\end{pspicture} |
| 3348 |
\end{LTXexample} |
| 3349 |
\vspace{-2ex} |
| 3350 |
{\captionof{figure}{Gravitational interaction: fixed landmark, trajectory of the stars}\label{fig:InterGravRepFix}} |
| 3351 |
|
| 3352 |
|
| 3353 |
|
| 3354 |
\bigskip |
| 3355 |
\begin{LTXexample}[width=5cm,wide] |
| 3356 |
\def\InitCond{ 1 1 .1 0 -1 -1 -2 0} |
| 3357 |
\begin{pspicture}[shift=-1.5,showgrid=true](-4,-1.75)(1,1) |
| 3358 |
\psplotDiffEqn[linecolor=red, plotpoints=200,method=varrkiv, varsteptol=.0001, showpoints=true, |
| 3359 |
plotfuncx=y dup 4 get exch 0 get sub, |
| 3360 |
plotfuncy=dup 5 get exch 1 get sub ]{0}{3.9}{\InitCond}{\Grav} |
| 3361 |
\end{pspicture} |
| 3362 |
\end{LTXexample} |
| 3363 |
\vspace{-2ex} |
| 3364 |
{\captionof{figure}{Gravitational interaction : landmark defined by one star}\label{fig:IGnewrep}} |
| 3365 |
|
| 3366 |
|
| 3367 |
\begin{center} |
| 3368 |
\bgroup |
| 3369 |
\def\InitCond{ 1 1 .1 0 -1 -1 -2 0} |
| 3370 |
\psset{xunit=2} |
| 3371 |
\begin{pspicture}[showgrid=true](0,0)(8,9) |
| 3372 |
\psset{showpoints=true} |
| 3373 |
\psplotDiffEqn[linecolor=red, method=varrkiv, plotpoints=2, varsteptol=.0001, |
| 3374 |
plotfuncy=dup 6 get dup mul exch 7 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav} |
| 3375 |
\psplotDiffEqn[linecolor=blue, method=varrkiv, plotpoints=2, varsteptol=.0001, |
| 3376 |
plotfuncy=dup 2 get dup mul exch 3 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav} |
| 3377 |
\end{pspicture} |
| 3378 |
\captionof{figure}{Gravitational interaction : speeds of the |
| 3379 |
stars} \egroup |
| 3380 |
\end{center} |
| 3381 |
|
| 3382 |
\begin{lstlisting} |
| 3383 |
\psset{xunit=2} |
| 3384 |
\begin{pspicture}[showgrid=true](0,0)(8,9) |
| 3385 |
\psset{showpoints=true} |
| 3386 |
\psplotDiffEqn[linecolor=red, method=varrkiv, plotpoints=2, varsteptol=.0001, |
| 3387 |
plotfuncy=dup 6 get dup mul exch 7 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav} |
| 3388 |
\psplotDiffEqn[linecolor=blue, method=varrkiv, plotpoints=2, varsteptol=.0001, |
| 3389 |
plotfuncy=dup 2 get dup mul exch 3 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav} |
| 3390 |
\end{pspicture} |
| 3391 |
\end{lstlisting} |
| 3392 |
|
| 3393 |
%-------------------------------------------------------------------------------------- |
| 3394 |
\clearpage |
| 3395 |
\subsubsection{Simple equation of first order $y'=y$} |
| 3396 |
%-------------------------------------------------------------------------------------- |
| 3397 |
|
| 3398 |
For the initial value $y(0)=1$ we have the solution $y(x)=e^x$. $y$ is always |
| 3399 |
on the stack, so we have to do nothing. Using the \Lkeyword{algebraic} option, we write it |
| 3400 |
as \verb$y[0]$. The following example shows different solutions depending to the number of plotpoints |
| 3401 |
with $y_0=1$: |
| 3402 |
|
| 3403 |
|
| 3404 |
\begin{center} |
| 3405 |
\bgroup |
| 3406 |
\psset{xunit=4, yunit=.4} |
| 3407 |
\begin{pspicture}(3,19)\psgrid[subgriddiv=1] |
| 3408 |
\psplot[linewidth=6\pslinewidth, linecolor=green]{0}{3}{Euler x exp} |
| 3409 |
\psplotDiffEqn[linecolor=magenta,plotpoints=16,algebraic]{0}{3}{1}{y[0]} |
| 3410 |
\psplotDiffEqn[linecolor=blue,plotpoints=151]{0}{3}{1}{} |
| 3411 |
\psplotDiffEqn[linecolor=red,method=rk4,plotpoints=15]{0}{3}{1}{} |
| 3412 |
\psplotDiffEqn[linecolor=Orange,method=rk4,plotpoints=4]{0}{3}{1}{} |
| 3413 |
\psset{linewidth=4\pslinewidth} |
| 3414 |
\rput*(0.35,19){\psline[linecolor=magenta](-.75cm,0)} |
| 3415 |
\rput*[l](0.35,19){\small Euler order 1 $h=0{,}2$} |
| 3416 |
\rput*(0.35,17){\psline[linecolor=blue](-.75cm,0)} |
| 3417 |
\rput*[l](0.35,17){\small Euler order 1 $h=0{,}02$} |
| 3418 |
\rput*(0.35,15){\psline[linecolor=Orange](-.75cm,0)} |
| 3419 |
\rput*[l](0.35,15){\small RK ordre 4 $h=1$} |
| 3420 |
\rput*(0.35,13){\psline[linecolor=red](-.75cm,0)} |
| 3421 |
\rput*[l](0.35,13){\small RK ordre 4 $h=0{,}2$} |
| 3422 |
\rput*(0.35,11){\psline[linecolor=green](-.75cm,0)} |
| 3423 |
\rput*[l](0.35,11){\small solution exacte} |
| 3424 |
\end{pspicture} |
| 3425 |
\egroup |
| 3426 |
\end{center} |
| 3427 |
|
| 3428 |
\begin{lstlisting} |
| 3429 |
\psset{xunit=4, yunit=.4} |
| 3430 |
\begin{pspicture}(3,19)\psgrid[subgriddiv=1] |
| 3431 |
\psplot[linewidth=6\pslinewidth, linecolor=green]{0}{3}{Euler x exp} |
| 3432 |
\psplotDiffEqn[linecolor=magenta,plotpoints=16,algebraic]{0}{3}{1}{y[0]} |
| 3433 |
\psplotDiffEqn[linecolor=blue,plotpoints=151]{0}{3}{1}{} |
| 3434 |
\psplotDiffEqn[linecolor=red,method=rk4,plotpoints=15]{0}{3}{1}{} |
| 3435 |
\psplotDiffEqn[linecolor=Orange,method=rk4,plotpoints=4]{0}{3}{1}{} |
| 3436 |
\psset{linewidth=4\pslinewidth} |
| 3437 |
\rput*(0.35,19){\psline[linecolor=magenta](-.75cm,0)} |
| 3438 |
\rput*[l](0.35,19){\small Euler order 1 $h=0{,}2$} |
| 3439 |
\rput*(0.35,17){\psline[linecolor=blue](-.75cm,0)} |
| 3440 |
\rput*[l](0.35,17){\small Euler order 1 $h=0{,}02$} |
| 3441 |
\rput*(0.35,15){\psline[linecolor=Orange](-.75cm,0)} |
| 3442 |
\rput*[l](0.35,15){\small RK ordre 4 $h=1$} |
| 3443 |
\rput*(0.35,13){\psline[linecolor=red](-.75cm,0)} |
| 3444 |
\rput*[l](0.35,13){\small RK ordre 4 $h=0{,}2$} |
| 3445 |
\rput*(0.35,11){\psline[linecolor=green](-.75cm,0)} |
| 3446 |
\rput*[l](0.35,11){\small solution exacte} |
| 3447 |
\end{pspicture} |
| 3448 |
\end{lstlisting} |
| 3449 |
|
| 3450 |
%-------------------------------------------------------------------------------------- |
| 3451 |
\clearpage |
| 3452 |
\subsubsection{$y'=\displaystyle\frac{2-ty}{4-t^2}$}% $ |
| 3453 |
%-------------------------------------------------------------------------------------- |
| 3454 |
|
| 3455 |
For the initial value $y(0)=1$ the exact solution is |
| 3456 |
$y(x)=\displaystyle\frac{t+\sqrt{4-t^2}}{2}$. The function $f$ |
| 3457 |
described in PostScript code is like (y is still on the stack): |
| 3458 |
\begin{lstlisting}[style=syntax] |
| 3459 |
x %% y x |
| 3460 |
mul %% x*y |
| 3461 |
2 exch sub %% 2-x*y |
| 3462 |
4 x dup mul %% 2-x*y 4 x^2 |
| 3463 |
sub %% 2-x*y 4-x^2 |
| 3464 |
div %% (2-x*y)/(4-x^2) |
| 3465 |
\end{lstlisting} |
| 3466 |
\noindent |
| 3467 |
The following example uses $y_0=1$. |
| 3468 |
|
| 3469 |
\begin{lstlisting}[style=syntax] |
| 3470 |
\newcommand{\InitCond}{1} |
| 3471 |
\newcommand{\Func}{x mul 2 exch sub 4 x dup mul sub div} |
| 3472 |
\newcommand{\FuncAlg}{(2-x*y[0])/(4-x^2)} |
| 3473 |
\end{lstlisting} |
| 3474 |
|
| 3475 |
\begin{center} |
| 3476 |
\bgroup |
| 3477 |
\psset{xunit=6.4, yunit=9.6, showpoints=false} |
| 3478 |
\begin{pspicture}(0,1)(2,1.5) \psgrid[griddots=10](0,1)(2,1.5) |
| 3479 |
{ \psset{linewidth=4\pslinewidth,linecolor=lightgray} |
| 3480 |
\psplot{0}{1.8}{x dup dup mul 4 exch sub sqrt add 2 div} |
| 3481 |
\psplot{1.8}{2}{x dup dup mul 4 exch sub sqrt add 2 div} } |
| 3482 |
\def\InitCond{1} |
| 3483 |
\def\Func{x mul 2 exch sub 4 x dup mul sub div} |
| 3484 |
\psplotDiffEqn[linecolor=magenta, plotpoints=20]{0}{1.9}{\InitCond}{\Func} |
| 3485 |
\psplotDiffEqn[linecolor=blue, plotpoints=191]{0}{1.9}{\InitCond}{\Func} |
| 3486 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11,% |
| 3487 |
algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)} |
| 3488 |
\psplotDiffEqn[linecolor=Orange, method=rk4, plotpoints=21,% |
| 3489 |
algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)} |
| 3490 |
\psset{linewidth=4\pslinewidth}\small |
| 3491 |
\rput*(0,1.4){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](0,1.4){Euler order 1 $h=0{,}1$} |
| 3492 |
\rput*(0,1.35){\psline[linecolor=blue](-.75cm,0)}\rput*[l](0,1.35){Euler order 1 $h=0{,}01$} |
| 3493 |
\rput*(0,1.3){\psline[linecolor=Orange](-.75cm,0)}\rput*[l](0,1.3){RK order 4 $h=0{,}19$} |
| 3494 |
\rput*(0,1.25){\psline[linecolor=red](-.75cm,0)}\rput*[l](0,1.25){RK order 4 $h=0{,}095$} |
| 3495 |
\rput*(0,1.2){\psline[linecolor=lightgray](-.75cm,0)}\rput*[l](0,1.2){exactly} |
| 3496 |
\end{pspicture} |
| 3497 |
\egroup |
| 3498 |
\end{center} |
| 3499 |
|
| 3500 |
\begin{lstlisting}[xrightmargin=-1cm,xleftmargin=-1cm] |
| 3501 |
\psset{xunit=6.4, yunit=9.6, showpoints=false} |
| 3502 |
\begin{pspicture}(0,1)(2,1.7) \psgrid[subgriddiv=5] |
| 3503 |
{ \psset{linewidth=4\pslinewidth,linecolor=lightgray} |
| 3504 |
\psplot{0}{1.8}{x dup dup mul 4 exch sub sqrt add 2 div} |
| 3505 |
\psplot{1.8}{2}{x dup dup mul 4 exch sub sqrt add 2 div} } |
| 3506 |
\def\InitCond{1} |
| 3507 |
\def\Func{x mul 2 exch sub 4 x dup mul sub div} |
| 3508 |
\psplotDiffEqn[linecolor=magenta, plotpoints=20]{0}{1.9}{\InitCond}{\Func} |
| 3509 |
\psplotDiffEqn[linecolor=blue, plotpoints=191]{0}{1.9}{\InitCond}{\Func} |
| 3510 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11,% |
| 3511 |
algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)} |
| 3512 |
\psplotDiffEqn[linecolor=Orange, method=rk4, plotpoints=21,% |
| 3513 |
algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)} |
| 3514 |
\psset{linewidth=4\pslinewidth} |
| 3515 |
\rput*(0.3,1.6){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](0.3,1.6){\small Euler order 1 $h=0{,}1$} |
| 3516 |
\rput*(0.3,1.55){\psline[linecolor=blue](-.75cm,0)}\rput*[l](0.3,1.55){\small Euler order 1 $h=0{,}01$} |
| 3517 |
\rput*(0.3,1.5){\psline[linecolor=Orange](-.75cm,0)}\rput*[l](0.3,1.5){\small RK order 4 $h=0{,}19$} |
| 3518 |
\rput*(0.3,1.45){\psline[linecolor=red](-.75cm,0)}\rput*[l](0.3,1.45){\small RK order 4 $h=0{,}095$} |
| 3519 |
\rput*(0.3,1.4){\psline[linecolor=lightgray](-.75cm,0)}\rput*[l](0.3,1.4){\small exactly} |
| 3520 |
\end{pspicture} |
| 3521 |
\end{lstlisting} |
| 3522 |
|
| 3523 |
|
| 3524 |
%-------------------------------------------------------------------------------------- |
| 3525 |
\clearpage |
| 3526 |
\subsubsection{$y'=-2xy$} |
| 3527 |
%-------------------------------------------------------------------------------------- |
| 3528 |
|
| 3529 |
For $y(-1)=\frac{1}{e}$ we get $y(x)=e^{-x^2}$. |
| 3530 |
|
| 3531 |
\begin{center} |
| 3532 |
\bgroup |
| 3533 |
\psset{unit=4} |
| 3534 |
\begin{pspicture}(-1,0)(3,1.1)\psgrid |
| 3535 |
\psplot[linewidth=4\pslinewidth,linecolor=gray]{-1}{3}{Euler x dup mul neg exp} |
| 3536 |
\psset{plotpoints=9} |
| 3537 |
\psplotDiffEqn[linecolor=cyan]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3538 |
\psplotDiffEqn[linecolor=yellow, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3539 |
\psset{plotpoints=21} |
| 3540 |
\psplotDiffEqn[linecolor=blue]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3541 |
\psplotDiffEqn[linecolor=Orange, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3542 |
\psset{linewidth=2\pslinewidth} |
| 3543 |
\rput*(2,1){\psline[linecolor=Orange](-0.25,0)} |
| 3544 |
\rput*[l](2,1){RK} |
| 3545 |
\rput*(2,.9){\psline[linecolor=blue](-0.25,0)} |
| 3546 |
\rput*[l](2,.9){\textsc{Euler}-1} |
| 3547 |
\rput*(2,.8){\psline[linecolor=gray](-0.25,0)} |
| 3548 |
\rput*[l](2,.8){solution} |
| 3549 |
\end{pspicture} |
| 3550 |
\egroup |
| 3551 |
\end{center} |
| 3552 |
|
| 3553 |
|
| 3554 |
\begin{lstlisting} |
| 3555 |
\psset{unit=4} |
| 3556 |
\begin{pspicture}(-1,0)(3,1.1)\psgrid |
| 3557 |
\psplot[linewidth=4\pslinewidth,linecolor=gray]{-1}{3}{Euler x dup mul neg exp} |
| 3558 |
\psset{plotpoints=9} |
| 3559 |
\psplotDiffEqn[linecolor=cyan]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3560 |
\psplotDiffEqn[linecolor=yellow, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3561 |
\psset{plotpoints=21} |
| 3562 |
\psplotDiffEqn[linecolor=blue]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3563 |
\psplotDiffEqn[linecolor=Orange, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul} |
| 3564 |
\psset{linewidth=2\pslinewidth} |
| 3565 |
\rput*(2,1){\psline[linecolor=Orange](-0.25,0)} |
| 3566 |
\rput*[l](2,1){RK} |
| 3567 |
\rput*(2,.9){\psline[linecolor=blue](-0.25,0)} |
| 3568 |
\rput*[l](2,.9){\textsc{Euler}-1} |
| 3569 |
\rput*(2,.8){\psline[linecolor=gray](-0.25,0)} |
| 3570 |
\rput*[l](2,.8){solution} |
| 3571 |
\end{pspicture} |
| 3572 |
\end{lstlisting} |
| 3573 |
|
| 3574 |
|
| 3575 |
%-------------------------------------------------------------------------------------- |
| 3576 |
\clearpage |
| 3577 |
\subsubsection{Spiral of Cornu} |
| 3578 |
%-------------------------------------------------------------------------------------- |
| 3579 |
|
| 3580 |
The integrals of \Index{Fresnel}: |
| 3581 |
\begin{align} x & =\int^t_0\cos\frac{\pi t^2}{2}\mathrm{d}t \\ |
| 3582 |
y & =\int^t_0\sin\frac{\pi t^2}{2}\mathrm{d}t \\ |
| 3583 |
\intertext{with} |
| 3584 |
\dot{x} &= \cos\frac{\pi t^2}{2} \\ |
| 3585 |
\dot{y} & =\sin\frac{\pi t^2}{2} |
| 3586 |
\end{align} |
| 3587 |
|
| 3588 |
\begin{lstlisting} |
| 3589 |
\psset{unit=8} |
| 3590 |
\begin{pspicture}(1,1)\psgrid[subgriddiv=5] |
| 3591 |
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=red,method=rk4,algebraic,% |
| 3592 |
plotpoints=500,showpoints=true]{0}{10}{0 0}{cos(Pi*x^2/2)|sin(Pi*x^2/2)} |
| 3593 |
\end{pspicture} |
| 3594 |
\end{lstlisting} |
| 3595 |
|
| 3596 |
|
| 3597 |
\begin{center} |
| 3598 |
\bgroup |
| 3599 |
\psset{unit=8} |
| 3600 |
\begin{pspicture}(1,1)\psgrid[subgriddiv=5] |
| 3601 |
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=red,method=rk4,algebraic,% |
| 3602 |
plotpoints=500,showpoints=true]{0}{10}{0 0}{cos(Pi*x^2/2)|sin(Pi*x^2/2)} |
| 3603 |
\end{pspicture} |
| 3604 |
\egroup |
| 3605 |
\end{center} |
| 3606 |
|
| 3607 |
|
| 3608 |
|
| 3609 |
%-------------------------------------------------------------------------------------- |
| 3610 |
\clearpage |
| 3611 |
\subsubsection{Lotka-Volterra} |
| 3612 |
%-------------------------------------------------------------------------------------- |
| 3613 |
|
| 3614 |
The Lotka-Volterra model describes interactions between two species in an ecosystem, a |
| 3615 |
predator and a prey. This represents our first multi-species model. Since we are considering |
| 3616 |
two species, the model will involve two equations, one which describes how the prey |
| 3617 |
population changes and the second which describes how the predator population changes. |
| 3618 |
|
| 3619 |
For concreteness let us assume that the prey in our model are rabbits, and that the |
| 3620 |
predators are foxes. If we let $R(t)$ and $F(t)$ represent the number of rabbits and |
| 3621 |
foxes, respectively, that are alive at time t, then the Lotka-Volterra model is: |
| 3622 |
% |
| 3623 |
\begin{align} |
| 3624 |
\dot R &= a\cdot R - b\cdot R\cdot F\\ |
| 3625 |
\dot F &= e\cdot b\cdot R\cdot F - c\cdot F |
| 3626 |
\end{align} |
| 3627 |
% |
| 3628 |
where the parameters are defined by: |
| 3629 |
\begin{description} |
| 3630 |
\item[a] is the natural growth rate of rabbits in the absence of predation, |
| 3631 |
\item[c] is the natural death rate of foxes in the absence of food (rabbits), |
| 3632 |
\item[b] is the death rate per encounter of rabbits due to predation, |
| 3633 |
\item[e] is the efficiency of turning predated rabbits into foxes. |
| 3634 |
\end{description} |
| 3635 |
|
| 3636 |
The Stella model representing the \Index{Lotka-Volterra} model will be slightly more complex than the |
| 3637 |
single species models we've dealt with before. The main difference is that our model will have |
| 3638 |
two stocks (reservoirs), one for each species. Each species will have its own birth and death |
| 3639 |
rates. In addition, the Lotka-Volterra model involves four parameters rather than two. All told, |
| 3640 |
the Stella representation of the Lotka-Volterra model will use two stocks, four flows, four |
| 3641 |
converters and many connectors. |
| 3642 |
|
| 3643 |
\bgroup |
| 3644 |
\begin{center} |
| 3645 |
\def\InitCond{ 0 10 10}%% xa ya xl |
| 3646 |
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3647 |
-\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3648 |
-\Vlapin} |
| 3649 |
\def\Vlapin{1} \def\Vaigle{1.6} |
| 3650 |
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,% |
| 3651 |
plotpoints=20,showpoints=true} |
| 3652 |
\begin{pspicture}[showgrid=true](-3,-3)(10,10) |
| 3653 |
\psplotDiffEqn[plotfuncy=pop 0,whichabs=2,linecolor=red]{0}{10}{\InitCond}{\Faiglelapin} |
| 3654 |
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=black,method=rk4]{0}{10}{\InitCond}{\Faiglelapin} |
| 3655 |
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin} |
| 3656 |
\end{pspicture} |
| 3657 |
\end{center} |
| 3658 |
|
| 3659 |
\begin{lstlisting}[label={fig:aiglelapin},xrightmargin=-1.5cm] |
| 3660 |
\def\InitCond{ 0 10 10}%% xa ya xl |
| 3661 |
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3662 |
-\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3663 |
-\Vlapin} |
| 3664 |
\def\Vlapin{1} \def\Vaigle{1.6} |
| 3665 |
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,% |
| 3666 |
plotpoints=20,showpoints=true} |
| 3667 |
\begin{pspicture}[showgrid=true](-3,-3)(10,10) |
| 3668 |
\psplotDiffEqn[plotfuncy=pop 0,whichabs=2,linecolor=red]{0}{10}{\InitCond}{\Faiglelapin} |
| 3669 |
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=black,method=rk4]{0}{10}{\InitCond}{\Faiglelapin} |
| 3670 |
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin} |
| 3671 |
\end{pspicture} |
| 3672 |
\end{lstlisting} |
| 3673 |
|
| 3674 |
|
| 3675 |
\begin{center} |
| 3676 |
\def\InitCond{ 0 10 10}%% xa ya xl |
| 3677 |
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3678 |
-\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3679 |
-\Vlapin} |
| 3680 |
\def\Vlapin{1} \def\Vaigle{1.6} |
| 3681 |
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,% |
| 3682 |
plotpoints=20,showpoints=true} |
| 3683 |
\begin{pspicture}[showgrid=true](0,-0.25)(10,14) |
| 3684 |
\psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup |
| 3685 |
mul add sqrt,linecolor=red,method=rk4]{0}{10}{\InitCond}{\Faiglelapin} |
| 3686 |
\psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup |
| 3687 |
mul add sqrt,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin} |
| 3688 |
\psplotDiffEqn[plotfuncy=pop Func aload pop pop dup mul exch dup mul add sqrt, |
| 3689 |
linecolor=yellow]{0}{10}{\InitCond}{\Faiglelapin} |
| 3690 |
\end{pspicture} |
| 3691 |
\end{center} |
| 3692 |
\egroup |
| 3693 |
|
| 3694 |
\begin{lstlisting}[label={fig:aiglelapin2},xrightmargin=-1.5cm] |
| 3695 |
\def\InitCond{ 0 10 10}%% xa ya xl |
| 3696 |
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3697 |
-\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|% |
| 3698 |
-\Vlapin} |
| 3699 |
\def\Vlapin{1} \def\Vaigle{1.6} |
| 3700 |
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,% |
| 3701 |
plotpoints=20,showpoints=true} |
| 3702 |
\begin{pspicture}[showgrid=true](10,12) |
| 3703 |
\psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup |
| 3704 |
mul add sqrt,linecolor=red,method=rk4]{0}{10}{\InitCond}{\Faiglelapin} |
| 3705 |
\psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup |
| 3706 |
mul add sqrt,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin} |
| 3707 |
\psplotDiffEqn[plotfuncy=pop Func aload pop pop dup mul exch dup mul add sqrt, |
| 3708 |
linecolor=yellow]{0}{10}{\InitCond}{\Faiglelapin} |
| 3709 |
\end{pspicture} |
| 3710 |
\end{lstlisting} |
| 3711 |
|
| 3712 |
|
| 3713 |
%-------------------------------------------------------------------------------------- |
| 3714 |
\subsubsection{$y''=y$} |
| 3715 |
%-------------------------------------------------------------------------------------- |
| 3716 |
|
| 3717 |
Beginning with the initial equation $\displaystyle y(x)=Ae^x+Be^{-x}$ we get the hyperbolic |
| 3718 |
trigonometrical functions. |
| 3719 |
|
| 3720 |
\begin{center} |
| 3721 |
\bgroup |
| 3722 |
\def\Funct{exch} \psset{xunit=5cm, yunit=0.75cm} |
| 3723 |
\begin{pspicture}(0,-0.25)(2,7)\psgrid[subgriddiv=1,griddots=10] |
| 3724 |
\psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler x exp} %%e^x |
| 3725 |
\psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 1}{\Funct} |
| 3726 |
\psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 1}{\Funct} |
| 3727 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 1}{\Funct} |
| 3728 |
\psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp %%ch(x) |
| 3729 |
exch x neg exp add 2 div} |
| 3730 |
\psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 0}{\Funct} |
| 3731 |
\psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 0}{\Funct} |
| 3732 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 0}{\Funct} |
| 3733 |
\psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp |
| 3734 |
exch x neg exp sub 2 div} %%sh(x) |
| 3735 |
\psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{0 1}{\Funct} |
| 3736 |
\psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{0 1}{\Funct} |
| 3737 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{0 1}{\Funct} |
| 3738 |
\rput*(1.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](1.3,.9){\small\textsc{Euler} order 1 $h=1$} |
| 3739 |
\rput*(1.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](1.3,.8){\small\textsc{Euler} order 1 $h=0{,}1$} |
| 3740 |
\rput*(1.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](1.3,.7){\small RK order 4 $h=1$} |
| 3741 |
\rput*(1.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](1.3,.6){\small exact solution} |
| 3742 |
\end{pspicture} |
| 3743 |
\egroup |
| 3744 |
\end{center} |
| 3745 |
|
| 3746 |
\begin{lstlisting}[label={fig:minusexp},xrightmargin=-1.5cm] |
| 3747 |
\def\Funct{exch} \psset{xunit=5cm, yunit=0.75cm} |
| 3748 |
\begin{pspicture}(0,-0.25)(2,7)\psgrid[subgriddiv=1,griddots=10] |
| 3749 |
\psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler x exp} %%e^x |
| 3750 |
\psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 1}{\Funct} |
| 3751 |
\psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 1}{\Funct} |
| 3752 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 1}{\Funct} |
| 3753 |
\psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp %%ch(x) |
| 3754 |
exch x neg exp add 2 div} |
| 3755 |
\psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 0}{\Funct} |
| 3756 |
\psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 0}{\Funct} |
| 3757 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 0}{\Funct} |
| 3758 |
\psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp |
| 3759 |
exch x neg exp sub 2 div} %%sh(x) |
| 3760 |
\psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{0 1}{\Funct} |
| 3761 |
\psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{0 1}{\Funct} |
| 3762 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{0 1}{\Funct} |
| 3763 |
\rput*(1.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](1.3,.9){\small\textsc{Euler} order 1 $h=1$} |
| 3764 |
\rput*(1.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](1.3,.8){\small\textsc{Euler} order 1 $h=0{,}1$} |
| 3765 |
\rput*(1.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](1.3,.7){\small RK order 4 $h=1$} |
| 3766 |
\rput*(1.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](1.3,.6){\small exact solution} |
| 3767 |
\end{pspicture} |
| 3768 |
\end{lstlisting} |
| 3769 |
|
| 3770 |
%-------------------------------------------------------------------------------------- |
| 3771 |
\clearpage |
| 3772 |
\subsubsection{$y''=-y$} |
| 3773 |
%-------------------------------------------------------------------------------------- |
| 3774 |
\begin{center} |
| 3775 |
\bgroup |
| 3776 |
\def\Funct{exch neg} |
| 3777 |
\psset{xunit=1, yunit=4} |
| 3778 |
\def\quatrepi{12.5663706144}%%4pi=12.5663706144 |
| 3779 |
\begin{pspicture}(0,-1.25)(\quatrepi,1.25)\psgrid[subgriddiv=1,griddots=10] |
| 3780 |
\psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg cos}%%cos(x) |
| 3781 |
\psplotDiffEqn[linecolor=blue, plotpoints=201]{0}{3.1415926}{1 0}{\Funct} |
| 3782 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=31]{0}{\quatrepi}{1 0}{\Funct} |
| 3783 |
\psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg sin} %%sin(x) |
| 3784 |
\psplotDiffEqn[linecolor=blue,plotpoints=201]{0}{3.1415926}{0 1}{\Funct} |
| 3785 |
\psplotDiffEqn[linecolor=red,method=rk4, plotpoints=31]{0}{\quatrepi}{0 1}{\Funct} |
| 3786 |
\rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](3.3,.9){\small Euler order 1 $h=1$} |
| 3787 |
\rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](3.3,.8){\small Euler order 1 $h=0{,}1$} |
| 3788 |
\rput*(3.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](3.3,.7){\small RK order 4 $h=1$} |
| 3789 |
\rput*(3.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](3.3,.6){\small exact solution} |
| 3790 |
\end{pspicture} |
| 3791 |
\egroup |
| 3792 |
\end{center} |
| 3793 |
|
| 3794 |
\begin{lstlisting}[label={fig:minusexp2}] |
| 3795 |
\def\Funct{exch neg} |
| 3796 |
\psset{xunit=1, yunit=4} |
| 3797 |
\def\quatrepi{12.5663706144}%%4pi=12.5663706144 |
| 3798 |
\begin{pspicture}(0,-1.25)(\quatrepi,1.25)\psgrid[subgriddiv=1,griddots=10] |
| 3799 |
\psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg cos}%%cos(x) |
| 3800 |
\psplotDiffEqn[linecolor=blue, plotpoints=201]{0}{3.1415926}{1 0}{\Funct} |
| 3801 |
\psplotDiffEqn[linecolor=red, method=rk4, plotpoints=31]{0}{\quatrepi}{1 0}{\Funct} |
| 3802 |
\psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg sin} %%sin(x) |
| 3803 |
\psplotDiffEqn[linecolor=blue,plotpoints=201]{0}{3.1415926}{0 1}{\Funct} |
| 3804 |
\psplotDiffEqn[linecolor=red,method=rk4, plotpoints=31]{0}{\quatrepi}{0 1}{\Funct} |
| 3805 |
\rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](3.3,.9){\small Euler order 1 $h=1$} |
| 3806 |
\rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](3.3,.8){\small Euler order 1 $h=0{,}1$} |
| 3807 |
\rput*(3.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](3.3,.7){\small RK order 4 $h=1$} |
| 3808 |
\rput*(3.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](3.3,.6){\small exact solution} |
| 3809 |
\end{pspicture} |
| 3810 |
\end{lstlisting} |
| 3811 |
|
| 3812 |
%-------------------------------------------------------------------------------------- |
| 3813 |
\clearpage |
| 3814 |
\subsubsection{The mechanical pendulum: $y''=-\frac{g}{l}\sin(y)$}% $ |
| 3815 |
%-------------------------------------------------------------------------------------- |
| 3816 |
|
| 3817 |
For small \Index{oscillation}s $\sin(y)\simeq y$: |
| 3818 |
|
| 3819 |
\[ y(x)=y_0\cos\left(\sqrt{\frac{g}{l}}x\right) \] |
| 3820 |
|
| 3821 |
The function $f$ is written in PostScript code: |
| 3822 |
|
| 3823 |
\begin{lstlisting}[style=syntax] |
| 3824 |
exch RadtoDeg sin -9.8 mul %% y' -gsin(y) |
| 3825 |
\end{lstlisting} |
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
\begin{center} |
| 3830 |
\bgroup |
| 3831 |
\def\Func{y[1]|-9.8*sin(y[0])} |
| 3832 |
\psset{yunit=2,xunit=4,algebraic,linewidth=1.5pt} |
| 3833 |
\begin{pspicture}(0,-2.25)(3,2.25) |
| 3834 |
\psaxes{->}(0,0)(0,-2)(3,2) |
| 3835 |
\psplot[linewidth=3\pslinewidth, linecolor=Orange]{0}{3}{.1*cos(sqrt(9.8)*x)} |
| 3836 |
\psset{method=rk4,plotpoints=50,linecolor=blue} |
| 3837 |
\psplotDiffEqn{0}{3}{.1 0}{\Func} |
| 3838 |
\psplot[linewidth=3\pslinewidth,linecolor=Orange]{0}{3}{.25*cos(sqrt(9.8)*x)} |
| 3839 |
\psplotDiffEqn{0}{3}{.25 0}{\Func} |
| 3840 |
\psplotDiffEqn{0}{3}{.5 0}{\Func} |
| 3841 |
\psplotDiffEqn{0}{3}{1 0}{\Func} |
| 3842 |
\psplotDiffEqn[plotpoints=100]{0}{3}{Pi 2 div 0}{\Func} |
| 3843 |
\end{pspicture} |
| 3844 |
\egroup |
| 3845 |
\end{center} |
| 3846 |
|
| 3847 |
\begin{lstlisting}[label=fig:second] |
| 3848 |
\def\Func{y[1]|-9.8*sin(y[0])} |
| 3849 |
\psset{yunit=2,xunit=4,algebraic,linewidth=1.5pt} |
| 3850 |
\begin{pspicture}(0,-2.25)(3,2.25) |
| 3851 |
\psaxes{->}(0,0)(0,-2)(3,2) |
| 3852 |
\psplot[linewidth=3\pslinewidth, linecolor=Orange]{0}{3}{.1*cos(sqrt(9.8)*x)} |
| 3853 |
\psset{method=rk4,plotpoints=50,linecolor=blue} |
| 3854 |
\psplotDiffEqn{0}{3}{.1 0}{\Func} |
| 3855 |
\psplot[linewidth=3\pslinewidth,linecolor=Orange]{0}{3}{.25*cos(sqrt(9.8)*x)} |
| 3856 |
\psplotDiffEqn{0}{3}{.25 0}{\Func} |
| 3857 |
\psplotDiffEqn{0}{3}{.5 0}{\Func} |
| 3858 |
\psplotDiffEqn{0}{3}{1 0}{\Func} |
| 3859 |
\psplotDiffEqn[plotpoints=100]{0}{3}{Pi 2 div 0}{\Func} |
| 3860 |
\end{pspicture} |
| 3861 |
\end{lstlisting} |
| 3862 |
|
| 3863 |
%-------------------------------------------------------------------------------------- |
| 3864 |
\clearpage |
| 3865 |
\subsubsection{$y''=-\frac{y'}{4}-2y$}% $ |
| 3866 |
%-------------------------------------------------------------------------------------- |
| 3867 |
|
| 3868 |
For $y_0=5$ and $y'_0=0$ the solution is: |
| 3869 |
|
| 3870 |
\[ |
| 3871 |
5e^{-\frac{x}{8}}\left(\cos\left(\omega x\right)+\frac{\sin(\omega x)}{8\omega}\right) |
| 3872 |
\mbox{ avec } \omega=\frac{\sqrt{127}}{8} |
| 3873 |
\] |
| 3874 |
|
| 3875 |
\begin{center} |
| 3876 |
\bgroup |
| 3877 |
\psset{xunit=.6,yunit=0.8,plotpoints=500} |
| 3878 |
\begin{pspicture}(0,-4.25)(26,5.25) |
| 3879 |
\psaxes{->}(0,0)(0,-4)(26,5) |
| 3880 |
\psplot[plotpoints=200,linewidth=4\pslinewidth,linecolor=gray]{0}{26}{% |
| 3881 |
Euler x -8 div exp x 127 sqrt 8 div mul RadtoDeg dup cos 5 mul exch sin 127 sqrt div 5 mul add mul} |
| 3882 |
\psplotDiffEqn[linecolor=red,linewidth=5\pslinewidth]{0}{26}{5 0} |
| 3883 |
{dup 3 1 roll -4 div exch 2 mul sub} |
| 3884 |
\psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0} {y[1]|-y[1]/4-2*y[0]} |
| 3885 |
\psset{method=rk4, plotpoints=50} |
| 3886 |
\psplotDiffEqn[linecolor=blue,linewidth=5\pslinewidth]{0}{26}{5 0}{% |
| 3887 |
dup 3 1 roll -4 div exch 2 mul sub} |
| 3888 |
\psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0}{y[1]|-y[1]/4-2*y[0]} |
| 3889 |
\end{pspicture} |
| 3890 |
\egroup |
| 3891 |
\end{center} |
| 3892 |
|
| 3893 |
\begin{lstlisting} |
| 3894 |
\psset{xunit=.6,yunit=0.8,plotpoints=500} |
| 3895 |
\begin{pspicture}(0,-4.25)(26,5.25) |
| 3896 |
\psaxes{->}(0,0)(0,-4)(26,5) |
| 3897 |
\psplot[plotpoints=200,linewidth=4\pslinewidth,linecolor=gray]{0}{26}{% |
| 3898 |
Euler x -8 div exp x 127 sqrt 8 div mul RadtoDeg dup cos 5 mul exch sin 127 sqrt div 5 mul add mul} |
| 3899 |
\psplotDiffEqn[linecolor=red,linewidth=5\pslinewidth]{0}{26}{5 0} |
| 3900 |
{dup 3 1 roll -4 div exch 2 mul sub} |
| 3901 |
\psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0} {y[1]|-y[1]/4-2*y[0]} |
| 3902 |
\psset{method=rk4, plotpoints=50} |
| 3903 |
\psplotDiffEqn[linecolor=blue,linewidth=5\pslinewidth]{0}{26}{5 0}{% |
| 3904 |
dup 3 1 roll -4 div exch 2 mul sub} |
| 3905 |
\psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0}{y[1]|-y[1]/4-2*y[0]} |
| 3906 |
\end{pspicture} |
| 3907 |
\end{lstlisting} |
| 3908 |
|
| 3909 |
|
| 3910 |
\clearpage |
| 3911 |
\subsection{Save final state of a equation} |
| 3912 |
With the macros \Lcs{BeginSaveFinalState} and \Lcs{EndSaveFinalState} the |
| 3913 |
end values of a differential equation |
| 3914 |
can be saved and then used with the optional argument \Lkeyword{GetFinalState} |
| 3915 |
as starting values for another equation. |
| 3916 |
|
| 3917 |
\begin{lstlisting} |
| 3918 |
\psset{unit=10cm,linewidth=2pt} |
| 3919 |
\begin{pspicture}(1,1)\psgrid[subgridcolor=black!20,subgriddiv=20] |
| 3920 |
\BeginSaveFinalState |
| 3921 |
\psplotDiffEqn[ |
| 3922 |
whichabs=0,whichord=1,linecolor=red,method=rk4, |
| 3923 |
plotpoints=10,showpoints=true]{0}{1}{0 0}{ |
| 3924 |
pop pop |
| 3925 |
x dup mul 2 div 180 mul cos %% dx/dt |
| 3926 |
x dup mul 2 div 180 mul sin %% dy/dt |
| 3927 |
} |
| 3928 |
\psplotDiffEqn[GetFinalState, |
| 3929 |
whichabs=0,whichord=1,linecolor=blue,method=rk4,%FinalState, |
| 3930 |
plotpoints=10,showpoints=true]{1}{2}{0 0}{ |
| 3931 |
pop pop |
| 3932 |
x dup mul 2 div 180 mul cos %% dx/dt |
| 3933 |
x dup mul 2 div 180 mul sin %% dy/dt |
| 3934 |
} |
| 3935 |
\psplotDiffEqn[GetFinalState, |
| 3936 |
whichabs=0,whichord=1,linecolor=cyan,method=rk4,%FinalState, |
| 3937 |
plotpoints=19,showpoints=true]{2}{3}{0 0 }{ |
| 3938 |
pop pop |
| 3939 |
x dup mul 2 div 180 mul cos %% dx/dt |
| 3940 |
x dup mul 2 div 180 mul sin %% dy/dt |
| 3941 |
} |
| 3942 |
\EndSaveFinalState |
| 3943 |
\end{pspicture} |
| 3944 |
\end{lstlisting} |
| 3945 |
|
| 3946 |
|
| 3947 |
\bigskip |
| 3948 |
\begin{center} |
| 3949 |
\psset{unit=6cm,linewidth=2pt} |
| 3950 |
\begin{pspicture}(1,1)\psgrid[subgridcolor=black!20,subgriddiv=20] |
| 3951 |
\BeginSaveFinalState |
| 3952 |
\psplotDiffEqn[ |
| 3953 |
whichabs=0,whichord=1,linecolor=red,method=rk4, |
| 3954 |
plotpoints=10,showpoints=true]{0}{1}{0 0}{ |
| 3955 |
pop pop |
| 3956 |
x dup mul 2 div 180 mul cos %% dx/dt |
| 3957 |
x dup mul 2 div 180 mul sin %% dy/dt |
| 3958 |
} |
| 3959 |
\psplotDiffEqn[GetFinalState, |
| 3960 |
whichabs=0,whichord=1,linecolor=blue,method=rk4,%FinalState, |
| 3961 |
plotpoints=10,showpoints=true]{1}{2}{0 0}{ |
| 3962 |
pop pop |
| 3963 |
x dup mul 2 div 180 mul cos %% dx/dt |
| 3964 |
x dup mul 2 div 180 mul sin %% dy/dt |
| 3965 |
} |
| 3966 |
\psplotDiffEqn[GetFinalState, |
| 3967 |
whichabs=0,whichord=1,linecolor=cyan,method=rk4,%FinalState, |
| 3968 |
plotpoints=19,showpoints=true]{2}{3}{0 0 }{ |
| 3969 |
pop pop |
| 3970 |
x dup mul 2 div 180 mul cos %% dx/dt |
| 3971 |
x dup mul 2 div 180 mul sin %% dy/dt |
| 3972 |
} |
| 3973 |
\EndSaveFinalState |
| 3974 |
\end{pspicture} |
| 3975 |
\end{center} |
| 3976 |
|
| 3977 |
\psset{unit=1cm,linewidth=0.75pt} |
| 3978 |
|
| 3979 |
|
| 3980 |
%-------------------------------------------------------------------------------------- |
| 3981 |
\clearpage |
| 3982 |
\section{\nxLcs{psMatrixPlot}}\label{sec:psMatrix} |
| 3983 |
%-------------------------------------------------------------------------------------- |
| 3984 |
|
| 3985 |
This macro allows you to visualize a matrix. The datafile must be |
| 3986 |
defined as a PostScript matrix named \Lps{dotmatrix}: |
| 3987 |
\begin{lstlisting}[style=syntax] |
| 3988 |
/dotmatrix [ % <------------ important line |
| 3989 |
0 1 1 0 0 0 0 1 1 1 |
| 3990 |
0 1 1 0 1 1 1 0 1 0 |
| 3991 |
1 0 1 1 0 0 0 1 1 0 |
| 3992 |
0 0 1 0 0 0 0 0 1 1 |
| 3993 |
1 1 1 1 1 0 1 0 0 1 |
| 3994 |
0 0 1 1 0 1 0 1 1 1 |
| 3995 |
1 0 0 0 1 1 0 0 0 1 |
| 3996 |
0 0 0 1 1 1 0 1 1 0 |
| 3997 |
1 1 0 0 0 0 1 0 0 1 |
| 3998 |
1 0 1 0 0 1 1 1 0 0 |
| 3999 |
] def % <------------ important line |
| 4000 |
\end{lstlisting} |
| 4001 |
|
| 4002 |
Only the value 0 is important, in which case nothing happens, and |
| 4003 |
for all other cases a dot is printed. The syntax of the macro is: |
| 4004 |
|
| 4005 |
\begin{BDef} |
| 4006 |
\Lcs{psMatrixPlot}\OptArgs\Largb{rows}\Largb{columns}\Largb{data file} |
| 4007 |
\end{BDef} |
| 4008 |
|
| 4009 |
The \Index{matrix} is scanned line by line from the the first one to the |
| 4010 |
last. In general it appears as a bottom-to-top version of the |
| 4011 |
above listed matrix, the first row $0\,1\,1\,0\,0\,0\,0\,1\,1\,1$ |
| 4012 |
is the first plotted line ($y=1$). With the option |
| 4013 |
\Lkeyword{ChangeOrder}=\true\ it looks exactly like the above view. |
| 4014 |
|
| 4015 |
\bgroup |
| 4016 |
\begin{center} |
| 4017 |
\psscalebox{0.6}{% |
| 4018 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4019 |
\psaxes{->}(11,11) |
| 4020 |
\psMatrixPlot[dotsize=0.95cm,dotstyle=square*,linecolor=magenta]% |
| 4021 |
{10}{10}{data/matrix.data} |
| 4022 |
\psMatrixPlot[dotsize=.7cm,dotstyle=o,ChangeOrder]{10}{10}{data/matrix.data} |
| 4023 |
\end{pspicture}}\quad |
| 4024 |
\psscalebox{0.6}{% |
| 4025 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4026 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4027 |
\psMatrixPlot[dotsize=0.95cm,dotstyle=square*,linecolor=magenta,XYoffset=-0.5]% |
| 4028 |
{10}{10}{data/matrix.data} |
| 4029 |
\psMatrixPlot[dotsize=.7cm,dotstyle=o,ChangeOrder,XYoffset=-0.5]{10}{10}{data/matrix.data} |
| 4030 |
\end{pspicture}} |
| 4031 |
\end{center} |
| 4032 |
|
| 4033 |
\begin{lstlisting} |
| 4034 |
\psscalebox{0.6}{% |
| 4035 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4036 |
\psaxes{->}(11,11) |
| 4037 |
\psMatrixPlot[dotsize=0.95cm,dotstyle=square*,linecolor=magenta]% |
| 4038 |
{10}{10}{data/matrix.data} |
| 4039 |
\psMatrixPlot[dotsize=.7cm,dotstyle=o,ChangeOrder]{10}{10}{data/matrix.data} |
| 4040 |
\end{pspicture}}\quad |
| 4041 |
\psscalebox{0.6}{% |
| 4042 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4043 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4044 |
\psMatrixPlot[dotsize=0.95cm,dotstyle=square*,linecolor=magenta,XYoffset=-0.5]% |
| 4045 |
{10}{10}{data/matrix.data} |
| 4046 |
\psMatrixPlot[dotsize=.7cm,dotstyle=o,ChangeOrder,XYoffset=-0.5]{10}{10}{data/matrix.data} |
| 4047 |
\end{pspicture}} |
| 4048 |
\end{lstlisting} |
| 4049 |
|
| 4050 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4051 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4052 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4053 |
\psMatrixPlot[dotscale=3,dotstyle=*,linecolor=blue]{10}{8}{data/matrix.data} |
| 4054 |
\end{pspicture} |
| 4055 |
\end{LTXexample} |
| 4056 |
|
| 4057 |
\clearpage |
| 4058 |
With the \Lkeyword{colorType}=1 the data is printed as continous color |
| 4059 |
in the range of the wavelength. The smallest value of the data array |
| 4060 |
is set to red and the biggest value is set to violett. All other values |
| 4061 |
are substituted by the corresponding color of the wavlength. |
| 4062 |
\Lkeyword{colorType}=2 ist the same, but vice versa |
| 4063 |
with the color, from violet to red. \Lkeyword{colorType}=3 is the grayscale |
| 4064 |
image and \Lkeyword{colorType}=4 the same invers. |
| 4065 |
|
| 4066 |
The following examples use a 200$\times$200 |
| 4067 |
matrix data, which is saved as /dotmatrix [...] in the file \LFile{pstricks-add-doc.dat}. To speed up such images it should |
| 4068 |
be printed with the optional argument \Lkeyword{PixelPlot}. Then each point is printed by a simple dot without using the PSTricks font dot. |
| 4069 |
The dot can be scaled by \Lkeyword{dotsize}, e.g. \verb|dotsize=5pt|. |
| 4070 |
|
| 4071 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4072 |
\begin{pspicture}(10,10) |
| 4073 |
\psMatrixPlot[PixelPlot,colorType=1,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data} |
| 4074 |
\end{pspicture} |
| 4075 |
\end{LTXexample} |
| 4076 |
|
| 4077 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4078 |
\begin{pspicture}(10,10) |
| 4079 |
\psMatrixPlot[PixelPlot,colorType=2,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data} |
| 4080 |
\end{pspicture} |
| 4081 |
\end{LTXexample} |
| 4082 |
|
| 4083 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4084 |
\begin{pspicture}(10,10) |
| 4085 |
\psMatrixPlot[PixelPlot,colorType=3,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data} |
| 4086 |
\end{pspicture} |
| 4087 |
\end{LTXexample} |
| 4088 |
|
| 4089 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4090 |
\begin{pspicture}(10,10) |
| 4091 |
\psMatrixPlot[PixelPlot,colorType=4,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data} |
| 4092 |
\end{pspicture} |
| 4093 |
\end{LTXexample} |
| 4094 |
\egroup |
| 4095 |
|
| 4096 |
\clearpage |
| 4097 |
With the \Lkeyword{colorType}=5 the color setting can be user defined by the |
| 4098 |
optional argument \Lkeyword{colorTypeDef}. On the stack is the current value |
| 4099 |
which can be used for the setting but must be left on the stack when everything |
| 4100 |
is finished. The following example prints the 0 as color white, the value 1 as |
| 4101 |
black and all other values depending to the corresponding gray value. |
| 4102 |
|
| 4103 |
|
| 4104 |
\begin{center} |
| 4105 |
\psscalebox{0.7}{% |
| 4106 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4107 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4108 |
\psMatrixPlot[ |
| 4109 |
colorType=5, |
| 4110 |
colorTypeDef={ |
| 4111 |
dup /value exch def % save value and leave one on the stack |
| 4112 |
value Min sub dMaxMin div neg 1 add 300 mul 400 add \pswavelengthToGRAY |
| 4113 |
value 0 eq \pslbrace 1 \psrbrace if % |
| 4114 |
value 1 eq \pslbrace 0 \psrbrace if |
| 4115 |
setgray |
| 4116 |
}, |
| 4117 |
dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{data/matrix1.data} |
| 4118 |
\end{pspicture}} |
| 4119 |
\end{center} |
| 4120 |
|
| 4121 |
|
| 4122 |
\begin{lstlisting} |
| 4123 |
\begin{filecontents}{data/matrix1.data} |
| 4124 |
/dotmatrix [ % <------------ important line |
| 4125 |
3 0 0 0 0 0 0 0 1 2 |
| 4126 |
0 0 0 0 0 0 0 1 2 1 |
| 4127 |
8 0 0 0 0 0 1 2 1 0 |
| 4128 |
0 0 0 0 0 1 2 1 0 0 |
| 4129 |
0 0 0 0 1 2 1 0 0 0 |
| 4130 |
9 0 0 1 2 1 3 0 0 0 |
| 4131 |
0 0 1 2 1 4 0 0 0 0 |
| 4132 |
0 1 2 1 5 0 0 0 0 0 |
| 4133 |
1 2 1 6 0 0 0 0 0 0 |
| 4134 |
2 1 7 0 0 0 0 0 0 3 |
| 4135 |
] def % <------------ important line |
| 4136 |
\end{filecontents} |
| 4137 |
\psscalebox{0.7}{% |
| 4138 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4139 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4140 |
\psMatrixPlot[ |
| 4141 |
colorType=5, |
| 4142 |
colorTypeDef={ |
| 4143 |
dup /value exch def % save value and leave one on the stack |
| 4144 |
value Min sub dMaxMin div neg 1 add 300 mul 400 add \pswavelengthToGRAY |
| 4145 |
value 0 eq \pslbrace 1 \psrbrace if % |
| 4146 |
value 1 eq \pslbrace 0 \psrbrace if |
| 4147 |
setgray |
| 4148 |
}, |
| 4149 |
dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{data/matrix1.data} |
| 4150 |
\end{pspicture}} |
| 4151 |
\end{lstlisting} |
| 4152 |
|
| 4153 |
|
| 4154 |
\Lps{if} statements in the color definition must be enclosed with \Lcs{pslbrace} and \Lcs{psrbrace} |
| 4155 |
when they are parentheses used in PostScript. In the above example the color definition should be |
| 4156 |
modified when the matrix is a real big one, in such a case a nested \Lps{ifelse} makes more sense: |
| 4157 |
|
| 4158 |
\begin{lstlisting} |
| 4159 |
colorTypeDef={ |
| 4160 |
dup /value exch def |
| 4161 |
value 0 eq |
| 4162 |
\pslbrace 1 setgray \psrbrace |
| 4163 |
\pslbrace value 1 eq |
| 4164 |
\pslbrace 0 setgray \psrbrace |
| 4165 |
\pslbrace Min sub dMaxMin div neg 1 add 300 mul 400 add |
| 4166 |
\pswavelengthToGRAY setgray \psrbrace ifelse |
| 4167 |
\psrbrace ifelse |
| 4168 |
}, |
| 4169 |
\end{lstlisting} |
| 4170 |
|
| 4171 |
Replace the \Lcs{pslbrace} and \Lcs{psrbrace} with \{ and \} if it maybe confusing to read: |
| 4172 |
|
| 4173 |
\begin{lstlisting} |
| 4174 |
dup /value exch def |
| 4175 |
value 0 eq |
| 4176 |
{ 1 setgray } |
| 4177 |
{ value 1 eq |
| 4178 |
{ 0 setgray } |
| 4179 |
{ Min sub dMaxMin div neg 1 add 300 mul 400 add |
| 4180 |
\pswavelengthToGRAY setgray } ifelse |
| 4181 |
} ifelse |
| 4182 |
\end{lstlisting} |
| 4183 |
|
| 4184 |
Another possibility is to define the color procedure onside the data file, where |
| 4185 |
it \emph{must} be named \Lps{colorTypeDef}. If such a definition exists, the one from |
| 4186 |
the optional argument \Lkeyword{colorTypeDef} will be ignored. There can be no |
| 4187 |
\TeX-specific code inside this definition because it is read on PostScript level, |
| 4188 |
the reason why \Lcs{pswavelengthToGRAY} cannot be used. |
| 4189 |
|
| 4190 |
\begin{center} |
| 4191 |
\psscalebox{0.7}{% |
| 4192 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4193 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4194 |
\psMatrixPlot[ |
| 4195 |
colorType=5,dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{data/matrix2.data} |
| 4196 |
\end{pspicture}} |
| 4197 |
\end{center} |
| 4198 |
|
| 4199 |
\begin{lstlisting} |
| 4200 |
\begin{filecontents}{data/matrix2.data} |
| 4201 |
/colorTypeDef { |
| 4202 |
dup /value exch def |
| 4203 |
value 0 eq |
| 4204 |
{ 1 setgray } |
| 4205 |
{ value 1 eq |
| 4206 |
{ 0 setgray } |
| 4207 |
{ Min sub dMaxMin div neg 1 add 300 mul 400 add |
| 4208 |
% \pswavelengthToRGB not possible |
| 4209 |
tx@addDict begin wavelengthToRGB Red Green Blue end |
| 4210 |
setrgbcolor |
| 4211 |
} ifelse |
| 4212 |
} ifelse |
| 4213 |
} def |
| 4214 |
/dotmatrix [ % <------------ important line |
| 4215 |
3 0 0 0 0 0 0 0 1 2 |
| 4216 |
0 0 0 0 0 0 0 1 2 1 |
| 4217 |
8 0 0 0 0 0 1 2 1 0 |
| 4218 |
0 0 0 0 0 1 2 1 0 0 |
| 4219 |
0 0 0 0 1 2 1 0 0 0 |
| 4220 |
9 0 0 1 2 1 3 0 0 0 |
| 4221 |
0 0 1 2 1 4 0 0 0 0 |
| 4222 |
0 1 2 1 5 0 0 0 0 0 |
| 4223 |
1 2 1 6 0 0 0 0 0 0 |
| 4224 |
2 1 7 0 0 0 0 0 0 3 |
| 4225 |
] def % <------------ important line |
| 4226 |
\end{filecontents} |
| 4227 |
\psscalebox{0.7}{% |
| 4228 |
\begin{pspicture}(-0.5,-0.75)(11,11) |
| 4229 |
\psaxes[ticksize=-5pt 0]{->}(11,11) |
| 4230 |
\psMatrixPlot[colorType=5,dotsize=1.1cm,xStep=1,yStep=1, |
| 4231 |
dotstyle=square*]{10}{10}{data/matrix1.data} |
| 4232 |
\end{pspicture}} |
| 4233 |
\end{lstlisting} |
| 4234 |
|
| 4235 |
|
| 4236 |
|
| 4237 |
%-------------------------------------------------------------------------------------- |
| 4238 |
\section{Dashed Lines} |
| 4239 |
%-------------------------------------------------------------------------------------- |
| 4240 |
Tobias Nähring has implemented an enhanced feature for dashed |
| 4241 |
lines. The number of arguments is no longer limited. |
| 4242 |
|
| 4243 |
\begin{BDef} |
| 4244 |
\Lkeyword{dash}=value1\OptArg*{unit} value2\OptArg*{unit} \ldots |
| 4245 |
\end{BDef} |
| 4246 |
|
| 4247 |
\begin{LTXexample}[width=0.4\linewidth] |
| 4248 |
\psset{linewidth=2.5pt,unit=0.6} |
| 4249 |
\begin{pspicture}(-5,-4)(5,4) |
| 4250 |
\psgrid[subgriddiv=0,griddots=10,gridlabels=0pt] |
| 4251 |
\psset{linestyle=dashed} |
| 4252 |
\pscurve[dash=5mm 1mm 1mm 1mm,linewidth=0.1](-5,4)(-4,3)(-3,4)(-2,3) |
| 4253 |
\psline[dash=5mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm](-5,0.9)(5,0.9) |
| 4254 |
\psccurve[linestyle=solid](0,0)(1,0)(1,1)(0,1) |
| 4255 |
\psccurve[linestyle=dashed,dash=5mm 2mm 0.1 0.2,linetype=0](0,0)(-2.5,0)(-2.5,-2.5)(0,-2.5) |
| 4256 |
\pscurve[dash=3mm 3mm 1mm 1mm,linecolor=red,linewidth=2pt](5,-4)(5,2)(4.5,3.5)(3,4)(-5,4) |
| 4257 |
\end{pspicture} |
| 4258 |
\end{LTXexample} |
| 4259 |
|
| 4260 |
|
| 4261 |
|
| 4262 |
|
| 4263 |
|
| 4264 |
\section{Ticks and other marks along a curve} |
| 4265 |
\subsection{Quick overview} |
| 4266 |
|
| 4267 |
The macros described below allow you to place tick and other marks along an arbitrary |
| 4268 |
parametric curve with placement rules similar to those used by \Lcs{psaxes} in |
| 4269 |
the \LPack{pst-plot} package. You have to define a metric function along the curve to |
| 4270 |
govern tick placement. That function can be a specified function of \texttt{x,y} which |
| 4271 |
should increase along the curve, or it can be an function whose increment is a specified |
| 4272 |
positive function of \texttt{x, y, dx, dy, ds} where the last term is the arc-length element |
| 4273 |
that you could specify alternately as \texttt{dx dup mul dy dup mul add sqrt}. |
| 4274 |
% start new material |
| 4275 |
|
| 4276 |
|
| 4277 |
In addition, a new command \Lcs{Put} is proposed, expanding as appropriate to \Lcs{rput} or \Lcs{uput}. Its syntax is |
| 4278 |
|
| 4279 |
\begin{BDef} |
| 4280 |
\LcsStar{Put}\OptArgs\OptArg*{\Largb{<ref>}}\Largr{<position>}\Largb{<stuff>} |
| 4281 |
\end{BDef} |
| 4282 |
|
| 4283 |
where the optional \texttt{*} blanks the background, the optional \OptArgs\ may be used to specify a rotation |
| 4284 |
using any form acceptable to \Lcs{SpecialCoor} (eg, \nxLkeyword{rot=45} or \Lkeyword{rot}\verb|={(1,1)}| |
| 4285 |
or \Lkeyword{rot}\verb|=(P)|, and \Larg{ref} takes one of |
| 4286 |
two forms: \verb=(a)= a refpt such as \texttt{Bl}, in which case \Lcs{rput} is called; (b) a polar form of offset |
| 4287 |
(eg, \verb=7pt;30=, or \verb=;(P)= --- in the latter case, \Ldim{pslabelsep} is substituted for the missing |
| 4288 |
radius), in which case a modified form of \Lcs{uput} is called. The idea of \Lcs{Put} is to allow \texttt{position}, |
| 4289 |
\texttt{ref} and \texttt{rot} to be specified in any of the forms acceptable to \Lcs{SpecialCoor} and to do so with |
| 4290 |
the same output no matter what form is used. The cost of this consistency is that \Lcs{Put} can lead to results |
| 4291 |
that differ from \Lcs{uput} in some special cases. |
| 4292 |
|
| 4293 |
|
| 4294 |
\subsection{Details} |
| 4295 |
Suppose you have drawn a parametric curve using \Lcs{psparametricplot}, and you wish to |
| 4296 |
indicate some points on the curve using tick-marks like those on the axes. This is a |
| 4297 |
two-step process, the first of which serves to define at the PostScript level a |
| 4298 |
number of data arrays containing information about the curve. Those arrays are used |
| 4299 |
in the second step to compute tick positions and draw the ticks. The first step is |
| 4300 |
to run the macro \Lcs{pscurvepoints}. For example, |
| 4301 |
|
| 4302 |
\begin{verbatim} |
| 4303 |
\pscurvepoints[plotpoints=20]{0}{6}{t t t mul 12 div}{Pt}% |
| 4304 |
\end{verbatim} |
| 4305 |
makes a virtual (ie, data only---nothing is rendered) polyline with 20 vertices approximating |
| 4306 |
the curve $x(t)=t, y(t)=t^2/12$, $0\le t\le 6$. The last argument \texttt{Pt} is the root name |
| 4307 |
given to the data arrays. PostScript arrays will be created with the following names: \texttt{Pt.X, Pt.Y} |
| 4308 |
for the coordinates of the vertices, \texttt{PtDelta.X, PtDelta.Y} for the increments between the |
| 4309 |
vertices (using, eg, \texttt{PtDelta.X[2]=Pt.X[2]-Pt.X[1]}) and \texttt{PtNormal.X, PtNormal.Y} for |
| 4310 |
a vector normal to \texttt{PtDelta.X, PtDelta.Y} in the visual, not mathematical, sense. |
| 4311 |
(Both senses are the same if the scales on the axes are identical.) The \texttt{Normal} is |
| 4312 |
always constructed so as to point ``upward'' (ie, to your left) as you traverse the curve |
| 4313 |
in the positive direction. The PostScript variable \texttt{unitratio} provides the ratio of |
| 4314 |
the unit on the y axis to that on x axis, and \texttt{unitratiosq} is its square. All of |
| 4315 |
these PostScript objects are stored in the main \texttt{pstricks} dictionary \nxLps{tx@Dict} |
| 4316 |
which should be automatically made available when using many \texttt{pstricks} macros. |
| 4317 |
If \texttt{gs} returns you an error message like |
| 4318 |
\begin{verbatim} |
| 4319 |
Error: /undefined in Pt.X |
| 4320 |
\end{verbatim} |
| 4321 |
then you may need to enclose the offending PostScript code within a block of the form |
| 4322 |
\begin{verbatim} |
| 4323 |
tx@Dict begin ... end |
| 4324 |
\end{verbatim} |
| 4325 |
so that the dictionary is made available. |
| 4326 |
|
| 4327 |
With this preparation, the main tick-making macro may be run. For example, |
| 4328 |
\begin{verbatim} |
| 4329 |
\pspolylineticks{Pt}{ dx dy add 3 div }{1}{2}% |
| 4330 |
\end{verbatim} |
| 4331 |
looks for data arrays made using \Lcs{pscurvepoints} with the root name \texttt{Pt}. The next argument, |
| 4332 |
\texttt{dx dy add 3 div}, specifies the (PostScript) function of increments that should be used to |
| 4333 |
construct the metric. If the keyword \verb|metricInitValue| is defined, eg, with |
| 4334 |
\Lcs{psset}\Largb{\Lkeyword{metricInitValue}=2.5}, it is used as the initial value of the metric, |
| 4335 |
otherwise it is defined to be 0. In the previous example, the increment function is always |
| 4336 |
positive, and care should be taken to guarantee this is so or the results will not be meaningful. |
| 4337 |
(If we wanted to use arc-length, the function would have been \texttt{ds}, assuming equal scales on |
| 4338 |
the axes.) The last two arguments determine the index of the first tick and the number of ticks. |
| 4339 |
Tick numbering begins with index 0, so the example says to drop the first tick and draw the |
| 4340 |
next 2 ticks. In this example, where all keywords take their default values, ticks are |
| 4341 |
potentially located at values on the curve where the metric takes a positive integer value. |
| 4342 |
In the arc-length example, the tick with index 0 is at the beginning of the curve, and subsequent |
| 4343 |
ticks are at unit distance, measured along the curve. At each index where a tick is drawn, a |
| 4344 |
\Lcs{pnode} is created: In this example, you create nodes \texttt{PtTick1, PtTick2} on the curve |
| 4345 |
where the ticks are located. This is handy for placing labels using, eg, \Lcs{Put}. In |
| 4346 |
addition, PostScript data arrays (in this example, \texttt{PtTickN.X, PtTickN.Y} of the normals |
| 4347 |
at these nodes are stored in the dictionary \texttt{TDict}. More importantly, the tangent and |
| 4348 |
normal vectors at \texttt{PtTick0} etc are constructed as nodes with names \texttt{PtTangent0, PtNormal0} |
| 4349 |
etc. See the last example below for typical usage. |
| 4350 |
|
| 4351 |
The shape of the ticks is governed by the keywords \Lkeyword{ticksize} (default value \texttt{-4pt 4pt}) |
| 4352 |
and \Lkeyword{tickwidth} (default value \verb|.5\linewidth|.) With the default settings, ticks |
| 4353 |
are drawn perpendicular the the curve extending \texttt{4pt} to each side. The line |
| 4354 |
\begin{verbatim} |
| 4355 |
\pspolylineticks[ticksize=-6pt 6pt]{Pt}{ dx dy add 3 div }{1}{2}% |
| 4356 |
\end{verbatim} |
| 4357 |
would draw longer ticks than the default. |
| 4358 |
|
| 4359 |
Placement of the ticks is governed by the keywords \Lkeyword{Ds} and \Lkeyword{Os}, whose meaning for the |
| 4360 |
curve is similar to (but not the same as) the meanings of \Lkeyword{Dx} and \Lkeyword{Ox} with respect to the x axis. |
| 4361 |
That is, if \texttt{Ds=2} and \texttt{Os=0}, ticks will be drawn where the metric takes |
| 4362 |
values 0, 2, 4 and so on. More generally, ticks are placed where the metric takes |
| 4363 |
value \texttt{Os, Os+Ds, Os+2*Ds,...}, as long as those positions are on the curve. If \Lkeyword{Os} |
| 4364 |
has an empty value as a result, say, of \verb|\psset{Os=}|, then \Lkeyword{Os} is set internally |
| 4365 |
to the initial metric value. If \Lkeyword{Ds} has an empty value, it is set internally to the |
| 4366 |
final metric value less the initial metric value, divided by 10. |
| 4367 |
|
| 4368 |
To draw major and minor ticks requires two passes---one to draw the minor ticks and then one to draw the major ticks. |
| 4369 |
|
| 4370 |
Note that a ticks may be placed at arbitrary metric values on the curve by running the macro once for each point, like: |
| 4371 |
\begin{verbatim} |
| 4372 |
\pspolylineticks[ticksize=-6pt 6pt,Os=1.3]{Pt}{ dx dy add 3 div }{0}{1}% |
| 4373 |
\pspolylineticks[ticksize=-6pt 6pt,Os=2.4]{Pt}{ dx dy add 3 div }{0}{1}% |
| 4374 |
\end{verbatim} |
| 4375 |
|
| 4376 |
You may also dispense entirely with the tick and use the macro to generate a node sequence |
| 4377 |
that can be used to place other graphic objects. For example: |
| 4378 |
\begin{verbatim} |
| 4379 |
\pspolylineticks[ticksize=0pt 0pt]{Pt}{ dx dy add 3 div }{0}{3}% |
| 4380 |
%This defines nodes PtTick0..PtTick2 |
| 4381 |
\multido{\iA=0+1}{3}{\psdot(PtTick\iA)} |
| 4382 |
\end{verbatim} |
| 4383 |
|
| 4384 |
|
| 4385 |
There is another way to define a metric function without using increments. If the keywork \Lkeyword{metricFunction} is set to \true, |
| 4386 |
then the function you present as an argument to \Lcs{pspolylineticks} must be a function of |
| 4387 |
$x$ and $y$ only, and must be designed to increase along the curve. It is useful only in |
| 4388 |
those cases where, in essence, the increment function can be explicitly integrated. |
| 4389 |
For example, in the elliptical motion of planets and comets around the sun, it is not hard |
| 4390 |
to integrate the area function explicitly, and this provides a convenient metric, being proportional to time elapsed. |
| 4391 |
|
| 4392 |
There is some useful information left in the log by these macros. |
| 4393 |
They report the starting and ending values of the metric function, |
| 4394 |
the the range of indices for the Tick related arrays. |
| 4395 |
|
| 4396 |
\subsection{Examples} |
| 4397 |
The examples in this section make use of very recent (as of May, 2010) versions |
| 4398 |
of \LPack{pstricks} and related packages. |
| 4399 |
%If the \texttt{pst-grapha} package is not available on CTAN, download it from |
| 4400 |
%\begin{verbatim} |
| 4401 |
%http://math.ucsd.edu/~msharpe/pst-grapha.dmg |
| 4402 |
%\end{verbatim} |
| 4403 |
|
| 4404 |
The first couple of examples are constructed entirely by hand, and have no interest |
| 4405 |
other than to illustrate what is going on under the surface in the simplest case. |
| 4406 |
|
| 4407 |
\begin{LTXexample}[pos=t] |
| 4408 |
\begin{pspicture}(-1,-1)(10,4) |
| 4409 |
\psline[showpoints=true](1,2)(4,0)(9,3)% |
| 4410 |
\uput[180](1,2){$s=0$}% |
| 4411 |
\uput[-90](4,0){$s=1$}% |
| 4412 |
\uput[0](9,3){$s=2$}% |
| 4413 |
\makeatletter% need to use macro names containing @ |
| 4414 |
\pstVerb{tx@Dict begin %the pstricks dictionary |
| 4415 |
% declare arrays of length 3 (indices 0,1,2) to hold points, differences and normals |
| 4416 |
/unitratiosq 1 def % yunit=xunit |
| 4417 |
/P.X [ 1 4 9 ] def %array of x coords |
| 4418 |
/P.Y [ 2 0 3 ] def %array of y coords |
| 4419 |
/PDelta.X [ 0 3 5 ] def % 3=4-1, 5=9-4, 0 never used |
| 4420 |
/PDelta.Y [ 0 -2 3 ] def % -2=0-2, 3=3-0, 0 never used |
| 4421 |
% normal to (3,-2) is (2,3), normal to (5,3) is (-3,5) |
| 4422 |
/PNormal.X [ 2 2 -3 ] def % index 0 =index 1 |
| 4423 |
/PNormal.Y [ 3 3 5 ] def % index 0 = index 1 |
| 4424 |
end } |
| 4425 |
\def\Ppointcount{2} |
| 4426 |
\makeatother % make ticks using metric function with values 0,1,2 |
| 4427 |
\pspolylineticks[Os=.5,Ds=1]{P}{1}{0}{2} |
| 4428 |
\uput[-135](PTick0){$s=0.5$}% % ticks at s=0.5,1.5 (increment function =1) |
| 4429 |
\uput[-45](PTick1){$s=1.5$}% |
| 4430 |
\end{pspicture} |
| 4431 |
\end{LTXexample} |
| 4432 |
|
| 4433 |
\clearpage |
| 4434 |
Now the same data, but with arc-length as metric. We change the last few lines: |
| 4435 |
|
| 4436 |
\begin{LTXexample}[pos=t] |
| 4437 |
\begin{pspicture}(-1,-1)(10,4) |
| 4438 |
\psline[showpoints=true](1,2)(4,0)(9,3)% |
| 4439 |
%\uput[180](1,2){$s=0$}% |
| 4440 |
%\uput[-90](4,0){$s=1$}% |
| 4441 |
%\uput[0](9,3){$s=2$}% |
| 4442 |
\makeatletter% need to use macro names containing @ |
| 4443 |
\pstVerb{tx@Dict begin %the pstricks dictionary |
| 4444 |
% declare arrays of length 3 (indices 0,1,2) to hold points, |
| 4445 |
% differences and normals |
| 4446 |
/unitratiosq 1 def % yunit=xunit |
| 4447 |
/P.X [ 1 4 9 ] def %array of x coords |
| 4448 |
/P.Y [ 2 0 3 ] def %array of y coords |
| 4449 |
/PDelta.X [ 0 3 5 ] def % 3=4-1, 5=9-4, 0 never used |
| 4450 |
/PDelta.Y [ 0 -2 3 ] def % -2=0-2, 3=3-0, 0 never used |
| 4451 |
% normal to (3,-2) is (2,3), normal to (5,3) is (-3,5) |
| 4452 |
/PNormal.X [ 2 2 -3 ] def % index 0 =index 1 |
| 4453 |
/PNormal.Y [ 3 3 5 ] def % index 0 = index 1 |
| 4454 |
end } |
| 4455 |
\def\Ppointcount{2} |
| 4456 |
\makeatother |
| 4457 |
% make ticks using metric function arc-length |
| 4458 |
\pspolylineticks[Os=1,Ds=1]{P}{ ds }{0}{9} |
| 4459 |
% ticks at s=1,2... (increment function = distance) |
| 4460 |
\uput[-135](PTick0){$s=1$}% |
| 4461 |
\uput[-135](PTick1){$s=2$}% |
| 4462 |
\end{pspicture} |
| 4463 |
\end{LTXexample} |
| 4464 |
|
| 4465 |
|
| 4466 |
|
| 4467 |
\clearpage |
| 4468 |
Once again the same data, but with metric equal to the x coordinate. Change the last few lines to: |
| 4469 |
|
| 4470 |
\begin{LTXexample}[pos=t] |
| 4471 |
\begin{pspicture}(-1,-1)(10,4) |
| 4472 |
\psline[showpoints=true](1,2)(4,0)(9,3)% |
| 4473 |
%\uput[180](1,2){$s=0$}% |
| 4474 |
%\uput[-90](4,0){$s=1$}% |
| 4475 |
%\uput[0](9,3){$s=2$}% |
| 4476 |
\makeatletter% need to use macro names containing @ |
| 4477 |
\pstVerb{tx@Dict begin %the pstricks dictionary |
| 4478 |
% declare arrays of length 3 (indices 0,1,2) to hold points, |
| 4479 |
% differences and normals |
| 4480 |
/unitratiosq 1 def % yunit=xunit |
| 4481 |
/P.X [ 1 4 9 ] def %array of x coords |
| 4482 |
/P.Y [ 2 0 3 ] def %array of y coords |
| 4483 |
/PDelta.X [ 0 3 5 ] def % 3=4-1, 5=9-4, 0 never used |
| 4484 |
/PDelta.Y [ 0 -2 3 ] def % -2=0-2, 3=3-0, 0 never used |
| 4485 |
% normal to (3,-2) is (2,3), normal to (5,3) is (-3,5) |
| 4486 |
/PNormal.X [ 2 2 -3 ] def % index 0 =index 1 |
| 4487 |
/PNormal.Y [ 3 3 5 ] def % index 0 = index 1 |
| 4488 |
end } |
| 4489 |
\def\Ppointcount{2} |
| 4490 |
\makeatother |
| 4491 |
% make ticks using metric function arc-length |
| 4492 |
\pspolylineticks[metricFunction,Os=1,Ds=2]{P}{ x }{0}{5} |
| 4493 |
% ticks at x=1,3,... , start at tick index 0, draw 5 ticks |
| 4494 |
% the tick at s=1 has index 0 |
| 4495 |
% ticks at s=1,2... (increment function = distance) |
| 4496 |
\uput[-135](PTick0){$s=1$}% |
| 4497 |
\uput[-135](PTick1){$s=3$}% |
| 4498 |
\end{pspicture} |
| 4499 |
\end{LTXexample} |
| 4500 |
|
| 4501 |
|
| 4502 |
|
| 4503 |
|
| 4504 |
|
| 4505 |
|
| 4506 |
\clearpage |
| 4507 |
The next example is a smooth path where subticks are drawn first, followed by major ticks. |
| 4508 |
The metric is arc-length with initial value $s=1$. |
| 4509 |
\begin{LTXexample}[pos=t] |
| 4510 |
\begin{pspicture}(-1,-1)(10,4) |
| 4511 |
%\parametricplot[algebraic]{0}{9}{(t^2)/9 | 4*Ex(-t)*(1+t+(t^{2})/2+(t^{3})/6)} |
| 4512 |
\psparametricplot[algebraic]{0}{9}{t^2/9 | sin(t)+1}% |
| 4513 |
\pscurvepoints{0}{9}{(t^2)/9 | sin(t)+1}{P}% |
| 4514 |
% make ticks using arc-length metric |
| 4515 |
\pspolylineticks[metricInitValue=1,ticksize=-2pt 2pt,Os=1,Ds=.2]{P}{ ds }{1}{56}% |
| 4516 |
\pspolylineticks[metricInitValue=1,Os=1,Ds=2]{P}{ ds }{0}{6}% |
| 4517 |
\multido{\iA=1+1,\iB=3+2}{5}{\Put{6pt;(PNormal\iA)}(PTick\iA){\tiny \iB}} |
| 4518 |
%\nodexn{(PTick\iA)+(10pt;{(PNormal\iA)})}{Q}\rput(Q){\tiny \iB}}% |
| 4519 |
%\multido{\iA=1+1,\iB=3+2}{5}{\uput{6pt}[{(PNormal\iA)}](PTick\iA){\iB}}% |
| 4520 |
% ticks at x=1,3,... , start at tick index 0, draw 5 ticks |
| 4521 |
% the tick at s=1 has index 0 |
| 4522 |
% ticks at s=1,2... (increment function = distance) |
| 4523 |
\end{pspicture} |
| 4524 |
\end{LTXexample} |
| 4525 |
|
| 4526 |
|
| 4527 |
|
| 4528 |
|
| 4529 |
\clearpage |
| 4530 |
Suppose for the next example that we have an ellipse $x^2/a^2+y^2/b^2=1$ ($a>b$) with |
| 4531 |
eccentricity $\epsilon=(1-b^2/a^2)^{1/2}$. With planetary motion in mind, a natural metric |
| 4532 |
for the ellipse is the area swept out by the radial line from the focus $(\epsilon a,0)$ |
| 4533 |
starting from $(a,0)$ around to an arbitrary location $(x,y)$, where $y>0$, as this quantity |
| 4534 |
is proportional to the time elapsed since perihelion. A routine calculation gives the following formula: |
| 4535 |
\[A=\frac{ab}{2}\arccos\bigg(\frac{x}{a}\bigg)-\frac{\epsilon a y}{2}.\] |
| 4536 |
Remembering that PostScript's \texttt{acos} gives its result in degrees, not radians, we have the |
| 4537 |
following, drawn for the case $a=4$, $b=3$. |
| 4538 |
|
| 4539 |
\begin{LTXexample}[pos=t] |
| 4540 |
\begin{pspicture}(-4.5,-.5)(4.5,3.5) |
| 4541 |
\pstVerb{ /smajor 4 def /sminor 3 def % define semimajor, semiminor |
| 4542 |
/ecc 1 sminor smajor div dup mul sub sqrt def % compute eccentricity |
| 4543 |
/ab smajor sminor mul 2 div def %first coeff |
| 4544 |
/ea smajor ecc mul 2 div def }% second coeff |
| 4545 |
\psparametricplot[algebraic]{0}{3.142}{smajor*cos(t) | sminor*sin(t)}% |
| 4546 |
\pscurvepoints{0}{3.142}{smajor*cos(t) | sminor*sin(t)}{P}% |
| 4547 |
\pspolylineticks[metricFunction,Ds=2,ticksize=-1.5pt 0]{P}{ ab x smajor div acos % |
| 4548 |
180 div PI mul mul ea y mul sub }{1}{9}% |
| 4549 |
\pnode(! ecc smajor mul 0){S}% focus |
| 4550 |
\psline[linecolor=lightgray](S)(!smajor 0)% |
| 4551 |
\multido{\i=1+1}{9}{\psline[linecolor=lightgray](S)(PTick\i)} |
| 4552 |
\psdot(S) |
| 4553 |
\end{pspicture} |
| 4554 |
\end{LTXexample} |
| 4555 |
|
| 4556 |
|
| 4557 |
|
| 4558 |
|
| 4559 |
|
| 4560 |
\clearpage |
| 4561 |
The next examples works without visible ticks, using the macros to construct nodes at which other objects will be placed. |
| 4562 |
|
| 4563 |
\begin{LTXexample}[pos=t] |
| 4564 |
\begin{pspicture}(-1,-1)(10,4) |
| 4565 |
\psparametricplot[algebraic]{0}{9}{t| 3*Ex(-t)*(1+t+t^2/2+t^3/6)} |
| 4566 |
\pscurvepoints{0}{9}{t| 3*Ex(-t)*(1+t+t^2/2+t^3/6)}{P}% |
| 4567 |
\pspolylineticks[Os=1,Ds=1,ticksize=0 0]{P}{ ds }{0}{9}% |
| 4568 |
\multido{\i=0+1}{9}{\psdot[dotscale=1.5,dotstyle=o](PTick\i)}% |
| 4569 |
% ticks at s=1,2,... , start at tick index 0, set 9 ticks |
| 4570 |
% the tick at s=1 has index 0 |
| 4571 |
% ticks at s=1,2... (increment function = distance) |
| 4572 |
\multido{\i=0+3}{3}{\Put[rot=(PTangent\i)]{7pt;(PNormal\i)}(PTick\i){PTick\i}}% |
| 4573 |
\uput[-135](PTick1){$s=2$}% |
| 4574 |
\end{pspicture} |
| 4575 |
\end{LTXexample} |
| 4576 |
|
| 4577 |
|
| 4578 |
|
| 4579 |
|
| 4580 |
|
| 4581 |
This variant also has no visible ticks, but makes a color gradient along the curve based on arc-length from the start. |
| 4582 |
|
| 4583 |
\begin{LTXexample}[pos=t] |
| 4584 |
\begin{pspicture}(-1,-1)(10,4) |
| 4585 |
\psparametricplot[plotpoints=200,linecolor=white]{0}{360}{ t cos 1 add 4 mul t 1 add 20 div ln 2 div 1 add } |
| 4586 |
\pscurvepoints[plotpoints=200]{0}{360}{ t cos 1 add 4 mul t 1 add 20 div ln 2 div 1 add }{P}% |
| 4587 |
\pspolylineticks[Os=0,Ds=.2,ticksize=0 0]{P}{ ds }{0}{90}% |
| 4588 |
\definecolorseries{ctest}{hsb}{last}{green}{violet} |
| 4589 |
\resetcolorseries[88]{ctest}% |
| 4590 |
\multido{\iA=0+1,\iB=1+1}{87}{\psline[linewidth=2pt,linecolor=ctest!(PTick\iB)}% |
| 4591 |
\end{pspicture} |
| 4592 |
\end{LTXexample} |
| 4593 |
|
| 4594 |
\clearpage |
| 4595 |
Here is a another variant of this technique which allows arrows to be placed at locations |
| 4596 |
on the curve where the metric takes particular values. |
| 4597 |
|
| 4598 |
|
| 4599 |
|
| 4600 |
|
| 4601 |
\begin{LTXexample}[pos=t] |
| 4602 |
\begin{pspicture}(-1,-1)(10,4.5) |
| 4603 |
\psparametricplot[plotpoints=100]{0}{360}{t cos 1 add 5 mul t sin 1 add 2 mul} |
| 4604 |
\pscurvepoints[plotpoints=100]{0}{360}{t cos 1 add 5 mul t sin 1 add 2 mul}{P}% |
| 4605 |
\pspolylineticks[Os=0,Ds=2.3,ticksize=0 0]{P}{ ds }{0}{10}% distance |
| 4606 |
\multido{\i=0+1}{10}{\psrline[arrows=->,arrowscale=1.5](PTick\i)(2pt;{(PTangent\i)})}% |
| 4607 |
\end{pspicture} |
| 4608 |
\end{LTXexample} |
| 4609 |
|
| 4610 |
\section{Troubleshooting} |
| 4611 |
If you get PostScript errors when you process your file, the most likely culprit is the |
| 4612 |
function you specified to define the metric. There are some things to look out for: |
| 4613 |
\begin{itemize} |
| 4614 |
\item If \Lkeyword{metricFunction}, the function you specify in PostScript code must |
| 4615 |
involve only \texttt{x} and \texttt{y}, and must leave exactly one real value on the stack as a result of |
| 4616 |
substituting specific values for \texttt{x} and \texttt{y}. The function must be strictly increasing on the curve. |
| 4617 |
\item If \Lkeyword{metricFunction}=\false (the default), the function you specify in PostScript |
| 4618 |
code must involve only the variables \texttt{x}, \texttt{y}, \texttt{dx}, \texttt{dy}, \texttt{ds} (where \texttt{ds} |
| 4619 |
is defined to be the arc-length element \texttt{dx dup mul dy dup mul add sqrt}, and must leave exactly |
| 4620 |
one strictly positive real value on the stack when specific values are substituted for those variables. |
| 4621 |
The constant function \texttt{1} gives equal weight to each segment in the curve, so in effect it gives |
| 4622 |
you the original parametrization, up to a constant factor. |
| 4623 |
\item If the function you specify in \Lcs{parametricplot} and \Lcs{pscurvepoints} is \Lkeyword{algebraic}, |
| 4624 |
make sure you follow precisely the syntax it understands. In complex cases, PostScript may be the safer solution. |
| 4625 |
\item It is unwise to use a different resolution for \Lcs{psparametricplot} and \Lcs{pscurvepoints}. |
| 4626 |
The default value of \Lkeyword{plotpoints}=50 is marginal except for modest curve segments, and 200 should |
| 4627 |
suffice for most smooth curves. |
| 4628 |
\end{itemize} |
| 4629 |
|
| 4630 |
|
| 4631 |
%-------------------------------------------------------------------------------------- |
| 4632 |
\section{Transparent colors} |
| 4633 |
%-------------------------------------------------------------------------------------- |
| 4634 |
|
| 4635 |
Transparency is now part of the main \LPack{pstricks} package. |
| 4636 |
But pay attention, the names and syntax have changed and you need |
| 4637 |
to run \Lprog{ps2pdf} with the option |
| 4638 |
\Loption{-dCompatibilityLevel}=1.4. |
| 4639 |
|
| 4640 |
|
| 4641 |
%-------------------------------------------------------------------------------------- |
| 4642 |
\section{,,Manipulating transparent colors''} |
| 4643 |
%-------------------------------------------------------------------------------------- |
| 4644 |
|
| 4645 |
\LPack{pstricks-add} supports real transparency and a simulated one with hatch lines: |
| 4646 |
\begin{lstlisting} |
| 4647 |
\def\defineTColor{\@ifnextchar[{\defineTColor@i}{\defineTColor@i[]}} |
| 4648 |
\def\defineTColor@i[#1]#2#3{% transparency "Colors" |
| 4649 |
\newpsstyle{#2}{% |
| 4650 |
fillstyle=vlines,hatchwidth=0.1\pslinewidth, |
| 4651 |
hatchsep=1\pslinewidth,hatchcolor=#3,#1% |
| 4652 |
}% |
| 4653 |
} |
| 4654 |
\defineTColor{TRed}{red} |
| 4655 |
\defineTColor{TGreen}{green} |
| 4656 |
\defineTColor{TBlue}{blue} |
| 4657 |
\end{lstlisting} |
| 4658 |
|
| 4659 |
There are three predefined "'transparent"` colors \verb+TRed+, |
| 4660 |
\verb+TGreen+, \verb+TBlue+. They are used as \PST{} styles and |
| 4661 |
not as colors: |
| 4662 |
|
| 4663 |
|
| 4664 |
|
| 4665 |
|
| 4666 |
\bgroup |
| 4667 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4668 |
\begin{pspicture}(-3,-5)(5,5) |
| 4669 |
\psframe(-1,-3)(5,5) % objet de base |
| 4670 |
\psrotate(2,-2){15}{% |
| 4671 |
\psframe[style=TRed](-1,-3)(5,5)} |
| 4672 |
\psrotate(2,-2){30}{% |
| 4673 |
\psframe[style=TGreen](-1,-3)(5,5)} |
| 4674 |
\psrotate(2,-2){45}{% |
| 4675 |
\psframe[style=TBlue](-1,-3)(5,5)} |
| 4676 |
\psframe[linewidth=3pt](-1,-3)(5,5) |
| 4677 |
\psdots[dotstyle=+,dotangle=45,dotscale=3](2,-2) % centre de la rotation |
| 4678 |
\end{pspicture} |
| 4679 |
\end{LTXexample} |
| 4680 |
\egroup |
| 4681 |
|
| 4682 |
%-------------------------------------------------------------------------------------- |
| 4683 |
\section{Calculated colors} |
| 4684 |
%-------------------------------------------------------------------------------------- |
| 4685 |
The \verb+xcolor+ package (version 2.6) has a new feature for defining colors: |
| 4686 |
\begin{lstlisting}[style=syntax] |
| 4687 |
\definecolor[ps]{<name>}{<model>}{< PS code >} |
| 4688 |
\end{lstlisting} |
| 4689 |
|
| 4690 |
\verb+model+ can be one of the color models, which \PS will |
| 4691 |
understand, e.g. \verb+rgb+. With this definition the color is |
| 4692 |
calculated on the \PS side. |
| 4693 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4694 |
\definecolor[ps]{bl}{rgb}{tx@addDict begin Red Green Blue end}% |
| 4695 |
\psset{unit=1bp} |
| 4696 |
\begin{pspicture}(0,-30)(400,100) |
| 4697 |
\multido{\iLAMBDA=0+1}{400}{% |
| 4698 |
\pstVerb{ |
| 4699 |
\iLAMBDA\space 379 add dup /lambda exch def |
| 4700 |
tx@addDict begin wavelengthToRGB end |
| 4701 |
}% |
| 4702 |
\psline[linecolor=bl](\iLAMBDA,0)(\iLAMBDA,100)% |
| 4703 |
} |
| 4704 |
\psaxes[yAxis=false,Ox=350,dx=50bp,Dx=50]{->}(-29,-10)(420,100) |
| 4705 |
\uput[-90](420,-10){$\lambda$[\textsf{nm}]} |
| 4706 |
\end{pspicture} |
| 4707 |
\end{LTXexample} |
| 4708 |
|
| 4709 |
|
| 4710 |
|
| 4711 |
|
| 4712 |
|
| 4713 |
\begin{center} |
| 4714 |
\newcommand{\Touch}{% |
| 4715 |
\psframe[linestyle=none,fillstyle=solid,fillcolor=bl,dimen=middle](0.1,0.75)} |
| 4716 |
\definecolor[ps]{bl}{rgb}{tx@addDict begin Red Green Blue end}% |
| 4717 |
% Echelle 1cm <-> 40 nm |
| 4718 |
% 1 nm <-> 0.025 cm |
| 4719 |
\psframebox[fillstyle=solid,fillcolor=black]{% |
| 4720 |
\begin{pspicture}(-1,-0.5)(12,1.5) |
| 4721 |
\multido{\iLAMBDA=380+2}{200}{% |
| 4722 |
\pstVerb{ |
| 4723 |
/lambda \iLAMBDA\space def |
| 4724 |
lambda |
| 4725 |
tx@addDict begin wavelengthToRGB end |
| 4726 |
}% |
| 4727 |
\rput(! lambda 0.025 mul 9.5 sub 0){\Touch} |
| 4728 |
} |
| 4729 |
\multido{\n=0+1,\iDiv=380+40}{11}{% |
| 4730 |
\psline[linecolor=white](\n,0.1)(\n,-0.1) |
| 4731 |
\uput[270](\n,0){\textbf{\white\iDiv}}} |
| 4732 |
\psline[linecolor=white]{->}(11,0) |
| 4733 |
\uput[270](11,0){\textbf{\white$\lambda$(nm)}} |
| 4734 |
\end{pspicture}} |
| 4735 |
|
| 4736 |
\psframebox[fillstyle=solid,fillcolor=black]{% |
| 4737 |
\begin{pspicture}(-1,-0.5)(12,1) |
| 4738 |
\pstVerb{ |
| 4739 |
/lambda 656 def |
| 4740 |
lambda |
| 4741 |
tx@addDict begin wavelengthToRGB end |
| 4742 |
}% |
| 4743 |
\rput(! 656 0.025 mul 9.5 sub 0){\Touch} |
| 4744 |
\pstVerb{ |
| 4745 |
/lambda 486 def |
| 4746 |
lambda |
| 4747 |
tx@addDict begin wavelengthToRGB end |
| 4748 |
}% |
| 4749 |
\rput(! 486 0.025 mul 9.5 sub 0){\Touch} |
| 4750 |
\pstVerb{ |
| 4751 |
/lambda 434 def |
| 4752 |
lambda |
| 4753 |
tx@addDict begin wavelengthToRGB end |
| 4754 |
}% |
| 4755 |
\rput(! 434 0.025 mul 9.5 sub 0){\Touch} |
| 4756 |
\pstVerb{ |
| 4757 |
/lambda 410 def |
| 4758 |
lambda |
| 4759 |
tx@addDict begin wavelengthToRGB end |
| 4760 |
}% |
| 4761 |
\rput(! 410 0.025 mul 9.5 sub 0){\Touch} |
| 4762 |
\multido{\n=0+1,\iDiv=380+40}{11}{% |
| 4763 |
\psline[linecolor=white](\n,0.1)(\n,-0.1) |
| 4764 |
\uput[270](\n,0){\textbf{\white\iDiv}}} |
| 4765 |
\psline[linecolor=white]{->}(11,0) |
| 4766 |
\uput[270](11,0){\textbf{\white$\lambda$(nm)}} |
| 4767 |
\end{pspicture}} |
| 4768 |
|
| 4769 |
\Index{Spectrum} of \Index{hydrogen} emission (Manuel Luque) |
| 4770 |
\end{center} |
| 4771 |
|
| 4772 |
\begin{lstlisting} |
| 4773 |
\newcommand\Touch{% |
| 4774 |
\psframe[linestyle=none,fillstyle=solid,fillcolor=bl,dimen=middle](0.1,0.75)} |
| 4775 |
\definecolor[ps]{bl}{rgb}{tx@addDict begin Red Green Blue end}% |
| 4776 |
% Echelle 1cm <-> 40 nm |
| 4777 |
% 1 nm <-> 0.025 cm |
| 4778 |
\psframebox[fillstyle=solid,fillcolor=black]{% |
| 4779 |
\begin{pspicture}(-1,-0.5)(12,1.5) |
| 4780 |
\multido{\iLAMBDA=380+2}{200}{% |
| 4781 |
\pstVerb{ |
| 4782 |
/lambda \iLAMBDA\space def |
| 4783 |
lambda |
| 4784 |
tx@addDict begin wavelengthToRGB end |
| 4785 |
}% |
| 4786 |
\rput(! lambda 0.025 mul 9.5 sub 0){\Touch} |
| 4787 |
} |
| 4788 |
\multido{\n=0+1,\iDiv=380+40}{11}{% |
| 4789 |
\psline[linecolor=white](\n,0.1)(\n,-0.1) |
| 4790 |
\uput[270](\n,0){\textbf{\white\iDiv}}} |
| 4791 |
\psline[linecolor=white]{->}(11,0) |
| 4792 |
\uput[270](11,0){\textbf{\white$\lambda$(nm)}} |
| 4793 |
\end{pspicture}} |
| 4794 |
|
| 4795 |
\psframebox[fillstyle=solid,fillcolor=black]{% |
| 4796 |
\begin{pspicture}(-1,-0.5)(12,1) |
| 4797 |
\pstVerb{ |
| 4798 |
/lambda 656 def |
| 4799 |
lambda |
| 4800 |
tx@addDict begin wavelengthToRGB end |
| 4801 |
}% |
| 4802 |
\rput(! 656 0.025 mul 9.5 sub 0){\Touch} |
| 4803 |
\pstVerb{ |
| 4804 |
/lambda 486 def |
| 4805 |
lambda |
| 4806 |
tx@addDict begin wavelengthToRGB end |
| 4807 |
}% |
| 4808 |
\rput(! 486 0.025 mul 9.5 sub 0){\Touch} |
| 4809 |
\pstVerb{ |
| 4810 |
/lambda 434 def |
| 4811 |
lambda |
| 4812 |
tx@addDict begin wavelengthToRGB end |
| 4813 |
}% |
| 4814 |
\rput(! 434 0.025 mul 9.5 sub 0){\Touch} |
| 4815 |
\pstVerb{ |
| 4816 |
/lambda 410 def |
| 4817 |
lambda |
| 4818 |
tx@addDict begin wavelengthToRGB end |
| 4819 |
}% |
| 4820 |
\rput(! 410 0.025 mul 9.5 sub 0){\Touch} |
| 4821 |
\multido{\n=0+1,\iDiv=380+40}{11}{% |
| 4822 |
\psline[linecolor=white](\n,0.1)(\n,-0.1) |
| 4823 |
\uput[270](\n,0){\textbf{\white\iDiv}}} |
| 4824 |
\psline[linecolor=white]{->}(11,0) |
| 4825 |
\uput[270](11,0){\textbf{\white$\lambda$(nm)}} |
| 4826 |
\end{pspicture}} |
| 4827 |
|
| 4828 |
Spectrum of hydrogen emission (Manuel Luque) |
| 4829 |
\end{lstlisting} |
| 4830 |
|
| 4831 |
|
| 4832 |
|
| 4833 |
|
| 4834 |
|
| 4835 |
%-------------------------------------------------------------------------------------- |
| 4836 |
\section{Gouraud shading} |
| 4837 |
%-------------------------------------------------------------------------------------- |
| 4838 |
\begin{quotation} |
| 4839 |
\Index{Gouraud} shading is a method used in computer graphics to simulate the differing effects of |
| 4840 |
light and colour across the surface of an object. In practice, Gouraud shading is used to |
| 4841 |
achieve smooth lighting on low-polygon surfaces without the heavy computational requirements |
| 4842 |
of calculating lighting for each pixel. The technique was first presented by Henri Gouraud in 1971.\\ |
| 4843 |
~\hfill{\small \url{http://www.wikipedia.org}} |
| 4844 |
\end{quotation} |
| 4845 |
|
| 4846 |
PostScript level 3 supports this kind of shading and it can only |
| 4847 |
be seen with Acroread 7 or later. The syntax is easy: |
| 4848 |
|
| 4849 |
\begin{lstlisting}[style=syntax] |
| 4850 |
\psGTriangle(x1,y1)(x2,y2)(x3,y3){color1}{color2}{color3} |
| 4851 |
\end{lstlisting} |
| 4852 |
|
| 4853 |
\psset{unit=0.75cm} |
| 4854 |
|
| 4855 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4856 |
\begin{pspicture}(0,-.25)(10,10) |
| 4857 |
\psGTriangle(0,0)(5,10)(10,0){red}{green}{blue} |
| 4858 |
\end{pspicture} |
| 4859 |
\end{LTXexample} |
| 4860 |
|
| 4861 |
|
| 4862 |
|
| 4863 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4864 |
\begin{pspicture}(0,-.25)(10,10) |
| 4865 |
\psGTriangle*(0,0)(9,10)(10,3){black}{white!50}{red!50!green!95} |
| 4866 |
\end{pspicture} |
| 4867 |
\end{LTXexample} |
| 4868 |
|
| 4869 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4870 |
\begin{pspicture}(0,-.25)(10,10) |
| 4871 |
\psGTriangle*(0,0)(5,10)(10,0){-red!100!green!84!blue!86} |
| 4872 |
{-red!80!green!100!blue!40} |
| 4873 |
{-red!60!green!30!blue!100} |
| 4874 |
\end{pspicture} |
| 4875 |
\end{LTXexample} |
| 4876 |
|
| 4877 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4878 |
\definecolor{rose}{rgb}{1.00, 0.84, 0.88} |
| 4879 |
\definecolor{vertpommepasmure}{rgb}{0.80, 1.0, 0.40} |
| 4880 |
\definecolor{fushia}{rgb}{0.60, 0.30, 1.0} |
| 4881 |
\begin{pspicture}(0,-.25)(10,10) |
| 4882 |
\psGTriangle(0,0)(5,10)(10,0){rose}{vertpommepasmure}{fushia} |
| 4883 |
\end{pspicture} |
| 4884 |
\end{LTXexample} |
| 4885 |
|
| 4886 |
|
| 4887 |
\section{\Lcs{psCallout}} |
| 4888 |
|
| 4889 |
\begin{BDef} |
| 4890 |
\Lcs{psCallout}\OptArgs\Largr{$x_0,y_0$}\Largb{Text} |
| 4891 |
\end{BDef} |
| 4892 |
|
| 4893 |
Possible parameter are: |
| 4894 |
|
| 4895 |
\begin{description} |
| 4896 |
\item[tipAngle] The angle of the tip depending to the horizontal line. |
| 4897 |
\item[tipLength] The length of the tip from the coordinates to the box. |
| 4898 |
\item[tipWidth] The width of the tip end. |
| 4899 |
\item[tipPos] Relative position of the tip end to the width of the box. |
| 4900 |
\end{description} |
| 4901 |
|
| 4902 |
|
| 4903 |
|
| 4904 |
|
| 4905 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4906 |
\begin{pspicture}(-5.5,-1)(4,5.5) |
| 4907 |
\psaxes[labels=none,ticks=none]{->}(0,0)(-5,-1)(3.5,5)[$x$,-90][$y$,0] |
| 4908 |
\psyTick(1){1}\uput[225](0,0){0} |
| 4909 |
\psplot[algebraic,,yMaxValue=4.5,linecolor=red,linewidth=1.5pt]{-2.5}{3}{Euler^(-(x))} |
| 4910 |
\psCallout(1,0.5){\scriptsize $f(x)=e^{-x}$} |
| 4911 |
\psCallout[tipAngle=90](1,1.6){\scriptsize $f(x)=e^{-x}$} |
| 4912 |
\psCallout[tipLength=10mm](1,3){$f(x)=e^{-x}$} |
| 4913 |
\psCallout[tipLength=10mm,tipAngle=120,tipPos=0.8](-1,1){$f(x)=e^{-x}$} |
| 4914 |
\psCallout[tipAngle=120,fillcolor=red!40,fillstyle=solid](-4,3){% |
| 4915 |
\shortstack{Some math\\$f(x)=e^{-x}$}} |
| 4916 |
\end{pspicture} |
| 4917 |
\end{LTXexample} |
| 4918 |
|
| 4919 |
|
| 4920 |
|
| 4921 |
|
| 4922 |
\begin{LTXexample}[pos=t,preset=\centering] |
| 4923 |
\begin{pspicture}(-5.5,-1)(4,5.5) |
| 4924 |
\psaxes[labels=none,ticks=none]{->}(0,0)(-5,-1)(3.5,5)[$x$,-90][$y$,0] |
| 4925 |
\psyTick(1){1}\uput[225](0,0){0} |
| 4926 |
\psplot[algebraic,,yMaxValue=4.5,linecolor=red,linewidth=1.5pt]{-2.5}{3}{Euler^(-(x))} |
| 4927 |
\psset{linearc=0.4}% |
| 4928 |
\psCallout(1,0.5){\scriptsize $f(x)=e^{-x}$} |
| 4929 |
\psCallout[tipAngle=90](1,1.6){\scriptsize $f(x)=e^{-x}$} |
| 4930 |
\psCallout[tipLength=10mm](1,3){$f(x)=e^{-x}$} |
| 4931 |
\psCallout[tipLength=10mm,tipAngle=120,tipPos=0.8](-1,1){$f(x)=e^{-x}$} |
| 4932 |
\psCallout[tipAngle=120,fillcolor=red!40,fillstyle=solid](-4,3){% |
| 4933 |
\shortstack{Some math\\$f(x)=e^{-x}$}} |
| 4934 |
\end{pspicture} |
| 4935 |
\end{LTXexample} |
| 4936 |
|
| 4937 |
|
| 4938 |
|
| 4939 |
\section{Internal color macros} |
| 4940 |
The internal macros \Lcs{pswavelengthToRGB} and \Lcs{pswavelengthToRGB} can be used for own purposed. |
| 4941 |
They are defines as follows: |
| 4942 |
|
| 4943 |
\begin{lstlisting} |
| 4944 |
\def\pswavelengthToGRAY{ tx@addDict begin wavelengthToGRAY end } |
| 4945 |
\def\pswavelengthToRGB{ tx@addDict begin wavelengthToRGB Red Green Blue end } |
| 4946 |
\end{lstlisting} |
| 4947 |
|
| 4948 |
both macros leave the value(s) on the stack which then can be used for further |
| 4949 |
manipulating or setting the color with \Lps{setgray} or \Lps{setrgbcolor}. |
| 4950 |
For an example see Section~\ref{sec:psMatrix}. |
| 4951 |
|
| 4952 |
|
| 4953 |
|
| 4954 |
|
| 4955 |
\appendix |
| 4956 |
|
| 4957 |
|
| 4958 |
%-------------------------------------------------------------------------------------- |
| 4959 |
\clearpage |
| 4960 |
\section{\nxLcs{resetOptions}} |
| 4961 |
%-------------------------------------------------------------------------------------- |
| 4962 |
|
| 4963 |
Sometimes it is difficult to know what options, which are changed |
| 4964 |
inside a long document, are different to the default ones. With |
| 4965 |
this macro all options belonging to \LPack{pst-plot} can be reset. |
| 4966 |
This refers to all options of the packages \LPack{pstricks}, |
| 4967 |
\LPack{pst-plot} and \LPack{pst-node}. |
| 4968 |
|
| 4969 |
|
| 4970 |
|
| 4971 |
%-------------------------------------------------------------------------------------- |
| 4972 |
\section{PostScript} |
| 4973 |
%-------------------------------------------------------------------------------------- |
| 4974 |
|
| 4975 |
\Index{PostScript} uses the stack system and the LIFO system, "'Last In, First Out"`. |
| 4976 |
|
| 4977 |
\newlength{\Li}\settowidth{\Li}{Function} |
| 4978 |
\begin{table}[htbp] |
| 4979 |
\caption{Some primitive PostScript macros}\label{tab:primpost} |
| 4980 |
\centering |
| 4981 |
\ttfamily |
| 4982 |
\begin{tabular}{@{} l | r@{ $\rightarrow$ } l @{}}\hline |
| 4983 |
\multirow{2}{\Li}{\normalfont\emph{Function}} & \multicolumn{2}{ c }{\normalfont\emph{Meaning}}\\ |
| 4984 |
&\normalfont\emph{on stack before} & \normalfont\emph{after}\\\hline |
| 4985 |
\Lps{add} & $x\quad y$&$x+y$\\ |
| 4986 |
\Lps{sub} & $x\quad y$&$x-y$\\ |
| 4987 |
\Lps{mul} & $x\quad y$&$x\times y$\\ |
| 4988 |
\Lps{div} & $x\quad y$&$x\div y$\\ |
| 4989 |
\Lps{sqrt} & $x$&$\sqrt{x}$\\ |
| 4990 |
\Lps{abs} & $x$&$|x|$\\ |
| 4991 |
\Lps{neg} & $x$&$-x$\\ |
| 4992 |
\Lps{cos} & $x$&$\cos(x)$ ($x$ in degrees)\\ |
| 4993 |
\Lps{sin} & $x$&$\sin(x)$ ($x$ in degrees)\\ |
| 4994 |
\Lps{tan} & $x$&$\tan(x)$ ($x$ in degrees)\\ |
| 4995 |
\Lps{atan} & $y\quad x$&$\angle{(\vec{Ox};\vec{OM})}$ (in degrees of $M(x,y)$)\\ |
| 4996 |
\Lps{ln} & $x$&$\ln(x)$\\ |
| 4997 |
\Lps{log} & $x$&$\log(x)$\\ |
| 4998 |
\Lps{array} & $n$&\normalfont$v$ (of dimension $n$)\\ |
| 4999 |
\Lps{aload} & $v$&$x_1\quad x_2\quad \cdots\quad x_n\quad v$\\ |
| 5000 |
\Lps{astore} & $x_1\quad x_2\quad \cdots\quad x_n\quad v$ & $[v]$\\ |
| 5001 |
\Lps{pop} & $x$ & --\\ |
| 5002 |
\Lps{dup} & $x$ & $x\quad x$ \\\hline |
| 5003 |
% \Lps{roll} & $x_1\quad x_2\quad \cdots\quad x_n\quad n p$ &\\\hline |
| 5004 |
\end{tabular} |
| 5005 |
\end{table} |
| 5006 |
|
| 5007 |
|
| 5008 |
\clearpage |
| 5009 |
\section{List of all optional arguments for \texttt{pstricks-add}} |
| 5010 |
|
| 5011 |
\xkvview{family=pstricks-add,columns={key,type,default}} |
| 5012 |
|
| 5013 |
|
| 5014 |
\nocite{*} |
| 5015 |
\bgroup |
| 5016 |
\RaggedRight |
| 5017 |
\printbibliography |
| 5018 |
\egroup |
| 5019 |
|
| 5020 |
\printindex |
| 5021 |
|
| 5022 |
|
| 5023 |
|
| 5024 |
|
| 5025 |
\end{document} |
| 5026 |
|