From 2dd820f377c1dccbc53a6d34d604b7b4a5ed317c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 1 Aug 2011 00:48:08 +0000 Subject: pst-bspline (31jul11) git-svn-id: svn://tug.org/texlive/trunk@23294 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/pst-bspline/README | 4 +- .../doc/generic/pst-bspline/pst-bspline-doc.pdf | Bin 111493 -> 142662 bytes .../doc/generic/pst-bspline/pst-bspline-doc.tex | 165 ++++++++++++++++----- 3 files changed, 132 insertions(+), 37 deletions(-) (limited to 'Master/texmf-dist/doc/generic/pst-bspline') diff --git a/Master/texmf-dist/doc/generic/pst-bspline/README b/Master/texmf-dist/doc/generic/pst-bspline/README index 5224a25cf46..62d5a1ef35c 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 %% -%% Version 1.41, 2010/10/19 +%% Version 1.44, 2011/07/30 %% %% License: Free -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. +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 update adds a number of macros allowing B-spline curves to be used as if they were parametric curves. 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 index 7b4beb03b8d..f8392d5358c 100644 Binary files a/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf and b/Master/texmf-dist/doc/generic/pst-bspline/pst-bspline-doc.pdf differ 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 8e034e19af3..d88db518937 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 @@ -7,6 +7,17 @@ \usepackage{multido,pst-node,pst-bspline,pstricks-add} \usepackage{amssymb} \usepackage[parfill]{parskip} +\usepackage{lmodern} +\usepackage[scaled=.82]{luximono}%requires T1+textcomp +\usepackage[T1]{fontenc} +\newcommand\textSMC[1]{{\SMC #1}} +\newcommand\acro[1]{\textSMC{#1}\@} +\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}} +\usepackage[cal=boondoxo]{mathalfa} +\usepackage{textcomp} +%\usepackage{url} +%\def\url@ttstyle{% +% \@ifundefined{selectfont}{\def\UrlFont{\tt}}{\def\UrlFont{\ttfamily\small}}} \usepackage{hyperref} \hyphenation{Post-Script} %\date{} % Activate to display a given date or no date @@ -15,17 +26,40 @@ \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, 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: +A cubic, uniform B-spline curve with control points $B_0 \ldots B_n$ ($n \ge 2$) 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]$ ($0\}}] defines a clipping path 12{\tt pt} wide around the B-spline curve with control points {\tt B0}..{\tt B5}, then draws the {\tt } clipped to that path. +\item[\cs{bspcurvenodes\{P\}\{Q\}}] creates a node sequence {\tt Q0} {\tt Q1},... from the position data in the arrays {\tt P.X}, {\tt P.Y}. +\end{description} +Details and examples are provided below. + +\section{Relaxed, Open B-spline} The algorithm to generate such a curve from a sequence of control points $B_0$, $\cdots$, $B_n$ is as follows: \begin{itemize} -\item The curve starts at $B_0$ and ends at $B_n$. -\item Divide each line $B_{k-1}B_k$ into equal thirds, with subdivision points labeled $R_{k-1}$, $L_k$ respectively, so that $B_k$ has $L_k$ as its immediate neighbor to the left, and $R_k$ as its immediate neighbor to the right. +\item The curve starts at $B_0$ and ends at $B_n$. (Important: $n \ge 2$.) +\item Divide each line segment $B_{k-1}B_k$ into equal thirds, with subdivision points labeled $R_{k-1}$, $L_k$ respectively, so that $B_k$ has $L_k$ as its immediate neighbor to the left, and $R_k$ as its immediate neighbor to the right. \item For $0}{} \end{verbatim} corresponding to the macros \verb|\psBspline|, \verb|\psBsplineC| and \verb|\psBsplineE|. The difference is that the macros with {\tt Nodes} in the name have as arguments the root node name and the last index, rather than the list of points. For example, with the above definition of {\tt P} in force, \verb|\psBsplineNodes{P}{2}| has exactly the same effect as \verb|\psBspline(2,1.5)(3,4)(5,1).| +\subsection{The \cs{bspcurvepoints} macros} +There are two macros that provide for B-spline curves essentially the same functionality as the \verb|\pscurvepoints| macro from {\tt pstricks-add}. (That macro takes as input a parametric curve and constructs as output (at the PostScript level) arrays of data associated with the curve: the positions of points along the curve, the increment from the previous point and a normal vector to the curve. The principal uses for such data are (i) the \verb|\pspolylineticks| macro from {\tt pstricks-add}, which allows placement of ticks and other marks along a curve that has been approximated by a polyline; (ii) the \cs{polyIntersections} macro from \textsf{pst-node}, which allows you to find the points of intersection of the curve (approximated by a polyline) and an arbitrary line.) The macros +\begin{verbatim} +\bspcurvepoints{}{}{} +\bspcurvepointsE{}{}{} +\end{verbatim} +work, in the first case, for a relaxed, uniform B-spline curve, and in the second, for such a curve with its initial and final segments removed, corresponding to the output from \verb|\psBsplineE| rather than \verb|\psBspline|. In both cases, you may set the keyword {\tt plotpoints} (default value: $50$) to change the number of sample points on each B\'ezier component. This will result in the construction of PostScript arrays with indices from $0$ to $n=$\textsf{num of segments}$\times$\textsf{(plotpoints-1)}. After running +\begin{verbatim} +\pnodes{B}(1,2)(3,-1)(4,1)(6,2)% define B0..B3 +\bspcurvepoints[plotpoint=11]{B}{3}{P} +\end{verbatim} +the following PostScript arrays are created, each indexed from 0 to 30: +\begin{verbatim} +P.X, P.Y (position) +PNormal.X, PNormal.Y (normal vector) +PDelta.X, PDelta.Y (increment from previous position) +\end{verbatim} +and these may be used in the usual way to create nodes. For example, +\begin{verbatim} +\pnode(! P.X 8 get P.Y 8 get){Q} +\pnode(! PNormal.X 8 get PNormal.Y get){Dir} +\psrline(Q)(1cm;{(Dir)}) +\end{verbatim} +places {\tt Q} at the position on the curve with index 8, defines {\tt Dir} to be a normal vector at that point, then draws a line from {\tt Q} of length {\tt 1cm} in the direction of that normal. +\subsection{Setting nodes on a B-spline curve} +To set a node at parameter value $t$ on a B-spline curve after running \cs{bspcurvepoints}{\tt[E]}, call the macro +\begin{verbatim} +\bspNode{}{}{}{} +\end{verbatim} +For example, if I have constructed a B-spline curve using control points $B_0$,$\dots$,$B_5$, then \verb|\bspNode{B}{5}{2.1}{Q}| defines a node named $Q$ at $t=2.1$. + +The macro \cs{bspcurvenodes\{P\}\{R\}} creates a node sequence {\tt R0}..{\tt Rn} at the locations specified by the arrays {\tt P.X}, {\tt P.Y}. (Those arrays must first have been created with one of the \cs{bspcurvepoints} macros.) +\subsection{B-spline function curves} +By this we mean an open B-spline curve which is the graph of a function $y=f(x)$ and whose orientation is toward the right. It is not analytically simple to specify a formula for $f$ in most cases, and to compute $y$ from $x$ involves (a) finding the index of the B\'ezier segment containing $x$; (b) solving the cubic $x(t)=x$ for $t$; (c) substituting in $y(t)$. The package provides a macro to perform these calculations after generating the data using \cs{bspcurvepoints}{\tt[E]}: +\begin{verbatim} +\bspfnNode{}{}{}{} +\end{verbatim} \section{B-spline Interpolation} This is the inverse problem. Being given points $(S_k)_{0\le k\le n}$, the goal is to produce the B-spline control points $B_k$ leading to the points $S_k$, so that the associated B-spline curve interpolates the $S_k$. @@ -206,7 +285,7 @@ for the $B_k$. In matrix form, this becomes the tridiagonal system &1&4&1\\ &&\cdots&&1\\ &&&1&4\end{pmatrix} -\begin{pmatrix}B_1\\B_2\\B_3\\ \cdots\\ B_{n-1}\end{pmatrix}=ß +\begin{pmatrix}B_1\\B_2\\B_3\\ \cdots\\ B_{n-1}\end{pmatrix}= \begin{pmatrix}6S_1-S_0\\6S_2\\6S_3\\ \cdots\\6S_{n-1}-S_{n}\end{pmatrix} \] The LU decomposition of the tridiagonal matrix may be seen to take the form @@ -263,7 +342,7 @@ for the $B_k$, $1\le k\le n$. In matrix form, this becomes the system &1&4&1\\ &&\cdots&&1\\ 1&&&1&4\end{pmatrix} -\begin{pmatrix}B_1\\B_2\\B_3\\ \cdots\\ B_{n}\end{pmatrix}=ß +\begin{pmatrix}B_1\\B_2\\B_3\\ \cdots\\ B_{n}\end{pmatrix}= \begin{pmatrix}6S_1\\6S_2\\6S_3\\ \cdots\\6S_{n}\end{pmatrix} \] Let $(x_k,y_k)=6S_k$. We perform Gaussian elimination on the matrix @@ -366,19 +445,30 @@ Slight difference between psccurve and B-spline interpolation\\ \end{center} A B-spline curve can in many cases provide a good function interpolation mechanism, but the result is not guaranteed to be the graph of a function. \begin{verbatim} -\begin{center} -\begin{pspicture}[showgrid=true](-.5,-.5)(6,4) -\psdots(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5) +\begin{pspicture}(-.5,-.5)(6,4) +\psdots(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5)% +\pnodes{S}(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5)% S0..S5 +\psBsplineInterp{S}{5}% construct SB0..SB5 +\psBsplineNodes{SB}{5}% draw B-spline with control pts SB0..SB5 +\bspcurvepoints[plotpoints=10]{SB}{5}{P} +% construct the PS arrays +\bspFnNode{SB}{5}{4.5}{QQ}% node QQ on curve at x=4.5 +\psdot[linecolor=red](QQ)% \psaxes(0,0)(-.5,-.5)(6,4) -\psbspline(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5) \end{pspicture} -\end{center} \end{verbatim} +\vspace{1pc} \begin{center} \begin{pspicture}(-.5,-.5)(6,4) -\psdots(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5) -\psbspline(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5) +\psdots(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5)% +\pnodes{S}(0,3.5)(1,.5)(3,2.5)(4,0)(5,2)(6,.5)% S0..S5 +\psBsplineInterp{S}{5}%SB0..SB5 +\psBsplineNodes{SB}{5}% draw B-spline with control pts SB0..SB5 +\bspcurvepoints[plotpoints=10]{SB}{5}{P} +% construct the PS arrays +\bspFnNode{SB}{5}{4.5}{QQ}% node QQ on curve at x=4.5 +\psdot[linecolor=red](QQ)% \psaxes(0,0)(-.5,-.5)(6,4) \end{pspicture} \end{center} @@ -386,7 +476,6 @@ A B-spline curve can in many cases provide a good function interpolation mechani \begin{verbatim} \documentclass{article} -\usepackage{graphicx} \usepackage{pstricks} \usepackage{pst-bspline,pstricks-add} \begin{document} @@ -442,7 +531,8 @@ which creates a framework of B-spline control points {\tt SB0..SB3}. (The {\tt [linestyle=none]} may be omitted if you want the curve to show.) \item Create a clipping path of specified thickness around the interpolating curve and place graphics to be clipped: \begin{verbatim} -\thickBspline[plotpoints=50,linestyle=none]{S}{3}{20pt}{\psline[linecolor=red,linestyle=solid](0,0)(6,6)}% +\thickBspline[plotpoints=50,linestyle=none]{S}{3}{20pt}% +{\psline[linecolor=red,linestyle=solid](0,0)(6,6)}% \end{verbatim} (The {\tt [linestyle=none]} controls whether the clipping path is rendered, and {\tt plotpoints} controls the number of subdivisions of each B\'ezier component. Its default value is 50.) \end{itemize} @@ -476,18 +566,20 @@ The clipping path is drawn by default positively oriented so that objects are cl \end{center} \vspace{12pt} -The \verb|\thickBspline| macro works as expected in the closed (periodic) case, taking advantage of automatic incrementing of the nodecount. +The \verb|\thickBspline| macro works as expected in the closed (periodic) case, taking advantage of automatic incrementing of the nodecount. Note that \verb|\thickBspline| interprets thickness as visual, unaffected by possible differences between {\tt xunit} and {\tt yunit}. \begin{verbatim} \documentclass{article} \usepackage{pstricks} \usepackage{pst-bspline,pstricks-add} \begin{document} +\psset{yunit=1.5cm} \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 +\pnodes{S}(1.5,0)(5,1)(4,4)(1,3)% +\psBsplineInterpC{S}{3}% +% defines nodes SB0, SB1, SB2, SB3, SB4 --- the Bspline control points % increments \Snodecount by 1 for future macros +% Don't use C form of \psBsplineNodes with this new \Snodecount \psBsplineNodes[linestyle=none,showpoints=false]{SB}{\Snodecount}% % Constructs the Bezier control points SBR0, SBL1, SBR1, etc \thickBspline[linestyle=none]{S}{\Snodecount}{22pt}% @@ -499,14 +591,17 @@ The \verb|\thickBspline| macro works as expected in the closed (periodic) case, \vspace{12pt} \begin{center} +\psset{yunit=1.5cm} \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 +\pnodes{S}(1.5,0)(5,1)(4,4)(1,3)% +\psBsplineInterpC{S}{3}% +% defines nodes SB0, SB1, SB2, SB3 --- 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)}% +\thickBspline[linestyle=none]{S}{\Snodecount}{22pt}% +{\psframe[fillstyle=vlines](-1,-1)(6,6)}% +%{\psframe[fillstyle=solid, fillcolor=lightgray](-1,-1)(6,6)}% \end{pspicture} \end{center} -- cgit v1.2.3