root/trunk/pst-map3d/pstricks-add.tex

Revision 5, 108.5 kB (checked in by jms, 2 years ago)

Déplacement des fichiers de Manuel dans le répertoire pst-map3d.

Line 
1%% $Id: pstricks-add.tex 7 2007-12-29 22:21:13Z herbert $
2%%
3%%
4%% This is file `pstricks-add.tex',
5%%
6%% IMPORTANT NOTICE:
7%%
8%% Package `pstricks-add.tex'
9%%
10%% Dominique Rodriguez <DR _at_ pstricks.de>
11%% Herbert Voss <Herbert.Voss _at_ pstricks.de>
12%%
13%% This program can be redistributed and/or modified under the terms
14%% of the LaTeX Project Public License Distributed from CTAN archives
15%% in directory macros/latex/base/lppl.txt.
16%%
17%% DESCRIPTION:
18%%   `pstricks-add' is a PSTricks package for additionals to the standard
19%%         pstricks package
20%%
21\csname PSTricksAddLoaded\endcsname
22\let\PSTricksAddLoaded\endinput
23%
24% Requires some packages
25\ifx\PSTricksLoaded\endinput\else\input pstricks \fi
26\ifx\PSTplotLoaded\endinput\else \input pst-plot \fi
27\ifx\PSTnodesLoaded\endinput\else\input pst-node \fi
28\ifx\PSTthreeDLoaded\endinput\else\input pst-3d \fi
29\ifx\MultidoLoaded\endinput\else \input multido  \fi
30\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey \fi
31%
32\def\fileversion{3.00}
33\def\filedate{2008/01/01}
34\message{`pstricks-add' v\fileversion, \filedate\space (dr,hv)}
35%
36\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
37\SpecialCoor
38\pst@addfams{pstricks-add}
39%
40%% prologue for postcript
41\pstheader{pstricks-add.pro}%
42%\pstheader{pst-algparser.pro}%  done by pstricks.tex
43%
44%-------------------------------- pstricks ------------------------------------
45%
46%%%%%%% \begin{pspicture} %%%%%%%%%%%%%%%%%%%
47\newdimen\pst@dimm%
48\newdimen\pst@dimn%
49\newdimen\pst@dimo%
50\newdimen\pst@dimp%
51\newcount\pst@cntm%
52\newcount\pst@cntn%
53\newcount\pst@cnto%
54\newcount\pst@cntp%
55%\psset{dx=0}%
56%\psset{dy=0}%
57\newcount\@zero\@zero=0\relax
58\chardef\f@ur=4
59%
60\def\psPiFour{12.566371}
61\def\psPiTwo{6.283185}
62\def\psPi{3.14159265}
63\def\psPiH{1.570796327}
64\newdimen\pstRadUnit
65\newdimen\pstRadUnitInv
66\pstRadUnit=1.047198cm % this is pi/3
67\pstRadUnitInv=0.95493cm % this is 3/pi
68%
69\def\pst@getdimdim#1 #2 #3\@nil{%
70  \def\pst@tempA{#2}%
71  \ifx\pst@tempA\@empty
72    \pssetlength\pst@dimn{#1}%
73    \pst@dimm=\z@%
74  \else%
75    \pssetlength\pst@dimm{#1}%
76    \pssetlength\pst@dimn{#2}%
77  \fi%
78}
79\def\pst@getxdimdim#1 #2 #3\@nil{%
80  \def\pst@tempA{#2}%
81  \ifx\pst@tempA\@empty
82    \pssetxlength\pst@dimn{#1}%
83    \pst@dimm=\z@
84  \else%
85    \pssetxlength\pst@dimm{#1}%
86    \pssetxlength\pst@dimn{#2}%
87  \fi%
88}
89\def\pst@getydimdim#1 #2 #3\@nil{%
90  \def\pst@tempA{#2}
91  \ifx\pst@tempA\@empty
92    \pssetylength\pst@dimn{#1}
93    \pst@dimm=\z@
94  \else
95    \pssetylength\pst@dimm{#1}%
96    \pssetylength\pst@dimn{#2}%
97  \fi%
98}
99%
100% stolen from latex.ltx to make it TeX compatible
101%
102\def\@fornoop#1\@@#2#3{}
103\long\def\@for#1:=#2\do#3{%
104  \expandafter\def\expandafter\@fortmp\expandafter{#2}%
105  \ifx\@fortmp\@empty \else
106    \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi}
107\long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
108       #5\def#4{#2}\ifx #4\@nnil \else#5\@iforloop #3\@@#4{#5}\fi\fi}
109\long\def\@iforloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
110       \expandafter\@fornoop \else
111      #4\relax\expandafter\@iforloop\fi#2\@@#3{#4}}
112\def\psforeach#1#2#3{%
113  \begingroup
114    \edef\reserved@a{#2}%
115    \@for#1:=\reserved@a\do{#3}%
116  \endgroup%
117}
118%
119% A modulo macro for integer values
120% \pst@mod{34}{6}\value ==> \value is 4
121%
122\def\pst@mod#1#2#3{%
123  \begingroup%
124  \pst@cntm=#1\pst@cntn=#2\relax%
125  \pst@cnto=\pst@cntm%
126  \divide\pst@cntm by \pst@cntn%
127  \multiply\pst@cntn by \pst@cntm%
128  \advance\pst@cnto by -\pst@cntn%
129  \edef\value{\endgroup\def\noexpand#3{\number\pst@cnto}}\value%
130}
131\def\pst@max#1#2#3{%
132  \begingroup%
133  \pst@cntm=#1\pst@cntn=#2\relax%
134  \ifnum\pst@cntm<\pst@cntn\pst@cntm=\pst@cntn\fi
135  \global#3=\the\pst@cntm%
136  \endgroup%
137}
138\def\pst@maxdim#1#2#3{%
139  \begingroup%
140  \pst@dimm=#1\pst@dimn=#2\relax%
141  \ifdim\pst@dimm<\pst@dimn\pst@dimm=\pst@dimn\fi
142  \global#3=\the\pst@dimm%
143  \endgroup%
144}
145\def\pst@abs#1#2{%
146  \begingroup%
147  \pst@cntm=#1\relax%
148  \ifnum\pst@cntm<\z@\pst@cntm=-\pst@cntm\fi%
149  \global#2=\the\pst@cntm
150  \endgroup%
151}
152\def\pst@absdim#1#2{%
153  \begingroup%
154  \pst@dimm=#1\relax%
155  \ifdim\pst@dimm<\z@\pst@dimm=-\pst@dimm\fi%
156  \global#2=\the\pst@dimm%
157  \endgroup%
158}
159%
160%--------------------------------------- small stuff -------------------------------
161\define@boolkey[psset]{pstricks-add}[Pst@]{CMYK}[true]{}
162\psset[pstricks-add]{CMYK=true}
163%
164\def\defineTColor{\@ifnextchar[{\defineTColor@i}{\defineTColor@i[]}}
165\def\defineTColor@i[#1]#2#3{%     "semi transparency colors"
166  \def\pst@tempA{#1}%
167  \newpsstyle{#2}{%
168     fillstyle=vlines,hatchwidth=0.1\pslinewidth,
169     hatchsep=1\pslinewidth,hatchcolor=#3}%
170  \ifx\pst@tempA\@empty\else\psset{#1}\fi%
171}
172\defineTColor{TRed}{red}
173\defineTColor{TGreen}{green}
174\defineTColor{TBlue}{blue}
175%
176\define@key[psset]{pstricks-add}{fsAngle}{\pst@getangle{#1}\pst@fsAngle }
177\define@key[psset]{pstricks-add}{fsOrigin}{%
178  \pst@@getcoor{#1}\edef\pst@fsOrigin{\pst@coor T }}
179\psset[pstricks-add]{fsOrigin={0,0},fsAngle=137.50775}
180%
181\def\psfs@spiral{\pst@fill{\pst@fsOrigin \pst@usecolor\psfillcolor clip newpath
1820 .1 500 { dup dup sqrt 4 div 0 360 arc fill \pst@fsAngle rotate } for }}
183%
184\def\rmultiput{\def\pst@par{}\pst@ifstar{\@ifnextchar[{\rmultiput@i}{\rmultiput@i[]}}}
185\def\rmultiput@i[#1]{\begingroup\psset{#1}\rmultiput@ii}
186\def\rmultiput@ii#1{\def\@rmultiputArg{#1}%
187  \@ifnextchar({\rmultiput@iii}{\rmultiput@iii(\z@,\z@)}}
188\def\rmultiput@iii(#1){%
189  \pst@killglue%
190  \if@star\rput*(#1){\@rmultiputArg}
191  \else\rput(#1){\@rmultiputArg}\fi
192  \@ifnextchar({\rmultiput@iii}{\endgroup}%
193}
194
195% #1: (x,y)  #2: rotAngle   #3: object
196\def\psrotate{\pst@object{psrotate}}
197\def\psrotate@i(#1)#2{%
198  \pst@killglue
199  \begingroup%
200  \use@par\pst@makebox{\psrotate@ii(#1){#2}}}
201\def\psrotate@ii(#1)#2{%
202  \pst@getcoor{#1}\pst@tempA%
203  \pst@getangle{#2}\pst@tempB%
204  \leavevmode%
205  \pst@Verb{%
206     { \pst@tempA /yRot ED /xRot ED
207       \pst@tempB dup cos /cosA ED sin /sinA ED
208       /ax cosA def
209       /by sinA def
210       /cx sinA neg def
211       /dy cosA def
212       /ex xRot cosA mul neg xRot add yRot sinA mul add def
213       /fy xRot sinA mul neg yRot add yRot cosA mul sub def
214       [ax by cx dy ex fy] concat } \tx@TMChange }%
215    \box\pst@hbox%
216  \pst@Verb{ \tx@TMRestore }\endgroup}
217%
218% [#1]: obtargs; (#2,#3): center; {#4}: factor; {#5}: object
219\def\psHomothetie{\pst@object{psHomothetie}}
220\def\psHomothetie@i(#1)#2{%
221  \begin@SpecialObj%
222  \pst@getcoor{#1}\pst@tempA% converts the coordinates without a unit into pt
223  \pst@makebox{\psHomothetie@ii{#2}}}% put the contents into a box
224\def\psHomothetie@ii#1{%
225  \pst@Verb{%
226    { \pst@tempA  /yH ED /xH ED 
227      [#1 0 0 #1 #1 xH mul neg xH add #1 yH mul neg yH add] concat }
228      \tx@TMChange }%
229  \box\pst@hbox%
230  \pst@Verb{\tx@TMRestore}%
231  \end@SpecialObj}
232%
233%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234%% Begin patch TN; Date (YY-MM-DD): 04-07-17; first part
235\define@key[psset]{}{dash}{%    defined in pstricks.tex
236  \pst@expandafter\psset@@dash{#1}\@nil% Error handling for empty argument.
237}
238\define@key[psset]{pstricks-add}{maxdashes}{\def\psk@maxdashes{#1}}
239%\psset{maxdashes=11}
240\def\psset@@dash#1\@nil{%
241 \def\psk@dash{}%
242 % modification 04-08-07:
243 \pst@cntm0
244 \def\next##1 ##2\relax{%
245   \expandafter\ifnum\psk@maxdashes>\pst@cntm\relax  % 04-08-07
246     \edef\@tempa{##1}%
247     \ifx\@tempa\@empty\else% gobble leading spaces
248       \pssetlength\pst@dimc{##1}%
249       \advance\pst@cntm by 1
250       \edef\psk@dash{\psk@dash\space\pst@number\pst@dimc}%
251     \fi%
252     \edef\@tempa{##2}%
253     \ifx\@tempa\@empty\else% detect end
254       \ifx\@tempa\space\else% gobble trailing spaces
255         \next##2\relax%
256     \fi\fi%
257   \else% 04-08-07
258     \@pstrickserr{Number of dashes > \psk@maxdashes. Increasing
259        'maxdashes' might work.}\@ehpa% 04-08-07
260   \fi% 04-08-07
261 }%
262\expandafter\next#1 \relax}
263%% End patch TN; Date (YY-MM-DD): 04-07-17; 1st part
264%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265%
266%\psset{dash=5pt 3pt}% black white black white
267%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268%% Begin patch TN; Date (YY-MM-DD): 04-07-17; 2nd part
269\def\psls@dashed{%
270  \ifpsdashadjust
271    [ \psk@dash ] \pst@linetype\space \tx@DashLine
272  \else
273    [ \psk@dash ] 0 setdash stroke
274  \fi}
275%% End patch TN; Date (YY-MM-DD): 04-07-17; 2nd part
276%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277%-----------------------------------------------------------------------------------
278\pst@def{DashLine}<
279    dup 0 gt
280    { /a .5 def PathLength exch div }
281    { pop /a 1 def PathLength } ifelse
282    /b ED % pattern should fit evenly in b
283    dup /X ED % pattern array
284    0 get /y ED % length of first black segment
285    /z 0 X {add} forall def % length of the full pattern
286    %% Computation of the scaling factor as described by van Zandt:
287    b a .5 sub 2 mul y mul sub z Div round
288    z mul a .5 sub 2 mul y mul add b exch Div
289    %%%% scaling factor on stack.
290    /z ED %% now, z is the scaling factor
291    false % for the length test below
292    X { z mul } forall X astore %% modification TN 04-08-07
293    %%% Checking whether at least one dash in X has positive length:
294    {0 gt or} forall
295    { X 1 a sub y mul }
296    { [ 1 0 ] 0 }
297    ifelse
298    setdash stroke >
299%% TN end patch; Date (YY-MM-DD): 04-07-17;
300%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301%
302\define@key[psset]{pstricks-add}{intSeparator}{\def\psk@intSeparator{#1}}
303%\psset{intSeparator={,}}
304%
305\def\psFormatInt{\def\pst@par{}\pst@object{psFormatInt}}
306\def\psFormatInt@i#1{{%
307  \pst@killglue
308  \use@par
309  \count1=#1\count2=\count1
310  \ifnum\count1=0 0\else
311    \ifnum\count1>999999
312    \count3=\count1
313    \divide\count3 by 1000000
314    \the\count3\psk@intSeparator\relax
315    \multiply\count3 by 1000000
316    \advance\count1 by -\count3 % modulo 1000000
317  \fi%
318  \ifnum\count2>999
319    \count3=\count1
320    \divide\count3 by 1000
321    \ifnum\count2>99999
322        \ifnum\count3<100 0\fi
323        \ifnum\count3<10 0\fi
324    \fi%
325    \the\count3\psk@intSeparator\relax
326    \multiply\count3 by 1000
327    \advance\count1 by -\count3 %modulo 1000
328  \fi%
329  \ifnum\count2>999
330    \ifnum\count1<100 0\fi
331    \ifnum\count1<10 0\fi
332  \fi%
333  \the\count1
334  \fi%
335}\ignorespaces}
336%
337\define@key[psset]{pstricks-add}{braceWidth}{\pst@getlength{#1}\psk@braceWidth}
338\define@key[psset]{pstricks-add}{bracePos}{\pst@checknum{#1}\psk@bracePos}
339\define@key[psset]{pstricks-add}{braceWidthInner}{\pst@getlength{#1}\psk@braceWidthInner}
340\define@key[psset]{pstricks-add}{braceWidthOuter}{\pst@getlength{#1}\psk@braceWidthOuter}
341%
342\def\psbrace{\pst@object{psbrace}}
343\def\psbrace@i(#1)(#2)#3{%
344  \addbefore@par{ref=lb,linewidth=0.01pt,fillstyle=solid,fillcolor=black}
345  \begin@SpecialObj
346  \if@star\def\pst@tempC{true }\else\def\pst@tempC{false }\fi
347  \ifx\psk@rot\empty\def\psk@@rot{0}\else\let\psk@@rot\psk@rot\fi
348  \def\psk@rot{Alpha \psk@@rot\space add 90 sub}%
349  \pst@getcoor{#1}\pst@tempA
350  \pst@getcoor{#2}\pst@tempB
351  \rput(!
352    /ifStar \pst@tempC def
353    /radius1 \psk@braceWidthOuter def
354    /radius2 \psk@braceWidthInner def
355    /Alpha \pst@tempA \pst@tempB 3 -1 roll sub 3 1 roll exch sub atan def
356    /Length \pst@tempA \pst@tempB Pyth2 def
357    /Left { Length \psk@bracePos\space mul } bind def
358    /Right { Length Left sub } bind def
359    /Width \psk@braceWidth def
360    /pop4 { pop pop pop pop } def
361    gsave
362    [ Alpha cos Alpha sin Alpha sin neg Alpha cos \pst@tempA ] concat
363    0 0 moveto
364    0 radius2 neg radius2 radius2 neg radius2 arcto pop4
365    Left radius2 sub radius1 sub 0 rlineto
366    Left radius2 neg Left radius2 radius1 add neg radius1 arcto pop4
367    currentpoint /y@Label ED /x@Label ED
368    Left radius2 neg Left radius1 add radius2 neg radius1 arcto pop4
369    Right radius2 sub radius1 sub 0 rlineto
370    Length radius2 neg Length 0 radius2 arcto pop4
371%    0 Width neg rlineto
372    Length radius2 Width add neg Length radius2 sub radius2 Width add neg radius2 arcto pop4
373    Right radius2 sub radius1 sub neg 0 rlineto
374    Left radius1 add Width radius1 add radius2 add neg radius1 90 180 arc
375    Left radius1 sub Width radius1 add radius2 add neg radius1 0 90 arc
376    Left radius2 sub radius1 sub neg 0 rlineto
377    radius2 Width neg radius2 270 180 arcn
378    0 0 lineto
379    gsave
380    ifStar { \pst@usecolor\pslinecolor }{ \pst@usecolor\psfillcolor } ifelse fill
381    grestore
382    0.01 setlinewidth \pst@usecolor\pslinecolor stroke
383    0 0 moveto
384    grestore
385%   now calculate the label pos
386    /Dh radius1 radius2 add Width add def
387    \pst@tempA \pst@tempB 3 -1 roll sub 3 1 roll exch sub % dy dx
388    \psk@bracePos\space mul exch \psk@bracePos\space mul  % d'x d'y
389    \pst@tempA 3 -1 roll add Dh Alpha cos mul sub         % d'x x yA
390    \psk@nodesepB sub                                     % use minus sign to shidt right
391    3 1 roll add Dh Alpha sin mul add \psk@nodesepA add
392    exch \tx@UserCoor ){#3}
393  \end@SpecialObj}
394%
395% -------------- the arrow part -------------
396%  the original table
397% \def\pst@arrowtable{,<->,<<->>,>-<,>>-<<,(-),[-],)-(,]-[,|>-<|}
398%
399% v : Vee arrow (inside)                 v,V,f and F by Christophe FOUREY
400% V : Vee arrow (outside)
401% f : Filled vee arrow (inside)
402% F : Filled vee arrow (outside)
403\edef\pst@arrowtable{\pst@arrowtable,v-v,V-V,f-f,F-F,t-t,T-T}
404
405% Vee arrow
406\define@key[psset]{pstricks-add}{veearrowlength}{\pst@getlength{#1}\psk@veearrowlength}
407\psset[pstricks-add]{veearrowlength=3mm} % default projected length
408\define@key[psset]{pstricks-add}{veearrowangle}{\pst@getangle{#1}\psk@veearrowangle}
409\psset[pstricks-add]{veearrowangle=30} % default angle
410\define@key[psset]{pstricks-add}{veearrowlinewidth}{\pst@getlength{#1}\psk@veearrowlinewidth}
411\psset[pstricks-add]{veearrowlinewidth=.35mm} % default vee arrow line width
412
413% Filled vee arrow
414\define@key[psset]{pstricks-add}{filledveearrowlength}{\pst@getlength{#1}\psk@filledveearrowlength}
415\psset[pstricks-add]{filledveearrowlength=3mm} % default projected length
416\define@key[psset]{pstricks-add}{filledveearrowangle}{\pst@getangle{#1}\psk@filledveearrowangle}
417\psset[pstricks-add]{filledveearrowangle=15} % default angle
418\define@key[psset]{pstricks-add}{filledveearrowlinewidth}{\pst@getlength{#1}\psk@filledveearrowlinewidth}
419\psset[pstricks-add]{filledveearrowlinewidth=.35mm} % default vee arrow line width
420\define@key[psset]{pstricks-add}{arrowLW}{\pst@getlength{#1}\psk@arrowLW}
421% arrowLW as LineWidth for the circled line ends
422%
423\def\psas@o{\psk@arrowLW\space dup 0 eq { pop }{ SLW } ifelse
424  {\pst@usecolor\psfillcolor true} false \psk@dotsize \tx@EndDot }
425\@namedef{psas@*}{\psk@arrowLW\space dup 0 eq { pop }{ SLW } ifelse
426  {\pst@usecolor\psfillcolor false} false \psk@dotsize \tx@EndDot}
427
428\pst@def{VeeArrow}<%
429    1 setlinecap            % round caps
430    1 setlinejoin            % round join
431    setlinewidth            % vee arrow line width
432    /y ED                % projected length
433    2 div /a ED                % angle (divide by 2)
434    /t ED                % false = inside, true = outside
435    a sin a cos div y mul /x ED        % perpendicular length : x=tan(a).y
436    t { 1 -1 scale } if            % if outside : symmetry
437    x neg y moveto            % point #1
438    0 0 L                % point #2
439    x y L                % point #3
440    {closepath gsave fill grestore} if    % if filled : close and fill
441    stroke                % draw line
442    0 t {y 2 mul} {0} ifelse moveto>    % if outside : twice longer line
443
444% VeeArrow : filled?   outside?   (total) angle   (projected) length   (arrow) line width
445
446\@namedef{psas@v}{%
447  false false \psk@veearrowangle \psk@veearrowlength \psk@veearrowlinewidth \tx@VeeArrow}
448\@namedef{psas@V}{%
449  false true \psk@veearrowangle \psk@veearrowlength \psk@veearrowlinewidth \tx@VeeArrow}
450\@namedef{psas@f}{%
451  true false \psk@filledveearrowangle \psk@filledveearrowlength \psk@filledveearrowlinewidth \tx@VeeArrow}
452\@namedef{psas@F}{%
453  true true \psk@filledveearrowangle \psk@filledveearrowlength \psk@filledveearrowlinewidth \tx@VeeArrow}
454
455% And An another arrowhead
456% architectural tick / oblique arrow
457
458% Tick arrow
459\define@key[psset]{pstricks-add}{tickarrowlength}{\pst@getlength{#1}\psk@tickarrowlength}
460\psset[pstricks-add]{tickarrowlength=1.5mm} % default projected length
461\define@key[psset]{pstricks-add}{tickarrowlinewidth}{\pst@getlength{#1}\psk@tickarrowlinewidth}
462\psset[pstricks-add]{tickarrowlinewidth=.35mm} % default tick arrow line width
463
464\pst@def{TickArrow}<%
465    1 setlinecap            % round caps
466    1 setlinejoin            % round join
467    setlinewidth            % tick line width
468    /y ED                % projected length
469    /t ED                % false = normal, true = reversed
470    t { 1 -1 scale } if            % if reversed : symmetry
471    y neg y moveto            % point #1
472    y y neg L                % point #2
473    stroke                % draw line
474    0 0 moveto>                % origin
475
476\@namedef{psas@t}{ false \psk@tickarrowlength \psk@tickarrowlinewidth \tx@TickArrow }
477\@namedef{psas@T}{ true \psk@tickarrowlength \psk@tickarrowlinewidth \tx@TickArrow }
478%
479% HookLeft/RightArrow
480\newdimen\pshooklength
481\newdimen\pshookwidth
482\define@key[psset]{pstricks-add}{hooklength}{\pssetlength\pshooklength{#1}}
483\define@key[psset]{pstricks-add}{hookwidth}{\pssetlength\pshookwidth{#1}}
484%\psset{hooklength=3mm,hookwidth=1mm}
485%
486\edef\pst@arrowtable{\pst@arrowtable,H-H,h-h} % add new arrow
487\def\tx@RHook{RHook }         % PostScript name
488\def\tx@Rhook{Rhook }         % PostScript name
489\@namedef{psas@H}{%
490  /RHook {
491    /x ED                     % hook width
492    /y ED                     % hook length
493    /z CLW 2 div def          % save it
494    x y moveto                % goto first point
495    x 0 0 0 0 y
496    curveto                   % draw Bezier
497    stroke
498    0 y moveto                % define current point
499  } def
500  \pst@number\pshooklength
501  \pst@number\pshookwidth
502  \tx@RHook
503}
504\@namedef{psas@h}{%
505  /Rhook {
506    CLW mul                     % size * CLW
507    add dup                     % +length  size*CLW+length size*CLW+length
508    2 div /w ED                 % (size*CLW+length)/2  -> w
509    mul dup /h ED mul           % (size*CLW+length)
510    /a ED 
511    w neg h abs moveto 0 0 L
512    gsave
513    stroke grestore
514  } def
515  0 \psk@arrowlength \psk@arrowsize \tx@Rhook
516}
517% New parameter "arrowfill", with default as "true"
518\define@boolkey[psset]{pstricks-add}[ps]{ArrowFill}[true]{}
519%
520% Modification of the PostScript macro Arrow to choose to fill or not the arrow
521% (it require to restore the current linewidth, despite of the scaling)
522\pst@def{Arrow}<{%
523    CLW mul add dup 2 div
524    /w ED mul dup
525    /h ED mul
526    /a ED { 0 h T 1 -1 scale } if
527    gsave
528    \ifpsArrowFill\else\pst@number\pslinewidth \pst@arrowscale\space div SLW \fi
529    w neg h moveto
530    0 0 L w h L w neg a neg rlineto
531    \ifpsArrowFill gsave fill grestore \else gsave closepath stroke grestore \fi
532    grestore
533    0 h a sub moveto
534}>
535%
536\define@key[psset]{pstricks-add}{nArrowsA}{\def\psk@nArrowsA{#1}}
537\define@key[psset]{pstricks-add}{nArrowsB}{\def\psk@nArrowsB{#1}}
538\define@key[psset]{pstricks-add}{nArrows}{\def\psk@nArrowsA{#1}\def\psk@nArrowsB{#1}}
539%\psset{nArrows=2}
540%
541\@namedef{psas@>>}{%
542    \psk@nArrowsA\space 1 sub {
543      false \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@Arrow
544      0 h a sub T
545    } repeat
546    gsave
547    newpath
548    false \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@Arrow
549    CP
550    grestore
551    moveto
552}
553%
554\@namedef{psas@<<}{%
555    true \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@Arrow
556    0 h neg a add T
557  \psk@nArrowsB\space 2 sub {
558    false \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@Arrow
559    0 h neg a add T
560  } repeat
561  false \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@Arrow
562  0 h a 5 mul 2 div sub moveto
563}
564%
565% DG addition begin - Dec. 18/19, 1997 and Oct. 11, 2002
566% Adapted from \psset@arrows
567\define@key[psset]{pstricks-add}{ArrowInside}{%
568  \def\pst@tempArrow{#1}%
569  \ifx\pst@tempArrow\@empty \def\psk@ArrowInside{} %
570  \else%
571    \begingroup%
572      \pst@activearrows%
573      \xdef\pst@tempg{<#1}%
574    \endgroup%
575    \expandafter\psset@@ArrowInside\pst@tempg\@empty-\@empty\@nil%
576    \if@pst\else\@pstrickserr{Bad intermediate arrow specification: #1}\@ehpa\fi%
577  \fi%
578}
579% Adapted from \psset@@arrows
580\def\psset@@ArrowInside#1-#2\@empty#3\@nil{%
581  \@psttrue
582  \def\next##1,#1-##2,##3\@nil{\def\pst@tempg{##2}}%
583  \expandafter\next\pst@arrowtable,#1-#1,\@nil
584  \@ifundefined{psas@#2}%
585    {\@pstfalse\def\psk@ArrowInside{}}%
586    {\def\psk@ArrowInside{#2}}%
587}
588% Default value empty
589\psset{ArrowInside={}}
590% Modified version of \pst@addarrowdef
591\def\pst@addarrowdef{%
592  \addto@pscode{%
593    /ArrowA {
594      \ifx\psk@arrowA\@empty
595        \pst@oplineto
596      \else
597        \pst@arrowdef{A}
598        moveto
599      \fi
600    } def
601    /ArrowB { 
602      \ifx\psk@arrowB\@empty \else \pst@arrowdef{B} \fi 
603    } def
604% DG addition
605    /ArrowInside { 
606      \ifx\psk@ArrowInside\@empty \else \pst@arrowdefA{Inside} \fi 
607    } def
608  }%
609}
610% Adapted from \pst@arrowdef
611\def\pst@arrowdefA#1{%
612  \ifnum\pst@repeatarrowsflag>\z@
613    /Arrow#1c [ 6 2 roll ] cvx def Arrow#1c
614  \fi   
615  \tx@BeginArrow
616  \psk@arrowscale
617  \@nameuse{psas@\@nameuse{psk@Arrow#1}}
618  \tx@EndArrow%
619}
620% ArrowInsidePos parameter (default value 0.5)
621\define@key[psset]{pstricks-add}{ArrowInsidePos}{\pst@checknum{#1}\psk@ArrowInsidePos}%
622%\psset{ArrowInsidePos=0.5}
623%
624% Modified version of \begin@ClosedObj
625\def\begin@ClosedObj{%
626  \leavevmode%
627  \pst@killglue%
628  \begingroup%
629  \use@par%
630  \solid@star%
631  \ifpsdoubleline\pst@setdoublesep\fi%
632  \pst@addarrowdef% DG addition
633  \init@pscode}
634%
635% Redefinition of the PostScript /Line macro to print the intermediate
636% arrow on each segment of the line
637%
638\define@key[psset]{pstricks-add}{ArrowInsideNo}{\pst@checknum{#1}\psk@ArrowInsideNo}% hv 20031001
639\define@key[psset]{pstricks-add}{ArrowInsideOffset}{\pst@checknum{#1}\psk@ArrowInsideOffset}% hv 20031001
640%\psset{ArrowInsideNo=1,ArrowInsideOffset=0}
641%
642\def\arrowType@H{H}
643\pst@def{Line}<
644  NArray n 0 eq not { n 1 eq { 0 0 /n 2 def } if
645  (\psk@ArrowInside) length 0 gt { 
646    \ifx\psk@arrowA\arrowType@H   % do we have a Hook arrow at the beginning?
647      \pst@number\pshooklength  % yes
648    \else
649      \psk@arrowsize\space CLW mul add dup \psk@arrowlength\space mul exch \psk@arrowinset mul neg add 
650    \fi
651    /arrowlength exch def
652    4 copy                              % copy all four values for the arrow line
653    /y1 ED /x1 ED /y2 ED /x2 ED         % save them
654    /Alpha y2 y1 sub x2 x1 sub Atan def % the gradient of the line
655%    2 copy /y1 ED /x1 ED ArrowA x1 y1 
656    ArrowA                              % draw arrowA
657    x1 Alpha cos arrowlength mul add    % dx add
658    y1 Alpha sin arrowlength mul add    % dy add, to get the current point at the end of the arrow tip
659    /n n 1 sub def
660    n {
661      4 copy
662      /y1 ED /x1 ED /y2 ED /x2 ED
663      x1 y1
664      \psk@ArrowInsidePos\space 1 gt {
665        /Alpha y2 y1 sub x2 x1 sub Atan def
666        /ArrowPos \psk@ArrowInsideOffset\space def
667        /Length x2 x1 sub y2 y1 sub Pyth def
668        /dArrowPos \psk@ArrowInsidePos\space abs def
669        {
670          /ArrowPos ArrowPos dArrowPos add def
671          ArrowPos Length gt { exit } if
672          x1 Alpha cos ArrowPos mul add
673          y1 Alpha sin ArrowPos mul add
674          ArrowInside
675          pop pop
676        } loop
677      }{
678        /ArrowPos \psk@ArrowInsideOffset\space def
679        /dArrowPos \psk@ArrowInsideNo 1 gt {%
680          1.0 \psk@ArrowInsideNo 1.0 add div
681        }{\psk@ArrowInsidePos } ifelse def
682          \psk@ArrowInsideNo\space cvi {
683            /ArrowPos ArrowPos dArrowPos add def
684            x2 x1 sub ArrowPos mul x1 add
685            y2 y1 sub ArrowPos mul y1 add
686            ArrowInside
687            pop pop
688          } repeat
689      } ifelse
690      pop pop Lineto
691    } repeat
692  }{ ArrowA /n n 2 sub def n { Lineto } repeat } ifelse
693  CP 4 2 roll ArrowB L pop pop } if >
694%
695% Redefinition of the PostScript /Polygon macro to print the intermediate
696% arrow on each segment of the line
697\pst@def{Polygon}<{%
698    NArray n 2 eq { 0 0 /n 3 def } if
699    n 3 lt {
700        n { pop pop } repeat
701    }{
702        n 3 gt { CheckClosed } if
703        n 2 mul -2 roll
704        /y0 ED
705        /x0 ED
706        /y1 ED
707        /x1 ED
708        /xx1 x1 def
709        /yy1 y1 def
710        x1 y1
711        /x1 x0 x1 add 2 div def
712        /y1 y0 y1 add 2 div def
713        x1 y1 moveto
714        /n n 2 sub def
715        /drawArrows {
716            x11 y11
717            \psk@ArrowInsidePos\space 1 gt {
718                /Alpha y12 y11 sub x12 x11 sub atan def
719                /ArrowPos \psk@ArrowInsideOffset\space def
720                /Length x12 x11 sub y12 y11 sub Pyth def
721                /dArrowPos \psk@ArrowInsidePos\space abs def
722                {
723                    /ArrowPos ArrowPos dArrowPos add def
724                    ArrowPos Length gt { exit } if
725                    x11 Alpha cos ArrowPos mul add
726                    y11 Alpha sin ArrowPos mul add
727                    currentdict /ArrowInside known { ArrowInside } if
728                    pop pop
729                } loop
730            }{
731                /ArrowPos \psk@ArrowInsideOffset\space def
732                /dArrowPos \psk@ArrowInsideNo\space 1 gt {%
733                    1.0 \psk@ArrowInsideNo\space 1.0 add div
734                }{ \psk@ArrowInsidePos } ifelse def
735                \psk@ArrowInsideNo\space cvi {
736                    /ArrowPos ArrowPos dArrowPos add def
737                    x12 x11 sub ArrowPos mul x11 add
738                    y12 y11 sub ArrowPos mul y11 add
739                    currentdict /ArrowInside known { ArrowInside } if
740                    pop pop
741                } repeat
742            } ifelse
743            pop pop Lineto
744        } def
745        n {
746            4 copy
747            /y11 ED /x11 ED /y12 ED /x12 ED
748            drawArrows
749        } repeat
750        x1 y1 x0 y0
751        6 4 roll
752        2 copy
753        /y11 ED /x11 ED /y12 y0 def /x12 x0 def
754        drawArrows
755        /y11 y0 def /x11 x0 def /y12 yy1 def /x12 xx1 def
756        drawArrows
757        pop pop
758        closepath
759    } ifelse %
760}>
761%
762%
763% Redefinition of the PostScript /OpenBezier macro to print the intermediate
764% arrow
765\pst@def{OpenBezier}<{%
766  /dArrowPos \psk@ArrowInsideNo 1 gt {%
767    1.0 \psk@ArrowInsideNo 1.0 add div
768    }{ \psk@ArrowInsidePos } ifelse def
769      BezierNArray
770      n 1 eq { pop pop
771      }{ 2 copy
772        /y0 ED /x0 ED
773        ArrowA
774        n 4 sub 3 idiv { 6 2 roll 4 2 roll curveto } repeat
775        6 2 roll
776        4 2 roll
777        ArrowB
778        /y3 ED /x3 ED /y2 ED /x2 ED /y1 ED /x1 ED
779        /cx x1 x0 sub 3 mul def
780        /cy y1 y0 sub 3 mul def
781        /bx x2 x1 sub 3 mul cx sub def
782        /by y2 y1 sub 3 mul cy sub def
783        /ax x3 x0 sub cx sub bx sub def
784        /ay y3 y0 sub cy sub by sub def
785        /getValues {
786          ax t0 3 exp mul bx t0 t0 mul mul add cx t0 mul add x0 add
787          ay t0 3 exp mul by t0 t0 mul mul add cy t0 mul add y0 add
788          ax t 3 exp mul bx t t mul mul add cx t mul add x0 add
789          ay t 3 exp mul by t t mul mul add cy t mul add y0 add
790        } def
791        /getdL {
792          getValues
793          3 -1 roll sub 3 1 roll sub Pyth
794        } def
795        /CurveLength {
796          /u 0 def
797          /du 0.01 def
798          0 100 {
799            /t0 u def
800            /u u du add def
801            /t u def
802            getdL add
803          } repeat } def
804          /GetArrowPos {
805            /ende \psk@ArrowInsidePos\space 1 gt
806              {ArrowPos}
807              {ArrowPos CurveLength mul} ifelse def
808            /u 0 def
809            /du 0.01 def
810            /sum 0 def
811            { /t0 u def
812              /u u du add def
813              /t u def
814              /sum getdL sum add def
815              sum ende gt {exit} if
816            } loop u
817          } def
818          /ArrowPos \psk@ArrowInsideOffset\space def
819          /loopNo \psk@ArrowInsidePos\space 1 gt {%
820            CurveLength \psk@ArrowInsidePos\space div cvi
821          }{ \psk@ArrowInsideNo } ifelse def
822            loopNo cvi {
823              /ArrowPos ArrowPos dArrowPos add def
824              /t GetArrowPos def
825              /t0 t 0.95 mul def
826              getValues
827              ArrowInside pop pop pop pop
828            } repeat
829            x1 y1 x2 y2 x3 y3 curveto
830  } ifelse
831}>
832%
833% Redefinition of the PostScript /NCLine macro to print the intermediate
834% arrow of the line
835\pst@def{NCLine}<{%
836        NCCoor
837        tx@Dict begin
838        ArrowA CP 4 2 roll ArrowB
839        4 copy
840        /y2 ED /x2 ED /y1 ED /x1 ED
841        x1 y1
842        \psk@ArrowInsidePos\space 1 gt {
843                /Alpha y2 y1 sub x2 x1 sub atan def
844                /ArrowPos \psk@ArrowInsideOffset\space def
845                /Length x2 x1 sub y2 y1 sub Pyth def
846                /dArrowPos \psk@ArrowInsidePos\space abs def
847                {%
848                        /ArrowPos ArrowPos dArrowPos add def
849                        ArrowPos Length gt { exit } if
850                        x1 Alpha cos ArrowPos mul add
851                        y1 Alpha sin ArrowPos mul add
852                        ArrowInside
853                        pop pop
854                } loop
855        }{%
856                /ArrowPos \psk@ArrowInsideOffset\space def
857                /dArrowPos \psk@ArrowInsideNo 1 gt {%
858                        1.0 \psk@ArrowInsideNo 1.0 add div
859                }{ \psk@ArrowInsidePos } ifelse def
860                \psk@ArrowInsideNo\space cvi {
861                        /ArrowPos ArrowPos dArrowPos add def
862                        x2 x1 sub ArrowPos mul x1 add
863                        y2 y1 sub ArrowPos mul y1 add
864                        ArrowInside
865                        pop pop
866                } repeat
867        } ifelse
868        pop pop lineto pop pop
869        end%
870}>
871%
872\pst@def{NCCurve}<{%
873        GetEdgeA GetEdgeB
874        xA1 xB1 sub yA1 yB1 sub
875        Pyth 2 div dup 3 -1 roll mul
876        /ArmA ED
877        mul
878        /ArmB ED
879        /ArmTypeA 0 def
880        /ArmTypeB 0 def
881        GetArmA GetArmB
882        xA2 yA2 xA1 yA1
883        2 copy
884        /y0 ED /x0 ED
885        tx@Dict begin
886                ArrowA
887        end
888        xB2 yB2 xB1 yB1
889        tx@Dict begin
890                ArrowB
891        end
892        /y3 ED /x3 ED /y2 ED /x2 ED /y1 ED /x1 ED
893        /cx x1 x0 sub 3 mul def
894        /cy y1 y0 sub 3 mul def
895        /bx x2 x1 sub 3 mul cx sub def
896        /by y2 y1 sub 3 mul cy sub def
897        /ax x3 x0 sub cx sub bx sub def
898        /ay y3 y0 sub cy sub by sub def
899        /getValues {
900                ax t0 3 exp mul bx t0 t0 mul mul add cx t0 mul add x0 add
901                ay t0 3 exp mul by t0 t0 mul mul add cy t0 mul add y0 add
902                ax t 3 exp mul bx t t mul mul add cx t mul add x0 add
903        ay t 3 exp mul by t t mul mul add cy t mul add y0 add
904        } def
905        /getdL {
906                getValues
907                3 -1 roll sub 3 1 roll sub Pyth
908        } def
909        /CurveLength {
910                /u 0 def
911                /du 0.01 def
912                0 100 {
913                        /t0 u def
914                        /u u du add def
915                        /t u def
916                        getdL add
917                } repeat } def
918        /GetArrowPos {
919                /ende \psk@ArrowInsidePos\space 1 gt {ArrowPos}{ArrowPos CurveLength mul} ifelse def
920                /u 0 def
921                /du 0.01 def
922                /sum 0 def
923                {
924                        /t0 u def
925                        /u u du add def
926                        /t u def
927                        /sum getdL sum add def
928                        sum ende gt {exit} if
929                } loop u
930        } def
931        /dArrowPos \psk@ArrowInsideNo 1 gt {%
932                1.0 \psk@ArrowInsideNo 1.0 add div
933        }{ \psk@ArrowInsidePos } ifelse def
934        /ArrowPos \psk@ArrowInsideOffset\space def
935        /loopNo \psk@ArrowInsidePos\space 1 gt {%
936                CurveLength \psk@ArrowInsidePos\space div cvi
937                }{ \psk@ArrowInsideNo } ifelse def
938        loopNo cvi {
939                /ArrowPos ArrowPos dArrowPos add def
940                /t GetArrowPos def
941                /t0 t 0.95 mul def
942                getValues
943                ArrowInside pop pop pop pop
944        } repeat
945        x1 y1 x2 y2 x3 y3 curveto
946        /LPutVar [ xA1 yA1 xA2 yA2 xB2 yB2 xB1 yB1 ] cvx def
947        /LPutPos { t LPutVar BezierMidpoint } def
948        /HPutPos { { HPutLines } HPutCurve } def
949        /VPutPos { { VPutLines } HPutCurve } def
950}>
951%
952\define@key[psset]{pstricks-add}{dashNo}{\def\psk@dashNo{#1}}
953\define@key[psset]{pstricks-add}{linecap}{\def\psk@linecap{#1}}
954\define@key[psset]{pstricks-add}{randomPoints}{\def\psk@randomPoints{#1}}
955\define@boolkey[psset]{pstricks-add}[Pst@]{color}[true]{}
956%\psset{randomPoints=1000,color=false}
957%
958\def\psRandom{\pst@object{psRandom}}%  hv  2004-11-12
959\def\psRandom@i{\@ifnextchar({\psRandom@ii}{\psRandom@iii(0,0)(1,1)}}
960\def\psRandom@ii(#1){\@ifnextchar({\psRandom@iii(#1)}{\psRandom@iii(0,0)(#1)}}
961\def\psRandom@iii(#1)(#2)#3{%
962  \def\pst@tempA{#3}%
963  \ifx\pst@tempA\pst@empty\psclip{\psframe(#2)}\else\psclip{#3}\fi
964  \pst@getcoor{#1}\pst@tempA
965  \pst@getcoor{#2}\pst@tempB
966  \begin@SpecialObj
967  \addto@pscode{
968    \pst@tempA\space /yMin exch def
969    /xMin exch def
970    \pst@tempB\space /yMax exch def
971    /xMax exch def
972    /dy yMax yMin sub def
973    /dx xMax xMin sub def
974    rrand srand                 % initializes the random generator
975    /getRandReal { rand 2147483647 div } def
976    \psk@dotsize % defines /DS ... def
977    \@nameuse{psds@\psk@dotstyle}
978    \psk@randomPoints {
979     \ifPst@color getRandReal getRandReal getRandReal setrgbcolor \fi
980     getRandReal dx mul xMin add
981     getRandReal dy mul yMin add
982     Dot
983     \ifx\psk@fillstyle\psfs@solid fill \fi stroke
984    } repeat
985  }%
986  \end@SpecialObj
987  \endpsclip
988  \ignorespaces
989}
990%
991%
992%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
993%%%%%%%%%%%                                                  %%%%%%%%%%
994%%%%%%%%%%%                pst-node                          %%%%%%%%%%
995%%%%%%%%%%%                                                  %%%%%%%%%%
996%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997%
998% This fixes a bug in pst-node, where the XY-direction is wrong
999% the types are changed 1<->2 between X<->Y
1000%
1001\define@key[psset]{}{XnodesepA}{%
1002    \pst@getlength{#1}\psk@nodesepA
1003    \def\psk@nodeseptypeA{2 }%
1004}
1005\define@key[psset]{}{XnodesepB}{%
1006    \pst@getlength{#1}\psk@nodesepB
1007    \def\psk@nodeseptypeB{2 }%
1008}
1009\define@key[psset]{}{Xnodesep}{%
1010    \pst@getlength{#1}\psk@nodesepA
1011    \let\psk@nodesepB\psk@nodesepA
1012    \def\psk@nodeseptypeA{2 }%
1013    \def\psk@nodeseptypeB{2 }%
1014}
1015\define@key[psset]{}{YnodesepA}{%
1016    \pst@getlength{#1}\psk@nodesepA
1017    \def\psk@nodeseptypeA{1 }%
1018}
1019\define@key[psset]{}{YnodesepB}{%
1020    \pst@getlength{#1}\psk@nodesepB
1021    \def\psk@nodeseptypeB{1 }%
1022}
1023\define@key[psset]{}{Ynodesep}{%
1024    \pst@getlength{#1}\psk@nodesepA
1025    \let\psk@nodesepB\psk@nodesepA
1026    \def\psk@nodeseptypeA{1 }%
1027    \def\psk@nodeseptypeB{1 }%
1028}
1029% \psGetNodeCenter defines the PS variable #1.x and #1.y, which can then
1030% be used by the user. #1 must be a valid node name
1031%
1032\def\psGetNodeCenter#1{ tx@NodeDict begin /N@#1 load GetCenter end % x y on stack in system coor
1033  \pst@number\psyunit div /#1.y ED      % /#1.y in user coor
1034  \pst@number\psxunit div /#1.x ED }    % /#1.x in user coor
1035%
1036\pst@def{NCLineII}<{
1037  NCCoor
1038  /y1 ED /x1 ED x1 y1 ArrowA x1 y1 moveto
1039  /y2 ED /x2 ED
1040  /y0 y1 def /x0 x1 def
1041  /linelength x2 x1 sub y2 y1 sub Pyth def
1042  \psk@dashNo\space 1.0 lt
1043     {/cntMax 1.0 \psk@dashNo\space div .49 add cvi def}
1044     {/cntMax linelength \psk@dashNo\space div .49 add cvi def} ifelse
1045  x2 x1 sub cntMax div /dx ED
1046  y2 y1 sub cntMax div /dy ED
1047  /cnt 0 def
1048  cntMax {
1049    gsave
1050    /x1 x1 dx add def
1051    /y1 y1 dy add def
1052    x1 y1
1053    cnt 2 mod 0 eq
1054      { \pst@usecolor\psDashColorI }
1055      { \pst@usecolor\psDashColorII } ifelse
1056    lineto stroke
1057    /cnt cnt 1 add def
1058    grestore
1059    x1 y1 moveto
1060  } repeat
1061  x0 y0 x2 y2 ArrowB L pop pop%
1062}>
1063%
1064\def\nclineII{\pst@object{nclineII}}%
1065\def\nclineII@i{\check@arrow{\nclineII@ii}}%
1066\def\nclineII@ii#1#2{\nc@object{Open}{#1}{#2}{.5}%
1067    {\tx@NCLineII /LPutPos { xB yB xA yA \tx@LPutLine } def}%
1068}%
1069\def\pclineII{\pst@object{pclineII}}%
1070\def\pclineII@i{\pc@object\nclineII@ii}%
1071%
1072\define@key[psset]{pstricks-add}{lineAngle}{\psset{armB=0.5}\def\psk@lineAngle{#1}}%
1073%\psset{lineAngle=0}%
1074%
1075\pst@def{NCDiag}<{
1076  GetEdgeA GetEdgeB GetArmA GetArmB mark
1077  \psk@lineAngle\space abs 0 gt {
1078    /xTemp xA2 10 add def
1079    /yTemp yA2 \psk@lineAngle\space dup sin exch cos div 10 mul add def
1080    /dY1 yTemp yA2 sub def
1081    /dX1 xTemp xA2 sub def
1082    /dY2 yB2 yB1 sub def
1083    /dX2 xB2 xB1 sub def
1084    dX1 abs 0.01 lt {
1085      /m2 dY2 dX2 div def
1086      /xB2 xA2 def
1087      /yB2 xA2 xB1 sub m2 mul yB1 add def
1088    }{
1089      dX2 abs 0.01 lt {
1090        /m1 dY1 dX1 div def
1091        /xB2 xB1 def
1092        /yB2 xB1 xA2 sub m1 mul yA2 add def
1093      }{%
1094        /m1 dY1 dX1 div def
1095        /m2 dY2 dX2 div def
1096        /xB2 m1 xA2 mul m2 xB1 mul sub yA2 sub yB1 add m1 m2 sub div def
1097        /yB2 xB2 xA2 sub m1 mul yA2 add def
1098      } ifelse
1099    } ifelse
1100  } if
1101  ArmB 0 ne { xB1 yB1 } if
1102  xB2 yB2
1103  xA2 yA2
1104  ArmA 0 ne { xA1 yA1 } if
1105  tx@Dict begin false Line end
1106  /LPutVar [ xB1 yB1 xB2 yB2 xA2 yA2 xA1 yA1 ] cvx def
1107  /LPutPos { LPutLines } def
1108  /HPutPos { HPutLines } def
1109  /VPutPos { VPutLines } def
1110}>
1111% hv 2003-12-22
1112\pst@def{NCDiagg}<{
1113  GetEdgeA GetArmA \psk@lineAngle\space abs 0 gt { \psk@lineAngle\space }
1114    { yB yA2 sub xB xA2 sub Atan 180 add } ifelse /AngleB ED
1115  GetEdgeB mark
1116  \psk@lineAngle\space abs 0 gt {
1117    /dY2 yA2 yA1 sub def
1118    /dX2 xA2 xA1 sub def
1119    \psk@lineAngle\space abs 90 eq {
1120      /m2 dY2 dX2 div def
1121      /yA2 xB xA2 sub m2 mul yA2 add def
1122      /xA2 xB def
1123    }{
1124      /m1 \psk@lineAngle\space dup sin exch cos div def % tan alpha
1125      dX2 abs 0.01 lt {
1126        /yA2 xA1 xB sub m1 mul yB add def
1127        /xA2 xA1 def
1128      }{%
1129        /m2 dY2 dX2 div def
1130        /xA2 m1 xB mul m2 xA2 mul sub yA2 add yB sub m1 m2 sub div def
1131        /yA2 xA2 xB sub m1 mul yB add def
1132      } ifelse
1133    } ifelse
1134  } if
1135  xB1 yB1 xA2 yA2
1136  ArmA 0 ne { xA1 yA1 } if
1137  tx@Dict begin false Line end
1138  /LPutVar [ xB1 yB1 xA2 yA2 xA1 yA1 ] cvx def
1139  /LPutPos { LPutLines } def
1140  /HPutPos { HPutLines } def
1141  /VPutPos { VPutLines } def
1142}>
1143%
1144\def\ncbarr{\pst@object{ncbarr}}
1145\def\ncbarr@i#1#2{
1146  \begingroup
1147  \use@par%
1148  \psLNode(#1)(#2){0.5}{barr@tempNode}%
1149  \pst@dimm=\psk@angleA pt
1150  \pst@dimn=180pt
1151  % be sure, that angleA is 0 or 180. if not, we set it to 0
1152  \ifdim\pst@dimm=\z@\else\ifdim\pst@dimm=\pst@dimn\else\psset{angleA=0}\fi\fi
1153  \ncbar[arrows=-]{#1}{barr@tempNode}
1154  \ifdim\psk@angleA pt=\z@\relax
1155    \ncbar[angleA=180,angleB=180]{barr@tempNode}{#2}
1156  \else\ncbar[angleA=0,angleB=0]{barr@tempNode}{#2}\fi%
1157  \endgroup
1158}
1159%   #1-------#4----------------#2
1160% where #1#4= #3 * #1#2
1161%
1162\def\psLNode(#1)(#2)#3#4{%
1163  \pst@getcoor{#1}\pst@tempA%
1164  \pst@getcoor{#2}\pst@tempB%
1165  \pnode(!%
1166    \pst@tempA /YA exch \pst@number\psyunit div def
1167    /XA exch \pst@number\psxunit div def
1168    \pst@tempB /YB exch \pst@number\psyunit div def
1169    /XB exch \pst@number\psxunit div def
1170    /dx XB XA sub def
1171    /dy YB YA sub def
1172    XA dx #3\space mul add YA dy #3\space mul add){#4}
1173}
1174%
1175% build the linear combination #2*#1+#4*#3=#5
1176\def\psLCNode(#1)#2(#3)#4#5{%
1177  \pst@getcoor{#1}\pst@tempA%
1178  \pst@getcoor{#3}\pst@tempB%
1179  \pnode(!%
1180    \pst@tempA /YA exch \pst@number\psyunit div def
1181    /XA exch \pst@number\psxunit div def
1182    \pst@tempB /YB exch \pst@number\psyunit div def
1183    /XB exch \pst@number\psxunit div def
1184    XA #2\space mul XB #4\space mul add
1185    YA #2\space mul YB #4\space mul add){#5}%
1186}
1187%
1188%
1189\define@boolkey[psset]{pstricks-add}[Pst@]{trueAngle}[true]{}
1190%\psset{trueAngle=false}
1191%
1192\def\psRelNode{\pst@object{psRelNode}}
1193\def\psRelNode@i(#1)(#2)#3#4{{% A - B - factor - node name
1194  \use@par
1195  \pst@getcoor{#1}\pst@tempA%
1196  \pst@getcoor{#2}\pst@tempB%
1197  \pnode(!
1198    \pst@tempA /YA exch \pst@number\psyunit div def
1199    /XA exch \pst@number\psxunit div def
1200    \pst@tempB /YB exch \pst@number\psyunit div def
1201    /XB exch \pst@number\psxunit div def
1202    /AlphaStrich \psk@angleA\space def
1203    /unit \pst@number\psyunit \pst@number\psxunit div def % yunit/xunit
1204%           
1205    /dx XB XA sub  def
1206    /dy YB YA sub \ifPst@trueAngle\space unit mul \fi\space def
1207    /laenge dy dup mul dx dup mul add sqrt #3 mul def
1208    /Alpha dy dx atan def
1209    /beta Alpha AlphaStrich add def
1210    laenge beta cos mul XA add
1211    laenge beta sin mul \ifPst@trueAngle\space unit div \fi\space YA add ){#4}%
1212}}
1213%
1214\def\psRelLine{\pst@object{psRelLine}}
1215\def\psRelLine@i{\@ifnextchar({\psRelLine@iii}{\psRelLine@ii}}
1216\def\psRelLine@ii#1{%
1217  \addto@par{arrows=#1}%
1218  \psRelLine@iii%
1219}
1220\def\psRelLine@iii(#1)(#2)#3#4{{
1221  \pst@killglue
1222  \use@par
1223  \psRelNode(#1)(#2){#3}{#4}
1224  \psline(#1)(#4)%
1225}\ignorespaces}
1226%
1227% #1 options
1228% draw a parallel line to #2 #3
1229%     #2---------#3
1230%         #4----------#5(new node)
1231% #5 length of the line
1232% #6 node name
1233\def\psParallelLine{\pst@object{psParallelLine}}
1234\def\psParallelLine@i{\@ifnextchar({\psParallelLine@iii}{\psParallelLine@ii}}
1235\def\psParallelLine@ii#1{%
1236  \addto@par{arrows=#1}%
1237  \psParallelLine@iii%
1238}
1239\def\psParallelLine@iii(#1)(#2)(#3)#4#5{{
1240  \pst@killglue
1241  \use@par
1242  \pst@getcoor{#1}\pst@tempA
1243  \pst@getcoor{#2}\pst@tempB
1244  \pst@getcoor{#3}\pst@tempC
1245%  \pst@getlength{#4}\pst@dima
1246  \pnode(!%
1247     \pst@tempA /YA exch \pst@number\psyunit div def
1248     /XA exch \pst@number\psxunit div def
1249     \pst@tempB /YB exch \pst@number\psyunit div def
1250     /XB exch \pst@number\psxunit div def
1251     \pst@tempC /YC exch \pst@number\psyunit div def
1252     /XC exch \pst@number\psxunit div def
1253%           
1254    /dx XB XA sub  def
1255    /dy YB YA sub  def
1256    /laenge dy dup mul dx dup mul add sqrt #4 mul def
1257    /Alpha dy dx atan def
1258    laenge Alpha cos mul XC add
1259    laenge Alpha sin mul YC add ){#5}%
1260  \psline(#3)(#5)
1261}\ignorespaces}
1262%
1263\def\psIntersectionPoint(#1)(#2)(#3)(#4)#5{%
1264    \pst@getcoor{#1}\pst@tempA
1265    \pst@getcoor{#2}\pst@tempB
1266    \pst@getcoor{#3}\pst@tempC
1267    \pst@getcoor{#4}\pst@tempd
1268\pnode(!%
1269     \pst@tempA /YA exch \pst@number\psyunit div def
1270     /XA exch \pst@number\psxunit div def
1271     \pst@tempB /YB exch \pst@number\psyunit div def
1272     /XB exch \pst@number\psxunit div def
1273     \pst@tempC /YC exch \pst@number\psyunit div def
1274     /XC exch \pst@number\psxunit div def
1275     \pst@tempd /YD exch \pst@number\psyunit div def
1276     /XD exch \pst@number\psxunit div def
1277    /dY1 YB YA sub def
1278    /dX1 XB XA sub def
1279    /dY2 YD YC sub def
1280    /dX2 XD XC sub def
1281    dX1 abs 0.01 lt {
1282        /m2 dY2 dX2 div def
1283        XA dup XC sub m2 mul YC add
1284    }{
1285        dX2 abs 0.01 lt {
1286            /m1 dY1 dX1 div def
1287            XC dup XA sub m1 mul YA add
1288        }{%
1289            /m1 dY1 dX1 div def
1290            /m2 dY2 dX2 div def
1291            m1 XA mul m2 XC mul sub YA sub YC add m1 m2 sub div dup
1292            XA sub m1 mul YA add
1293        } ifelse
1294    } ifelse ){#5}%
1295}
1296%
1297\def\psLDNode(#1)(#2)#3#4{
1298% #1: node A  #2: node B  #3: dimen measured from A  #4: node name
1299  \pst@getcoor{#1}\pst@tempA%
1300  \pst@getcoor{#2}\pst@tempB%
1301  \pssetlength\pst@dimp{#3}%
1302  \pnode(!%
1303    \pst@tempA /YA exch \pst@number\psyunit div def
1304    /XA exch \pst@number\psxunit div def
1305    \pst@tempB /YB exch \pst@number\psyunit div def
1306    /XB exch \pst@number\psxunit div def
1307    /dx XB XA sub def
1308    /dy YB YA sub def
1309    /angle dy dx Atan def
1310    /linelength \pst@number\pst@dimp \pst@number\psunit div def
1311    XA linelength angle cos mul add YA linelength angle sin mul add ){#4}%
1312}
1313\def\nlput{\pst@object{nlput}}
1314\def\nlput@i(#1)(#2)#3#4{%
1315  \begin@SpecialObj
1316  \psLDNode(#1)(#2){#3}{temp@lnput}
1317  \pcline[linestyle=none](#1)(temp@lnput)%
1318  \ncput[npos=1]{#4}%
1319  \end@SpecialObj
1320}%
1321\define@cmdkeys[psset]{pstricks-add}[PSTPSPNk@]{% Christophe Jorssen 2007
1322  blName,bcName,brName,
1323  clName,ccName,crName,
1324  tlName,tcName,trName}[]{}%
1325\psset[pstricks-add]{%
1326  blName=PSPbl,bcName=PSPbc,brName=PSPbr,
1327  clName=PSPcl,ccName=PSPcc,crName=PSPcr,
1328  tlName=PSPtl,tcName=PSPtc,trName=PSPtr}
1329\def\psDefPSPNodes{\pst@object{psDefPSPNodes}}
1330\def\psDefPSPNodes@i{%
1331  \pst@killglue
1332  \begingroup
1333  \use@par
1334  \expandafter\psDefPSPNodes@ii\pic@coor}
1335%
1336\def\psDefPSPNodes@ii(#1)(#2)(#3){%
1337%    \pnode(#1){PSPN@temp}\pnode([nodesep=.75,angle=45]PSPN@temp){\PSTPSPNk@blName}
1338%    \pnode(#3){PSPN@temp}\pnode([nodesep=.75,angle=-135]PSPN@temp){\PSTPSPNk@trName}
1339    \pnode(#1){PSPN@temp}\pnode([angle=45]PSPN@temp){\PSTPSPNk@blName}
1340    \pnode(#3){PSPN@temp}\pnode([angle=-135]PSPN@temp){\PSTPSPNk@trName}
1341    \pnode(\PSTPSPNk@blName|\PSTPSPNk@trName){\PSTPSPNk@tlName}
1342    \pnode(\PSTPSPNk@trName|\PSTPSPNk@blName){\PSTPSPNk@brName}
1343    \ncline[linestyle=none]{\PSTPSPNk@blName}{\PSTPSPNk@tlName}
1344    \ncput[npos=.5]{\pnode{\PSTPSPNk@clName}}
1345    \ncline[linestyle=none]{\PSTPSPNk@blName}{\PSTPSPNk@brName}
1346    \ncput[npos=.5]{\pnode{\PSTPSPNk@bcName}}
1347    \pnode(\PSTPSPNk@brName|\PSTPSPNk@clName){\PSTPSPNk@crName}
1348    \pnode(\PSTPSPNk@bcName|\PSTPSPNk@trName){\PSTPSPNk@tcName}
1349    \pnode(\PSTPSPNk@bcName|\PSTPSPNk@clName){\PSTPSPNk@ccName}
1350  \endgroup
1351  \ignorespaces}
1352%
1353%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1354%%%%%%%%%%%                                                  %%%%%%%%%%
1355%%%%%%%%%%%                pst-plot                          %%%%%%%%%%
1356%%%%%%%%%%%                                                  %%%%%%%%%%
1357%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1358%
1359\define@key[psset]{pstricks-add}{labelFontSize}{\def\psk@labelFontSize{#1}}%
1360\psset{labelFontSize={}}
1361\def\pshlabel#1{\psk@labelFontSize#1}%
1362\def\psvlabel#1{\psk@labelFontSize#1}
1363%
1364\define@boolkey[psset]{pstricks-add}[Pst@]{comma}[true]{}
1365\define@boolkey[psset]{pstricks-add}[Pst@]{xAxis}[true]{}
1366\define@boolkey[psset]{pstricks-add}[Pst@]{yAxis}[true]{}
1367\define@boolkey[psset]{pstricks-add}[Pst@]{xyAxes}[true]{%
1368    \@nameuse{Pst@xAxis#1}\@nameuse{Pst@yAxis#1}}%
1369%\psset{xyAxes=true}%
1370%
1371\define@key[psset]{pstricks-add}{xyDecimals}{\def\psk@xDecimals{#1}\def\psk@yDecimals{#1}}
1372\define@key[psset]{pstricks-add}{xDecimals}{\def\psk@xDecimals{#1}}
1373\define@key[psset]{pstricks-add}{yDecimals}{\def\psk@yDecimals{#1}}
1374%\psset{xyDecimals={}}%
1375%
1376\define@key[psset]{pstricks-add}{xlogBase}{\def\psk@xlogBase{#1}}
1377\define@key[psset]{pstricks-add}{ylogBase}{\def\psk@ylogBase{#1}}
1378\define@key[psset]{pstricks-add}{xylogBase}{\def\psk@xlogBase{#1}\def\psk@ylogBase{#1}}%
1379%\psset{xylogBase={}}%
1380%
1381\define@key[psset]{pstricks-add}{trigLabelBase}{\pst@getint{#1}{\psk@trigLabelBase}}
1382\psset{trigLabelBase=0}
1383
1384\define@boolkey[psset]{pstricks-add}[Pst@]{trigLabels}[true]{%
1385  \ifPst@trigLabels
1386    \def\pst@@@hlabel##1{\pshlabel{##1}}
1387    \def\pshlabel##1{%
1388      \ifnum\psk@trigLabelBase<2
1389        \def\de@nominator{\@ne}\else\def\de@nominator{\psk@trigLabelBase}\fi
1390      \def\pst@tempA{##1} 
1391      \pst@abs{\pst@tempA}\pst@cntm
1392      \pst@mod{\pst@cntm}{\de@nominator}\pst@cntp % cntb=##1 modulo trigLabelBase
1393      \ifnum\@ne>\pst@cntp                  % 1 > modulo -> then we have pi/x
1394        \pst@cnto=\pst@cntm \divide\pst@cnto by \de@nominator 
1395        \psk@labelFontSize
1396        \ifnum\pst@tempA<0 $-$\fi%
1397        \ifnum\pst@cnto=\@ne                % #1 = trigLabelBase
1398          $\pi$                             % print pi
1399        \else
1400          $\the\pst@cnto\pi$                % print \pst@cnto/\de@nominator pi
1401        \fi   
1402      \else
1403        \psk@labelFontSize
1404        \ifnum\pst@cntp=\@ne                % < 1 pi?
1405          \if\pst@cntm=\@ne
1406            $\frac{\pi}{\de@nominator}$   % pi/x
1407          \else\ifnum\pst@tempA=-1 $\frac{-\pi}{\de@nominator}$
1408             \else \ifnum\pst@tempA=1 $\frac{\pi}{\de@nominator}$
1409                 \else$\frac{\pst@tempA\pi}{\de@nominator}$  % (x pi)/y
1410          \fi\fi\fi
1411        \else
1412          \ifnum\pst@tempA=1 $\frac{\pi}{\de@nominator}$
1413          \else\ifnum\pst@tempA=\de@nominator $\pi$
1414            \else$\frac{\pst@tempA\pi}{\de@nominator}$ 
1415      \fi\fi\fi\fi%
1416    }%
1417  \else
1418    \def\pst@@@hlabel##1{%
1419      \edef\@xyDecimals{\psk@xDecimals}%
1420      \ifnum\psk@ticks<\tw@ % ticks=all|x
1421        \ifx\psk@xlogBase\@empty
1422          \pshlabel{\psk@labelFontSize\expandafter\@LabelComma##1..\@nil\psk@xlabelFactor}%
1423        \else%
1424          \pshlabel{\psk@labelFontSize\psk@xlogBase\textsuperscript{\expandafter\@stripDecimals##1..\@nil }}
1425        \fi%
1426      \fi%
1427    }
1428    \def\pshlabel##1{\psk@labelFontSize##1}%
1429  \fi
1430}
1431\psset{trigLabels=false}
1432%
1433%logLines=all|x|y|none  (0,1,2,3)
1434\define@key[psset]{pstricks-add}{logLines}{\pst@expandafter\psset@@logLines{#1}\@nil\psk@logLines}
1435\def\psset@@logLines#1#2\@nil#3{%
1436  \ifx#1a\let#3\z@\else
1437    \ifx#1x\let#3\@ne\else
1438      \ifx#1y\let#3\tw@\else
1439        \ifx#1n\let#3\thr@@\else
1440          \@pstrickserr{Bad argument: `#1#2'}\@ehpa
1441  \fi\fi\fi\fi}
1442%\psset{logLines=none}%
1443%
1444% Define "ticklines" parameter (ticklines=all|x|y|none with default=none)
1445%\def\psset@ticklines#1{\pst@expandafter\psset@@ticklines{#1}\@nil\psk@ticklines}
1446%\psset@ticklines{none}
1447\define@key[psset]{pstricks-add}{ylabelFactor}{\def\psk@ylabelFactor{#1}}
1448\define@key[psset]{pstricks-add}{xlabelFactor}{\def\psk@xlabelFactor{#1}}
1449%\psset{xlabelFactor=\relax,ylabelFactor=\relax}%
1450
1451%% #1 : optional arguments passed to psline
1452%% #2 : x value
1453%% #3 : label
1454\def\psxTick{\pst@object{psxTick}}% idea by Martin Chicoine
1455\def\psxTick@i(#1)#2{{
1456  \pst@killglue
1457  \addbefore@par{arrows=-}
1458  \use@par
1459  \psline(#1,\pst@xticksizeB)(#1,\pst@xticksizeA)
1460  \rput[t](! #1 \pst@number\pslabelsep \pst@number\pst@xticksizeB add
1461           \pst@number\psyunit div neg ){\vphantom{1}#2}}\ignorespaces}
1462%
1463%% #1 : optional arguments passed to psline
1464%% #2 : y value
1465%% #3 : label
1466\def\psyTick{\pst@object{psyTick}}% idea by Martin Chicoine
1467\def\psyTick@i(#1)#2{{
1468  \pst@killglue
1469  \addbefore@par{arrows=-}
1470  \use@par
1471  \psline(\pst@yticksizeB,#1)(\pst@yticksizeA,#1)
1472  \rput[r]{0}(!\pst@number\pst@yticksizeB \pst@number\pslabelsep add
1473              \pst@number\psxunit div neg #1){#2}}\ignorespaces}
1474%
1475%
1476%% #1 integer
1477%% #2 decimals
1478%% #3 dot
1479\def\@stripDecimals#1.#2.#3\@nil{%
1480  \def\dummy{#1}%
1481  \ifx\dummy\@empty\the\@zero\else#1\fi% the integer part
1482}
1483%
1484\def\pst@@@vlabel#1{%
1485  \edef\@xyDecimals{\psk@yDecimals}%
1486%  \psk@yLabel%
1487  \ifodd\psk@ticks  % ticks=all||y (0,2)
1488  \else
1489    \ifx\psk@ylogBase\@empty
1490%      \ifPst@comma
1491       \psvlabel{\expandafter\@LabelComma#1..\@nil\psk@ylabelFactor}%
1492%      \else\psvlabel{#1\psk@ylabelFactor}\fi%
1493    \else%
1494      \psvlabel{\psk@ylogBase\textsuperscript{\expandafter\@stripDecimals#1..\@nil }}
1495    \fi%
1496  \fi%
1497}
1498\newcount\@digitcounter\@digitcounter=0\relax
1499\def\@inc@digitcounter{\global\advance\@digitcounter by 1\relax}
1500\def\@get@digitcounter{\the\@digitcounter\relax}
1501\def\@Reset@digitcounter{\global\@digitcounter=0\relax}
1502\def\@zeroFill{%
1503  \ifnum \@xyDecimals>\@get@digitcounter
1504    \bgroup
1505      0\@inc@digitcounter\@zeroFill
1506    \egroup%
1507  \fi%
1508}
1509% #1 the value, maybe empty
1510%
1511\def\@process@digits#1#2;{%
1512        \ifx *#1\@zeroFill\else#1\@inc@digitcounter\@process@digits#2;\fi%
1513}
1514\def\@writeDecimals#1{%
1515  \ifx\@xyDecimals\@empty% take value as is
1516    \def\@tempa{#1}% write only if not empty
1517    \ifx\@tempa\@empty% write nothing
1518    \else
1519      \ifPst@comma{,}\else.\fi%
1520      #1%
1521    \fi%
1522  \else% write only \xy@decimals
1523    \ifnum\@xyDecimals>\@zero
1524      \ifPst@comma{,}\else.\fi
1525        \@Reset@digitcounter
1526        \@process@digits#1*;
1527      \fi%
1528  \fi%
1529}
1530%% #1 integer
1531%% #2 decimals
1532%% #3 dot
1533\def\@LabelComma#1.#2.#3\@nil{%
1534  \def\pst@tempA{#1}%
1535  \ifx\pst@tempA\@empty\the\@zero\else#1\fi% the integer part
1536  \def\pst@tempA{#2}%
1537  \ifx\pst@tempA\@empty\@writeDecimals{}\else\@writeDecimals{#2}\fi%
1538}
1539%
1540\def\psxs@none{%
1541  \let\psk@arrowA\@empty%
1542  \let\psk@arrowB\@empty%
1543  \psxs@axes%
1544}
1545%\def\psxs@axes{%
1546%  \psxs@@axes\pst@dima\pst@dimc{}%
1547%  \psxs@@axes\pst@dimb\pst@dimd{exch}%
1548%}
1549
1550%
1551\def\psxs@axes{{%
1552  \ifPst@xAxis\psxs@@axes\pst@dima\pst@dimb\pst@dimc\pst@dimd{}\fi%
1553  \ifPst@yAxis\psxs@@axes\pst@dima\pst@dimb\pst@dimc\pst@dimd{exch}\fi%
1554}}
1555\def\psaxes{\pst@object{psaxes}}
1556\def\psaxes@i{\pst@getarrows\psaxes@ii}
1557\def\psaxes@ii(#1){\@ifnextchar({\psaxes@iii(#1)}{\psaxes@iv(0,0)(0,0)(#1)}}
1558\def\psaxes@iii(#1)(#2){\@ifnextchar({\psaxes@iv(#1)(#2)}{\psaxes@iv(#1)(#1)(#2)}}
1559\def\psaxes@iv(#1)(#2)(#3){\@ifnextchar[{\psaxes@v(#1)(#2)(#3)}{\psaxes@vii(#1)(#2)(#3)}}%
1560\def\psaxes@v(#1)(#2)(#3)[#4]{\@ifnextchar[{\psaxes@vi(#1)(#2)(#3)[#4]}{\psaxes@vi(#1)(#2)(#3)[#4][]}}%
1561\def\psaxes@v(#1)(#2)(#3)[#4,#5][#6,#7]{%
1562  \psaxes@vii(#1)(#2)(#3)%
1563  \uput[#5](#3|0,0){#4}\uput[#7](0,0|#3){#6}%
1564}
1565%
1566\def\psaxes@vii(#1,#2)(#3,#4)(#5,#6){%
1567  \pst@killglue%
1568  \begingroup%
1569  \setbox\pst@hbox=\hbox\bgroup%
1570  \use@par%
1571  \pssetxlength\pst@dimg{#1}% o-x
1572  \pssetylength\pst@dimh{#2}% o-y
1573  \pssetxlength\pst@dima{#3}% bl-x
1574  \pssetylength\pst@dimb{#4}% bl-y
1575  \pssetxlength\pst@dimc{#5}% ur-x
1576  \pssetylength\pst@dimd{#6}% ur-y
1577    % If minimum values are negative in log mode, we modify Ox
1578    % (respectively Oy) if this was not done by the user
1579    % X axis labels (\psk@log = 0 or 1)
1580%
1581% Whole thing will be translated to origin:
1582  \advance\pst@dima-\pst@dimg% Dist. from bl-x to o-x
1583  \advance\pst@dimb-\pst@dimh% Dist. from bl-y to o-y
1584  \advance\pst@dimc-\pst@dimg% Dist. from ur-x to o-x
1585  \advance\pst@dimd-\pst@dimh% Dist. from ur-y to o-y
1586% Make lines/arrows or frame:
1587  \@nameuse{psxs@\psk@axesstyle}%  \psxs@axes or \psxs@frame
1588  \ifPst@yAxis%
1589  \begingroup%
1590    \ifdim\pst@dima=\z@\else\showoriginfalse\fi%
1591    \ifnum\psk@dy=\z@%
1592      \pst@dimg=\psk@Dy\psyunit%
1593      \edef\psk@dy{\number\pst@dimg}%
1594    \fi%
1595    \ifPst@xAxis\else\showorigintrue\fi%
1596    \pst@vlabels{\pst@dimd}{\psk@arrowB}{#3}{#5}%
1597    \ifPst@xAxis\showoriginfalse\fi%
1598    \pst@vlabels{\pst@dimb}{\psk@arrowA}{#3}{#5}%
1599  \endgroup%
1600  \fi%
1601  \ifPst@xAxis%
1602  \begingroup%
1603    \ifdim\pst@dimb=\z@\else\showoriginfalse\fi%
1604    \ifnum\psk@dx=\z@%
1605      \pst@dimg=\psk@Dx\psxunit%
1606      \edef\psk@dx{\number\pst@dimg}%
1607    \fi%
1608    \ifPst@yAxis\else\showorigintrue\fi%
1609    \pst@hlabels{\pst@dimc}{\psk@arrowB}{#4}{#6}%
1610    \ifPst@yAxis\showoriginfalse\fi%
1611    \pst@hlabels{\pst@dima}{\psk@arrowA}{#4}{#6}%
1612  \endgroup%
1613  \fi%
1614% Now close "\pst@hbox" (which is 0-dimensional), and put it at the origin.
1615  \egroup%
1616  \pssetxlength\pst@dimg{#1}%
1617  \pssetylength\pst@dimh{#2}%
1618  \leavevmode\psput@cartesian\pst@hbox%
1619  \endgroup
1620  \ignorespaces%
1621}
1622%
1623\newdimen\psk@subticksize\psk@subticksize=\z@
1624\newdimen\pst@xticksizeA
1625\newdimen\pst@xticksizeB
1626\newdimen\pst@xticksizeC
1627\newdimen\pst@yticksizeA
1628\newdimen\pst@yticksizeB
1629\newdimen\pst@yticksizeC
1630%
1631\def\set@xticksize#1{%
1632  \pst@expandafter\pst@getydimdim{#1} {} {}\@nil % y-unit!!
1633  \pst@xticksizeA=\the\pst@dimm%
1634  \pst@xticksizeB=\the\pst@dimn%
1635  \edef\psk@xticksize{\pst@number\pst@xticksizeA \pst@number\pst@xticksizeB}%
1636  \ifdim\pst@dimm=\z@\relax
1637    \pst@xticksizeC=\z@
1638  \else%
1639    \pst@absdim{\pst@xticksizeA}\pst@dimm%
1640    \pst@absdim{\pst@xticksizeB}\pst@dimn%
1641    \pst@maxdim{\pst@dimm}{\pst@dimn}\pst@dimo%
1642    \pst@xticksizeC=\pst@dimo%
1643  \fi%
1644}
1645\def\set@yticksize#1{%
1646  \pst@expandafter\pst@getxdimdim{#1} {} {}\@nil % x-unit!
1647  \pst@yticksizeA=\the\pst@dimm%
1648  \pst@yticksizeB=\the\pst@dimn%
1649  \edef\psk@yticksize{\pst@number\pst@yticksizeA \pst@number\pst@yticksizeB}%
1650  \ifdim\pst@dimm=\z@\relax
1651    \pst@yticksizeC=\z@
1652  \else%
1653    \pst@absdim{\pst@yticksizeA}\pst@dimm%
1654    \pst@absdim{\pst@yticksizeB}\pst@dimn%
1655    \pst@maxdim{\pst@dimm}{\pst@dimn}\pst@dimo%
1656    \pst@yticksizeC=\pst@dimo%
1657  \fi%
1658}
1659\define@key[psset]{}{ticksize}{\set@xticksize{#1}\set@yticksize{#1}}
1660\define@key[psset]{pstricks-add}{xticksize}{\set@xticksize{#1}}
1661\define@key[psset]{pstricks-add}{yticksize}{\set@yticksize{#1}}%  overwrites the definition in pstricks
1662%\psset{ticksize=-4pt 4pt}
1663%
1664% full= 0, top=1, bottom=-1
1665\define@key[psset]{}{tickstyle}{%
1666  \pst@expandafter\psset@@tickstyle{#1}\@nil%
1667  \pst@cnta=\psk@tickstyle
1668  \advance\pst@cnta by 1
1669  \ifcase\pst@cnta% bottom
1670    \pst@xticksizeB=\z@
1671    \pst@yticksizeB=\z@
1672  \or% full
1673  \or% top
1674    \pst@xticksizeA=\z@
1675    \pst@yticksizeA=\z@
1676  \fi
1677}
1678%\psset{tickstyle=full}%
1679%
1680%
1681\define@key[psset]{pstricks-add}{subticks}{\def\psk@xsubticks{#1}\def\psk@ysubticks{#1}}
1682\define@key[psset]{pstricks-add}{xsubticks}{\def\psk@xsubticks{#1}}
1683\define@key[psset]{pstricks-add}{ysubticks}{\def\psk@ysubticks{#1}}
1684%
1685\define@key[psset]{pstricks-add}{subticksize}{\def\psk@xsubticksize{#1}\def\psk@ysubticksize{#1}}
1686\define@key[psset]{pstricks-add}{xsubticksize}{\def\psk@xsubticksize{#1}}
1687\define@key[psset]{pstricks-add}{ysubticksize}{\def\psk@ysubticksize{#1}}
1688%
1689\define@key[psset]{pstricks-add}{tickwidth}{%
1690  \pst@getlength{#1}\psk@xtickwidth%
1691  \pst@getlength{#1}\psk@ytickwidth}
1692\define@key[psset]{pstricks-add}{xtickwidth}{\pst@getlength{#1}\psk@xtickwidth}
1693\define@key[psset]{pstricks-add}{ytickwidth}{\pst@getlength{#1}\psk@ytickwidth}
1694\define@key[psset]{pstricks-add}{subtickwidth}{%
1695  \pst@getlength{#1}\psk@xsubtickwidth%
1696  \pst@getlength{#1}\psk@ysubtickwidth}
1697\define@key[psset]{pstricks-add}{xsubtickwidth}{\pst@getlength{#1}\psk@xsubtickwidth}
1698\define@key[psset]{pstricks-add}{ysubtickwidth}{\pst@getlength{#1}\psk@ysubtickwidth}
1699%
1700\define@key[psset]{pstricks-add}{tickcolor}{%
1701    \pst@getcolor{#1}\psk@xtickcolor%
1702    \pst@getcolor{#1}\psk@ytickcolor}
1703\define@key[psset]{pstricks-add}{xtickcolor}{\pst@getcolor{#1}\psk@xtickcolor}
1704\define@key[psset]{pstricks-add}{ytickcolor}{\pst@getcolor{#1}\psk@ytickcolor}
1705\define@key[psset]{pstricks-add}{subtickcolor}{%
1706  \pst@getcolor{#1}\psk@xsubtickcolor%
1707  \pst@getcolor{#1}\psk@ysubtickcolor}
1708\define@key[psset]{pstricks-add}{xsubtickcolor}{\pst@getcolor{#1}\psk@xsubtickcolor}
1709\define@key[psset]{pstricks-add}{ysubtickcolor}{\pst@getcolor{#1}\psk@ysubtickcolor}
1710%
1711\define@key[psset]{pstricks-add}{xticklinestyle}{%
1712  \@ifundefined{psls@#1}%
1713    {\@pstrickserr{Line style `#1' not defined}\@eha}%
1714    {\def\psxticklinestyle{#1}}}
1715\define@key[psset]{pstricks-add}{xsubticklinestyle}{%
1716  \@ifundefined{psls@#1}%
1717    {\@pstrickserr{Line style `#1' not defined}\@eha}%
1718    {\def\psxsubticklinestyle{#1}}}
1719\define@key[psset]{pstricks-add}{yticklinestyle}{%
1720  \@ifundefined{psls@#1}%
1721    {\@pstrickserr{Line style `#1' not defined}\@eha}%
1722    {\def\psyticklinestyle{#1}}}
1723\define@key[psset]{pstricks-add}{ysubticklinestyle}{%
1724  \@ifundefined{psls@#1}%
1725    {\@pstrickserr{Line style `#1' not defined}\@eha}%
1726    {\def\psysubticklinestyle{#1}}}
1727\define@key[psset]{pstricks-add}{ticklinestyle}{%
1728  \@ifundefined{psls@#1}%
1729    {\@pstrickserr{Line style `#1' not defined}\@eha}%
1730    {\def\psxticklinestyle{#1}\def\psyticklinestyle{#1}}}
1731\define@key[psset]{pstricks-add}{subticklinestyle}{%
1732  \@ifundefined{psls@#1}%
1733    {\@pstrickserr{Line style `#1' not defined}\@eha}%
1734    {\def\psxsubticklinestyle{#1}\def\psysubticklinestyle{#1}}}
1735%
1736%\psset{subticksize=0.75,subticks=1,tickcolor=black,ticklinestyle=solid,%
1737%  subticklinestyle=solid,%
1738%  subtickcolor=gray,%
1739%  tickwidth=0.5\pslinewidth,%
1740%  subtickwidth=0.25\pslinewidth}
1741%
1742\newif\ifis@yAxis%
1743%
1744\def\psxs@@axes#1#2#3#4#5{% llx,lly,urx,ury,exch,arrowA,arrowB
1745  \pst@killglue%
1746  \begin@SpecialObj%
1747    \def\pst@tempA{#5}%
1748    \ifx\pst@tempA\@empty\relax%
1749      \is@yAxisfalse%
1750      \ifnum\psk@dx=\z@%
1751        \pst@dimg=\psk@Dx\psxunit%
1752        \def\psk@dx{\number\pst@dimg}%
1753      \fi%
1754    \else%
1755      \is@yAxistrue%
1756      \ifnum\psk@dy=\z@%
1757        \pst@dimg=\psk@Dy\psyunit%
1758        \def\psk@dy{\number\pst@dimg}%
1759      \fi%
1760    \fi%
1761    \let\pst@linetype\pst@arrowtype%
1762    \def\pst@tempA{none}%
1763    \pst@addarrowdef%
1764    \addto@pscode{
1765      \ifis@yAxis 0 \pst@number#4 \else \pst@number#3 0 \fi
1766      \ifis@yAxis 0 \pst@number#2 \else \pst@number#1 0 \fi
1767      ArrowA
1768      CP 4 2 roll
1769      ArrowB
1770      /yEnd exch def /xEnd exch def
1771      xEnd yEnd
1772      \ifx\psk@axesstyle\pst@tempA
1773        pop pop % axesstyle = none (only ticks)
1774      \else
1775        L                                  % the line with arrows
1776      \fi
1777      /yStart exch def
1778      /xStart exch def
1779      \@nameuse{psls@\pslinestyle}                 % linestyle for the axes
1780      stroke                                       % draw the main line
1781%     \psk@ticks: all=0; x=1; y=2; none=3
1782      \number\psk@ticks\space dup 2 mod 0 eq \ifis@yAxis true \else false \fi and
1783      exch 2 lt \ifis@yAxis false \else true \fi and or {
1784      /viceversa
1785        \ifis@yAxis\pst@number#2 \pst@number#4 \else\pst@number#1 \pst@number#3 \fi
1786         gt { true }{ false } ifelse def           % other way round
1787      /epsilon 0.01 def                            % rounding errors
1788      /minTickline \ifis@yAxis \pst@number#1 \else \pst@number#2 \fi def
1789      /maxTickline \ifis@yAxis \pst@number#3 \else \pst@number#4 \fi def
1790      /dT \ifis@yAxis \psk@dy \else \psk@dx \fi\space abs  % added abs 2006-07-07
1791        65536 div viceversa { neg } if def                 % div to get pt instead of sp
1792      /subTNo \ifis@yAxis\psk@ysubticks\else\psk@xsubticks\fi \space def
1793      subTNo 0 gt { /dsubT dT subTNo div def}{ /dsubT 0 def } ifelse  % deltaSubTick
1794      \ifis@yAxis \psk@yticksize \else \psk@xticksize \fi
1795      /tickend exch def /tickstart exch def
1796      /Twidth \ifis@yAxis \psk@ytickwidth \else \psk@xtickwidth \fi\space def
1797      /subTwidth \ifis@yAxis \psk@ysubtickwidth \else \psk@xsubtickwidth \fi\space def
1798      /STsize \ifis@yAxis \psk@ysubticksize \else \psk@xsubticksize \fi\space def
1799      /TColor {
1800        \ifis@yAxis\pst@usecolor\psk@ytickcolor
1801        \else\pst@usecolor\psk@xtickcolor\fi\space } def
1802      /subTColor {
1803        \ifis@yAxis\pst@usecolor\psk@ysubtickcolor
1804        \else\pst@usecolor\psk@xsubtickcolor\fi\space } def
1805      /MinValue { \ifis@yAxis yStart \else xStart \fi
1806        \ifx\psk@arrowA\@empty\else 
1807          \psk@arrowsize\space CLW mul add \psk@arrowlength\space mul
1808           viceversa { sub epsilon add } { add epsilon sub } ifelse \fi } def
1809      /MaxValue { \ifis@yAxis yEnd \else xEnd \fi
1810        \ifx\psk@arrowB\@empty\else
1811          \psk@arrowsize\space CLW mul add \psk@arrowlength\space mul
1812           viceversa { add epsilon sub } { sub epsilon add } ifelse \fi } def
1813      /logLines {
1814        \ifnum\psk@logLines=\z@ true \else         % all axes
1815          \ifnum\psk@logLines<\tw@                 % x axis
1816            \ifis@yAxis false \else true \fi       % do we have x or y axis
1817          \else
1818            \ifnum\psk@logLines<\thr@@             % y axis
1819              \ifis@yAxis true \else false \fi     % do we have x or y axis
1820            \else 
1821              false                                % no one
1822            \fi
1823          \fi
1824        \fi
1825      } def
1826      /LSstroke {                                  % set linestyle and stroke
1827        \ifis@yAxis\@nameuse{psls@\psyticklinestyle}
1828        \else\@nameuse{psls@\psxticklinestyle}\fi stroke} def
1829      /subLSstroke {                               % set sublinestyle and stroke
1830        \ifis@yAxis\@nameuse{psls@\psysubticklinestyle}
1831        \else\@nameuse{psls@\psxsubticklinestyle}\fi stroke} def
1832%\iffalse
1833% start ticks ---------------------------------------------------------
1834      0 dT MaxValue {                              % the positive part of the axes
1835        /cntTick exch def                          % the index
1836        logLines {                                 % log lines?
1837          gsave
1838          1 10 subTNo div 9.99 {                   % do not write a line for 1
1839            /dx exch def                           % save index
1840            /x cntTick dT dx log mul add def       %
1841            x abs MaxValue abs le {                % out of range?
1842              x minTickline #5\space moveto
1843              x maxTickline #5\space lineto
1844            } if
1845          } for
1846          subTwidth SLW subTColor                  % set line width and subtick color
1847          subLSstroke
1848          grestore                                 % restore main tick status
1849          stroke
1850          /dsubT 0 def                             % no other subticks
1851        } if
1852        dsubT abs 0 gt {                           % du we have subticks?
1853          gsave                                    % save graphic state
1854% start subticks ----------------------------------------------------------
1855            /cntsubTick cntTick dsubT add def
1856            subTNo 1 sub {
1857            cntsubTick abs MaxValue abs le {       % out of range?
1858              cntsubTick tickstart STsize mul #5\space moveto
1859              cntsubTick tickend STsize mul #5\space lineto
1860            }{ exit }  ifelse
1861            /cntsubTick cntsubTick dsubT add def
1862          } repeat
1863          subTwidth SLW subTColor                  % set line width and subtick color
1864          subLSstroke
1865% end subticks ----------------------------------------------------------
1866          grestore                                 % restore tick status
1867        } if
1868        gsave
1869        cntTick tickstart #5\space moveto          % line begin main Tick
1870        cntTick tickend #5\space lineto            % lineto tick end
1871        Twidth SLW TColor                          % set line width and tick color
1872        LSstroke
1873        grestore
1874      } for
1875% end ticks ----------------------------------------------------------
1876%\fi
1877%\iffalse
1878% ================================================ % the other side
1879      /dT dT neg def                               % the other side of the axis
1880      /dsubT dsubT neg def
1881% start ticks ----------------------------------------------------------
1882      0 dT MinValue epsilon viceversa { add }{ sub } ifelse {
1883        /cntTick exch def
1884        logLines {                                 % log lines?
1885          gsave
1886          1 10 subTNo div 9.99 {                   % do not write a line for 1
1887            /dx exch def                           % save index
1888            /x cntTick dT dx log mul add def       %
1889            x abs MinValue abs le {                % out of range?
1890              x minTickline #5\space moveto
1891              x maxTickline #5\space lineto
1892            } if
1893          } for
1894          /dsubT 0 def
1895          subTwidth SLW subTColor                  % set line width and subtick color
1896          subLSstroke
1897          grestore
1898        }
1899        dsubT abs 0 gt {                           % do we have subticks?
1900          gsave                                    % save main state
1901% start subticks ----------------------------------------------------------
1902          /cntsubTick cntTick dsubT add def
1903          subTNo 1 sub {
1904            cntsubTick abs MinValue abs le {       % out of range?
1905              cntsubTick tickstart STsize mul #5\space moveto
1906              cntsubTick tickend STsize mul #5\space lineto
1907            }{ exit } ifelse
1908            /cntsubTick cntsubTick dsubT add def
1909          } repeat % for
1910% end subticks ----------------------------------------------------------
1911          subTwidth SLW subTColor                  % set line width and subtick color
1912          subLSstroke
1913          grestore                                 % restore main state
1914        } if
1915        gsave
1916        cntTick tickstart #5\space moveto         % line begin main Tick
1917        cntTick tickend #5\space lineto           % lineto tick end
1918        Twidth SLW TColor                         % set line width and tick color
1919        LSstroke
1920        grestore
1921      } for
1922% end ticks ----------------------------------------------------------
1923%\fi   
1924    } if%
1925   }
1926  \end@SpecialObj%
1927  \ignorespaces%
1928}%
1929%
1930\def\psxs@frame{%
1931  \begin@SpecialObj%
1932    \addto@pscode{%
1933      \pst@number\pst@dima \pst@number\pst@dimb moveto \pst@number\pst@dimc \pst@number\pst@dimb L
1934      \pst@number\pst@dimc \pst@number\pst@dimd L \pst@number\pst@dima \pst@number\pst@dimd L
1935      closepath}%
1936    \pst@stroke%
1937    \psk@fillstyle%
1938  \end@SpecialObj%
1939  \let\psk@arrowA\@empty%
1940  \let\psk@arrowB\@empty%
1941%  \pst@dima=0pt\pst@dimb=0pt%
1942%  \psset{xticksize=0 \pst@dimd,yticksize=0 \pst@dimc}%
1943  \pst@xticksizeC=\z@\pst@yticksizeC=\z@%
1944  \psxs@@axes\pst@dima\pst@dimb\pst@dimc\pst@dimd{}%
1945  \psxs@@axes\pst@dima\pst@dimb\pst@dimc\pst@dimd{exch}%
1946}
1947%
1948% #1:Max/Min in pt from origin; #2:arrow; #3:min; #4:max
1949\def\pst@hlabels#1#2#3#4{%
1950  \ifdim#1=\z@\else%                   % start from 0 ?
1951    \ifx#2\empty\else\advance#1\ifdim#1>\z@-\fi7\pslinewidth\fi%
1952    \pst@cnta=#1\relax%                % Distance (in sp) to end.
1953    \divide\pst@cnta\psk@dx\relax%     % Number of ticks/labels
1954    \ifnum\pst@cnta=\z@\else%
1955      \pst@dimb=\psk@dx sp%            % Space between ticks.
1956%        \ifPst@yAxis\else\showorigintrue\fi%
1957        \ifnum\psk@labels<\tw@ \ifPst@xAxis\pst@@hlabels\fi\fi%
1958        \showoriginfalse%
1959    \fi%
1960  \fi%
1961}
1962% Knows \pst@dimb and \pst@cnta
1963\def\pst@@hlabels{%
1964  \pst@dimm=\pst@xticksizeC\advance\pst@dimm by \pslabelsep%
1965  \vbox to\z@{%
1966    \ifdim\pst@dimd>\z@\vskip\pst@dimm\else\vss\fi%
1967    \ifnum\pst@cnta<\z@\pst@dimb=-\pst@dimb\fi%
1968    \hbox to\z@{%
1969      \ifshoworigin\hbox to \z@{\hss\pst@@@hlabel{\psk@Ox}\hss}\fi%
1970      \mmultido{\n=\psk@Ox+\psk@Dx}{\pst@cnta}{%
1971        \hskip\pst@dimb\hbox to \z@{\hss\pst@@@hlabel{\n}\hss}%
1972      }\hss%
1973    }%
1974    \ifdim\pst@dimd>\z@\vss\else\vskip\pst@dimm\fi%
1975}}%
1976
1977% #1:Max/Min in pt from origin; #2:arrow; #3:min; #4:max
1978% \psk@labels 0:all; 1:x; 2:y; 3:none
1979\def\pst@vlabels#1#2#3#4{%
1980  \ifdim#1=\z@\else%
1981    \ifx#2\empty\else\advance#1\ifdim#1>\z@-\fi7\pslinewidth\fi%
1982    \pst@cnta=#1\relax          %      % Distance (in sp) to end.
1983    \divide\pst@cnta\psk@dy\relax  %   % Number of ticks/labels
1984    \ifnum\pst@cnta=\z@\else%
1985      \pst@dima=\psk@dy sp%            % Space between ticks.
1986%      \ifPst@xAxis\else\showorigintrue\fi%
1987      \ifodd\number\psk@labels\else\ifPst@yAxis\pst@@vlabels\fi\fi%
1988      \showoriginfalse%
1989    \fi%
1990  \fi%
1991}
1992% \pst@dima: the width between two labels in pt
1993% \pst@dimc: the coordinate of the origin in pt
1994% \pst@cnta: the lowest label
1995\def\pst@@vlabels{%
1996  \pst@dimm=\pst@yticksizeC%
1997  \advance\pst@dimm by \pslabelsep%
1998  \vbox to\z@{%
1999    \ifnum\pst@cnta>\z@\pst@dima=-\pst@dima\fi%
2000    \offinterlineskip%
2001    \ifshoworigin
2002      \vbox to \z@{\vss\hbox to\z@{%
2003        \ifdim\pst@dimc>\z@\hss\else\hskip\pst@dimm\fi
2004        \pst@@@vlabel{\psk@Oy}%
2005        \ifdim\pst@dimc>\z@\hskip\pst@dimm\else\hss\fi}\vss}%
2006    \fi%
2007    \mmultido{\n=\psk@Oy+\psk@Dy}{\pst@cnta}{%
2008      \vbox to\pst@dima{\vss}
2009      \vbox to \z@{%
2010        \vss\hbox to\z@{%
2011          \ifdim\pst@dimc>\z@%
2012            \hss\pst@@@vlabel{\n}\hskip\pst@dimm%
2013          \else%
2014            \hskip\pst@dimm\pst@@@vlabel{\n}\hss%
2015          \fi
2016        }\vss%
2017    }}%
2018    \vss%
2019}}
2020%
2021\define@key[psset]{pstricks-add}{nStep}{\def\psk@nStep{#1}}
2022\define@key[psset]{pstricks-add}{nStart}{\def\psk@nStart{#1}}
2023\define@key[psset]{pstricks-add}{nEnd}{\def\psk@nEnd{#1}}
2024\define@key[psset]{pstricks-add}{xStep}{\def\psk@xStep{#1}}
2025\define@key[psset]{pstricks-add}{yStep}{\def\psk@yStep{#1}}
2026%
2027\define@key[psset]{pstricks-add}{xStart}{\def\psk@xStart{#1}}
2028\define@key[psset]{pstricks-add}{xEnd}{\def\psk@xEnd{#1}}
2029\define@key[psset]{pstricks-add}{yStart}{\def\psk@yStart{#1}}
2030\define@key[psset]{pstricks-add}{yEnd}{\def\psk@yEnd{#1}}
2031%
2032\define@key[psset]{pstricks-add}{plotNo}{\def\psk@plotNo{#1}}
2033\define@key[psset]{pstricks-add}{plotNoMax}{\def\psk@plotNoMax{#1}}
2034%
2035%\psset{nStep=1, nStart=0, nEnd={},%
2036%  xStep=0, yStep=0, xStart={}, xEnd={},  yStart={}, yEnd={}, comma=false,%
2037%  plotNo=1,plotNoMax=1}%
2038%
2039\def\pstScalePoints(#1,#2)#3#4{%
2040%  xScale | yScale | xOperator | yOperator 
2041% the operators can be any Postscript code
2042  \pst@def{ScalePoints}<%
2043    /y ED /x ED
2044    counttomark dup dup cvi eq not { exch pop } if
2045    /m exch def /n m 2 div cvi def
2046    n {
2047      #4\space y mul #2\space mul m 1 roll
2048      #3\space x mul #1\space mul m 1 roll
2049      /m m 2 sub
2050      def } repeat>%
2051}
2052%\pstScalePoints(1,1){}{}% the default -> no special operators
2053%
2054\def\listplot@ii#1{%
2055  \@nameuse{beginplot@\psplotstyle}%
2056  \addto@pscode{/D {} def mark}%
2057  #1%
2058  \addto@pscode{%
2059    \tx@PreparePoints
2060    \pst@number\psxunit
2061    \pst@number\psyunit
2062    \tx@ScalePoints%
2063  }%
2064  \@nameuse{endplot@\psplotstyle}%
2065}
2066%
2067\define@boolkey[psset]{pstricks-add}[Pst@]{ChangeOrder}[true]{}
2068\pst@def{PreparePoints}<{%
2069  counttomark /m exch def
2070  \ifPst@ChangeOrder
2071    /m0 m def
2072    m \psk@plotNoMax\space 1 add div 1 sub cvi {
2073      m0 \psk@plotNoMax\space 1 add roll /m0 m0 \psk@plotNoMax\space 1 add sub def
2074    } repeat
2075  \fi
2076  /n m \psk@plotNoMax\space 1 add div cvi def
2077  \psk@plotNoMax\space 1 gt {% multiple data files?
2078    n {
2079      \psk@plotNoMax\space \psk@plotNo\space 1 sub neg roll % x yNo y y y ...
2080      \psk@plotNoMax\space 1 sub { pop } repeat % x yNo
2081      /m m \psk@plotNoMax\space 1 sub sub def
2082      m 2 roll
2083    } repeat
2084  } if % no multiple data files
2085%       counttomark /m exch def
2086%       /n m 2 div cvi def
2087  /xMax -99999 def /yMax -99999 def
2088  /xP 0 def /yP 0 def
2089  m copy
2090  n {
2091    /y exch def /x exch def
2092    xMax x lt { /xMax x def } if
2093    yMax y lt {/yMax y def } if
2094    xP x gt { /xP x def } if
2095    yP y gt { /yP y def } if
2096  } repeat
2097%       m 2 roll
2098  \psk@xStep\space 0 gt \psk@yStep\space 0 gt or (\psk@xStart) length 0 gt or
2099  (\psk@yStart) length 0 gt or (\psk@xEnd) length 0 gt or (\psk@yEnd) length 0 gt or {
2100%
2101    (\psk@xStart) length 0 gt {\psk@xStart\space }{ xP } ifelse /xStart exch def
2102    (\psk@yStart) length 0 gt {\psk@yStart\space }{ yP } ifelse /yStart exch def
2103    (\psk@xEnd) length 0 gt { \psk@xEnd\space }{ xMax } ifelse /xEnd exch def
2104    (\psk@yEnd) length 0 gt { \psk@yEnd\space }{ yMax } ifelse /yEnd exch def
2105    n {
2106      m -2 roll
2107      2 copy /yVal exch def /xVal exch def
2108      xVal xP ge
2109      yVal yP ge and
2110      xVal xEnd le and
2111      yVal yEnd le and
2112      xVal xStart ge and
2113      yVal yStart ge and {
2114        /xP xP \psk@xStep\space add def
2115        /yP yP \psk@yStep\space add def
2116      }{%
2117        pop pop
2118        /m m 2 sub def
2119      } ifelse
2120    } repeat
2121  }{%
2122    /ncount 0 def
2123    (\psk@nEnd) length 0 gt { \psk@nEnd\space }{ m } ifelse
2124    /nEnd exch def
2125    n {
2126      m -2 roll
2127      \psk@nStep\space 1 gt {
2128        ncount \psk@nStart\space sub \psk@nStep\space mod 0 eq }{ true } ifelse
2129        ncount nEnd le and
2130        ncount \psk@nStart\space ge and not {
2131          pop pop
2132          /m m 2 sub def
2133        } if
2134        /ncount ncount 1 add def
2135      } repeat
2136  } ifelse
2137}>
2138%
2139%
2140\define@key[psset]{pstricks-add}{xAxisLabel}{\def\psk@xAxisLabel{#1}}
2141\define@key[psset]{pstricks-add}{yAxisLabel}{\def\psk@yAxisLabel{#1}}
2142%\psset{xAxisLabel=x,yAxisLabel=y}
2143\define@key[psset]{pstricks-add}{xAxisLabelPos}{\def\psk@xAxisLabelPos{#1}}
2144\define@key[psset]{pstricks-add}{yAxisLabelPos}{\def\psk@yAxisLabelPos{#1}}
2145%\psset{yAxisLabelPos={},xAxisLabelPos={}}
2146%
2147\newdimen\psk@llx
2148\newdimen\psk@lly
2149\newdimen\psk@urx
2150\newdimen\psk@ury
2151\define@key[psset]{pstricks-add}{llx}{\pssetxlength\psk@llx{#1}}
2152\define@key[psset]{pstricks-add}{lly}{\pssetylength\psk@lly{#1}}
2153\define@key[psset]{pstricks-add}{urx}{\pssetxlength\psk@urx{#1}}
2154\define@key[psset]{pstricks-add}{ury}{\pssetylength\psk@ury{#1}}
2155%\psset{llx=\z@, lly=\z@, urx=\z@, ury=\z@}% prevents rounding errors
2156\newif\ifPst@plot@box
2157\define@key[psset]{pstricks-add}{box}[true]{\@nameuse{Pst@plot@box#1}}
2158%
2159\newdimen\pst@xunit
2160\newdimen\pst@yunit
2161%
2162\def\psgraph{\pst@object{psgraph}}
2163\def\psgraph@i{\pst@getarrows\psgraph@ii}
2164\def\psgraph@ii(#1,#2){\catcode`\!=12\@ifnextchar({\psgraph@iii(#1,#2)}{\psgraph@iv(0,0)(#1,#2)}}
2165\def\psgraph@iii(#1,#2)(#3,#4){\@ifnextchar({\psgraph@v(#1,#2)(#3,#4)}{\psgraph@iv(#1,#2)(#3,#4)}}
2166%
2167\def\psgraph@iv(#1,#2)(#3,#4)#5#6{%  no special origin defined
2168% minX | minY | maxX | maxY | Length x-axis | length y-axis% 
2169  \pst@killglue%
2170  \begingroup%
2171  \pst@dimo=#3\p@\advance\pst@dimo by -#1\p@% delta x
2172  \pst@divide{#5}{\pst@dimo}\pst@tempA%
2173  \pst@xunit=\pst@tempA\p@%
2174  \pst@dimo=#4\p@\advance\pst@dimo by -#2\p@% delta y
2175  \ifx!#6 \pst@dima=\pst@tempA\pst@dimo\else\pst@dima=#6\fi
2176  \pst@divide\pst@dima{\pst@dimo}\pst@tempA%
2177  \pst@yunit=\pst@tempA\p@%
2178  %
2179  \pst@dima=#1\pst@xunit \advance\pst@dima by \psk@llx%
2180  \pst@dimb=#2\pst@yunit \advance\pst@dimb by \psk@lly%
2181  \pst@dimc=#3\pst@xunit \advance\pst@dimc by \psk@urx%
2182  \pst@dimd=#4\pst@yunit \advance\pst@dimd by \psk@ury%
2183  \if@star\pspicture*(\pst@dima,\pst@dimb)(\pst@dimc,\pst@dimd)\else%
2184    \pspicture(\pst@dima,\pst@dimb)(\pst@dimc,\pst@dimd)\fi%
2185  \psset{xunit=\pst@xunit,yunit=\pst@yunit}%
2186  \bgroup%
2187  \use@par%
2188  \psaxes(#1,#2)(#3,#4)%
2189  \egroup%
2190  \psgraph@vi(#1,#2)(#3,#4)%
2191}
2192\def\psgraph@v(#1,#2)(#3,#4)(#5,#6)#7#8{%  with special origin
2193% Xorig | yorig | minX | minY | maxX | maxY | Length x-axis | length y-axis% 
2194  \pst@killglue%
2195  \begingroup%
2196  \pst@dimo=#5\p@\advance\pst@dimo by -#3\p@% delta x
2197  \pst@divide{#7}{\pst@dimo}\pst@tempA%
2198  \pst@xunit=\pst@tempA\p@%
2199  \pst@dimo=#6\p@\advance\pst@dimo by -#4\p@% delta y
2200  \ifx!#8 \pst@dima=\pst@tempA\pst@dimo\else\pst@dima=#8\fi
2201  \pst@divide\pst@dima{\pst@dimo}\pst@tempA%
2202  \pst@yunit=\pst@tempA\p@%
2203  %
2204  \pst@dima=#3\pst@xunit \advance\pst@dima by \psk@llx%
2205  \pst@dimb=#4\pst@yunit \advance\pst@dimb by \psk@lly%
2206  \pst@dimc=#5\pst@xunit \advance\pst@dimc by \psk@urx%
2207  \pst@dimd=#6\pst@yunit \advance\pst@dimd by \psk@ury%
2208  \if@star\pspicture*(\pst@dima,\pst@dimb)(\pst@dimc,\pst@dimd)\else%
2209    \pspicture(\pst@dima,\pst@dimb)(\pst@dimc,\pst@dimd)\fi%
2210  \psset{xunit=\pst@xunit,yunit=\pst@yunit}%
2211  \bgroup%
2212  \use@par%
2213  \psaxes(#1,#2)(#3,#4)(#5,#6)%
2214  \egroup%
2215  \psgraph@vi(#1,#2)(#5,#6)%
2216}
2217\def\psgraph@vi(#1,#2)(#3,#4){%
2218  \ifx\psk@xAxisLabel\@empty\else%
2219    \ifx\psk@xAxisLabelPos\@empty\uput[0](#3,#2){\psk@xAxisLabel}%
2220    \else\rput(\psk@xAxisLabelPos){\psk@xAxisLabel}%
2221    \fi%
2222  \fi%
2223  \ifx\psk@yAxisLabel\@empty\else%
2224    \ifx\psk@yAxisLabelPos\@empty\uput[90](#1,#4){\psk@yAxisLabel}%
2225    \else\rput{90}(\psk@yAxisLabelPos){\psk@yAxisLabel}%
2226    \fi%
2227  \fi%
2228  \ignorespaces%
2229}
2230\def\endpsgraph{%
2231  \pst@killglue%
2232  \endpspicture%
2233  \endgroup%
2234}
2235\@namedef{psgraph*}{\psgraph*}
2236\@namedef{endpsgraph*}{\endpsgraph}
2237%
2238\define@key[psset]{pstricks-add}{ignoreLines}{\def\psk@ignoreLines{#1}}
2239
2240\newcount\linecnt
2241\begingroup
2242\catcode`\,=13
2243\catcode`\_=13
2244\gdef\savedata@#1[#2]{%
2245  \xdef\pst@tempg{#2_}%
2246  \endgroup
2247  \let#1\pst@tempg
2248  \global\let\pst@tempg\relax
2249  \ignorespaces}
2250\gdef\readdata@{%
2251  \read1 to \pst@tempA
2252  \ifnum\linecnt=\psk@nStep
2253    \global\linecnt=0
2254    \expandafter\readdata@@\pst@tempA_\@nil
2255  \fi
2256  \global\advance\linecnt by 1
2257  \ifeof1\else\expandafter\readdata@\fi}
2258\gdef\pst@@readfile#1#2\@nil{\addto@pscode{,#1#2}}%
2259\gdef\readdata@@#1#2\@nil{\xdef\pst@tempg{\pst@tempg,#1#2}}%
2260\endgroup
2261
2262\def\readdata{\@ifnextchar[{\readdata@i}{\readdata@i[]}}
2263\def\readdata@i[#1]#2#3{%
2264  \def\pst@tempA{#1}%
2265  \ifx\pst@tempA\@empty\else\psset{#1}\fi
2266  \openin1=#3
2267  \begingroup
2268  \def\pst@tempg{}%
2269  \ifeof1
2270    \@pstrickserr{Data file `#3' not found.}\@ehpa
2271  \else
2272    \pst@datadelimiters
2273    \catcode`\[=1
2274    \catcode`\]=2
2275    \pst@cnta=0
2276    \loop \ifnum\the\pst@cnta<\psk@ignoreLines
2277      \advance\pst@cnta by 1\relax
2278      \read1 to \pst@tempA
2279    \repeat
2280    \ifnum\Pst@Debug>0 \typeout{>>> ignored \the\pst@cnta\space data lines}\fi%
2281    \global\linecnt=\psk@nStep%
2282    \readdata@%
2283  \fi%
2284  \endgroup%
2285  \global\let#2\pst@tempg%
2286  \global\let\pst@tempg\relax%
2287\ignorespaces}
2288%
2289% D.G. addition - Jun.  9, 1998 - Polar plots using the \psplot macro
2290% Code added according the way suggested by Ulrich Dirr <udirr@das-team.com>
2291% For polar plots
2292\define@boolkey[psset]{pstricks-add}[Pst@]{polarplot}[true]{}
2293\define@boolkey[psset]{pstricks-add}[Pst@]{algebraic}[true]{}
2294\psset[pstricks-add]{polarplot=false,algebraic=false}% remark of ML
2295%
2296\define@key[psset]{pstricks-add}{method}{\def\psk@method{#1}}%             adams - rk4
2297\define@key[psset]{pstricks-add}{whichabs}{\def\psk@whichabs{#1}}%
2298\define@key[psset]{pstricks-add}{whichord}{\def\psk@whichord{#1}}%
2299\define@key[psset]{pstricks-add}{plotfuncx}{\def\psk@plotfuncx{#1}}%
2300\define@key[psset]{pstricks-add}{plotfuncy}{\def\psk@plotfuncy{#1}}%
2301\define@key[psset]{pstricks-add}{expression}{\def\psk@expression{#1}}%
2302\define@boolkey[psset]{pstricks-add}[Pst@]{buildvector}[true]{}%
2303\def\@rkiv{rk4}%                Runge-Kutta 4  method
2304\def\@adams{adams}%             Adams method
2305\def\@default{default}%         Adams method
2306%
2307\define@boolkey[psset]{pstricks-add}[Pst@]{VarStep}[true]{}
2308\define@key[psset]{pstricks-add}{PlotDerivative}{\def\psk@PlotDerivative{#1}}%
2309\define@key[psset]{pstricks-add}{VarStepEpsilon}{\def\psk@VarStepEpsilon{#1}}%
2310\define@key[psset]{pstricks-add}{varsteptol}{\def\psk@varsteptol{#1}}%              adams - rk4
2311\define@key[psset]{pstricks-add}{adamsorder}{\def\psk@adamsorder{#1}}%              adams - rk4
2312%\define@key[psset]{pstricks-add}{varstepincrease}{\def\psk@varstepincrease{#1}}% varrk4
2313%
2314\def\psplot@i#1#2#3{%
2315  \pst@killglue
2316  \begingroup
2317    \use@par
2318    \@nameuse{beginplot@\psplotstyle}%
2319% D.G. modification begin - Jun.  9, 1998
2320    \ifPst@polarplot
2321      \addto@pscode{%
2322        \psplot@init
2323        /x #1 def
2324        /x1 #2 def
2325        /dx x1 x sub \psk@plotpoints div def
2326        /F@pstplot \ifPst@algebraic (#3)
2327                    \ifx\psk@PlotDerivative\@none\else
2328                      \psk@PlotDerivative\space { (x) tx@Derive begin Derive end } repeat
2329                    \fi\space
2330                    tx@AlgToPs begin AlgToPs end cvx
2331                 \else { #3 } \fi  def
2332        \ifPst@VarStep
2333          /StillZero 0 def /LastNonZeroStep dx def
2334          /F2@pstplot tx@Derive begin (#3) (x) Derive (x) Derive end
2335                     \ifx\psk@PlotDerivative\@none\else
2336                       \psk@PlotDerivative\space { (x) tx@Derive begin Derive end } repeat
2337                     \fi\space
2338                    tx@AlgToPs begin AlgToPs end cvx def
2339          %% computation of the tolerance defined by plotpoints
2340          /epsilon12 \ifx\psk@VarStepEpsilon\@default tx@Derive begin F2@pstplot end dx 3 exp abs mul abs
2341                    \else\psk@VarStepEpsilon\space 12 mul \fi def
2342          /ComputeStep {
2343            dup 1e-4 lt
2344            { pop StillZero 2 ge { LastNonZeroStep 2 mul } { LastNonZeroStep } ifelse /StillZero StillZero 1 add def }
2345            { epsilon12 exch div 1 3 div exp /StillZero 0 def }
2346            ifelse } bind def
2347        \fi
2348        /xy {% Adapted from \parametricplot@i
2349          F@pstplot x \ifPst@algebraic RadtoDeg \fi PtoC
2350%          #3 dup x cos mul exch x sin mul
2351          \pst@number\psyunit mul exch
2352          \pst@number\psxunit mul exch
2353        } def}%
2354    \else
2355% D.G. modification end
2356    \addto@pscode{%
2357      \psplot@init
2358      /x #1 def
2359      /x1 #2 def
2360      /dx x1 x sub \psk@plotpoints div def
2361      /F@pstplot \ifPst@algebraic (#3)
2362                    \ifx\psk@PlotDerivative\@none\else
2363                      \psk@PlotDerivative\space { (x) tx@Derive begin Derive end } repeat
2364                    \fi\space
2365                    tx@AlgToPs begin AlgToPs end cvx
2366                 \else { #3 } \fi  def
2367      \ifPst@VarStep
2368         /StillZero 0 def /LastNonZeroStep dx def
2369         /F2@pstplot tx@Derive begin (#3) (x) Derive (x) Derive end
2370                     \ifx\psk@PlotDerivative\@none\else
2371                       \psk@PlotDerivative\space { (x) tx@Derive begin Derive end } repeat
2372                     \fi\space
2373                    tx@AlgToPs begin AlgToPs end cvx def
2374         %% computation of the tolerance defined by plotpoints
2375         /epsilon12 \ifx\psk@VarStepEpsilon\@default tx@Derive begin F2@pstplot end dx 3 exp abs mul abs
2376                    \else\psk@VarStepEpsilon\space 12 mul \fi def
2377         /ComputeStep {
2378           dup 1e-4 lt
2379           { pop StillZero 2 ge { LastNonZeroStep 2 mul } { LastNonZeroStep } ifelse /StillZero StillZero 1 add def }
2380           { epsilon12 exch div 1 3 div exp /StillZero 0 def }
2381           ifelse } bind def
2382      \fi
2383      /xy {
2384        x \pst@number\psxunit mul F@pstplot \pst@number\psyunit mul
2385%       \ifPst@algebraic F@pstplot \else #3 \fi \pst@number\psyunit mul
2386      } def}%
2387    \fi
2388    \gdef\psplot@init{}%
2389    \@pstfalse
2390    \@nameuse{testqp@\psplotstyle}%
2391    \if@pst
2392      \psplot@ii
2393    \else
2394      \psplot@iii
2395    \fi
2396  \endgroup
2397  \ignorespaces}
2398%
2399\def\psplot@ii{%
2400  \ifPst@VarStep
2401    \addto@pscode{%
2402      mark xy \@nameuse{beginqp@\psplotstyle}
2403      { F2@pstplot abs ComputeStep
2404        x 2 copy add dup x1 gt {pop x1} if /x exch def F2@pstplot abs ComputeStep
2405        /x 3 -1 roll def 2 copy gt { exch } if pop
2406        /x x 3 -1 roll add dup x1 gt {pop x1} if def
2407        xy \@nameuse{doqp@\psplotstyle}
2408        x x1 eq { exit } if} loop}%
2409  \else\pst@killglue%
2410    \addto@pscode{%
2411      xy \@nameuse{beginqp@\psplotstyle}
2412      \ifx\psk@method\@varrkiv\else\psk@plotpoints 1 sub \fi {
2413        /x x dx add \ifx\psk@method\@varrkiv  dup x1 gt { pop x1 } if \fi def
2414        xy \@nameuse{doqp@\psplotstyle}
2415        \ifx\psk@method\@varrkiv  x x1 eq { exit } if \fi
2416      } \ifx\psk@method\@varrkiv loop\else repeat\fi
2417      /x x1 def
2418      xy \@nameuse{doqp@\psplotstyle}}%
2419  \fi%
2420  \@nameuse{endqp@\psplotstyle}}
2421\def\psplot@iii{%
2422  \ifPst@VarStep
2423    \addto@pscode{%
2424      /n 2 def
2425      mark
2426      { xy n 2 roll F2@pstplot abs
2427        ComputeStep x 2 copy add dup x1 gt {pop x1} if
2428        /x exch def F2@pstplot abs ComputeStep
2429        /x 3 -1 roll def 2 copy gt { exch } if pop
2430        /x x 3 -1 roll dup /LastNonZeroStep exch def add dup x1 gt {pop x1} if def /n n 2 add def
2431        x x1 eq { exit } if } loop
2432      xy n 2 roll}%
2433  \else\pst@killglue%
2434    \addto@pscode{%
2435      mark
2436      /n 2 def
2437      \ifx\psk@method\@varrkiv\else\psk@plotpoints\fi {
2438        xy
2439        n 2 roll
2440        /n n 2 add def
2441        /x x dx add \ifx\psk@method\@varrkiv  dup x1 gt { pop x1 } if \fi def
2442        \ifx\psk@method\@varrkiv  x x1 eq { exit } if \fi
2443      } \ifx\psk@method\@varrkiv loop\else repeat\fi
2444      /x x1 def
2445      xy
2446      n 2 roll}%
2447  \fi%
2448  \@nameuse{endplot@\psplotstyle}}
2449%
2450%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2451\def\parametricplot@i#1#2#3{%
2452  \pst@killglue%
2453  \begingroup
2454    \use@par
2455    \@nameuse{beginplot@\psplotstyle}%
2456    \addto@pscode{%
2457      \psplot@init
2458      /t #1 def
2459      /t1 #2 def
2460      /dt t1 t sub \psk@plotpoints div def
2461      /F@pstplot \ifPst@algebraic (#3)
2462                    \ifx\psk@PlotDerivative\@none\else
2463                      \psk@PlotDerivative\space { (t) tx@Derive begin Derive end } repeat
2464                    \fi\space
2465                    tx@AlgToPs begin AlgToPs end cvx
2466                 \else { #3 } \fi  def
2467      \ifPst@VarStep
2468         /StillZero 0 def /LastNonZeroStep dt def
2469         /F2@pstplot tx@Derive begin (#3) (t) Derive (t) Derive end
2470                     \ifx\psk@PlotDerivative\@none\else
2471                       \psk@PlotDerivative\space { (t) tx@Derive begin Derive end } repeat
2472                     \fi\space
2473                    tx@AlgToPs begin AlgToPs end cvx def
2474         %% computation of the tolerance defined by plotpoints
2475         /epsilon12 \ifx\psk@VarStepEpsilon\@default
2476                       tx@Derive begin F2@pstplot end Pyth
2477                       dt 3 exp abs mul
2478                    \else\psk@VarStepEpsilon\space 12 mul \fi def
2479         /ComputeStep {
2480           dup 1e-4 lt
2481           { pop StillZero 2 ge { LastNonZeroStep 2 mul } { LastNonZeroStep } ifelse /StillZero StillZero 1 add def }
2482           { epsilon12 exch div 1 3 div exp /StillZero 0 def }
2483           ifelse } bind def
2484      \fi
2485      /xy {
2486        \ifPst@algebraic F@pstplot \else #3 \fi
2487        \pst@number\psyunit mul exch
2488        \pst@number\psxunit mul exch
2489      } def}%
2490    \gdef\psplot@init{}%
2491    \@pstfalse
2492    \@nameuse{testqp@\psplotstyle}%
2493    \if@pst
2494      \parametricplot@ii
2495    \else
2496      \parametricplot@iii
2497    \fi
2498  \endgroup
2499  \ignorespaces}
2500\def\parametricplot@ii{%
2501  \ifPst@VarStep
2502    \addto@pscode{%
2503      mark xy \@nameuse{beginqp@\psplotstyle}
2504      { F2@pstplot Pyth ComputeStep
2505        t 2 copy add dup t1 gt {pop t1} if /t exch def F2@pstplot Pyth ComputeStep
2506        /t 3 -1 roll def 2 copy gt { exch } if pop
2507        /t t 3 -1 roll add dup t1 gt {pop t1} if def
2508        xy \@nameuse{doqp@\psplotstyle}
2509        t t1 eq { exit } if } loop}%
2510  \else\pst@killglue%
2511    \addto@pscode{%
2512      xy \@nameuse{beginqp@\psplotstyle}
2513      \psk@plotpoints 1 sub {
2514        /t t dt add def
2515        xy \@nameuse{doqp@\psplotstyle}
2516      } repeat
2517      /t t1 def
2518      xy \@nameuse{doqp@\psplotstyle}}%
2519  \fi%
2520  \@nameuse{endqp@\psplotstyle}}
2521\def\parametricplot@iii{%
2522  \ifPst@VarStep
2523    \addto@pscode{%
2524      /n 2 def
2525      mark
2526      { xy n 2 roll F2@pstplot Pyth
2527        ComputeStep t 2 copy add dup t1 gt {pop t1} if
2528        /t exch def F2@pstplot Pyth ComputeStep
2529        /t 3 -1 roll def 2 copy gt { exch } if pop
2530        /t t 3 -1 roll dup /LastNonZeroStep exch def add dup t1 gt {pop t1} if def /n n 2 add def
2531        t t1 eq { exit } if } loop
2532      xy n 2 roll}%
2533  \else\pst@killglue%
2534    \addto@pscode{%
2535      mark
2536      /n 2 def
2537      \psk@plotpoints {
2538        xy
2539        n 2 roll
2540        /n n 2 add def
2541        /t t dt add def
2542      } repeat
2543      /t t1 def
2544      xy
2545      n 2 roll}%
2546  \fi%
2547  \@nameuse{endplot@\psplotstyle}}
2548%
2549\define@key[psset]{pstricks-add}{barwidth}{\pst@getlength{#1}\Add@barwidth}
2550\psset[pstricks-add]{barwidth=0.25cm}
2551%
2552\def\psbar@ii{\addto@pscode{false \tx@NArray \psbar@iii}}
2553\def\psbar@iii{%
2554  newpath
2555  n { 
2556    /Yval exch def /Xval exch def
2557    Xval \number\Add@barwidth 0.5 mul sub 0 moveto
2558    0 Yval rlineto \number\Add@barwidth 0 rlineto
2559    0 Yval neg rlineto \number\Add@barwidth neg 0 rlineto
2560  } repeat
2561}%
2562\def\beginplot@bar{\begin@SpecialObj}
2563\def\endplot@bar{%
2564  \psbar@ii\psk@fillstyle\ifpsshadow\pst@closedshadow\fi%
2565  \pst@stroke
2566  \end@SpecialObj%
2567}
2568%
2569% LSM Least Square Method 2006-03-13 (hv)
2570\def\psLSM@ii{\addto@pscode{false \tx@NArray \psLSM@iii}}
2571\def\psLSM@iii{%
2572  /xiSquare 0 def                               % xi*xi
2573  /xi 0 def                                     % xi
2574  /fi 0 def                                     % f(xi)
2575  /xifi 0 def                                   % xi*f(xi)
2576  exch dup dup /xEnd ED /xStart ED exch
2577  n {                                           % number of data pairs
2578    /Yval ED /Xval ED                           % save x y values
2579    /xi xi Xval add def                         % sum xi
2580    /xiSquare xiSquare Xval dup mul add def     % sum xi*xi
2581    /xifi xifi Xval Yval mul add def            % sum xi*yi, same as xi*f(xi)
2582    /fi fi Yval add def                         % sum yi, same as f(xi)
2583    Xval xStart lt { /xStart Xval def } if      % find the lowest xi
2584    Xval xEnd gt { /xEnd Xval def } if          % find the largest xi
2585  } repeat
2586  /u xiSquare fi mul xi xifi mul sub n xiSquare mul xi dup mul sub div def
2587  /v n xifi mul xi fi mul sub n xiSquare mul xi dup mul sub div def
2588  \Pst@Debug\space 0 gt {                       % print the equation
2589    /Helvetica findfont 12 scalefont setfont   
2590    0 -50 moveto (y=)show                       % print y=
2591    v 20 string cvs show ( x+) show             % v x+
2592    u \pst@number\psyunit div 20 string cvs show } if
2593  newpath
2594  (\psk@xStart) length 0 gt                     % special start value?
2595    { \psk@xStart\space \pst@number\psxunit mul }
2596    { xStart } ifelse 
2597  dup v mul u add                               % xStart f(xStart) 
2598  moveto                                        % goto first point x1 y(x1)
2599  (\psk@xEnd) length 0 gt                       % special end value?
2600    { \psk@xEnd\space \pst@number\psxunit mul }
2601    { xEnd } ifelse
2602  dup v mul u add                               % xEnd f(xEnd) 
2603  lineto                                        % line to second point x2 y(x2)
2604}%
2605%
2606\def\beginplot@LSM{\begin@SpecialObj}
2607\def\endplot@LSM{%
2608  \psLSM@ii\psk@fillstyle\ifpsshadow\pst@closedshadow\fi%
2609  \pst@stroke
2610  \end@SpecialObj%
2611}
2612%
2613\define@key[psset]{pstricks-add}{StepType}{\pst@expandafter\psset@@StepType{#1}\@nil}%
2614\def\psset@@StepType#1#2\@nil{%
2615  \ifx#1u\let\psk@StepType\@ne
2616  \else\ifx#1l\let\psk@StepType\z@
2617  \else\ifx#1i\let\psk@StepType\thr@@
2618  \else\ifx#1s\let\psk@StepType\f@ur
2619  \else\let\psk@StepType\tw@\fi\fi\fi\fi}
2620\psset{StepType=lower} %               alternative StepType=upper/inf/sup/Riemann
2621%
2622\def\psStep{\pst@object{psStep}}
2623\def\psStep@i(#1,#2)#3#4{%
2624  \begin@ClosedObj%
2625  \addto@pscode{
2626    \ifPst@algebraic /Func (#4) tx@addDict begin AlgParser end cvx def \fi 
2627    /x #1  def
2628    /dx #2 #1 sub #3 div def
2629    /scx { \pst@number\psxunit mul } def
2630    /scy { \pst@number\psyunit mul } def
2631    \ifcase\psk@StepType % 0->lower, height is always f(x)
2632      x scx 0 moveto
2633      #3 {
2634        \ifPst@algebraic Func \else #4 \fi scy dup x scx exch lineto
2635        /x x dx add def
2636        x scx exch lineto x scx 0 lineto
2637      } repeat
2638    \or % 1-> upper, height is always f(x+dx)
2639      x scx 0 moveto
2640      #3 {
2641        /x x dx add def
2642        \ifPst@algebraic Func \else #4 \fi scy dup x dx sub scx exch lineto
2643        x scx exch lineto x scx 0 lineto
2644      } repeat
2645    \or % 2-> Riemann
2646      /eps3 100 def
2647      /xMinMax [] def
2648      /AMax [] def
2649      /AMin [] def
2650      /dt dx eps3 div def
2651      #3 {
2652        /Max \ifPst@algebraic Func \else #4 \fi def
2653        /Min Max def
2654        /t x def % save x value
2655        eps3 {
2656          \ifPst@algebraic Func \else #4 \fi 
2657          dup
2658          Max lt { /Max exch def } { dup Min gt { /Min exch def }{ pop } ifelse } ifelse
2659          /x x dt add def
2660        } repeat
2661        /x t def  % restore
2662        x scx Min scy Max scy xMinMax aload length 3 add array astore /xMinMax exch def
2663        /x x dx add def
2664      } repeat
2665      /dx dx scx def
2666      xMinMax aload length 3 div cvi { 
2667        /yMax ED /yMin ED /x ED
2668        x yMin moveto dx 0 rlineto x dx add yMax lineto
2669        dx neg 0 rlineto x yMin lineto } repeat
2670    \or % 3->inf(imum)
2671      x scx 0 moveto
2672      #3 {
2673        \ifPst@algebraic Func \else #4 \fi /y0 ED % left value f(x)
2674        /xOld x def
2675        /x x dx add def
2676        \ifPst@algebraic Func \else #4 \fi /y1 ED % right value f(x+dx)
2677        y0 y1 lt { y0 }{ y1 } ifelse              % use infimum
2678        scy dup xOld scx exch lineto
2679        x scx exch lineto x scx 0 lineto
2680      } repeat
2681    \or % 4-> sup(remum)
2682      x scx 0 moveto
2683      #3 {
2684        \ifPst@algebraic Func \else #4 \fi /y0 ED % left value f(x)
2685        /x x dx add def
2686        \ifPst@algebraic Func \else #4 \fi /y1 ED % right value f(x+dx)
2687        y0 y1 gt { y0 }{ y1 } ifelse              % use supremum
2688        scy dup x dx sub scx exch lineto
2689        x scx exch lineto x scx 0 lineto
2690      } repeat
2691    \fi
2692  }%
2693  \psk@fillstyle
2694  \pst@stroke
2695  \end@ClosedObj%
2696}
2697%
2698\define@key[psset]{pstricks-add}{Derive}{\def\psk@Derive{#1}}%
2699\define@boolkey[psset]{pstricks-add}[PST@]{Tnormal}[true]{}
2700
2701\psset[pstricks-add]{CMYK=true}
2702\def\@NOTEMPTY{NOT@EMPTY}%%dr 0606
2703%
2704%% #1 : x value
2705%% #2 : delta x
2706%% #3 : function
2707\def\psplotTangent{\pst@object{psplotTangent}}%  idea from Dominique Rodriguez
2708\def\psplotTangent@i#1#2#3{%
2709  \begin@OpenObj%
2710%  \let\pst@linetype\pst@arrowtype%
2711%  \pst@addarrowdef%
2712  \ifx\psk@Derive\@empty\ifPst@algebraic\psset{Derive=NOT@EMPTY}\fi\fi%%dr 0606
2713  \addto@pscode{
2714    gsave % save current state
2715    /F@pstplot \ifPst@algebraic (#3) tx@addDict begin AlgParser end cvx \else { #3 } \fi def % define function
2716    \ifx\psk@Derive\@empty\else
2717    \ifx\psk@Derive\@NOTEMPTY\else%%dr 0606
2718      /FDer@pstplot % do we have a derivation defined?
2719        \ifPst@algebraic (\psk@Derive) tx@addDict begin AlgParser end cvx \else { \psk@Derive } \fi def % define derivation
2720    \fi%%dr 0606
2721    \fi
2722    /@parametric false def %%dr 0606
2723    % first we calculate the origin
2724    #1 dup /x ED /t ED tx@addDict begin mark F@pstplot end counttomark 1 gt % test, if we have parametricplot
2725      %%{ /y ED /x ED } % if yes, then we have 2 values
2726      { /y ED /x ED /@parametric true def } % if yes, then we have 2 values%%dr 0606
2727      { \ifPst@polarplot x \ifPst@algebraic RadtoDeg \fi PtoC /y ED /x ED \else /y ED \fi } ifelse
2728    cleartomark
2729    \ifx\psk@Derive\@NOTEMPTY%%begin dr 0606
2730        %% algebraic we can use the derivative machine
2731        /FDer@pstplot (#3) @parametric { (t) } { (x) } ifelse
2732        tx@Derive begin Derive end tx@addDict begin AlgParser end cvx def
2733    \fi%%end dr 0606
2734    x \pst@number\psxunit mul y \pst@number\psyunit mul
2735    translate % define the temporary origin
2736    % now we calculate the slope of the tangent
2737    \ifx\psk@Derive\@empty% de we have a derivation defined?
2738      #1 abs 1.0e-6 lt % no, we choose secant for the tangent
2739      { #1 0.0005 add dup /x ED /t ED tx@addDict begin mark F@pstplot end counttomark 1 gt % test, if we have parametricplot
2740        { /y2 ED /x2 ED }  % we have 2 values
2741        { \ifPst@polarplot dup x \ifPst@algebraic RadtoDeg \fi 
2742          cos mul /x2 ED x \ifPst@algebraic RadtoDeg \fi sin mul \else /x2 x def \fi /y2 ED } ifelse
2743        cleartomark % delete the mark
2744        #1 0.0005 sub dup /x ED /t ED tx@addDict begin mark F@pstplot end counttomark 1 gt % test, if we have parametricplot
2745          { /y1 ED /x1 ED }
2746          { \ifPst@polarplot dup x \ifPst@algebraic RadtoDeg \fi 
2747            cos mul /x1 ED x \ifPst@algebraic RadtoDeg \fi sin mul \else /x1 x def \fi /y1 ED } ifelse
2748         cleartomark
2749        y2 y1 sub x2 x1 sub } % dy dx
2750      {  % > 1.0e-06
2751        #1 1.0005 mul dup /x ED /t ED tx@addDict begin mark F@pstplot end counttomark 1 gt % test, if we have parametricplot
2752          { /y2 ED /x2 ED } % we have 2 values
2753          { \ifPst@polarplot dup x \ifPst@algebraic RadtoDeg \fi 
2754            cos mul /x2 ED x \ifPst@algebraic RadtoDeg \fi sin mul \else /x2 x def \fi /y2 ED } ifelse
2755        cleartomark
2756        #1 .9995 mul dup /x ED /t ED tx@addDict begin mark F@pstplot end counttomark 1 gt % test, if we have parametricplot
2757          { /y1 ED /x1 ED } % we have 2 values
2758          { \ifPst@polarplot dup x \ifPst@algebraic RadtoDeg \fi 
2759            cos mul /x1 ED x \ifPst@algebraic RadtoDeg \fi sin mul \else /x1 x def \fi /y1 ED } ifelse
2760        cleartomark
2761        y2 y1 sub \pst@number\psyunit mul x2 x1 sub \pst@number\psxunit mul } ifelse
2762      atan %  atan(dy dx), we have the slope angle of the secant
2763    \else % there is a derivation defined
2764    #1 dup /x ED /t ED tx@addDict begin mark FDer@pstplot end counttomark 1 gt % test, if we have parametricplot
2765      { /y ED /x ED }
2766      { \ifPst@polarplot /Fphi ED % the value F'(phi)
2767           tx@addDict begin F@pstplot end x \ifPst@algebraic RadtoDeg \fi PtoC /y0 ED /x0 ED % the x y values
2768           x \ifPst@algebraic RadtoDeg \fi sin Fphi mul x0 add /y ED
2769           x \ifPst@algebraic RadtoDeg \fi cos Fphi mul y0 sub /x ED
2770      \else /y ED /x 1 def \fi } ifelse
2771    cleartomark
2772    y \pst@number\psyunit mul x \pst@number\psxunit mul Atan \ifPST@Tnormal 90 add \fi
2773%    y ATAN1  % we have the slope angle of the tangent. ATAN is defined int the pstricks.pro, patch 6
2774    \fi
2775    rotate                                      % rotate, depending to the origin
2776    /Lineto /lineto load def
2777    [
2778    \ifPST@Tnormal
2779      0 0 % moveto
2780      #2
2781      y \pst@number\psyunit mul x \pst@number\psxunit mul Atan 90 add cos div \pst@number\psxunit mul 0  % lineto
2782    \else   
2783      -#2 \pst@number\psxunit mul 0             % moveto
2784       #2 \pst@number\psxunit mul 0             % lineto
2785    \fi
2786    \pst@cp                                     % kill the currentpoint, if any
2787    false                                       % don't show the points
2788    \tx@Line
2789%      ArrowA CP 4 2 roll ArrowB L              % the line with arrows L is defined in pstricks.pro
2790%     \pst@number\pslinewidth SLW               % set linewidth in pt
2791%     \@nameuse{psls@\pslinestyle}              % linestyle
2792%     \pst@usecolor\pslinecolor                 % linecolor
2793    stroke                                      % stroke everything
2794    \ifshowpoints                               % show the points?
2795      \psk@dotsize
2796      \@nameuse{psds@\psk@dotstyle}%
2797      0 0 Dot
2798    \fi
2799    grestore                                    % restore old graphics state
2800   }%
2801  \use@pscode                                   % part of \end@OpenObj
2802  \endgroup%                                    % part of \end@OpenObj
2803  \ignorespaces%                                % part of \end@OpenObj
2804}%
2805%
2806\def\@varrkiv{varrkiv}%         Runge-Kutta 4 with an adaptive step method
2807%% #1-#2 x range
2808%% #3 initial value of y (which is a vector) y(0) y'(0) y''(0) ...
2809%% #4 value of the derivative (y and t can be used)
2810%
2811\define@key[psset]{pstricks-add}{filename}{\def\psk@filename{#1}}%
2812\define@boolkey[psset]{pstricks-add}[Pst@]{saveData}[true]{} % \ifPst@saveData
2813\psset[pstricks-add]{saveData=false,filename=PSTdata}
2814%
2815\def\psplotDiffEqn{\pst@object{psplotDiffEqn}}% initial code by Dominique 2005-05-21
2816\def\psplotDiffEqn@i#1#2#3#4{%
2817  \pst@killglue%
2818  \begingroup%
2819  \use@par%
2820  \@nameuse{beginplot@\psplotstyle}%
2821  \addto@pscode{%
2822    \ifPst@saveData /Pst@data (\psk@filename) (w) file def \fi
2823    /x #1 def                           % first value
2824    /x1 #2 def                          % last value
2825    /y [ #3 ] def                       % values for t=0
2826    /ylength y length def               % number of elements in #3
2827    /addvect {
2828      1 1 ylength {
2829        /i exch def
2830        ylength i sub 2 add -1 roll add ylength 2 mul i sub 1 roll
2831      } for
2832    } def
2833    /dx x1 x sub \psk@plotpoints\space div def
2834    /mulvect {
2835      ylength exch
2836      1 index {
2837        dup 4 -1 roll mul 2 index 2 add 1 roll
2838      } repeat
2839      pop pop } def
2840    /divvect { ylength exch 1 index { dup 4 -1 roll exch div 2 index 2 add 1 roll } repeat pop pop } def
2841    /k0 0 def /k1 0 def /k2 0 def /k3 0 def
2842    \ifPst@algebraic /F@pstplot (#4) tx@addDict begin AlgParser end cvx def \fi
2843    /Func {
2844      \ifPst@algebraic F@pstplot ylength array astore
2845      \else
2846        \ifPst@buildvector\else y aload pop \fi #4
2847        \ifPst@buildvector\else ylength array astore \fi
2848      \fi
2849    } def
2850    \ifx\psk@method\@adams /F1 0 def /F2 0 def /F3 0 def /F4 0 def /F5 0 def /F6 0 def /INIT 1 def \fi
2851    \ifx\psk@method\@empty\else
2852      \ifx\psk@method\@varrkiv  %% RUNGE-KUTTA method with var step algorithm
2853        /VarStep false def /VarStepRatio 1 def
2854        /RK {
2855           /k0 Func { dx mul } forall ylength array astore def                          %% y
2856           dup aload pop k0 { 2 div } forall addvect ylength array astore /y exch def %
2857           x dup dx 2 div add /x exch def                                               %% y x
2858           /k1 Func { dx mul } forall ylength array astore def                          %% y x
2859           exch dup aload pop k1 { 2 div } forall addvect y astore pop                  %% x y
2860           /k2 Func { dx mul } forall ylength array astore def                          %% x y
2861           dup aload pop k2 aload pop addvect y astore pop exch dup dx add /x exch def  %% y x
2862           /k3 Func { dx mul } forall ylength array astore def %% y x
2863           /x exch def                                                                  %% y
2864           dup aload pop k0 aload pop k1 aload pop k2 aload pop addvect
2865           2 mulvect addvect k3 aload pop addvect
2866           6 divvect addvect y astore
2867        } def
2868        /VARRK {
2869          VarStep
2870          %{ /dx dx \psk@varstepincrease\space mul def /VarStep false def } if
2871          { /dx dx VarStepRatio mul def /VarStep false def } if
2872          x dx add x1 gt { /dx x1 x sub def } if
2873          %{ /dx dx \psk@varstepdecrease\space div def } ifelse
2874          %% we compute y(x+dx) from y(x) using RK4
2875          RK %% y(x) y(x+dx)
2876          exch /y exch def /dx dx 2 div def
2877          { %% we compute y(x+dx/2) from y(x) using RK4
2878            y RK %% y(x+dx) y(x+dx/2)
2879            %% then y(x+dx) from y(x+dx/2) using RK4
2880            /y exch def y RK %% y(x+dx) y(x) y(x+dx/2) y(x+dx)
2881            dup aload pop 4 ylength add -1 roll
2882            { -1 mul } forall addvect 0 ylength { exch abs 2 copy lt { exch } if pop } repeat
2883            0 3 -1 roll {abs 2 copy lt { exch } if pop } forall
2884            dup 1e-6 lt { pop } { div } ifelse
2885            /dx dx 2 mul def
2886            dup \psk@varsteptol\space lt
2887            %{ \psk@varsteptol\space div .1 lt { /VarStep true def } if pop exit } if
2888            %pop /dx dx 4 div def exch /y exch def } loop
2889            { .001 div dup .1 lt
2890              { dup 1e-6 lt { pop 3 } { log neg } ifelse /VarStepRatio exch def /VarStep true def }
2891              { pop } ifelse pop exit } if
2892            pop /dx dx 4 div def exch /y exch def } loop
2893        } def
2894      \else                     %% RUNGE-KUTTA & ADAMS  methods
2895        /RK {
2896           /k0 Func { dx mul } forall ylength array astore def                          %% y
2897           dup aload pop k0 { 2 div } forall addvect ylength array astore /y exch def %
2898           x dup dx 2 div add /x exch def                                               %% y x
2899           /k1 Func { dx mul } forall ylength array astore def                          %% y x
2900           exch dup aload pop k1 { 2 div } forall addvect y astore pop                  %% x y
2901           /k2 Func { dx mul } forall ylength array astore def                          %% x y
2902           dup aload pop k2 aload pop addvect y astore pop exch dup dx add /x exch def  %% y x
2903           /k3 Func { dx mul } forall ylength array astore def %% y x
2904           /x exch def                                                                  %% y
2905           dup aload pop k0 aload pop k1 aload pop k2 aload pop addvect
2906           2 mulvect addvect k3 aload pop addvect
2907           6 divvect addvect y astore pop
2908        } def
2909        \ifx\psk@method\@adams
2910           /ADAMS {
2911             \ifcase\psk@adamsorder
2912                \errmessage{pstricks-add error: no order 0th for adams method (see user's manual)}
2913             \or\errmessage{pstricks-add error: no order 1st for adams method (see user's manual)}
2914             \or\errmessage{pstricks-add error: no order 2nd for adams method (see user's manual)}
2915             \or\errmessage{pstricks-add error: no order 3rd for adams method (see user's manual)}
2916             \or
2917             %% ORDRE 4
2918               F4 aload pop  55 mulvect
2919               F3 aload pop -59 mulvect addvect
2920               F2 aload pop  37 mulvect addvect
2921               F1 aload pop  -9 mulvect addvect
2922               dx mulvect 24 divvect
2923             \or
2924             %% ORDRE 5
2925               F5 aload pop  1901 mulvect
2926               F4 aload pop -2774 mulvect addvect
2927               F3 aload pop  2616 mulvect addvect
2928               F2 aload pop -1274 mulvect addvect
2929               F1 aload pop   251 mulvect addvect
2930               dx mulvect 720 divvect
2931             \or
2932             %% ORDRE 6
2933               F6 aload pop  4277 mulvect
2934               F5 aload pop -7923 mulvect addvect
2935               F4 aload pop  9982 mulvect addvect
2936               F3 aload pop -7298 mulvect addvect
2937               F2 aload pop  2877 mulvect addvect
2938               F1 aload pop  -475 mulvect addvect
2939               dx mulvect 1440 divvect
2940             \fi
2941             y aload pop addvect ylength array astore /y exch def } def
2942        \fi
2943      \fi
2944    \fi
2945    /xy {
2946      \ifx\psk@plotfuncx\@empty
2947        \ifx\psk@whichabs\@empty x \else y \psk@whichabs\space get \fi
2948      \else \psk@plotfuncx\space \fi
2949      \pst@number\psxunit mul y
2950      \ifx\psk@method\@empty                                                    %% EULER method
2951        /y Func { dx mul } forall y aload pop addvect ylength array astore def
2952      \else%
2953        \ifx\psk@method\@varrkiv                                                %% RUNGE-KUTTA method
2954          VARRK
2955        \else\ifx\psk@method\@rkiv                                              %% RUNGE-KUTTA method
2956          RK
2957        \else
2958          /F1 F2 def /F2 F3 def /F3 F4 def /F4                                  %% ADAMS method
2959          \ifcase\psk@adamsorder\or\or\or\or
2960           %% ORDRE 4
2961           Func def
2962           \or
2963           %% ORDRE 5
2964           F5 def /F5 Func def
2965           \or
2966           %% ORDRE 6
2967           F5 def /F5 F6 def /F6 Func def
2968          \fi
2969           INIT \psk@adamsorder\space lt
2970           { RK /INIT INIT 1 add def }
2971           { ADAMS } ifelse
2972        \fi\fi
2973      \fi
2974      \ifx\psk@plotfuncy\@empty
2975        \ifx\psk@whichord\@empty 0 \else \psk@whichord\space \fi  get %
2976      \else \psk@plotfuncy\space \fi
2977      \pst@number\psyunit mul 
2978      \ifPst@saveData
2979        2 copy \pst@number\psyunit div exch  \pst@number\psxunit div
2980        20 string cvs Pst@data exch writestring
2981        Pst@data (\space) writestring
2982        20 string cvs Pst@data exch writestring
2983        Pst@data (\string\n) writestring
2984      \fi
2985    } def
2986  }%
2987  \gdef\psplot@init{}%
2988  \@pstfalse
2989  \@nameuse{testqp@\psplotstyle}%
2990  \if@pst\psplot@ii\else\psplot@iii\fi
2991  \addto@pscode{\ifPst@saveData Pst@data closefile \fi}
2992  \endgroup%
2993  \ignorespaces%
2994}
2995%
2996%
2997\def\psGTriangle{\pst@object{psGTriangle}}
2998\def\psGTriangle@i(#1)(#2)(#3)#4#5#6{{%
2999  \def\solid@star{}%
3000  \begin@ClosedObj
3001  \pst@getcoor{#1}\pst@tempA%   A: "rgb xr xg xb" or "gray xg"
3002  \pst@getcoor{#2}\pst@tempB%   B
3003  \pst@getcoor{#3}\pst@tempC%   C
3004  \pst@getcolor{#4}\pst@colorA
3005  \pst@getcolor{#5}\pst@colorB
3006  \pst@getcolor{#6}\pst@colorC
3007  \addto@pscode{%
3008    \pst@tempC              % C
3009    \pst@tempB              % B
3010    \psk@gangle             %   rotating angle
3011    \pst@tempA              % A, temporary origin
3012    /rgb {} def
3013    /gray {} def
3014    [ \pst@colorC ] aload length 1 eq { dup dup } if 3 array astore % gray -> rgb
3015    [ \pst@colorB ] aload length 1 eq { dup dup } if 3 array astore
3016    [ \pst@colorA ] aload length 1 eq { dup dup } if 3 array astore
3017    tx@addDict begin GTriangle end % PS part
3018  }%
3019  \if@star\pspolygon(#1)(#2)(#3)\fi%    draw borderline
3020  \def\pst@linetype{2}%
3021  \end@ClosedObj%
3022}}
3023%
3024\define@key[psset]{pstricks-add}{dicescale}{\def\psk@dicescale{#1}}
3025\def\psdice{\pst@object{psdice}}
3026\def\psdice@i#1{{%
3027  \pst@killglue
3028  \psset{framearc=0.3,linewidth=1pt,dicescale=1.0}%
3029  \use@par%
3030  \psscalebox{\psk@dicescale}{%
3031  \psframe(-0.5,-0.5)(0.5,0.5)%
3032  \ifcase#1%
3033    \or\qdisk(0,0){3pt}%
3034    \or\qdisk(-0.3,-0.3){3pt}\qdisk(0.3,0.3){3pt}%
3035    \or\psdice@i{1}\psdice@i{2}%
3036    \or\qdisk(-0.3,0.3){3pt}\qdisk(-0.3,-0.3){3pt}%
3037       \qdisk(0.3,0.3){3pt}\qdisk(0.3,-0.3){3pt}%
3038    \or\psdice@i{1}\psdice@i{4}%
3039    \or\psdice@i{4}\qdisk(-0.3,0){3pt}\qdisk(0.3,0){3pt}%
3040  \fi}%
3041  \ignorespaces%
3042}}
3043%
3044% the datafile must be a matrix with
3045% /dotmatrix [
3046%   .....
3047%   .....
3048% ] def
3049%
3050\def\psMatrixPlot{\pst@object{psMatrixPlot}}
3051\def\psMatrixPlot@i#1#2#3{%
3052  \pst@killglue
3053  \begingroup
3054  \begin@SpecialObj%
3055  \addto@pscode{
3056    (#3) run            % load the data file
3057    \psk@dotsize
3058    \@nameuse{psds@\psk@dotstyle} %
3059    /n 0 def            % index for element
3060    1 1 #1 {            % the y loop (outer one)
3061      /y exch def       % save y
3062      1 1 #2 {          % the x loop (inner one)
3063        /x exch def     % save x
3064        dotmatrix n get % get value from matrix
3065        dup 0 gt {      % test if > 0
3066          x \pst@number\psxunit mul
3067          \ifPst@ChangeOrder #1 y sub 1 add \else y \fi \pst@number\psyunit mul Dot%
3068        } { pop } ifelse
3069        /n n 1 add def
3070      } for
3071    } for
3072  }%
3073  \end@SpecialObj%
3074  \endgroup%
3075  \ignorespaces%
3076}
3077%
3078\def\resetOptions{%
3079  \@zero=0%
3080  \def\pst@linetype{0}%
3081  \psset[pstricks-add]{%
3082    hooklength=3mm, hookwidth=1mm,
3083    ArrowFill=true,
3084    ArrowInside={}, ArrowInsidePos=0.5,
3085    ArrowInsideNo=1, ArrowInsideOffset=0,
3086    arrowLW=0,
3087    dashNo=0.2,linecap=0,
3088    xyAxes=true,
3089    trigLabels=false,trigLabelBase=0,
3090    xDecimals={},yDecimals={},
3091    xlogBase={},ylogBase={},
3092    logLines=none,
3093    ignoreLines=0,
3094    nStep=1,nStart=0,nEnd={},
3095    xStep=0,yStep=0,xStart={},xEnd={},yStart={},yEnd={},comma=false,
3096    plotNo=1,plotNoMax=1,
3097    xAxisLabel=x,yAxisLabel=y,
3098    yAxisLabelPos={},xAxisLabelPos={},
3099    llx=\z@, lly=\z@, urx=\z@, ury=\z@,% prevents rounding errors
3100    randomPoints=1000,color=false,
3101    method={},whichabs={},whichord={},
3102    plotfuncx={},plotfuncy={},buildvector=false,
3103%  algebraic=false, % indivisuelly set
3104    Derive={},adamsorder=4,
3105    VarStep=false, PlotDerivative=none, VarStepEpsilon=default,
3106    varsteptol=.001,
3107    Tnormal=false,
3108    braceWidth=2\pslinewidth,
3109    bracePos=0.5,
3110    braceWidthInner=10\pslinewidth,
3111    braceWidthOuter=10\pslinewidth
3112  }
3113  \psset{%
3114%%%% pstricks %%%%%%%%
3115%    opacity=1,
3116%    blendmode=0,
3117%    shapealpha=0.6,
3118  unit=1cm,%
3119  swapaxes=false,%
3120  showpoints=false,%
3121  border=0pt, bordercolor=white,%
3122  doubleline=false, doublesep=1.25\pslinewidth,%
3123  doublecolor=white,%
3124  shadow=false, shadowsize=3pt, shadowangle=-45, shadowcolor=darkgray,%
3125  linewidth=.8pt,%
3126  linecolor=black,%
3127  maxdashes=11, dash=5pt 3pt, dashadjust=true, %
3128  dotsep=3pt,%
3129  linestyle=solid,%
3130  fillcolor=white,%
3131  hatchwidth=.8pt, hatchsep=4pt, hatchcolor=black, hatchangle=45,%
3132  hatchsepinc=0pt,hatchwidthinc=0pt,%
3133  fillstyle=none,%
3134  nArrows=2,%
3135  arrows=-, arrowscale=1, arrowsize=1.5pt 2, arrowlength=1.4, arrowinset=.4,%
3136  tbarsize=2pt 5,%
3137  bracketlength=.15, rbracketlength=.15,%
3138  liftpen=0, linetype=0,%
3139  gangle=0,%
3140  curvature=1 .1 0,%
3141  dotsize=2pt 2,%
3142  dotangle=0, dotscale=1, dotstyle=*,%
3143  linearc=0pt,%
3144  framearc=0,%
3145  cornersize=relative,%
3146  dimen=middle,%
3147  gridwidth=.8pt, griddots=0, gridcolor=black,%
3148  subgridwidth=.4pt, subgridcolor=gray, subgriddots=0, subgriddiv=5,%
3149  gridlabels=10pt, gridlabelcolor=black,%
3150  framesep=3pt, boxsep=true,%
3151  trimode=U,%
3152  arcsep=0,radius=.25cm,%
3153  ref=c,rot=0,labelsep=5pt,refangle=0,%
3154  intSeparator={,},%
3155  dicescale=1.0,%
3156%%%%%%%%% pst-plot %%%%%%%%%%%%%
3157  labelFontSize={},%
3158  StepType=lower, % alternative SumType=upper
3159  plotstyle=line,plotpoints=50,%
3160%  barwidth=0.25cm,%   individuell set
3161  ticksize=-4pt 4pt,
3162  tickstyle=full, ticks=all,%
3163  subticksize=0.75,subticks=1,tickcolor=black,%
3164  ticklinestyle=solid,subticklinestyle=solid,%
3165  subtickcolor=gray,%
3166  tickwidth=0.5\pslinewidth,subtickwidth=0.25\pslinewidth,%
3167  labels=all,Ox=0,Dx=1,dx=0,Oy=0,Dy=1,dy=0,%
3168  xlabelFactor=\relax,ylabelFactor=\relax,%
3169  showorigin=true,%
3170  axesstyle=axes,%
3171  ChangeOrder=false,%
3172  arrowscale=1,%
3173  %%%%%%%%% pst-node %%%%%%%%%%
3174  lineAngle=0,
3175  nodealign=false,
3176  href=0,
3177  vref=.7ex,
3178  framesize=10pt,
3179  nodesep=0pt,
3180  arm=10pt,
3181  offset=0pt,
3182  angle=0,
3183  arcangle=8,
3184  ncurv=.67,
3185  loopsize=1cm,
3186  boxsize=.4cm,
3187  nrot=0,
3188  npos=,
3189  tpos=0.5,
3190  shortput=none,
3191  colsep=1.5cm,
3192  rowsep=1.5cm,
3193  mcol=c,
3194  mnode=R,
3195  emnode=none%
3196}}
3197%
3198\resetOptions
3199%
3200\catcode`\@=\PstAtCode\relax
3201%
3202%% END: pstricks-add.tex
3203\endinput
Note: See TracBrowser for help on using the browser.