summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-10-24 23:37:47 +0000
committerKarl Berry <karl@freefriends.org>2010-10-24 23:37:47 +0000
commit9e2770a473f440628f782f2af002bb98475d61e1 (patch)
treeea0060b8713a317e345ea6fbaeed202dc366a744 /Master/texmf-dist/tex/generic
parented591f3387c5ae42c8da11c3fca9ecc305b9ff3c (diff)
pst-bspline (19oct10)
git-svn-id: svn://tug.org/texlive/trunk@20173 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
-rw-r--r--Master/texmf-dist/tex/generic/pst-bspline/pst-bspline.tex103
1 files changed, 68 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/generic/pst-bspline/pst-bspline.tex b/Master/texmf-dist/tex/generic/pst-bspline/pst-bspline.tex
index b5a0b11b139..eaea89f9b77 100644
--- a/Master/texmf-dist/tex/generic/pst-bspline/pst-bspline.tex
+++ b/Master/texmf-dist/tex/generic/pst-bspline/pst-bspline.tex
@@ -5,11 +5,11 @@
\csname PSTBsplineLoaded\endcsname
\let\PSTBsplineLoaded\endinput
-\ifx\PSTricksLoaded\endinput \else\input pstricks.tex\fi
-\ifx\PSTnodeLoaded\endinput \else\input pst-node.tex\fi
+\ifx\PSTricksLoaded\endinput \else\input pstricks \fi
+\ifx\PSTnodeLoaded\endinput \else\input pst-node \fi
\ifx\PSTXKeyLoaded\endinput \else\input pst-xkey \fi
-\def\fileversion{1.4}
-\def\filedate{2010/10/14}
+\def\fileversion{1.41}
+\def\filedate{2010/10/19}
\message{`pst-bspline' v\fileversion, \filedate\space Bspline routines for pstricks (ms)}
%
@@ -27,6 +27,7 @@
%\newif\ifbsp@showpoints
%\newif\ifbsp@doubleline
\newif\ifbsp@seq
+\newif\ifbsp@per %flag for periodic interpolation
%
\def\bsp@init{%these items are used only within the plotting macros
\def\bsp@arrowA{}%
@@ -196,15 +197,17 @@
\next@NodeX}%
%
\def\make@mcoeff#1{%
-\pstVerb{ /mcoeff #1\space 1 add array def %
+\pstVerb{ tx@Dict begin /mcoeff #1\space 1 add array def %
mcoeff 1 0.25 put %
1 1 #1\space 1 sub %
{/j exch def %j is counter
- mcoeff j 1 add 1 4 mcoeff j get sub div put } for }}%
+ mcoeff j 1 add 1 4 mcoeff j get sub div put } for end }}%
%
-\def\psBsplineInterp#1#2{%
+\def\psBsplineInterp#1#2{{%
% #1=node name root to interpolate, #2=end index,
% eg, if we want to interpolate S0,..., S100, #1=S, #2=100,
+\pst@killglue
+\global\bsp@perfalse %
\newcount\top@mone \top@mone=#2\relax%100
\newcount\top@ndx \top@ndx=\top@mone%
\advance\top@ndx by -1\relax%99
@@ -225,57 +228,68 @@
\else% exactly 3 points to interpolate
\nodexn{1.5(\noderoot1)-.25(\noderoot0)-.25(\noderoot2)}{\noderoot B1}%
\fi\fi%
-}% end def
-\def\psBsplineInterpC#1#2{%
+}\ignorespaces}% end def
+%
+\def\psBsplineInterpC#1#2{{%
% #1=node name root, #2=top index,
% eg, if we want to interpolate S0,..., S100, #1=S, #2=100
% interpolation in this case is periodic (closed curve)
\pst@killglue
+\global\bsp@pertrue %
+\pst@cnta=\csname#1nodecount\endcsname\advance\pst@cnta \@ne %
\newcount\top@mone \top@mone=#2\relax%
+\ifnum \top@mone<\pst@cnta %
+ \expandafter\xdef \csname #1nodecount\endcsname {\the\pst@cnta}%
+ \typeout{Changed #1nodecount to \the\pst@cnta}%
+ %\top@mone=\pst@cnta %
+\else%
+ \ifnum \top@mone>\pst@cnta \top@mone=\pst@cnta\advance\top@mone \m@ne\fi
+\fi%
\newcount\top@ndx \top@ndx=\top@mone%
\advance\top@ndx by \@ne%number of nodes to interpolate
+\
\newcount\top@mtwo \top@mtwo=\top@mone \advance\top@mtwo\m@ne%
% After copying S0 to S101, \top@ndx, \top@mone, \top@mtwo are top index, top index-1, top index-two---101, 100, 99 in the example
\make@mcoeff{\the\top@ndx}%
\def\noderoot{#1}%
-\pstVerb{ /bcoeff #2\space 2 add array def /ccoeff #2\space 2 add array def /xcoeff #2\space 2 add array def /ycoeff #2\space 2 add array def
+\pstVerb{ tx@Dict begin /bcoeff #2\space 2 add array def /ccoeff #2\space 2 add array def /xcoeff #2\space 2 add array def /ycoeff #2\space 2 add array def %
%% initialize b, c, x ,y values
1 1 \the\top@ndx\space %1 add
{/j exch def %j is counter
- ccoeff j 0 put bcoeff j 0 put } for
-bcoeff 1 1 put bcoeff #2\space 1 put bcoeff #2\space 1 add 4 put
-ccoeff 1 0.25 put ccoeff #2\space 1 put }%
+ ccoeff j 0 put bcoeff j 0 put } for %
+ bcoeff 1 1 put bcoeff #2\space 1 put bcoeff #2\space 1 add 4 put %
+ ccoeff 1 0.25 put ccoeff #2\space 1 put end }%
%end \pstVerb
\pnode(\noderoot 0){\noderoot\the\top@ndx}%copy node 0 to top end
-\pstVerb{ xcoeff 1 1 put ycoeff 1 1.5 put }
+\pstVerb{ tx@Dict begin xcoeff 1 1 put ycoeff 1 1.5 put end }%
\pnode(! \psGetNodeCenter{\noderoot 1} xcoeff 1 \noderoot 1.x 1.5 mul put ycoeff 1 \noderoot 1.y 1.5 mul put 1 1){temp@}% 1.5=6*0.25
\multido{\iA=2+1}{\the\top@mone}{\pnode(! ycoeff \iA\space xcoeff \iA\space \psGetNodeCenter{#1\iA} #1\iA.x 6 mul put #1\iA.y 6 mul put 1 1){temp@}}% move x, y coords times 6 to arrays
-\multido{\iA=2+1,\iB=1+1}{\the\top@mtwo}{\pstVerb{%
- ccoeff \iA\space ccoeff \iA\space get ccoeff \iB\space get sub mcoeff \iA\space get mul put
- xcoeff \iA\space xcoeff \iA\space get xcoeff \iB\space get sub mcoeff \iA\space get mul put
+\multido{\iA=2+1,\iB=1+1}{\the\top@mtwo}{\pstVerb{ tx@Dict begin %
+ ccoeff \iA\space ccoeff \iA\space get ccoeff \iB\space get sub mcoeff \iA\space get mul put %
+ xcoeff \iA\space xcoeff \iA\space get xcoeff \iB\space get sub mcoeff \iA\space get mul put %
ycoeff \iA\space ycoeff \iA\space get ycoeff \iB\space get sub mcoeff \iA\space get mul put
-bcoeff \iA\space bcoeff \iA\space get bcoeff \iB\space get mcoeff \iB\space get mul sub put
-bcoeff \the\top@ndx\space bcoeff \the\top@ndx\space get bcoeff \iB\space get ccoeff \iB\space get mul sub put
-xcoeff \the\top@ndx\space xcoeff \the\top@ndx\space get xcoeff \iB\space get bcoeff \iB\space get mul sub put
-ycoeff \the\top@ndx\space ycoeff \the\top@ndx\space get ycoeff \iB\space get bcoeff \iB\space get mul sub put
+ bcoeff \iA\space bcoeff \iA\space get bcoeff \iB\space get mcoeff \iB\space get mul sub put
+ bcoeff \the\top@ndx\space bcoeff \the\top@ndx\space get bcoeff \iB\space get ccoeff \iB\space get mul sub put
+ xcoeff \the\top@ndx\space xcoeff \the\top@ndx\space get xcoeff \iB\space get bcoeff \iB\space get mul sub put
+ ycoeff \the\top@ndx\space ycoeff \the\top@ndx\space get ycoeff \iB\space get bcoeff \iB\space get mul sub put end %
}% end \pstVerb
}% end \multido
-\pstVerb{%
+\pstVerb{ tx@Dict begin %
bcoeff \the\top@ndx\space bcoeff \the\top@ndx\space get bcoeff \the\top@mone\space get
-ccoeff \the\top@mone\space get mul sub put %b(n)=b(n)-b(n-1)*c(n-1)
-xcoeff \the\top@ndx\space xcoeff \the\top@ndx\space get xcoeff \the\top@mone\space get bcoeff \the\top@mone\space get mul sub bcoeff \the\top@ndx\space get div put %x(n)=(x(n)-x(n-1)*b(n-1))/b(n)
-ycoeff \the\top@ndx\space ycoeff \the\top@ndx\space get ycoeff \the\top@mone\space get bcoeff \the\top@mone\space get mul sub bcoeff \the\top@ndx\space get div put %y(n)=(y(n)-y(n-1)*b(n-1))/b(n)
-xcoeff \the\top@mone\space xcoeff \the\top@mone\space get xcoeff \the\top@ndx\space get ccoeff \the\top@mone\space get mul sub put %x(n-1)=x(n-1)-c(n-1)*x(n)
-ycoeff \the\top@mone\space ycoeff \the\top@mone\space get ycoeff \the\top@ndx\space get ccoeff \the\top@mone\space get mul sub put %y(n-1)=y(n-1)-c(n-1)*y(n)
+ ccoeff \the\top@mone\space get mul sub put %b(n)=b(n)-b(n-1)*c(n-1)
+ xcoeff \the\top@ndx\space xcoeff \the\top@ndx\space get xcoeff \the\top@mone\space get bcoeff \the\top@mone\space get mul sub bcoeff \the\top@ndx\space get div put %x(n)=(x(n)-x(n-1)*b(n-1))/b(n)
+ ycoeff \the\top@ndx\space ycoeff \the\top@ndx\space get ycoeff \the\top@mone\space get bcoeff \the\top@mone\space get mul sub bcoeff \the\top@ndx\space get div put %y(n)=(y(n)-y(n-1)*b(n-1))/b(n)
+ xcoeff \the\top@mone\space xcoeff \the\top@mone\space get xcoeff \the\top@ndx\space get ccoeff \the\top@mone\space get mul sub put %x(n-1)=x(n-1)-c(n-1)*x(n)
+ ycoeff \the\top@mone\space ycoeff \the\top@mone\space get ycoeff \the\top@ndx\space get ccoeff \the\top@mone\space get mul sub put end %y(n-1)=y(n-1)-c(n-1)*y(n)
}% end pstVerb
\mmultido{\iA=\the\top@mone+-1,\iB=\the\top@ndx+-1}{\the\top@mtwo}{%
-\pstVerb{ xcoeff \iA\space xcoeff \iA\space get mcoeff \iA\space get xcoeff \iB\space get mul sub ccoeff \iA\space get xcoeff \the\top@ndx\space get mul sub put % x(k)=x(k)-m(k)*x(k+1)-c(k)*x(n)
-ycoeff \iA\space ycoeff \iA\space get mcoeff \iA\space get ycoeff \iB\space get mul sub ccoeff \iA\space get ycoeff \the\top@ndx\space get mul sub put
+\pstVerb{ tx@Dict begin xcoeff \iA\space xcoeff \iA\space get mcoeff \iA\space get xcoeff \iB\space get mul sub ccoeff \iA\space get xcoeff \the\top@ndx\space get mul sub put % x(k)=x(k)-m(k)*x(k+1)-c(k)*x(n)
+ ycoeff \iA\space ycoeff \iA\space get mcoeff \iA\space get ycoeff \iB\space get mul sub ccoeff \iA\space get ycoeff \the\top@ndx\space get mul sub put end %
}}%y(k)=...
\multido{\iA=1+1}{\the\top@ndx}{\pnode(! xcoeff \iA\space get ycoeff \iA\space get )%
{\noderoot B\iA}}%
\pnode(\noderoot B\the\top@ndx){\noderoot B0}%
-\ignorespaces}%
+}\ignorespaces}%
%
\def\thickBspline{\def\pst@par{}\pst@object{thickBspline}}%
\def\thickBspline@i#1#2#3#4{{%
@@ -349,16 +363,35 @@ ycoeff \iA\space ycoeff \iA\space get mcoeff \iA\space get ycoeff \iB\space get
/lindex lindex 2 add def /uindex uindex 2 sub def ){tmp@P}%
}% end multido \i
}% end multido \iA
+% if periodic, we have to adjust 2 points so as not too leave a wege in the
+% clipping region. We have to set Q_{nk} to Q_0 and R_{nk} to R_0
+% R_{nk} is at position 2*nk, 2*nk+1 and Q_{nk} is at the next pair
+%\ifbsp@per %
+% \pstVerb{%
+% tx@Dict begin /itemcnt #2 nplotpt mul 2 mul def %first item to change is index 2nk
+% clipary itemcnt clipary 0 get put /itemcnt itemcnt 1 add def %
+% clipary itemcnt clipary 1 get put /itemcnt itemcnt 1 add def %
+% clipary itemcnt clipary \the\n@cnt\space 1 sub get put /itemcnt itemcnt 1 add def %
+% clipary itemcnt clipary \the\n@cnt\space get put %
+% end }%
+%\fi%
% make a clipping path in PS and pass commands #4
-\psclip{\pscustom{%
+\ifbsp@per %periodic
+ \psclip{\pscustom{%
+ \code{ clipary aload pop moveto nseg nplotpt mul %
+ { lineto } repeat closepath %
+ moveto nseg nplotpt mul { lineto } repeat closepath }}}%
+ #4
+ \endpsclip%
+\else % not periodic
+ \psclip{\pscustom{%
\code{ clipary aload pop moveto nseg nplotpt mul 2 mul %
1 add { lineto } repeat closepath %
\ifPst@reverseclip\space reversepath \fi}}}%
#4
-\endpsclip%
-\pstVerb{%
-tx@Dict begin %
-}}%
+ \endpsclip%
+\fi%
+}%
\ignorespaces}%
\catcode`\@=\TheAtCode\relax
\endinput \ No newline at end of file