diff options
author | Karl Berry <karl@freefriends.org> | 2010-10-24 23:37:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-10-24 23:37:47 +0000 |
commit | 9e2770a473f440628f782f2af002bb98475d61e1 (patch) | |
tree | ea0060b8713a317e345ea6fbaeed202dc366a744 /Master/texmf-dist | |
parent | ed591f3387c5ae42c8da11c3fca9ecc305b9ff3c (diff) |
pst-bspline (19oct10)
git-svn-id: svn://tug.org/texlive/trunk@20173 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-bspline/README | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf | bin | 101556 -> 111493 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.tex | 52 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/pst-bspline/pst-bspline.tex | 103 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pst-bspline/pst-bspline.sty | 4 |
5 files changed, 121 insertions, 42 deletions
diff --git a/Master/texmf-dist/doc/generic/pst-bspline/README b/Master/texmf-dist/doc/generic/pst-bspline/README index 3e8dd393146..5224a25cf46 100644 --- a/Master/texmf-dist/doc/generic/pst-bspline/README +++ b/Master/texmf-dist/doc/generic/pst-bspline/README @@ -2,10 +2,10 @@ %% %% Michael Sharpe <msharpe@ucsd.edu> %% -%% Version 1.4, 2010/10/14 +%% Version 1.41, 2010/10/19 %% %% License: Free -This package draws uniform, cubic Bspline curves, open and closed, based on a sequence of Bspline control points. There is also code which permits drawing the open or closed cubic Bspline curve interplating a sequence of points. This version adds a \thickBspline macro. +This package draws uniform, cubic B-spline curves, open and closed, based on a sequence of B-spline control points. There is also code which permits drawing the open or closed cubic B-spline curve interpolating a sequence of points. This version adds a \thickBspline macro. The .tex and .sty files should be installed in a folder searched by TeX. All documentation is in pst-bspline-doc.pdf.
\ No newline at end of file diff --git a/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf b/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf Binary files differindex 6c395adbf4f..7b4beb03b8d 100644 --- a/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf +++ b/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf diff --git a/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.tex b/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.tex index 9e08c19d7f1..8e034e19af3 100644 --- a/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.tex +++ b/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.tex @@ -1,3 +1,4 @@ +\listfiles \documentclass[dvips,11pt]{article} \usepackage{amsmath} \usepackage{amsthm} @@ -14,7 +15,7 @@ \large Michael Sharpe\\[10pt] msharpe@ucsd.edu} \end{center} -A cubic uniform B-spline curve with control points $B_0 \ldots B_n$ is a curve parametrized by the interval $[0,n]$, which is $C^2$-continuous (that is, has continuous curvature) and is on each interval $[k-1,k]$ given by a cubic B\'ezier curve whose control points are derived from the $(B_k)$. These curves are discussed in any reasonably modern text on Numerical Analysis. One easily accessible source is the UCLA lecture notes of Kirby Baker: +A cubic uniform B-spline curve with control points $B_0 \ldots B_n$ is a curve parametrized by the interval $[0,n]$, which is, except in degenerate cases, $C^2$-continuous (that is, has continuous curvature) and is on each interval $[k-1,k]$ given by a cubic B\'ezier curve whose control points are derived from the $(B_k)$. These curves are discussed in any reasonably modern text on Numerical Analysis. One easily accessible source is the UCLA lecture notes of Kirby Baker: \noindent\url{http://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf} @@ -316,20 +317,27 @@ for k=n-2 downto 1 x(k)=x(k)-m(k)* x(k+1)-c(k)*x(n) y(k)=y(k)-m(k)* y(k+1)-c(k)*y(n) \end{verbatim} -This algorithm is implemented in \TeX/PostScript code in {\tt pst-Bspline.tex} and may be invoked using the macro +This algorithm is implemented in \TeX/PostScript code in {\tt pst-bspline.tex} and may be invoked using the macro \begin{verbatim} \psBsplineInterpC{<node root>}{<index>} \end{verbatim} - You must previously have defined a sequence, say {\tt S0} $\cdots$ {\tt S100} of \verb|\pnode|s that you plan to interpolate with a closed curve. Then + You must previously have defined a sequence, say {\tt S0} $\cdots$ {\tt S100} of \verb|\pnode|s that you plan to interpolate with a closed curve. If you used \verb|\pnodes| to do this, it would have constructed a macro \verb|\Snodecount| to store the value $100$. Then \begin{verbatim} \psBsplineInterpC{S}{100} \end{verbatim} constructs the sequence {\tt SB0} $\cdots$ {\tt SB100} of B-spline control points (appending~{\tt B} to the root name) for a closed curve interpolating {\tt S0} $\cdots$ {\tt S100}, which may then be rendered with the command \begin{verbatim} -\psBsplineNodesC{SB}{100} +\psBsplineNodesC{SB}{101} \end{verbatim} with any keywords options you wish. +{\bf IMPORTANT:} The macro \verb|\psBsplineInterpC| modifies the node sequence {\tt S}, setting \verb|S101=S0|, and changing \verb|\Snodecount| to take the value $101$. This is convenient when you use the construction: +\begin{verbatim} +\pnodes{S}()()()()% sets \Snodecount to 3 +\psBsplineInterpC{S}{\Snodecount}% constructs B-spline control pts SB0..SB4 +\psBsplineNodesC{SB}{\Snodecount} +\end{verbatim} + The following example illustrates that there is a difference between \verb|\psccurve| and B-spline interpolation, the former having a rounder appearance. Generally speaking, B-spline interpolation comes closer to minimizing the average curvature. \begin{verbatim} \documentclass{article} @@ -456,6 +464,7 @@ The clipping path is drawn by default positively oriented so that objects are cl \end{document} \end{verbatim} +\vspace{12pt} \begin{center} \begin{pspicture}[showgrid=true](-.5,-.5)(6,5) \pnodes{S}(1,0)(5,1)(4,4)(1,3)% @@ -466,4 +475,39 @@ The clipping path is drawn by default positively oriented so that objects are cl \end{pspicture} \end{center} +\vspace{12pt} +The \verb|\thickBspline| macro works as expected in the closed (periodic) case, taking advantage of automatic incrementing of the nodecount. + +\begin{verbatim} +\documentclass{article} +\usepackage{pstricks} +\usepackage{pst-bspline,pstricks-add} +\begin{document} +\begin{pspicture}[showgrid=true](-.5,-.5)(6,5) +\pnodes{S}(1,0)(5,1)(4,4)(1,3)% +\psBsplineInterpC{S}{\Snodecount}% +% defines nodes SB0, SB1, SB2 etc --- the Bspline control points +% increments \Snodecount by 1 for future macros +\psBsplineNodes[linestyle=none,showpoints=false]{SB}{\Snodecount}% +% Constructs the Bezier control points SBR0, SBL1, SBR1, etc +\thickBspline[linestyle=none]{S}{\Snodecount}{22pt}% +{\psframe[fillstyle=vlines](-1,-1)(6,6)}% +\end{pspicture} +\end{document} +\end{verbatim} + +\vspace{12pt} + +\begin{center} +\begin{pspicture}[showgrid=true](-.5,-.5)(6,5) +\pnodes{S}(1,0)(5,1)(4,4)(1,3)% +\psBsplineInterpC{S}{\Snodecount}% +% defines nodes SB0, SB1, SB2 etc --- the Bspline control points +% increments \Snodecount by 1 for future macros +\psBsplineNodes[linestyle=none,showpoints=false]{SB}{\Snodecount}% +% Constructs the Bezier control points SBR0, SBL1, SBR1, etc +\thickBspline[linestyle=none]{S}{\Snodecount}{22pt}{\psframe[fillstyle=vlines](-1,-1)(6,6)}% +\end{pspicture} +\end{center} + \end{document}
\ No newline at end of file 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 diff --git a/Master/texmf-dist/tex/latex/pst-bspline/pst-bspline.sty b/Master/texmf-dist/tex/latex/pst-bspline/pst-bspline.sty index 6500f4dbefb..1dabf7aafc8 100644 --- a/Master/texmf-dist/tex/latex/pst-bspline/pst-bspline.sty +++ b/Master/texmf-dist/tex/latex/pst-bspline/pst-bspline.sty @@ -1,5 +1,7 @@ \ProvidesPackage{pst-bspline} - + [2010/10/19 v1.41 LaTeX wrapper for pst-bspline (MS)] \input{pst-bspline} +\ProvidesFile{pst-bspline.tex} + [\filedate\space \fileversion\space `pst-bspline' (ms)] \endinput
\ No newline at end of file |