| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2014 by Christoph Bersch <[email protected]> |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 11 |
% version 2008/05/04 or later. |
| 12 |
% \fi |
| 13 |
% |
| 14 |
% \iffalse |
| 15 |
%<*driver> |
| 16 |
\ProvidesFile{pst-intersect.dtx} |
| 17 |
%</driver> |
| 18 |
%<stylefile>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 19 |
%<stylefile>\ProvidesPackage{pst-intersect} |
| 20 |
%<*stylefile> |
| 21 |
[2014/03/16 v0.4 package wrapper for pst-intersect.tex] |
| 22 |
%</stylefile> |
| 23 |
% |
| 24 |
%<*driver> |
| 25 |
\documentclass[a4paper, DIV=9, oneside, toc=index, parskip=half-]{scrreprt} |
| 26 |
\usepackage{scrhack} |
| 27 |
\usepackage{doc} |
| 28 |
\setcounter{IndexColumns}{2} |
| 29 |
\usepackage[utf8]{inputenc} |
| 30 |
\usepackage[T1]{fontenc} |
| 31 |
\usepackage{lmodern} |
| 32 |
\usepackage{amsmath, marvosym} |
| 33 |
\usepackage{bera} |
| 34 |
\providecommand*\mainlang{} |
| 35 |
\usepackage[ngerman, english,\mainlang]{babel} |
| 36 |
\usepackage{prettyref} |
| 37 |
\usepackage[dvipsnames,x11names,svgnames]{xcolor} |
| 38 |
\usepackage{ragged2e, calc} |
| 39 |
\newlength{\PITcaptionmargin} |
| 40 |
\newlength{\PITcaptionheight} |
| 41 |
\usepackage[labelfont={color=DOrange}, |
| 42 |
singlelinecheck=false, |
| 43 |
justification=raggedright]{caption} |
| 44 |
\DeclareCaptionFormat{pitnocaption}{% |
| 45 |
\setlength{\PITcaptionmargin}{\widthof{#1}+7pt}% |
| 46 |
\setlength{\PITcaptionheight}{\heightof{#1}+3pt}% |
| 47 |
\hspace*{-\PITcaptionmargin}#1\par\vspace*{-\PITcaptionheight}% |
| 48 |
}% |
| 49 |
\DeclareCaptionFormat{pitcaption}{% |
| 50 |
\setlength{\PITcaptionmargin}{\widthof{#1}+7pt}% |
| 51 |
\hspace*{-\PITcaptionmargin}#1#2#3\par |
| 52 |
}% |
| 53 |
\captionsetup[lstlisting]{format=pitnocaption} |
| 54 |
\usepackage{multido} |
| 55 |
\usepackage{pst-intersect} |
| 56 |
\usepackage[makeindex]{splitidx} |
| 57 |
\usepackage{hypdoc} |
| 58 |
\hypersetup{% |
| 59 |
colorlinks=true, |
| 60 |
urlcolor=DOrange, |
| 61 |
linkcolor=pdflinkcolor, |
| 62 |
breaklinks, |
| 63 |
linktocpage=true} |
| 64 |
\usepackage{breakurl} |
| 65 |
\definecolor{DOrange}{rgb}{1,.4,.2}% |
| 66 |
\definecolor{DDOrange}{rgb}{0.7, 0.23, 0.07}% |
| 67 |
\colorlet{pdflinkcolor}{DOrange} |
| 68 |
\usepackage{showexpl} |
| 69 |
\makeatletter\renewcommand*\SX@Info{}\makeatother |
| 70 |
\usepackage{etoolbox} |
| 71 |
\undef{\cs}\undef{\cmd} |
| 72 |
\usepackage{ltxdockit} |
| 73 |
\definecolor{colKeys}{rgb}{0,0,0} |
| 74 |
\definecolor{colIdentifier}{rgb}{0,0,0} |
| 75 |
\colorlet{colComments}{green!60!black} |
| 76 |
\definecolor{colString}{rgb}{0,0.5,0} |
| 77 |
\newlength{\codeoverhang} |
| 78 |
\setlength{\codeoverhang}{0.5\marginparwidth+\marginparsep} |
| 79 |
\lstset{% |
| 80 |
language=[LaTeX]TeX, identifierstyle=\color{colIdentifier}, |
| 81 |
keywordstyle=\color{colKeys}, |
| 82 |
keywordstyle = [21]\color{DOrange}, |
| 83 |
keywordstyle = [22]\color{DOrange}, |
| 84 |
stringstyle=\color{colString}, |
| 85 |
commentstyle=\color{colComments}, |
| 86 |
alsoletter={12}, |
| 87 |
float=hbp, |
| 88 |
basicstyle=\ttfamily\small, |
| 89 |
columns=flexible, |
| 90 |
tabsize=4, |
| 91 |
showspaces=false, |
| 92 |
showstringspaces=false, |
| 93 |
breaklines=true, |
| 94 |
breakautoindent=true, |
| 95 |
breakatwhitespace=true, |
| 96 |
captionpos=t, |
| 97 |
belowcaptionskip=0pt, |
| 98 |
abovecaptionskip=0pt, |
| 99 |
xleftmargin=1em, |
| 100 |
prebreak = {\raisebox{-0.5ex}[\ht\strutbox]{\kern0.5ex\large\Righttorque}}, |
| 101 |
rulecolor=\color{black!20}, |
| 102 |
texcsstyle = [20]\color{DDOrange}, |
| 103 |
moretexcs = [20]{pssavebezier, pssavepath, pstracecurve, psintersect}, |
| 104 |
explpreset={% |
| 105 |
pos=l, width=-99pt, hsep=5mm, overhang=\codeoverhang, varwidth, |
| 106 |
vsep=\bigskipamount, rframe={}}, extendedchars=true |
| 107 |
}% |
| 108 |
\lstdefinestyle{example}{explpreset={% |
| 109 |
escapechar=*, pos=l, width=-99pt, hsep=5mm, overhang=\codeoverhang, |
| 110 |
varwidth, vsep=\bigskipamount, rframe={}}} |
| 111 |
\makeatletter |
| 112 |
\providecommand\ON{% |
| 113 |
\gdef\lst@alloverstyle##1{\textcolor{black!50}{\strut##1}% |
| 114 |
}} |
| 115 |
\providecommand\OFF{\xdef\lst@alloverstyle##1{##1}} |
| 116 |
\makeatother |
| 117 |
\colorlet{sectioncolor}{DOrange} |
| 118 |
\addtokomafont{sectioning}{\color{sectioncolor}} |
| 119 |
\usepackage[automark,nouppercase]{scrpage2} |
| 120 |
\pagestyle{scrheadings} |
| 121 |
\clearscrheadings |
| 122 |
\clearscrplain |
| 123 |
\ohead{\pagemark} |
| 124 |
\ihead{\headmark} |
| 125 |
\ofoot[\pagemark]{} |
| 126 |
\automark[subsection]{section} |
| 127 |
\setheadsepline{.4pt}[\color{DOrange}] |
| 128 |
\setheadwidth[0pt]{text} |
| 129 |
\setfootwidth[0pt]{text} |
| 130 |
\makeatletter |
| 131 |
\patchcmd{\l@chapter}{1.5em}{2em}{}{} |
| 132 |
\renewcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{3.0em}} |
| 133 |
\renewcommand*\l@subsection{\bprot@dottedtocline{2}{3.8em}{4.0em}} |
| 134 |
\newrobustcmd*{\fnurl}[1][]{\hyper@normalise\ltd@fnurl{#1}} |
| 135 |
\def\ltd@fnurl#1#2{\footnote{#1\hyper@linkurl{\Hurl{#2}}{#2}}} |
| 136 |
\newrobustcmd*{\arxivurl}[1]{\href{http://arxiv.org/abs/#1}{arXiv:#1}} |
| 137 |
\newrobustcmd*{\doiurl}[1]{\href{http://dx.doi.org/#1}{DOI:#1}} |
| 138 |
\makeatother |
| 139 |
\usepackage{csquotes} |
| 140 |
\MakeAutoQuote{«}{»} |
| 141 |
%^^A spot is used in ltxdockit.sty |
| 142 |
\colorlet{spot}{sectioncolor} |
| 143 |
%^^A Fonts definitions used in ltxdockit.sty |
| 144 |
\renewcommand*{\verbatimfont}{\ttfamily} |
| 145 |
\renewcommand*{\displayverbfont}{\ttfamily} |
| 146 |
\renewcommand*{\marglistfont}{\spotcolor\sffamily\small} |
| 147 |
\renewcommand*{\margnotefont}{\sffamily\small} |
| 148 |
\renewcommand*{\optionlistfont}{\spotcolor\sffamily\displayverbfont} |
| 149 |
\renewcommand*{\ltxsyntaxfont}{\ttfamily} |
| 150 |
\renewcommand*{\ltxsyntaxlabelfont}{\spotcolor\displayverbfont} |
| 151 |
\renewcommand*{\changelogfont}{\normalfont} |
| 152 |
\renewcommand*{\changeloglabelfont}{\spotcolor\sffamily\bfseries} |
| 153 |
|
| 154 |
\makeatletter |
| 155 |
\renewenvironment*{ltxsyntax} |
| 156 |
{\list{}{% |
| 157 |
\setlength{\labelwidth}{\marglistwidth}% |
| 158 |
\setlength{\labelsep}{0pt}% |
| 159 |
\setlength{\leftmargin}{0pt}% |
| 160 |
\renewcommand*{\makelabel}[1]{% |
| 161 |
\hss\ltxsyntaxfont\ltxsyntaxlabelfont##1}}% |
| 162 |
\let\cmditem\PIT@cmditem} |
| 163 |
{\endlist} |
| 164 |
|
| 165 |
\def\ltd@optionlist{% |
| 166 |
\let\optitem\PIT@optitem |
| 167 |
\let\valitem\PIT@valitem |
| 168 |
\let\choitem\PIT@choitem |
| 169 |
\let\boolitem\PIT@boolitem |
| 170 |
\let\intitem\PIT@intitem |
| 171 |
\let\numitem\PIT@numitem |
| 172 |
\let\psnumitem\PIT@psnumitem |
| 173 |
\let\pititem\ltd@item |
| 174 |
\let\typeitem\PIT@typeitem} |
| 175 |
|
| 176 |
\def\PIT@typeitem#1#2{% |
| 177 |
\item[{#1}]% |
| 178 |
\label{prm:#1}% |
| 179 |
\begingroup\raggedright |
| 180 |
#2% |
| 181 |
\settowidth\@tempdimb{\prm{psstyle}}% |
| 182 |
\settowidth\@tempdimc{#1}% |
| 183 |
\@tempdimc=\dimexpr\@tempdimc+\labelsep-\labelwidth\relax |
| 184 |
\ifdim\@tempdimc>0pt% |
| 185 |
\@tempdima=\dimexpr\linewidth-\@tempdimb-\@tempdimc-1em\relax |
| 186 |
\else |
| 187 |
\@tempdima=\dimexpr\linewidth-\@tempdimb-1em\relax |
| 188 |
\fi |
| 189 |
\par\endgroup} |
| 190 |
|
| 191 |
\def\PIT@option#1#2#3{% |
| 192 |
\item[#1]% |
| 193 |
\begingroup\raggedright |
| 194 |
\ltd@textverb{=}% |
| 195 |
\settowidth\@tempdimb{\ltd@textverb{=}}% |
| 196 |
\settowidth\@tempdimc{#1}% |
| 197 |
\@tempdimc=\dimexpr\labelwidth-\@tempdimc\relax |
| 198 |
\ifdim\@tempdimc<0pt |
| 199 |
\@tempdima=\dimexpr\linewidth-\@tempdimb+\@tempdimc-2em\relax |
| 200 |
\else |
| 201 |
\@tempdima=\dimexpr\linewidth-\@tempdimb-2em\relax |
| 202 |
\fi |
| 203 |
\ifblank{#3} |
| 204 |
{} |
| 205 |
{\settowidth\@tempdimb{default: #3}% |
| 206 |
\@tempdima=\dimexpr\@tempdima-\@tempdimb-2em\relax}% |
| 207 |
\parbox[t]{\@tempdima}{\raggedright #2}% |
| 208 |
\ifblank{#3} |
| 209 |
{} |
| 210 |
{\hfill default:~#3}% |
| 211 |
\par\endgroup |
| 212 |
\nobreak\vspace{\itemsep}} |
| 213 |
|
| 214 |
\def\PIT@optitem{% |
| 215 |
\@ifstar |
| 216 |
{\boolfalse{@tempswa}\PIT@optitem@i} |
| 217 |
{\booltrue{@tempswa}\PIT@optitem@i}} |
| 218 |
\newcommand*{\PIT@optitem@i}[3][]{% |
| 219 |
\ifbool{@tempswa}% |
| 220 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 221 |
{\xLkeyword{#2}}% |
| 222 |
\ifblank{#1} |
| 223 |
{\PIT@option{#2}{#3}{}} |
| 224 |
{\PIT@option{#2}{#3}{\ltd@textverb{#1}}}}% |
| 225 |
|
| 226 |
\def\PIT@valitem{% |
| 227 |
\@ifstar |
| 228 |
{\boolfalse{@tempswa}\PIT@valitem@i} |
| 229 |
{\booltrue{@tempswa}\PIT@valitem@i}} |
| 230 |
\newcommand*{\PIT@valitem@i}[3][]{% |
| 231 |
\ifbool{@tempswa}% |
| 232 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 233 |
{\xLkeyword{#2}}% |
| 234 |
\ifblank{#1} |
| 235 |
{\PIT@option{#2}{\prm{#3}}{}} |
| 236 |
{\PIT@option{#2}{\prm{#3}}{\ltd@textverb{#1}}}}% |
| 237 |
|
| 238 |
\def\PIT@choitem{% |
| 239 |
\@ifstar |
| 240 |
{\boolfalse{@tempswa}\PIT@choitem@i} |
| 241 |
{\booltrue{@tempswa}\PIT@choitem@i}} |
| 242 |
\newcommand*{\PIT@choitem@i}[3][]{% |
| 243 |
\ifbool{@tempswa}% |
| 244 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 245 |
{\xLkeyword{#2}}% |
| 246 |
\ifblank{#1} |
| 247 |
{\PIT@option{#2}{\ltd@verblist{#3}}{}} |
| 248 |
{\PIT@option{#2}{\ltd@verblist{#3}}{\ltd@textverb{#1}}}}% |
| 249 |
|
| 250 |
\def\PIT@boolitem{% |
| 251 |
\@ifstar |
| 252 |
{\boolfalse{@tempswa}\PIT@boolitem@i} |
| 253 |
{\booltrue{@tempswa}\PIT@boolitem@i}} |
| 254 |
\newcommand*{\PIT@boolitem@i}[2][]{% |
| 255 |
\ifbool{@tempswa}% |
| 256 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 257 |
{\xLkeyword{#2}}% |
| 258 |
\ifblank{#1} |
| 259 |
{\PIT@option{#2}{\ltd@verblist{true,false}}{}} |
| 260 |
{\PIT@option{#2}{\ltd@verblist{true,false}}{\ltd@textverb{#1}}}}% |
| 261 |
|
| 262 |
\def\PIT@intitem{% |
| 263 |
\@ifstar |
| 264 |
{\boolfalse{@tempswa}\PIT@intitem@i} |
| 265 |
{\booltrue{@tempswa}\PIT@intitem@i}} |
| 266 |
\newcommand*{\PIT@intitem@i}[2][]{% |
| 267 |
\ifbool{@tempswa}% |
| 268 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 269 |
{\xLkeyword{#2}}% |
| 270 |
\ifblank{#1} |
| 271 |
{\PIT@option{#2}{\prm{int}}{}} |
| 272 |
{\PIT@option{#2}{\prm{int}}{\ltd@textverb{#1}}}}% |
| 273 |
|
| 274 |
\def\PIT@numitem{% |
| 275 |
\@ifstar |
| 276 |
{\boolfalse{@tempswa}\PIT@numitem@i} |
| 277 |
{\booltrue{@tempswa}\PIT@numitem@i}} |
| 278 |
\newcommand*{\PIT@numitem@i}[2][]{% |
| 279 |
\ifbool{@tempswa}% |
| 280 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 281 |
{\xLkeyword{#2}}% |
| 282 |
\ifblank{#1} |
| 283 |
{\PIT@option{#2}{\prm{num}}{}} |
| 284 |
{\PIT@option{#2}{\prm{num}}{\ltd@textverb{#1}}}}% |
| 285 |
|
| 286 |
\def\PIT@psnumitem{% |
| 287 |
\@ifstar |
| 288 |
{\boolfalse{@tempswa}\PIT@psnumitem@i} |
| 289 |
{\booltrue{@tempswa}\PIT@psnumitem@i}} |
| 290 |
\newcommand*{\PIT@psnumitem@i}[2][]{% |
| 291 |
\ifbool{@tempswa}% |
| 292 |
{\label{prm:#2}\xdefLkeyword{#2}}% |
| 293 |
{\xLkeyword{#2}}% |
| 294 |
\ifblank{#1} |
| 295 |
{\PIT@option{#2}{\prm{psnum}}{}} |
| 296 |
{\PIT@option{#2}{\prm{psnum}}{\ltd@textverb{#1}}}}% |
| 297 |
|
| 298 |
\def\ltd@csitem{% |
| 299 |
\@ifstar |
| 300 |
{\boolfalse{@tempswa}\ltd@csitem@i} |
| 301 |
{\booltrue{@tempswa}\ltd@csitem@i}} |
| 302 |
\def\ltd@csitem@i#1{% |
| 303 |
\ifbool{@tempswa} |
| 304 |
{\ltd@item@ii{\textbackslash#1\hspace\marglistsep}{#1}} |
| 305 |
{\ltd@item@ii{\textbackslash#1\hspace\marglistsep}{}}} |
| 306 |
|
| 307 |
\def\PIT@cmditem{% |
| 308 |
\@ifstar |
| 309 |
{\boolfalse{@tempswa}\PIT@cmditem@i} |
| 310 |
{\booltrue{@tempswa}\PIT@cmditem@i}} |
| 311 |
\def\PIT@cmditem@i#1{% |
| 312 |
\ifbool{@tempswa} |
| 313 |
{\PIT@cmditem@ii{\textbackslash#1}{cs:#1}} |
| 314 |
{\PIT@cmditem@ii{\textbackslash#1}{}}} |
| 315 |
\def\PIT@compitem{% |
| 316 |
\@ifstar |
| 317 |
{\boolfalse{@tempswa}\PIT@compitem@i} |
| 318 |
{\booltrue{@tempswa}\PIT@compitem@i}} |
| 319 |
\def\PIT@compitem@i#1{% |
| 320 |
\ifbool{@tempswa} |
| 321 |
{\PIT@cmditem@ii{\textbackslash#1}{comp:#1}} |
| 322 |
{\PIT@cmditem@ii{\textbackslash#1}{}}} |
| 323 |
\def\PIT@cmditem@ii#1#2{% |
| 324 |
\ltd@itemsave |
| 325 |
\ifhmode |
| 326 |
\itemsep-\topsep |
| 327 |
\else |
| 328 |
\ltd@itembreak |
| 329 |
\fi |
| 330 |
\item[#1]% |
| 331 |
\ltd@itemrest |
| 332 |
\ifblank{#2}{}{\label{#2}}% |
| 333 |
\begingroup |
| 334 |
\ltd@syntaxsetup |
| 335 |
\ltxsyntaxfont |
| 336 |
\let\@tempa\@empty |
| 337 |
\ltd@parseargs} |
| 338 |
|
| 339 |
\def\ltd@csitem@ii#1#2{% |
| 340 |
\ltd@itemsave |
| 341 |
\ifhmode |
| 342 |
\itemsep-\topsep |
| 343 |
\else |
| 344 |
\ltd@itembreak |
| 345 |
\fi |
| 346 |
\item[#1]% |
| 347 |
\ltd@itemrest |
| 348 |
\ifblank{#2}{}{\label{cs:#2}}% |
| 349 |
\begingroup |
| 350 |
\ltd@syntaxsetup |
| 351 |
\ltxsyntaxfont |
| 352 |
\let\@tempa\@empty |
| 353 |
\ltd@parseargs} |
| 354 |
|
| 355 |
|
| 356 |
\let\plainllap\llap |
| 357 |
\newrobustcmd\macro@llap[1]{{\global\let\llap\plainllap |
| 358 |
\setbox0=\hbox\bgroup \macro@font\small\saved@macroname\egroup |
| 359 |
\ifdim\wd0>30mm |
| 360 |
\hbox to\z@ \bgroup\hss \hbox to30mm{\unhcopy0\hss}\egroup |
| 361 |
\edef\@tempa{\hskip\dimexpr\the\wd0-30mm}\global\everypar\expandafter{\the\expandafter\everypar |
| 362 |
\@tempa \global\everypar{}}% |
| 363 |
\else \llap{\unhbox0}\fi}} |
| 364 |
\AtBeginEnvironment{macro}{\let\llap\macro@llap} |
| 365 |
\makeatother |
| 366 |
|
| 367 |
\newcommand*{\PSstring}[1]{{\normalfont\small\ttfamily(#1)}} |
| 368 |
\newcommand*{\PSarray}[1]{{\normalfont\small\ttfamily[#1]}} |
| 369 |
\newcommand*{\PSname}[1]{{\normalfont\small\ttfamily/#1}} |
| 370 |
\newcommand*{\PSproc}[1]{{\normalfont\small\ttfamily\textbraceleft #1\textbraceright}} |
| 371 |
\newcommand*{\PSvar}[1]{{\normalfont\small\ttfamily #1}} |
| 372 |
\newcommand*{\PSop}[1]{{\normalfont\small\ttfamily\color{DOrange}\hskip 3pt #1\hskip 3pt}} |
| 373 |
|
| 374 |
\newcommand*{\compref}[1]{\ref{comp:#1}} |
| 375 |
\newcommand*{\hyperpagedef}[1]{\textbf{\hyperpage{#1}}} |
| 376 |
\newcommand*{\nodename}[1]{\emph{#1}} |
| 377 |
\newcommand*{\param}[1]{\normalfont\texttt{#1}} |
| 378 |
\newcommand*{\paramvalue}[1]{\texttt{#1}} |
| 379 |
\newcommand*{\styleshape}[1]{\texttt{#1}} |
| 380 |
\newcommand{\docindex}[1]{\sindex[doc]{#1|hyperpage}} |
| 381 |
\newcommand{\docindexdef}[1]{\sindex[doc]{#1|hyperpagedef}} |
| 382 |
\makeatletter |
| 383 |
\def\Lcs{\@ifstar{\Lcs@nobm}{\Lcs@bm}} |
| 384 |
\def\Lcs@nobm#1{\nxLcs{#1}\xLcs{#1}} |
| 385 |
\def\Lcs@bm#1{\hyperref[cs:#1]{\Lcs@nobm{#1}}} |
| 386 |
\def\xLcs#1{} |
| 387 |
\def\nxLcs#1{\texttt{\textbackslash#1}} |
| 388 |
|
| 389 |
\def\Lcomp{\@ifstar{\Lcomp@nobm}{\Lcomp@bm}} |
| 390 |
\def\Lcomp@nobm#1{\nxLcomp{#1}\xLcomp{#1}} |
| 391 |
\def\Lcomp@bm#1{\hyperref[comp:#1]{\Lcomp@nobm{#1}}} |
| 392 |
\def\xLcomp#1{} |
| 393 |
\def\nxLcomp#1{\texttt{\textbackslash#1}} |
| 394 |
|
| 395 |
\def\LPack#1{\nxLPack{#1}} |
| 396 |
\def\nxLPack#1{\texttt{#1}} |
| 397 |
|
| 398 |
\def\Lenv{\@ifstar{\Lenv@nobm}{\Lenv@bm}} |
| 399 |
\def\Lenv@nobm#1{\nxLenv{#1}\xLenv{#1}} |
| 400 |
\def\Lenv@bm#1{\hyperref[env:#1]{\Lenv@nobm{#1}}} |
| 401 |
\def\xLenv#1{} |
| 402 |
\def\nxLenv#1{\texttt{#1}} |
| 403 |
\let\orig@ltd@envitem\ltd@envitem |
| 404 |
\def\ltd@envitem#1{\orig@ltd@envitem{#1}\label{env:#1}\xLenv{#1}} |
| 405 |
|
| 406 |
\def\Lkeyword{\@ifstar{\Lkeyword@nobm}{\Lkeyword@bm}} |
| 407 |
\def\Lkeyword@nobm#1{\nxLkeyword{#1}\xLkeyword{#1}} |
| 408 |
\def\Lkeyword@bm#1{\hyperref[prm:#1]{\Lkeyword@nobm{#1}}} |
| 409 |
\def\xLkeyword#1{} |
| 410 |
\def\xdefLkeyword#1{} |
| 411 |
\def\nxLkeyword#1{\texttt{#1}} |
| 412 |
|
| 413 |
\def\xLoption#1{} |
| 414 |
\def\Loption#1{\texttt{#1}\xLoption{#1}} |
| 415 |
\def\nxLoption#1{\texttt{#1}} |
| 416 |
|
| 417 |
\def\Lstyle{\@ifstar{\Lstyle@nobm}{\Lstyle@bm}} |
| 418 |
\def\Lstyle@nobm#1{\nxLstyle{#1}\xLstyle{#1}} |
| 419 |
\def\Lstyle@bm#1{\hyperref[sty:#1]{\Lstyle@nobm{#1}}} |
| 420 |
\def\xLstyle#1{} |
| 421 |
\def\xdefLstyle#1{} |
| 422 |
\def\nxLstyle#1{\texttt{#1}} |
| 423 |
|
| 424 |
\makeatother |
| 425 |
|
| 426 |
\newcommand{\dipoledesc}[1]{% |
| 427 |
\xLdipole{#1}% |
| 428 |
\compitem{#1}[options](in)(out){label}% |
| 429 |
} |
| 430 |
\newcommand{\tripoledesc}[1]{% |
| 431 |
\xLtripole{#1}% |
| 432 |
\compitem{#1}[options](in)(center)(out){label}% |
| 433 |
} |
| 434 |
|
| 435 |
\newcommand{\fiberdipoledesc}[1]{% |
| 436 |
\xLfdipole{#1}% |
| 437 |
\compitem{#1}[options](in)(out){label}% |
| 438 |
} |
| 439 |
|
| 440 |
\newenvironment*{pssyntax} |
| 441 |
{\list{}{\small |
| 442 |
\setlength{\labelsep}{0pt}% |
| 443 |
\setlength{\leftmargin}{10pt}% |
| 444 |
\item[]}} |
| 445 |
{\endlist} |
| 446 |
|
| 447 |
\newcommand{\psarglistfont}{\small} |
| 448 |
\newenvironment*{psarglist} |
| 449 |
{\list{}{% |
| 450 |
\setlength{\labelwidth}{10pt}% |
| 451 |
\setlength{\labelsep}{0pt}% |
| 452 |
\setlength{\leftmargin}{0pt}% |
| 453 |
\setlength{\itemsep}{\parsep}% |
| 454 |
\setlength{\parsep}{0pt}% |
| 455 |
\renewcommand*{\makelabel}[1]{\hss\psarglistfont##1}}} |
| 456 |
{\endlist} |
| 457 |
|
| 458 |
\makeatletter |
| 459 |
\renewenvironment{theglossary}{\GlossaryParms \let\item\@idxitem \ignorespaces}{} |
| 460 |
\makeatother |
| 461 |
\def\psargitem#1{\item[#1]\hfill\par\nobreak} |
| 462 |
|
| 463 |
\addtopsstyle{Fiber}{linecolor=DOrange,linewidth=1.5\pslinewidth} |
| 464 |
\addtopsstyle{Beam}{linewidth=1.5\pslinewidth} |
| 465 |
\EnableCrossrefs |
| 466 |
\CodelineIndex |
| 467 |
\OnlyDescription |
| 468 |
\begin{document} |
| 469 |
\DocInput{pst-intersect.dtx} |
| 470 |
\end{document} |
| 471 |
%</driver> |
| 472 |
% \fi |
| 473 |
% |
| 474 |
% \CheckSum{0} |
| 475 |
% |
| 476 |
% \CharacterTable |
| 477 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 478 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 479 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 480 |
% Exclamation \! Double quote \" Hash (number) \# |
| 481 |
% Dollar \$ Percent \% Ampersand \& |
| 482 |
% Acute accent \' Left paren \( Right paren \) |
| 483 |
% Asterisk \* Plus \+ Comma \, |
| 484 |
% Minus \- Point \. Solidus \/ |
| 485 |
% Colon \: Semicolon \; Less than \< |
| 486 |
% Equals \= Greater than \> Question mark \? |
| 487 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 488 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 489 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 490 |
% Right brace \} Tilde \~} |
| 491 |
% |
| 492 |
% \GetFileInfo{pst-intersect.dtx} |
| 493 |
% |
| 494 |
% \newif\ifGERMAN \GERMANfalse |
| 495 |
% \newif\ifENGLISH \ENGLISHfalse |
| 496 |
% \iflanguage{ngerman}{\GERMANtrue}{% |
| 497 |
% \iflanguage{german}{\GERMANtrue}{\GERMANfalse}} |
| 498 |
% \iflanguage{english}{\ENGLISHtrue}{\ENGLISHfalse} |
| 499 |
% |
| 500 |
% \ifGERMAN |
| 501 |
% \newrefformat{chap}{Kap.~\ref{#1}} |
| 502 |
% \newrefformat{sec}{Kap.~\ref{#1}} |
| 503 |
% \newrefformat{l}{Zeile~\ref{#1}} |
| 504 |
% \newrefformat{ex}{Bsp.~\ref{#1}} |
| 505 |
% \newrefformat{tab}{Tab.~\ref{#1}} |
| 506 |
% \newrefformat{fig}{Abb.~\ref{#1}} |
| 507 |
% \newindex[Quelltextindex]{idx} |
| 508 |
% \newcommand{\PITindexMacro}{Makros} |
| 509 |
% \newcommand{\PITindexKeyword}{Parameter} |
| 510 |
% \newcommand{\PITindexEnv}{Umgebungen} |
| 511 |
% \newcommand{\PITindexPack}{Pakete} |
| 512 |
% \renewcommand*\lstlistingname{Bsp.} |
| 513 |
% \fi |
| 514 |
% \ifENGLISH |
| 515 |
% \newrefformat{chap}{Sec.~\ref{#1}} |
| 516 |
% \newrefformat{sec}{Sec.~\ref{#1}} |
| 517 |
% \newrefformat{l}{Line~\ref{#1}} |
| 518 |
% \newrefformat{ex}{Ex.~\ref{#1}} |
| 519 |
% \newrefformat{tab}{Tab.~\ref{#1}} |
| 520 |
% \newrefformat{fig}{Fig.~\ref{#1}} |
| 521 |
% \newindex[Code index]{idx} |
| 522 |
% \newcommand{\PITindexMacro}{macros} |
| 523 |
% \newcommand{\PITindexKeyword}{parameters} |
| 524 |
% \newcommand{\PITindexEnv}{environments} |
| 525 |
% \newcommand{\PITindexPack}{packages} |
| 526 |
% \renewcommand*\lstlistingname{Ex.} |
| 527 |
% \fi |
| 528 |
% |
| 529 |
% \makeatletter |
| 530 |
% \renewcommand\maketitle{^^A |
| 531 |
% \thispagestyle{empty}^^A |
| 532 |
% \begin{titlepage} |
| 533 |
% \begin{pspicture}(1.6in,0.685in)(10,21.7) |
| 534 |
% \psframe[fillstyle=solid,linecolor=lightgray,fillcolor=lightgray,linestyle=solid](0,-5.75)(21.5,10) |
| 535 |
% \psframe[fillstyle=solid,linecolor=Orange!85!Red,fillcolor=Orange!85!Red,linestyle=solid](0,10)(21.5,10.5) |
| 536 |
% \psframe[fillstyle=solid,linecolor=Orange!85!Red,fillcolor=Orange!85!Red,linestyle=solid](0,21.1)(21.5,21.2) |
| 537 |
% \rput[lb](3,22){\Huge\sffamily\color{Orange!65!Red}\psscalebox{2}{\textbf{PSTricks}}} |
| 538 |
% \rput[lb](3,14.1){\parbox{15cm}{\sffamily\RaggedRight\bfseries\huge\@title}} |
| 539 |
% \rput[lb](3,7.6){\parbox{13cm}{\sffamily\@date}} |
| 540 |
% \rput[lb](3,-2.6){\parbox[b]{17cm}{\sffamily\RaggedRight |
| 541 |
% ~\hfill\makebox[7cm][l]{\ifGERMAN Paketautor:\fi\ifENGLISH Package author:\fi}\\ |
| 542 |
% ~\hfill\makebox[7cm][l]{^^A |
| 543 |
% \bfseries\tabular[t]{@{}l@{}}\@author\endtabular}}} |
| 544 |
% \rput[C](11,4){\bgImage} |
| 545 |
% \end{pspicture}^^A |
| 546 |
% \end{titlepage}} |
| 547 |
% \makeatother |
| 548 |
% |
| 549 |
% \ifGERMAN |
| 550 |
% \title{\texttt{pst-intersect}\\ Berechnen der Schnittpunkte beliebiger Kurven\\[0.5ex] \small \fileversion} |
| 551 |
% \hypersetup{pdftitle={Berechnen der Schnittpunkte beliebiger Kurven}} |
| 552 |
% \fi |
| 553 |
% \ifENGLISH |
| 554 |
% \title{\texttt{pst-intersect}\\ Intersecting arbitrary curves\\[0.5ex] \small \fileversion} |
| 555 |
% \hypersetup{pdftitle={Intersecting arbitrary curves}} |
| 556 |
% \fi |
| 557 |
% \author{Christoph Bersch} |
| 558 |
% \date{\filedate} |
| 559 |
% \def\bgImage{} |
| 560 |
% |
| 561 |
% \maketitle |
| 562 |
% |
| 563 |
% \clearpage |
| 564 |
% \tableofcontents |
| 565 |
% \clearpage |
| 566 |
% |
| 567 |
% \ifGERMAN |
| 568 |
% \chapter{Einführung} |
| 569 |
% \fi |
| 570 |
% \ifENGLISH |
| 571 |
% \chapter{Introduction} |
| 572 |
% \fi |
| 573 |
% |
| 574 |
% \ifGERMAN |
| 575 |
% \section{Über das Paket} |
| 576 |
% |
| 577 |
% \LPack{pst-intersect} ist ein PSTricks-Paket zur |
| 578 |
% Berechnung der Schnittpunkte von Bézier-Kurven und beliebigen |
| 579 |
% Postscript-Pfaden. |
| 580 |
% |
| 581 |
% Beachten Sie, dass die Paket-Versionen 0.x sich in einem |
| 582 |
% experimentellen Status befinden, und sich grundlegende Änderungen |
| 583 |
% ergeben können, die zur Vorgängerversion inkompatibel sind. |
| 584 |
% \fi |
| 585 |
% \ifENGLISH |
| 586 |
% \section{About the package} |
| 587 |
% \LPack{pst-intersect} is a PSTricks package to calculate |
| 588 |
% the intersections of Bezier curves and arbitrary Postscript paths. |
| 589 |
% |
| 590 |
% Please note, that package versions 0.x are experimental, and may be |
| 591 |
% subject to fundamental changes, which aren't backward compatible. |
| 592 |
% \fi |
| 593 |
% |
| 594 |
% \ifGERMAN |
| 595 |
% \section{Anforderungen} |
| 596 |
% \LPack{pst-intersect} benötigt aktuelle Versionen der Pakete |
| 597 |
% \LPack{pstricks}, \LPack{pst-node}, \LPack{pst-eucl} und |
| 598 |
% \LPack{pst-func}. |
| 599 |
% |
| 600 |
% Alle PSTricks-Pakete machen regen Gebrauch von der Postscript-Sprache, so |
| 601 |
% dass der typische Arbeitsfluss \opt{latex}, \opt{dvips} und |
| 602 |
% ggf. \opt{ps2pdf} umfasst. Es gibt viele alternative Methoden um die |
| 603 |
% Dokumente zu |
| 604 |
% kompilieren.\fnurl{http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput} |
| 605 |
% \fi |
| 606 |
% \ifENGLISH |
| 607 |
% \section{Requirements} |
| 608 |
% \LPack{pst-intersect} requires recent versions of \LPack{pstricks}, |
| 609 |
% \LPack{pst-node}, \LPack{pst-eucl} and \LPack{pst-func}. |
| 610 |
% |
| 611 |
% All PSTricks package rely heavily on the Postscript language so that the |
| 612 |
% typical workflow involves \opt{latex}, \opt{dvips}, and \opt{ps2pdf}. Of |
| 613 |
% course there are several alternative ways to compile your |
| 614 |
% documents.\fnurl{http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput} |
| 615 |
% \fi |
| 616 |
% |
| 617 |
% \ifGERMAN |
| 618 |
% \section{Verbreitung und Installation} |
| 619 |
% Dieses Paket ist auf |
| 620 |
% CTAN\fnurl{http://mirror.ctan.org/help/Catalogue/entries/pst-intersect.html} |
| 621 |
% erhältlich. |
| 622 |
% |
| 623 |
% Das \LPack{pst-intersect}-Paket umfasst die zwei Hauptdateien |
| 624 |
% \texttt{pst-intersect.ins} und \texttt{pst-intersect.dtx}. Durch Aufrufen |
| 625 |
% von \texttt{tex pst-intersect.ins} werden die drei folgenden |
| 626 |
% Dateien erzeugt: |
| 627 |
% \begin{itemize} |
| 628 |
% \item \texttt{pst-intersect.pro}: die Postscript Prologdatei |
| 629 |
% \item \texttt{pst-intersect.sty}: die \LaTeX-Stildatei |
| 630 |
% \item \texttt{pst-intersect.tex}: die \TeX-Datei |
| 631 |
% \end{itemize} |
| 632 |
% Speichern Sie diese Dateien in einem Verzeichnis der Teil Ihres |
| 633 |
% lokalen \TeX-Baums ist. |
| 634 |
% |
| 635 |
% Vergessen Sie nicht \texttt{texhash} aufzurufen um den Baum zu |
| 636 |
% aktualisieren. MiK\TeX{}-Benutzer müssen die Dateinamen-Datenbank |
| 637 |
% (FNDB) aktualisieren. |
| 638 |
% |
| 639 |
% Detailliertere Information finden Sie in der Dokumentation Ihrer |
| 640 |
% \LaTeX-Distribution über die Installation in den lokalen |
| 641 |
% \TeX{}-Baum. |
| 642 |
% \fi |
| 643 |
% \ifENGLISH |
| 644 |
% \section{Distribution and installation} |
| 645 |
% This package is available on |
| 646 |
% CTAN\fnurl{http://mirror.ctan.org/help/Catalogue/entries/pst-intersect.html}. |
| 647 |
% |
| 648 |
% The \LPack{pst-intersect} package consists of the two main files |
| 649 |
% \texttt{pst-intersect.ins} and \texttt{pst-intersect.dtx}. By running \texttt{tex |
| 650 |
% pst-intersect.ins} the following derived files are generated: |
| 651 |
% \begin{itemize} |
| 652 |
% \item \texttt{pst-intersect.pro}: the Postscript prolog file |
| 653 |
% \item \texttt{pst-intersect.sty}: the \LaTeX{} style file |
| 654 |
% \item \texttt{pst-intersect.tex}: the \TeX{} file |
| 655 |
% \end{itemize} |
| 656 |
% Save the files in a directory which is part of your local \TeX{} tree. |
| 657 |
% |
| 658 |
% Do not forget to run \texttt{texhash} to update this tree. For MiK\TeX{} |
| 659 |
% users, do not forget to update the file name database (FNDB). |
| 660 |
% |
| 661 |
% For more detailed information see the documentation of your personal |
| 662 |
% \LaTeX{} distribution on installing packages to your local \TeX{} |
| 663 |
% system. |
| 664 |
% \fi |
| 665 |
% |
| 666 |
% \ifGERMAN\section{Lizenz}\fi |
| 667 |
% \ifENGLISH\section{License}\fi |
| 668 |
% \ifGERMAN |
| 669 |
% Es wird die Erlaubnis gewährt, dieses Dokument zu kopieren, zu verteilen |
| 670 |
% und\slash oder zu modifizieren, unter den Bestimmungen der \LaTeX{} Project |
| 671 |
% Public License, Version |
| 672 |
% 1.3c.\fnurl{http://www.latex-project.org/lppl.txt}. Dieses |
| 673 |
% Paket wird vom Autor betreut (author-maintained). |
| 674 |
% \fi |
| 675 |
% \ifENGLISH |
| 676 |
% Permission is granted |
| 677 |
% to copy, distribute and\slash or modify this software under the terms of the |
| 678 |
% \LaTeX{} Project Public License, version |
| 679 |
% 1.3c.\fnurl{http://www.latex-project.org/lppl.txt} This |
| 680 |
% package is author-maintained. |
| 681 |
% \fi |
| 682 |
% |
| 683 |
% \ifGERMAN |
| 684 |
% \section{Danksagung} |
| 685 |
% \fi |
| 686 |
% \ifENGLISH |
| 687 |
% \section{Acknowledgements} |
| 688 |
% \fi |
| 689 |
% \ifGERMAN |
| 690 |
% Ich danke Marco Cecchetti, dessen |
| 691 |
% \opt{lib2geom}-Bibliothek\fnurl{http://lib2geom.sourceforge.net/} |
| 692 |
% mir als Vorlage für einen Großteil des Postscript-Kodes für den |
| 693 |
% Bézier-Clipping-Algorithmus diente. Außerdem gilt mein Dank William |
| 694 |
% A. Casselman, für seine Erlaubnis, den Quicksort-Kode und den Kode zur |
| 695 |
% Berechung der konvexen Hüllen aus seinem Buch «Mathematical |
| 696 |
% Illustration» verwenden zu |
| 697 |
% dürfen\fnurl{http://www.math.ubc.ca/~cass/graphics/text/www/}. Der |
| 698 |
% Dokumentationsstil ist eine Mischung aus der \opt{pst-doc} Klasse |
| 699 |
% (Herbert Voß) und dem \opt{ltxdockit} Paket für die \opt{biblatex} |
| 700 |
% Dokumentation (Philipp Lehmann). |
| 701 |
% \fi |
| 702 |
% \ifENGLISH |
| 703 |
% I thank Marco Cecchetti, for his |
| 704 |
% \opt{lib2geom}-library\fnurl{http://lib2geom.sourceforge.net/} from |
| 705 |
% which I derived great parts of the Postscript code for the Bézier |
| 706 |
% clipping algorithm. Also I want to thank William A. Casselman for the |
| 707 |
% Postscript code of the quicksort procedure and the procedure for |
| 708 |
% calculating the convex hull from his book «Mathematical |
| 709 |
% Illustration»\fnurl{http://www.math.ubc.ca/~cass/graphics/text/www/}, |
| 710 |
% and the permission to use it. The documentation style is a mixture of |
| 711 |
% the \opt{pst-doc} class (Herbert Voß) and the \opt{ltxdockit} package |
| 712 |
% for the \opt{biblatex} documentation (Philipp Lehman). |
| 713 |
% \fi |
| 714 |
% |
| 715 |
% |
| 716 |
% \ifGERMAN |
| 717 |
% \chapter{Benutzung} |
| 718 |
% \fi |
| 719 |
% \ifENGLISH |
| 720 |
% \chapter{Usage} |
| 721 |
% \fi |
| 722 |
% |
| 723 |
% \ifGERMAN |
| 724 |
% Das \LPack{pst-intersect}-Paket kann Schnittpunkte von beliebigen |
| 725 |
% Postscript-Pfaden berechnen. Diese setzen sich nur aus drei primitiven |
| 726 |
% Operation zusammen: Linien (\opt{lineto}), Bézier-Kurven dritter |
| 727 |
% Ordnung (\opt{curveto}) und Sprüngen (\opt{moveto}). Speziellere |
| 728 |
% Konstruktionen, wie z.B. Kreise werden intern zu |
| 729 |
% \opt{curveto}-Anweisungen umgewandelt. Über diese Kommandos hinaus |
| 730 |
% kann \LPack{pst-intersect} auch Bézier-Kurven bis neunter Ordnung |
| 731 |
% verwenden. Das diese keine primitiven Postscript-Pfadelemente |
| 732 |
% darstellen, müssen sie gesondert behandelt werden. |
| 733 |
% |
| 734 |
% Der allgemeine Arbeitsablauf besteht darin eine oder mehrere Kurven |
| 735 |
% oder Pfade zu speichern, und danach die Schnittpunkte zu |
| 736 |
% berechnen. Anschließend können die Schnittpunkte als normale |
| 737 |
% PSTricks-Knoten verwendet werden, oder Abschnitte der Kurven und Pfade |
| 738 |
% nachgezogen werden (z.B. zwischen zwei Schnittpunkten). |
| 739 |
% \fi |
| 740 |
% \ifENGLISH |
| 741 |
% The \LPack{pst-intersect} package can compute the intersections of |
| 742 |
% arbitrary Postscript paths. These are composed of three primitive |
| 743 |
% operations: lines (\opt{lineto}), third order Bézier curves |
| 744 |
% (\opt{curveto}) and jumps (\opt{moveto}). More specialized |
| 745 |
% constructions, like circles, are converted internally to \opt{curveto} |
| 746 |
% operations. Besides these three path operations, the |
| 747 |
% \LPack{pst-intersect} supports Bézier curves up to nineth order. As |
| 748 |
% these aren't primitive Postscript path elements, they require separate |
| 749 |
% handling. |
| 750 |
% |
| 751 |
% The general workflow consists in defining and saving paths and curves, |
| 752 |
% and then compute the intersections between them. Following, those |
| 753 |
% intersection points can be used as normal PSTricks nodes, or portions |
| 754 |
% of the curves and paths can be retraced (e.g. between two |
| 755 |
% intersections). |
| 756 |
% \fi |
| 757 |
% |
| 758 |
% \ifGERMAN |
| 759 |
% \section{Speichern von Pfaden und Kurven} |
| 760 |
% \fi |
| 761 |
% \ifENGLISH |
| 762 |
% \section{Saving paths and curves} |
| 763 |
% \fi |
| 764 |
% |
| 765 |
% \ifGERMAN |
| 766 |
% |
| 767 |
% \fi |
| 768 |
% |
| 769 |
% \begin{ltxsyntax} |
| 770 |
% \cmditem{pssavepath}[options]{curvename}{commands} |
| 771 |
% |
| 772 |
% \ifGERMAN |
| 773 |
% Speichert den gesamten Pfad, der durch \prm{commands} erstellt wird, |
| 774 |
% unter Verwendung des Namens \prm{curvename}. Das Makro funktioniert |
| 775 |
% genauso wie \cs{pscustom}, und kann daher auch nur die darin |
| 776 |
% erlaubten Kommandos verarbeiten. |
| 777 |
% |
| 778 |
% In den Standardeinstellungen wird der entsprechende Pfad auch gleich |
| 779 |
% gezeichnet, was mit \prm{options} beeinflusst werden kann. Mit |
| 780 |
% \opt{linestyle=none} wird das unterbunden. |
| 781 |
% \fi |
| 782 |
% \ifENGLISH |
| 783 |
% Saves the complete path, which is generated by \prm{commands}, under |
| 784 |
% the name \prm{curvename}. The macro is a modification of |
| 785 |
% \cs{pscustom}, and does, therefore, supports only the same commands. |
| 786 |
% |
| 787 |
% By default, the path is also drawn, which can be changed over the |
| 788 |
% \prm{options}, e.g. with \opt{linestyle=none}. |
| 789 |
% \fi |
| 790 |
% \end{ltxsyntax} |
| 791 |
%\iffalse |
| 792 |
%<*ignore> |
| 793 |
%\fi |
| 794 |
\begin{LTXexample} |
| 795 |
\begin{pspicture}(3,2) |
| 796 |
\pssavepath[linecolor=DOrange]{MyPath}{% |
| 797 |
\pscurve(0,2)(0,0.5)(3,1) |
| 798 |
}% |
| 799 |
\end{pspicture} |
| 800 |
\end{LTXexample} |
| 801 |
%\iffalse |
| 802 |
%</ignore> |
| 803 |
%\fi |
| 804 |
% |
| 805 |
% \begin{ltxsyntax} |
| 806 |
% \cmditem{pssavebezier}[options]{curvename}($X_0$)\ldots(\prm{$X_n$}) |
| 807 |
% |
| 808 |
% \ifGERMAN |
| 809 |
% Die Postscript-Sprache unterstützt nur Bézier-Kurven dritter |
| 810 |
% Ordnung. Mit dem Makro \Lcs{pssavebezier} können Bézier-Kurven |
| 811 |
% bis neunter Ordnung definiert werden. Die angegebenen Knoten sind die |
| 812 |
% Kontrollpunkte der Kurve, für eine Kurve $n$-ter Ordnung werden |
| 813 |
% $(n+1)$ Kontrollpunkte benötigt. Die Darstellung der Kurve erfolgt |
| 814 |
% mit dem Makro \cs{psBezier} aus dem \LPack{pst-func}-Paket. |
| 815 |
% \fi |
| 816 |
% \ifENGLISH |
| 817 |
% The Postscript language supports only third-order Bézier |
| 818 |
% curves. With the macro \Lcs{pssavebezier} you can define Bézier |
| 819 |
% curves up to nineth order. The specified nodes are the control |
| 820 |
% points of the curve, for an $n$-th order curve $n+1$ control points |
| 821 |
% are required. The drawing of the curve is done with the |
| 822 |
% \cs{psBezier} macro from the \LPack{pst-func} package. |
| 823 |
% \fi |
| 824 |
% \end{ltxsyntax} |
| 825 |
%\iffalse |
| 826 |
%<*ignore> |
| 827 |
%\fi |
| 828 |
\begin{LTXexample} |
| 829 |
\begin{pspicture}(3,2) |
| 830 |
\pssavebezier[showpoints]{MyBez}(0,0)(0,1)(1,2)(3,2)(1,0)(3,0) |
| 831 |
\end{pspicture} |
| 832 |
\end{LTXexample} |
| 833 |
%\iffalse |
| 834 |
%</ignore> |
| 835 |
%\fi |
| 836 |
% |
| 837 |
% \ifGERMAN |
| 838 |
% \section{Schnittpunkte berechnen} |
| 839 |
% \fi |
| 840 |
% \ifENGLISH |
| 841 |
% \section{Calculating intersections} |
| 842 |
% \fi |
| 843 |
% |
| 844 |
% \begin{ltxsyntax} |
| 845 |
% \cmditem{psintersect}{curveA}{curveB} |
| 846 |
% |
| 847 |
% \ifGERMAN |
| 848 |
% Nachdem Sie nun Pfade oder Kurven gespeichert haben, können Sie |
| 849 |
% deren Schnittpunkte berechnen. Das geschieht mit dem Makro |
| 850 |
% \Lcs{psintersect}. Dieses benötigt als Argumente zwei Namen von |
| 851 |
% Pfaden oder Kurven (Das Argument \prm{curvename} der beiden |
| 852 |
% \cs{pssave*} Makros). |
| 853 |
% \fi |
| 854 |
% \ifENGLISH |
| 855 |
% After having saved some paths and curves, you can now calculate the |
| 856 |
% intersections. That is done with the \Lcs{psintersect} macro. This |
| 857 |
% needs as arguments two names of paths or curves (the \prm{curvename} |
| 858 |
% argument of the two \cs{pssave*} macros). |
| 859 |
% \fi |
| 860 |
% \end{ltxsyntax} |
| 861 |
% |
| 862 |
%\iffalse |
| 863 |
%<*ignore> |
| 864 |
%\fi |
| 865 |
\begin{LTXexample} |
| 866 |
\begin{pspicture}(3,2) |
| 867 |
\pssavepath[linecolor=DOrange]{MyPath}{\pscurve(0,2)(0,0.5)(3,1)} |
| 868 |
\pssavebezier{MyBez}(0,0)(0,1)(1,2)(3,2)(1,0)(3,0) |
| 869 |
\psintersect[showpoints]{MyPath}{MyBez} |
| 870 |
\end{pspicture} |
| 871 |
\end{LTXexample} |
| 872 |
%\iffalse |
| 873 |
%</ignore> |
| 874 |
%\fi |
| 875 |
% |
| 876 |
% \ifGERMAN |
| 877 |
% Der PSTricks-Parameter \opt{showpoints} steuert dabei, ob die |
| 878 |
% Schnittpunkte angezeigt werden. |
| 879 |
% \fi |
| 880 |
% \ifENGLISH |
| 881 |
% The \opt{showpoints} PSTricks parameter determines, if the |
| 882 |
% intersections are drawn directly. |
| 883 |
% \fi |
| 884 |
% |
| 885 |
% \begin{optionlist} |
| 886 |
% \valitem[@tmp]{name}{string} |
| 887 |
% \ifGERMAN |
| 888 |
% Die berechneten Schnittpunkte können unter einem hier angegebenen |
| 889 |
% Namen gespeichert und zu einem späteren Zeitpunkt verwendet werden |
| 890 |
% (siehe \prettyref{sec:pstracecurve-int}). |
| 891 |
% \fi |
| 892 |
% \ifENGLISH |
| 893 |
% The calculated intersections can be saved for later use under this |
| 894 |
% name (see \prettyref{sec:pstracecurve-int}). |
| 895 |
% \fi |
| 896 |
% |
| 897 |
% \boolitem[true]{saveintersections} |
| 898 |
% \ifGERMAN |
| 899 |
% Ist dieser Schalter gesetzt, dann werden die Schnittpunkte als |
| 900 |
% PSTricks-Knoten unter den Namen \prm{name}1, \prm{name}2 \ldots |
| 901 |
% gespeichert. Die Nummerierung erfolgt aufsteigend nach dem Wert der |
| 902 |
% $x$-Koordinate. |
| 903 |
% \fi |
| 904 |
% \ifENGLISH |
| 905 |
% If this option is set, the intersections are saved as PSTricks nodes |
| 906 |
% with the names \prm{name}1, \prm{name}2 \ldots. The numbering is |
| 907 |
% ascending according to the value of their $x$-coordinate. |
| 908 |
% \fi |
| 909 |
% |
| 910 |
%\iffalse |
| 911 |
%<*ignore> |
| 912 |
%\fi |
| 913 |
\begin{LTXexample} |
| 914 |
\begin{pspicture}(5,5) |
| 915 |
\pssavebezier[linecolor=DOrange]{A}% |
| 916 |
(0,0)(0,5)(5,5)(5,1)(1,1.5) |
| 917 |
\pssavebezier{B}(0,5)(0,0)(5,0)(5,5)(0,2) |
| 918 |
\psintersect[name=C, showpoints]{A}{B} |
| 919 |
\uput[150](C1){1} |
| 920 |
\uput[85](C2){2} |
| 921 |
\uput[90](C3){3} |
| 922 |
\uput[-20](C4){4} |
| 923 |
\end{pspicture} |
| 924 |
\end{LTXexample} |
| 925 |
%\iffalse |
| 926 |
%</ignore> |
| 927 |
%\fi |
| 928 |
% \end{optionlist} |
| 929 |
% |
| 930 |
% \ifGERMAN |
| 931 |
% \section{Darstellung gespeicherter Pfade} |
| 932 |
% \fi |
| 933 |
% \ifENGLISH |
| 934 |
% \section{Visualization of saved paths} |
| 935 |
% \fi |
| 936 |
% |
| 937 |
% \begin{ltxsyntax} |
| 938 |
% \cmditem{pstracecurve}[options]{curvename} |
| 939 |
% |
| 940 |
% \ifGERMAN |
| 941 |
% Gespeicherte Pfade und Kurven können mit diesem Makro nachträglich |
| 942 |
% gezeichnet werden. |
| 943 |
% \fi |
| 944 |
% \ifENGLISH |
| 945 |
% Saved paths and curves can be drawn again with this macro. |
| 946 |
% \fi |
| 947 |
% \end{ltxsyntax} |
| 948 |
% |
| 949 |
%\iffalse |
| 950 |
%<*ignore> |
| 951 |
%\fi |
| 952 |
\begin{LTXexample} |
| 953 |
\begin{pspicture}(2,2) |
| 954 |
\pssavepath{Circle}{\pscircle(1,1){1}} |
| 955 |
\pstracecurve[linestyle=dashed, linecolor=green]{Circle} |
| 956 |
\end{pspicture} |
| 957 |
\end{LTXexample} |
| 958 |
%\iffalse |
| 959 |
%</ignore> |
| 960 |
%\fi |
| 961 |
% |
| 962 |
% \begin{optionlist} |
| 963 |
% \numitem{tstart} |
| 964 |
% \numitem{tstop} |
| 965 |
% |
| 966 |
% \ifGERMAN Unter Verwendung dieser beiden Parameter können auch |
| 967 |
% Abschnitte von Pfaden und Kurven gezeichnet werden. Bei Bézier-Kurven |
| 968 |
% ist der Parameterbereich $[0, 1]$, wobei $0$ dem Anfang der Kurve, |
| 969 |
% also dem ersten bei \Lcs{pssavebezier} angegebenen Knoten entspricht. |
| 970 |
% \fi |
| 971 |
% \ifENGLISH |
| 972 |
% With these parameters also parts of paths and curves can be drawn. For |
| 973 |
% Bézier curves the allowed range is $[0, 1]$, where $0$ corresponds to |
| 974 |
% the start of the curve, which is given by the first node given to |
| 975 |
% \Lcs{pssavebezier}. |
| 976 |
% \fi |
| 977 |
% |
| 978 |
%\iffalse |
| 979 |
%<*ignore> |
| 980 |
%\fi |
| 981 |
\begin{LTXexample} |
| 982 |
\begin{pspicture}(5,5) |
| 983 |
\psset{showpoints} |
| 984 |
\pssavebezier{B}(0,5)(0,0)(5,0)(5,5)(0,2) |
| 985 |
\pstracecurve[linestyle=dashed, linecolor=blue!50, |
| 986 |
tstart=0, tstop=0.5]{B} |
| 987 |
\end{pspicture} |
| 988 |
\end{LTXexample} |
| 989 |
%\iffalse |
| 990 |
%</ignore> |
| 991 |
%\fi |
| 992 |
% |
| 993 |
% \medskip |
| 994 |
% \ifGERMAN |
| 995 |
% Pfaden können aus mehr als einem Abschnitt bestehen, der Bereich ist |
| 996 |
% also $[0, n]$, wobei $n$ die Anzahl der Pfadabschnitte ist. Dabei ist |
| 997 |
% zu beachten, dass z.B. \cs{pscurve}-Pfade oder auch Kreise und |
| 998 |
% Kreisbögen aus mehreren Abschnitten bestehen. |
| 999 |
% \fi |
| 1000 |
% \ifENGLISH |
| 1001 |
% Paths can be composed of more than one segmet, and the range is $[0, |
| 1002 |
% n]$, where $n$ is the number of path segments. For this you must keep |
| 1003 |
% in mind, that also e.g \cs{pscurve} paths, circles or arcs consist of |
| 1004 |
% several segments. |
| 1005 |
% \fi |
| 1006 |
% |
| 1007 |
%\iffalse |
| 1008 |
%<*ignore> |
| 1009 |
%\fi |
| 1010 |
\begin{LTXexample} |
| 1011 |
\begin{pspicture}(2,2) |
| 1012 |
\pssavepath[linestyle=none]{Circle}{\pscircle(1,1){1}} |
| 1013 |
\pstracecurve[tstart=0, tstop=1, linecolor=green]{Circle} |
| 1014 |
\pstracecurve[tstart=2, tstop=3, linecolor=red]{Circle} |
| 1015 |
\pstracecurve[tstart=1.25, tstop=1.75, linecolor=blue]{Circle} |
| 1016 |
\end{pspicture} |
| 1017 |
\end{LTXexample} |
| 1018 |
%\iffalse |
| 1019 |
%</ignore> |
| 1020 |
%\fi |
| 1021 |
% |
| 1022 |
% \end{optionlist} |
| 1023 |
% |
| 1024 |
% \ifGERMAN |
| 1025 |
% Beachten Sie, dass die Reihenfolge von \Lkeyword{tstart} und |
| 1026 |
% \Lkeyword{tstop} eine Rolle spielt. Ist \Lkeyword{tstart} |
| 1027 |
% \textgreater{} \Lkeyword{tstop} dann wird die Pfadrichtung umgekehrt. |
| 1028 |
% \fi |
| 1029 |
% \ifENGLISH |
| 1030 |
% Please note, that the order of \Lkeyword{tstart} and \Lkeyword{tstop} |
| 1031 |
% plays a role. For \Lkeyword{tstart} \textgreater{} \Lkeyword{tstop} |
| 1032 |
% the path direction is reversed. |
| 1033 |
% \fi |
| 1034 |
% |
| 1035 |
% \iffalse |
| 1036 |
%<*ignore> |
| 1037 |
% \fi |
| 1038 |
\begin{LTXexample} |
| 1039 |
\begin{pspicture}(2,2) |
| 1040 |
\psset{arrows=->, arrowscale=1.5} |
| 1041 |
\pssavepath[linestyle=dashed, linewidth=0.5\pslinewidth]{A}{\psline(0,0)(1,2)(2,0)} |
| 1042 |
\pstracecurve[tstart=0.1, tstop=0.9]{A} |
| 1043 |
\end{pspicture} |
| 1044 |
\end{LTXexample} |
| 1045 |
|
| 1046 |
\begin{LTXexample} |
| 1047 |
\begin{pspicture}(2,2) |
| 1048 |
\psset{arrows=->, arrowscale=1.5} |
| 1049 |
\pssavepath[linestyle=dashed, linewidth=0.5\pslinewidth]{A}{\psline(0,0)(1,2)(2,0)} |
| 1050 |
\pstracecurve[tstart=0.9, tstop=0.1]{A} |
| 1051 |
\end{pspicture} |
| 1052 |
\end{LTXexample} |
| 1053 |
% \iffalse |
| 1054 |
%</ignore> |
| 1055 |
% \fi |
| 1056 |
% |
| 1057 |
% \begin{ltxsyntax} |
| 1058 |
% \cmditem{psGetCurvePoint}{curvename}{t} |
| 1059 |
% |
| 1060 |
% \ifGERMAN |
| 1061 |
% Speichert die Koordinaten der Kurve \prm{curvename} am Punkt \prm{t}. |
| 1062 |
% \fi |
| 1063 |
% \ifENGLISH |
| 1064 |
% Save the coordinates of \prm{curvename} at the point \prm{t}. |
| 1065 |
% \fi |
| 1066 |
% \end{ltxsyntax} |
| 1067 |
% \iffalse |
| 1068 |
%<*ignore> |
| 1069 |
% \fi |
| 1070 |
\begin{LTXexample} |
| 1071 |
\begin{pspicture}(3,3) |
| 1072 |
\pssavebezier{A}(0,0)(0,3)(3,0)(3,3) |
| 1073 |
\multido{\r=0+0.1}{11}{% |
| 1074 |
\psdot(! \psGetCurvePoint{A}{\r} I-A.x I-A.y)} |
| 1075 |
\end{pspicture} |
| 1076 |
\end{LTXexample} |
| 1077 |
% \iffalse |
| 1078 |
%</ignore> |
| 1079 |
% \fi |
| 1080 |
% |
| 1081 |
% \ifGERMAN |
| 1082 |
% \section{Darstellung gespeicherter Schnitte} |
| 1083 |
% \fi |
| 1084 |
% \ifENGLISH |
| 1085 |
% \section{Visualization of saved intersections} |
| 1086 |
% \fi |
| 1087 |
% \label{sec:pstracecurve-int} |
| 1088 |
% |
| 1089 |
% \begin{ltxsyntax} |
| 1090 |
% \cmditem*{pstracecurve}[options]{intersection}{curvename} |
| 1091 |
% \end{ltxsyntax} |
| 1092 |
% |
| 1093 |
% \begin{optionlist} |
| 1094 |
% \numitem{istart} |
| 1095 |
% \numitem{istop} |
| 1096 |
% |
| 1097 |
% \ifGERMAN |
| 1098 |
% Dieser beiden Parameter können auch verwendet werden um Abschnitte von |
| 1099 |
% Pfaden und Kurven zwischen Schnittpunkten zu zeichnen. Die |
| 1100 |
% Schnittpunkte werden dabei angefangen bei $1$ in aufsteigender |
| 1101 |
% Reihenfolge entlang der Kurve durchnummeriert. |
| 1102 |
% \fi |
| 1103 |
% \ifENGLISH |
| 1104 |
% These two parameters can be used to draw path or curve segments |
| 1105 |
% between intersections. The intersections are numbered starting at $1$ |
| 1106 |
% in ascending order along the curve. |
| 1107 |
% \fi |
| 1108 |
% \end{optionlist} |
| 1109 |
% |
| 1110 |
%\iffalse |
| 1111 |
%<*ignore> |
| 1112 |
%\fi |
| 1113 |
\begin{LTXexample} |
| 1114 |
\begin{pspicture}(5.2,5.2) |
| 1115 |
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{A}(0,0)(0,5)(5,2)(5,5) |
| 1116 |
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{B}(0,2.5)(2.5,2.5)(4.5, 3)(2,4) |
| 1117 |
\psintersect[linecolor=green!70!black, name=C]{A}{B} |
| 1118 |
\pstracecurve[linecolor=red, istart=1, istop=2]{C}{A} |
| 1119 |
\pstracecurve[linecolor=blue, istart=1, istop=2]{C}{B} |
| 1120 |
\end{pspicture} |
| 1121 |
\end{LTXexample} |
| 1122 |
%\iffalse |
| 1123 |
%</ignore> |
| 1124 |
%\fi |
| 1125 |
% |
| 1126 |
% \ifGERMAN |
| 1127 |
% Wird nur ein Wert angegeben, beispielsweise \Lkeyword{istop}, dann |
| 1128 |
% wird die Kurve vom Anfang bis zum entsprechenden Schnittpunkt |
| 1129 |
% gezeichnet. Wird nur \Lkeyword{istart} angegeben, dann endet die Kurve |
| 1130 |
% am Ende. Die Parameter \Lkeyword{istart} bzw. \Lkeyword{istop} können |
| 1131 |
% mit \Lkeyword{tstart} bzw. \Lkeyword{tstop} kombiniert werden. |
| 1132 |
% \fi |
| 1133 |
% \ifENGLISH |
| 1134 |
% If only one value is specified, e.g. \Lkeyword{istop}, the curve is |
| 1135 |
% drawn from the start to the respective intersection. If only |
| 1136 |
% \Lkeyword{istart} is given, the curve is drawn from this intersection |
| 1137 |
% to the curve end. The parameters \Lkeyword{istart} and |
| 1138 |
% \Lkeyword{istop} can be combined with \Lkeyword{tstart} and |
| 1139 |
% \Lkeyword{tstop}. |
| 1140 |
% \fi |
| 1141 |
% |
| 1142 |
%\iffalse |
| 1143 |
%<*ignore> |
| 1144 |
%\fi |
| 1145 |
\begin{LTXexample} |
| 1146 |
\begin{pspicture}(5.2,5.2) |
| 1147 |
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{A}(0,0)(0,5)(5,2)(5,5) |
| 1148 |
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{B}(0,2.5)(2.5,2.5)(4.5, 3)(2,4) |
| 1149 |
\psintersect[linecolor=green!70!black, name=C]{A}{B} |
| 1150 |
\pstracecurve[linecolor=red, istop=2]{C}{A} |
| 1151 |
\pstracecurve[linecolor=blue, istart=1]{C}{B} |
| 1152 |
\end{pspicture} |
| 1153 |
\end{LTXexample} |
| 1154 |
%\iffalse |
| 1155 |
%</ignore> |
| 1156 |
%\fi |
| 1157 |
% |
| 1158 |
% \begin{ltxsyntax} |
| 1159 |
% \cmditem{psGetIsectCenter}{intersection}{curvename}{n} |
| 1160 |
% |
| 1161 |
% \ifGERMAN |
| 1162 |
% Lädt die Koordinaten des $n$-ten Schnittpunkts des Pfades |
| 1163 |
% \prm{curvename} in der Schnittmenge \prm{intersection}. Dabei |
| 1164 |
% startet die Nummer der Schnittpunkte bei \prm{n}$=1$ und wird in |
| 1165 |
% Pfadrichtung durchnummeriert. |
| 1166 |
% \fi |
| 1167 |
% \ifENGLISH |
| 1168 |
% Loads the coordinates of the $n$-th intersection point of the path |
| 1169 |
% \prm{curvename} in the intersection set \prm{intersection}. The |
| 1170 |
% numbering of the intersections starts at \prm{n}$=1$ and the number |
| 1171 |
% increases along the path in its original direction. |
| 1172 |
% \fi |
| 1173 |
% \end{ltxsyntax} |
| 1174 |
% |
| 1175 |
% \iffalse |
| 1176 |
%<*ignore> |
| 1177 |
%\fi |
| 1178 |
\begin{LTXexample} |
| 1179 |
\begin{pspicture}(4,5) |
| 1180 |
\pssavebezier[linecolor=DOrange, arrows=->]{A}% |
| 1181 |
(0,0)(0,5)(5,5)(5,1)(1,1.5) |
| 1182 |
\pssavebezier[arrows=->]{B}(0,5)(0,0)(5,0)(5,5)(0,2) |
| 1183 |
\psintersect[name=C, showpoints]{A}{B} |
| 1184 |
\color{DOrange} |
| 1185 |
\uput[150](!\psGetIsectCenter{C}{A}{1} I-C1.x I-C1.y){1} |
| 1186 |
\uput[85](!\psGetIsectCenter{C}{A}{2} I-C2.x I-C2.y){2} |
| 1187 |
\uput[-20](!\psGetIsectCenter{C}{A}{3} I-C3.x I-C3.y){3} |
| 1188 |
\uput[90](!\psGetIsectCenter{C}{A}{4} I-C4.x I-C4.y){4} |
| 1189 |
\end{pspicture} |
| 1190 |
\end{LTXexample} |
| 1191 |
%\iffalse |
| 1192 |
%</ignore> |
| 1193 |
%\fi |
| 1194 |
% |
| 1195 |
% \ifGERMAN |
| 1196 |
% Wenn kein Kurvenname \prm{curvename} angegeben wird, dann werden die |
| 1197 |
% Punkte nach aufsteigender $x$-Koordinate sortiert: |
| 1198 |
% \fi |
| 1199 |
% \ifENGLISH |
| 1200 |
% Without \prm{curvename} the points are sorted according to their |
| 1201 |
% $x$-coordinate: |
| 1202 |
% \fi |
| 1203 |
% |
| 1204 |
% \iffalse |
| 1205 |
%<*ignore> |
| 1206 |
%\fi |
| 1207 |
\begin{LTXexample} |
| 1208 |
\begin{pspicture}(4,5) |
| 1209 |
\pssavebezier[linecolor=DOrange, arrows=->]{A}% |
| 1210 |
(0,0)(0,5)(5,5)(5,1)(1,1.5) |
| 1211 |
\pssavebezier[arrows=->]{B}(0,5)(0,0)(5,0)(5,5)(0,2) |
| 1212 |
\psintersect[name=C, showpoints]{A}{B} |
| 1213 |
\uput[150](!\psGetIsectCenter{C}{}{1} I-C1.x I-C1.y){1} |
| 1214 |
\uput[85](!\psGetIsectCenter{C}{}{2} I-C2.x I-C2.y){2} |
| 1215 |
\uput[90](!\psGetIsectCenter{C}{}{3} I-C3.x I-C3.y){3} |
| 1216 |
\uput[-20](!\psGetIsectCenter{C}{}{4} I-C4.x I-C4.y){4} |
| 1217 |
\end{pspicture} |
| 1218 |
\end{LTXexample} |
| 1219 |
%\iffalse |
| 1220 |
%</ignore> |
| 1221 |
%\fi |
| 1222 |
% |
| 1223 |
% \ifGERMAN |
| 1224 |
% Die Schnittpunkte können auch mit \Lkeyword{saveintersections} und |
| 1225 |
% \opt{saveNodeCoors} geladen werden. Diese werden dann ebenfalls nach |
| 1226 |
% aufsteigender $x$-Koordinate nummeriert. |
| 1227 |
% \fi |
| 1228 |
% \ifENGLISH |
| 1229 |
% The intersection points can also be loaded with |
| 1230 |
% \Lkeyword{saveintersections} and \opt{saveNodeCoors}. In that case, |
| 1231 |
% the numbering of the intersection increases according to their $x$ |
| 1232 |
% coordinate. |
| 1233 |
% \fi |
| 1234 |
% |
| 1235 |
% \ifGERMAN |
| 1236 |
% \chapter{Beispiele} |
| 1237 |
% \fi |
| 1238 |
% \ifENGLISH |
| 1239 |
% \chapter{Examples} |
| 1240 |
% \fi |
| 1241 |
%\iffalse |
| 1242 |
%<*ignore> |
| 1243 |
%\fi |
| 1244 |
\begin{LTXexample}[caption={caption}] |
| 1245 |
\begin{pspicture}(5,5) |
| 1246 |
\pssavebezier{A}(0,0)(0,5)(5,5)(5,1)(1,1.5) |
| 1247 |
\multido{\i=100+-20,\r=1+-0.2}{5}{% |
| 1248 |
\pstracecurve[linecolor=red!\i, tstop=\r, arrows=-|, showpoints]{A} |
| 1249 |
}% |
| 1250 |
\end{pspicture} |
| 1251 |
\end{LTXexample} |
| 1252 |
%\iffalse |
| 1253 |
%</ignore> |
| 1254 |
%\fi |
| 1255 |
% |
| 1256 |
%\iffalse |
| 1257 |
%<*ignore> |
| 1258 |
%\fi |
| 1259 |
\begingroup |
| 1260 |
\captionsetup[lstlisting]{format=pitcaption} |
| 1261 |
\begin{LTXexample}[pos=t, caption={% |
| 1262 |
\ifGERMAN Mit diesem Paket können auch die Schnittpunkte von |
| 1263 |
Funktionen berechnet werden, die mit \cs{psplot} gezeichnet |
| 1264 |
werden. Dabei ist zu beachten, dass beide einzelnen Kurven aus |
| 1265 |
\opt{plotpoints} Abschnitten bestehen, von denen jeder mit jedem |
| 1266 |
geschnitten wird, was zu langen Berechnungen führen kann. |
| 1267 |
\fi |
| 1268 |
\ifENGLISH |
| 1269 |
The package can also calculate the intersections of functions which are |
| 1270 |
drawn with \cs{psplot}. Here you must keep in mind, that such curves |
| 1271 |
consists of \opt{plotpoints} segments, which must all be considered for |
| 1272 |
intersections, what can result in long calculations. |
| 1273 |
\fi}] |
| 1274 |
\begin{pspicture}(10,4.4) |
| 1275 |
\pssavepath{A}{\psplot[plotpoints=200]{0}{10}{x 180 mul sin 1 add 2 mul}} |
| 1276 |
\pssavepath{B}{\psplot[plotpoints=50]{0}{10}{2 x neg 0.5 mul exp 4 mul}} |
| 1277 |
\psintersect[name=C, showpoints]{A}{B} |
| 1278 |
\multido{\i=1+1}{5}{\uput[210](C\i){\i}} |
| 1279 |
\multido{\i=6+2,\ii=7+2}{3}{\uput[225](C\i){\i}\uput[-45](C\ii){\ii}} |
| 1280 |
\end{pspicture} |
| 1281 |
\end{LTXexample} |
| 1282 |
\endgroup |
| 1283 |
%\iffalse |
| 1284 |
%</ignore> |
| 1285 |
%\fi |
| 1286 |
% |
| 1287 |
% \appendix |
| 1288 |
% |
| 1289 |
% \ifGERMAN |
| 1290 |
% \chapter{Versionsgeschichte} |
| 1291 |
% |
| 1292 |
% Diese Versionsgeschichte ist eine Liste von Änderungen, die für den Nutzer des |
| 1293 |
% Pakets von Bedeutung sind. Änderungen, die eher technischer Natur sind und für |
| 1294 |
% den Nutzer des Pakets nicht relevant sind und das Verhalten des Pakets nicht |
| 1295 |
% ändern, werden nicht aufgeführt. Wenn ein Eintrag der Versionsgeschichte ein |
| 1296 |
% Feature als \emph{improved} oder \emph{extended} bekannt gibt, so bedeutet |
| 1297 |
% dies, dass eine Modifikation die Syntax und das Verhalten des Pakets nicht |
| 1298 |
% beeinflusst, oder das es für ältere Versionen kompatibel ist. Einträge, die |
| 1299 |
% als \emph{deprecated}, \emph{modified}, \emph{renamed}, oder \emph{removed} |
| 1300 |
% deklariert sind, verlangen besondere Aufmerksamkeit. Diese bedeuten, dass eine |
| 1301 |
% Modifikation Änderungen in existierenden Dokumenten mit sich ziehen kann. |
| 1302 |
% \fi |
| 1303 |
% \ifENGLISH |
| 1304 |
% \chapter{Revision history} |
| 1305 |
% |
| 1306 |
% This revision history is a list of changes relevant to users of this |
| 1307 |
% package. Changes of a more technical nature which do not affect the |
| 1308 |
% user interface or the behavior of the package are not included in the |
| 1309 |
% list. If an entry in the revision history states that a feature has |
| 1310 |
% been \emph{improved} or \emph{extended}, this indicates a modification |
| 1311 |
% which either does not affect the syntax and behavior of the package or |
| 1312 |
% is syntactically backwards compatible (such as the addition of an |
| 1313 |
% optional argument to an existing command). Entries stating that a |
| 1314 |
% feature has been \emph{deprecated}, \emph{modified}, \emph{fixed}, |
| 1315 |
% \emph{renamed}, or \emph{removed} demand attention. They indicate a |
| 1316 |
% modification which may require changes to existing documents. |
| 1317 |
% \fi |
| 1318 |
% |
| 1319 |
% \begin{changelog} |
| 1320 |
% \patchcmd{\release}{\setlength{\itemsep}{0pt}}{\setlength{\itemsep}{0pt}\setlength{\parsep}{0pt}}{}{} |
| 1321 |
% \begin{release}{0.4}{2014-03-16} |
| 1322 |
% \item Added \cs{psGetCurvePoint}. |
| 1323 |
% \item Fixed \cs{pstracecurve} for use with \cs{pscustom}. |
| 1324 |
% \item Fixed arrow behavior. |
| 1325 |
% \end{release} |
| 1326 |
% \begin{release}{0.3}{2014-03-04} |
| 1327 |
% \item Fixed \cs{psGetIsectNode} to work with more than one segment. |
| 1328 |
% \item Modified \cs{psGetIsectNode} and the naming conventions of the |
| 1329 |
% variables. |
| 1330 |
% \item Fixed missing support for \opt{pst-node}'s \opt{saveNodeCoors} |
| 1331 |
% parameter to \opt{saveintersections}. |
| 1332 |
% \end{release} |
| 1333 |
% \begin{release}{0.2}{2014-02-26} |
| 1334 |
% \item Added support for \opt{arrows} parameter to \cs{pstracecurve}. |
| 1335 |
% \item Modified parameters \opt{tstart}, \opt{tstop}, \opt{istart} |
| 1336 |
% and \opt{istop} to respect different directions. |
| 1337 |
% \item Added \cs{psGetIsectCenter} |
| 1338 |
% \item Fixed a bug in the termination of the iteration procedure. |
| 1339 |
% \item Fixed a bug in the point order of Bézier curves, which was |
| 1340 |
% related to a now fixed bug in \opt{pst-func}. |
| 1341 |
% \item Several other improvements. |
| 1342 |
% \end{release} |
| 1343 |
% \begin{release}{0.1}{2014-02-19} |
| 1344 |
% \item First CTAN version |
| 1345 |
% \end{release} |
| 1346 |
% \end{changelog} |
| 1347 |
% |
| 1348 |
% \StopEventually{} |
| 1349 |
% |
| 1350 |
% \begin{otherlanguage}{english} |
| 1351 |
% \printindex[idx] |
| 1352 |
% \end{otherlanguage} |
| 1353 |
% |
| 1354 |
% \chapter{The \LaTeX\ wrapper} |
| 1355 |
%<*stylefile> |
| 1356 |
% \begin{macrocode} |
| 1357 |
\RequirePackage{pstricks} |
| 1358 |
\RequirePackage{pst-xkey} |
| 1359 |
\RequirePackage{pst-node} |
| 1360 |
\RequirePackage{pst-func} |
| 1361 |
\input{pst-intersect.tex} |
| 1362 |
\IfFileExists{pst-intersect.pro}{% |
| 1363 |
\ProvidesFile{pst-intersect.pro} |
| 1364 |
[2014/03/16 PostScript prologue file] |
| 1365 |
\@addtofilelist{pst-intersect.pro}}{}% |
| 1366 |
% \end{macrocode} |
| 1367 |
%</stylefile> |
| 1368 |
% |
| 1369 |
% \chapter{The \TeX\ implementation} |
| 1370 |
% |
| 1371 |
%<*texfile> |
| 1372 |
% \begin{macrocode} |
| 1373 |
\csname PSTintersectLoaded\endcsname |
| 1374 |
\let\PSTintersectLoaded\endinput |
| 1375 |
|
| 1376 |
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex \fi |
| 1377 |
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi |
| 1378 |
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex \fi |
| 1379 |
\ifx\PSTfuncLoaded\endinput\else \input pst-func.tex \fi |
| 1380 |
|
| 1381 |
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax |
| 1382 |
|
| 1383 |
\pst@addfams{intersect} |
| 1384 |
\pstheader{pst-intersect.pro} |
| 1385 |
|
| 1386 |
\def\pst@intersectdict{tx@IntersectDict begin } |
| 1387 |
\def\PIT@dict#1{\pst@intersectdict #1 end} |
| 1388 |
\def\PIT@Verb#1{\pst@Verb{\PIT@dict{#1} }}% |
| 1389 |
% \end{macrocode} |
| 1390 |
% \section{The parameter definitions} |
| 1391 |
% \begin{macrocode} |
| 1392 |
\define@key[psset]{intersect}{tstart}{% |
| 1393 |
\pst@checknum{#1}\PIT@key@tstart |
| 1394 |
} |
| 1395 |
\define@key[psset]{intersect}{tstop}{% |
| 1396 |
\pst@checknum{#1}\PIT@key@tstop |
| 1397 |
} |
| 1398 |
\define@key[psset]{intersect}{istart}{% |
| 1399 |
\pst@checknum{#1}\PIT@key@istart |
| 1400 |
} |
| 1401 |
\define@key[psset]{intersect}{istop}{% |
| 1402 |
\pst@checknum{#1}\PIT@key@istop |
| 1403 |
} |
| 1404 |
\define@key[psset]{intersect}{name}{% |
| 1405 |
\def\PIT@key@name{#1}% |
| 1406 |
}% |
| 1407 |
\newif\PIT@saveintersections |
| 1408 |
\define@boolkey[psset]{intersect}[PIT@]{saveintersections}[true]{} |
| 1409 |
\newif\PIT@addintersections |
| 1410 |
\define@boolkey[psset]{intersect}[PIT@]{addintersections}[true]{} |
| 1411 |
|
| 1412 |
\psset[intersect]{% |
| 1413 |
tstart=-1, |
| 1414 |
tstop=-1, |
| 1415 |
istart=-1, |
| 1416 |
istop=-1, |
| 1417 |
name={}, |
| 1418 |
saveintersections, |
| 1419 |
addintersections=false |
| 1420 |
}% |
| 1421 |
% \end{macrocode} |
| 1422 |
% |
| 1423 |
% \begin{macro}{\PIT@use@pscode} |
| 1424 |
% This is a modified version of the \cs{use@pscode} core macro. It |
| 1425 |
% explicitely allows the content of the stack to be moved outside the |
| 1426 |
% local Postscript-scope created by the \cs{pstverb} macro. This |
| 1427 |
% allows to save these values on the global level for later |
| 1428 |
% use. Beware, that you cannot leave arrays or marks on the stack. |
| 1429 |
% \begin{macrocode} |
| 1430 |
\def\PIT@use@pscode{% |
| 1431 |
\pstverb{% |
| 1432 |
\pst@dict |
| 1433 |
\tx@STP |
| 1434 |
\pst@newpath |
| 1435 |
\psk@origin |
| 1436 |
\psk@swapaxes |
| 1437 |
\pst@code |
| 1438 |
end |
| 1439 |
count /ocount exch def |
| 1440 |
}% |
| 1441 |
\gdef\pst@code{}% |
| 1442 |
}% |
| 1443 |
% \end{macrocode} |
| 1444 |
% \end{macro} |
| 1445 |
% |
| 1446 |
% \begin{macro}{\PIT@save@path} |
| 1447 |
% Modified version of the \cs{pst@stroke} core macro, which puts the |
| 1448 |
% whole current path on the stack. |
| 1449 |
% \begin{macrocode} |
| 1450 |
\let\PIT@pst@stroke@orig\pst@stroke |
| 1451 |
\def\PIT@save@path{% |
| 1452 |
\PIT@pst@stroke@orig |
| 1453 |
\addto@pscode{% |
| 1454 |
clear mark |
| 1455 |
\pst@intersectdict GetFullPath end |
| 1456 |
counttomark 1 add -1 roll pop count }% |
| 1457 |
}% |
| 1458 |
% \end{macrocode} |
| 1459 |
% \end{macro} |
| 1460 |
% |
| 1461 |
% \begin{macrocode} |
| 1462 |
\def\PIT@name@default{@tmp}% |
| 1463 |
\def\PIT@name#1{PIT@#1}% |
| 1464 |
\def\PIT@checkname#1{% |
| 1465 |
\ifx\@empty#1\@empty |
| 1466 |
\@pstrickserr{Unexpected empty argument!}\@ehpb |
| 1467 |
\fi |
| 1468 |
}% |
| 1469 |
% \end{macrocode} |
| 1470 |
% |
| 1471 |
% \begin{macro}{\pssavebezier} |
| 1472 |
% \begin{macrocode} |
| 1473 |
\def\pssavebezier{\pst@object{pssavebezier}} |
| 1474 |
% \end{macrocode} |
| 1475 |
% \end{macro} |
| 1476 |
% |
| 1477 |
% \begin{macro}{\pssavebezier@i} |
| 1478 |
% Process all nodes following the \cs{pssavebezier} macro call. |
| 1479 |
% \begin{macrocode} |
| 1480 |
\def\pssavebezier@i#1{% |
| 1481 |
\begin@OpenObj |
| 1482 |
\PIT@checkname{#1}% |
| 1483 |
\addto@pscode{ /\PIT@name{#1} }% |
| 1484 |
\pst@getcoors[\pssavebezier@ii%] |
| 1485 |
}% |
| 1486 |
% \end{macrocode} |
| 1487 |
% \end{macro} |
| 1488 |
% |
| 1489 |
% \begin{macro}{\pssavebezier@ii} |
| 1490 |
% This does the whole actual work. |
| 1491 |
% \begin{macrocode} |
| 1492 |
\def\pssavebezier@ii{% |
| 1493 |
\addto@pscode{% |
| 1494 |
% \end{macrocode} |
| 1495 |
% only 10 points allowed, remove the rest |
| 1496 |
% \begin{macrocode} |
| 1497 |
counttomark 20 gt { counttomark 20 sub { pop } repeat } if |
| 1498 |
counttomark 2 idiv 1 sub |
| 1499 |
\psk@plotpoints\space exch |
| 1500 |
\txFunc@BezierCurve |
| 1501 |
\ifshowpoints \txFunc@BezierShowPoints \else pop \fi |
| 1502 |
tx@FuncDict begin Points aload pop end |
| 1503 |
}% |
| 1504 |
\let\use@pscode\PIT@use@pscode |
| 1505 |
\end@OpenObj |
| 1506 |
\PIT@Verb{% |
| 1507 |
[ count 1 sub 1 roll ] ArrayToPointArray def |
| 1508 |
}% |
| 1509 |
\ignorespaces}% |
| 1510 |
% \end{macrocode} |
| 1511 |
% \end{macro} |
| 1512 |
% |
| 1513 |
% \begin{macro}{\pssavepath} |
| 1514 |
% \begin{macrocode} |
| 1515 |
\def\pssavepath{\pst@object{pssavepath}}% |
| 1516 |
% \end{macrocode} |
| 1517 |
% \end{macro} |
| 1518 |
% |
| 1519 |
% \begin{macro}{\pssavepath@i} |
| 1520 |
% \begin{macrocode} |
| 1521 |
\long\def\pssavepath@i#1#2{% |
| 1522 |
\begin@SpecialObj |
| 1523 |
\PIT@checkname{#1}% |
| 1524 |
\let\pst@stroke\PIT@save@path |
| 1525 |
\let\use@pscode\PIT@use@pscode |
| 1526 |
\pscustom{#2}% |
| 1527 |
\PIT@Verb{% |
| 1528 |
/\PIT@name{#1} |
| 1529 |
[ 3 -1 roll 2 add 2 roll ] def }% |
| 1530 |
\end@SpecialObj |
| 1531 |
}% |
| 1532 |
% \end{macrocode} |
| 1533 |
% \end{macro} |
| 1534 |
% |
| 1535 |
% \begin{macro}{\pstracecurve} |
| 1536 |
% \begin{macrocode} |
| 1537 |
\def\pstracecurve{\pst@object{pstracecurve}}% |
| 1538 |
% \end{macrocode} |
| 1539 |
% \end{macro} |
| 1540 |
% |
| 1541 |
% \begin{macro}{\pstracecurve@i} |
| 1542 |
% \begin{macrocode} |
| 1543 |
\def\pstracecurve@i#1{% |
| 1544 |
\addbefore@par{plotpoints=200}% |
| 1545 |
\begin@OpenObj |
| 1546 |
\@ifnextchar\bgroup |
| 1547 |
{\PIT@traceintersection{#1}}% |
| 1548 |
{\PIT@tracecurve{#1}}% |
| 1549 |
}% |
| 1550 |
% \end{macrocode} |
| 1551 |
% \end{macro} |
| 1552 |
% |
| 1553 |
% \begin{macro}{\PIT@tracecurve} |
| 1554 |
% \begin{macrocode} |
| 1555 |
\def\PIT@tracecurve#1{% |
| 1556 |
\PIT@checkname{#1}% |
| 1557 |
\addto@pscode{% |
| 1558 |
\pst@intersectdict |
| 1559 |
/\PIT@name{#1} currentdict exch known not { |
| 1560 |
(You haven't defined the curve '#1') == |
| 1561 |
} if |
| 1562 |
\PIT@name{#1} \PIT@key@tstart\space\PIT@key@tstop\space % [curve] tstart tstop |
| 1563 |
{\psk@plotpoints exch |
| 1564 |
\txFunc@BezierCurve |
| 1565 |
\ifshowpoints \txFunc@BezierShowPoints \else pop \fi |
| 1566 |
} |
| 1567 |
TraceCurveOrPath |
| 1568 |
end |
| 1569 |
}% |
| 1570 |
%\showpointsfalse |
| 1571 |
\end@OpenObj |
| 1572 |
}% |
| 1573 |
% \end{macrocode} |
| 1574 |
% \end{macro} |
| 1575 |
% |
| 1576 |
% \begin{macro}{PIT@traceintersection} |
| 1577 |
% \begin{macrocode} |
| 1578 |
\def\PIT@traceintersection#1#2{% |
| 1579 |
\PIT@checkname{#2}% |
| 1580 |
\addto@pscode{% |
| 1581 |
\pst@intersectdict |
| 1582 |
\ifx\\#1\\% |
| 1583 |
/\PIT@name{\PIT@name@default} |
| 1584 |
\else |
| 1585 |
/\PIT@name{#1} |
| 1586 |
\fi |
| 1587 |
dup currentdict exch known not { |
| 1588 |
\ifx\\#1\\% |
| 1589 |
(You haven't defined an intersection!) == |
| 1590 |
\else |
| 1591 |
(You haven't defined the intersection '#1') == |
| 1592 |
\fi |
| 1593 |
} if |
| 1594 |
load |
| 1595 |
dup dup type /dicttype eq exch /\PIT@name{#2} known and not { |
| 1596 |
(You haven't defined the intersection '#2') == |
| 1597 |
} if |
| 1598 |
dup /\PIT@name{#2} get |
| 1599 |
exch /\PIT@name{#2}@t get |
| 1600 |
dup length \PIT@key@istart\space ge 0 \PIT@key@istart\space lt and { |
| 1601 |
dup \PIT@key@istart\space cvi 1 sub get |
| 1602 |
} { |
| 1603 |
\PIT@key@tstart |
| 1604 |
} ifelse |
| 1605 |
exch % [curve] t_istart|tstart [ts] |
| 1606 |
dup length \PIT@key@istop\space ge 0 \PIT@key@istop\space lt and { |
| 1607 |
\PIT@key@istop\space cvi 1 sub get |
| 1608 |
} { |
| 1609 |
pop \PIT@key@tstop |
| 1610 |
} ifelse % [curve] tstart tstop |
| 1611 |
{\psk@plotpoints exch |
| 1612 |
\txFunc@BezierCurve |
| 1613 |
\ifshowpoints \txFunc@BezierShowPoints \else pop \fi |
| 1614 |
} |
| 1615 |
TraceCurveOrPath |
| 1616 |
end |
| 1617 |
}% |
| 1618 |
%\showpointsfalse |
| 1619 |
\end@OpenObj |
| 1620 |
}% |
| 1621 |
% \end{macrocode} |
| 1622 |
% \end{macro} |
| 1623 |
% |
| 1624 |
% \begin{macro}{\psintersect} |
| 1625 |
% \begin{macrocode} |
| 1626 |
\def\psintersect{\pst@object{psintersect}} |
| 1627 |
\def\psintersect@i#1#2{% |
| 1628 |
\PIT@checkname{#1}% |
| 1629 |
\PIT@checkname{#2}% |
| 1630 |
\begin@SpecialObj |
| 1631 |
\def\PIT@@name{% |
| 1632 |
\ifx\PIT@key@name\@empty |
| 1633 |
\PIT@name{\PIT@name@default} |
| 1634 |
\else |
| 1635 |
\PIT@name{\PIT@key@name} |
| 1636 |
\fi}% |
| 1637 |
\PIT@Verb{% |
| 1638 |
currentdict /\PIT@name{#1} known not { |
| 1639 |
(You haven't defined the curve or path '#1') == |
| 1640 |
} if |
| 1641 |
currentdict /\PIT@name{#2} known not { |
| 1642 |
(You haven't defined the curve or path '#2') == |
| 1643 |
} if |
| 1644 |
\PIT@name{#1} \PIT@name{#2} |
| 1645 |
\PIT@name{#1} IsPath { |
| 1646 |
\PIT@name{#2} IsPath { |
| 1647 |
IntersectPaths |
| 1648 |
}{ |
| 1649 |
IntersectPathCurve |
| 1650 |
} ifelse |
| 1651 |
}{ |
| 1652 |
\PIT@name{#2} IsPath { |
| 1653 |
IntersectCurvePath |
| 1654 |
}{ |
| 1655 |
IntersectBeziers |
| 1656 |
4 copy LoadIntersectionPoints 5 1 roll |
| 1657 |
} ifelse |
| 1658 |
} ifelse |
| 1659 |
/\PIT@name{#1} /\PIT@name{#2} /\PIT@@name |
| 1660 |
\ifPIT@addintersections true \else false \fi |
| 1661 |
SaveIntersection |
| 1662 |
}% |
| 1663 |
\ifPIT@saveintersections |
| 1664 |
\pst@Verb{% |
| 1665 |
\pst@intersectdict |
| 1666 |
\PIT@@name\space /Points get |
| 1667 |
ArrayToPointArray |
| 1668 |
end |
| 1669 |
dup length 1 1 3 -1 roll { |
| 1670 |
2 copy 1 sub get |
| 1671 |
\ifPst@saveNodeCoors |
| 1672 |
\pst@intersectdict |
| 1673 |
2 copy aload pop \tx@UserCoor 3 -1 roll |
| 1674 |
20 string cvs (N-\PIT@key@name) exch strcat dup |
| 1675 |
(.y) strcat cvn exch (.x) strcat cvn |
| 1676 |
end |
| 1677 |
4 -1 roll def exch def |
| 1678 |
\fi |
| 1679 |
cvx |
| 1680 |
false 3 -1 roll (N@\PIT@key@name) exch 20 string cvs |
| 1681 |
\pst@intersectdict strcat end cvn |
| 1682 |
tx@NodeDict begin |
| 1683 |
10 {InitPnode} /NodeScale {} def NewNode |
| 1684 |
end |
| 1685 |
} for |
| 1686 |
pop |
| 1687 |
}% |
| 1688 |
\fi |
| 1689 |
\ifshowpoints |
| 1690 |
\addto@pscode{% |
| 1691 |
\pst@intersectdict |
| 1692 |
[ \PIT@@name\space /Points get aload pop |
| 1693 |
end |
| 1694 |
}% |
| 1695 |
\psdots@ii |
| 1696 |
\else |
| 1697 |
\end@SpecialObj |
| 1698 |
\fi |
| 1699 |
}% |
| 1700 |
% \end{macrocode} |
| 1701 |
% \end{macro} |
| 1702 |
% |
| 1703 |
% \begin{macro}{\psGetIsectCenter} |
| 1704 |
% \begin{macrocode} |
| 1705 |
\def\psGetIsectCenter#1#2#3{% |
| 1706 |
\pst@intersectdict |
| 1707 |
\ifx\\#2\\% |
| 1708 |
\PIT@name{#1} /Points get dup #3 1 sub 2 mul get exch #3 2 mul 1 sub get |
| 1709 |
\else |
| 1710 |
\PIT@name{#1} /\PIT@name{#2@t} get #3 1 sub get |
| 1711 |
\PIT@name{#1} /\PIT@name{#2} get |
| 1712 |
dup IsPath { |
| 1713 |
PreparePath dup length 1 sub |
| 1714 |
3 -1 roll dup dup |
| 1715 |
cvi sub 4 1 roll |
| 1716 |
cvi sub get |
| 1717 |
} if |
| 1718 |
PointArrayToArray |
| 1719 |
tx@FuncDict begin 2 dict begin |
| 1720 |
dup length 2 idiv 1 sub /BezierType exch def /Points exch def GetBezierCoor |
| 1721 |
end end |
| 1722 |
\fi |
| 1723 |
end |
| 1724 |
\tx@UserCoor /I-#1#3.y exch def /I-#1#3.x exch def |
| 1725 |
}% |
| 1726 |
% \end{macrocode} |
| 1727 |
% \end{macro} |
| 1728 |
% |
| 1729 |
% \begin{macro}{\psGetCurvePoint} |
| 1730 |
% \begin{macrocode} |
| 1731 |
\def\psGetCurvePoint#1#2{% |
| 1732 |
\pst@intersectdict |
| 1733 |
currentdict /\PIT@name{#1} known not { |
| 1734 |
(You haven't defined the curve or path '#1') == |
| 1735 |
} if |
| 1736 |
#2 \PIT@name{#1} GetCurvePoint \tx@UserCoor |
| 1737 |
end |
| 1738 |
/I-#1.y exch def /I-#1.x exch def |
| 1739 |
}% |
| 1740 |
% \end{macrocode} |
| 1741 |
% \end{macro} |
| 1742 |
% \begin{macrocode} |
| 1743 |
\catcode`\@=\PstAtCode\relax |
| 1744 |
% \end{macrocode} |
| 1745 |
%</texfile> |
| 1746 |
% |
| 1747 |
% \chapter{The Postscript header file} |
| 1748 |
% \makeatletter |
| 1749 |
%^^A Copied this definition from doc.sty and changed it not to add a |
| 1750 |
%^^A backslash to the Postscript procedure name in the index. |
| 1751 |
% \def\SpecialIndex@#1#2{% |
| 1752 |
% \@SpecialIndexHelper@#1\@nil |
| 1753 |
% \def\@tempb{ }% |
| 1754 |
% \ifcat \@tempb\@gtempa |
| 1755 |
% \special@index{\quotechar\space\actualchar |
| 1756 |
% \string\verb\quotechar*\verbatimchar |
| 1757 |
% \quotechar\space\verbatimchar#2}% |
| 1758 |
% \else |
| 1759 |
% \def\@tempb##1##2\relax{\ifx\relax##2\relax |
| 1760 |
% \def\@tempc{\special@index{\quotechar##1\actualchar |
| 1761 |
% \string\verb\quotechar*\verbatimchar |
| 1762 |
% \quotechar##1\verbatimchar#2}}% |
| 1763 |
% \else |
| 1764 |
% \def\@tempc{\special@index{##1##2\actualchar |
| 1765 |
% \string\verb\quotechar*\verbatimchar##1##2\verbatimchar#2}}% |
| 1766 |
% \fi}% |
| 1767 |
% \expandafter\@tempb\@gtempa\relax |
| 1768 |
% \@tempc |
| 1769 |
% \fi} |
| 1770 |
% \makeatother |
| 1771 |
% |
| 1772 |
%<*prolog> |
| 1773 |
% \begin{macrocode} |
| 1774 |
/tx@IntersectDict 200 dict def |
| 1775 |
tx@IntersectDict begin |
| 1776 |
% \end{macrocode} |
| 1777 |
% These are some helper procedures for vector operations. |
| 1778 |
% |
| 1779 |
% \begin{macro}{VecAdd} |
| 1780 |
% Addition of two vectors. |
| 1781 |
% \begin{pssyntax} |
| 1782 |
% \PSvar{Xa Ya Xb Yb} \PSop{VecAdd} \PSvar{Xa+Xb Ya+Yb} |
| 1783 |
% \end{pssyntax} |
| 1784 |
% \begin{macrocode} |
| 1785 |
/VecAdd { |
| 1786 |
3 -1 roll add 3 1 roll add exch |
| 1787 |
} bind def |
| 1788 |
% \end{macrocode} |
| 1789 |
% \end{macro} |
| 1790 |
% |
| 1791 |
% \begin{macro}{VecSub} |
| 1792 |
% Subtraction of two vectors. |
| 1793 |
% \begin{pssyntax} |
| 1794 |
% \PSvar{Xa Ya Xb Yb} \PSop{VecSub} \PSvar{Xa-Xb Ya-Yb} |
| 1795 |
% \end{pssyntax} |
| 1796 |
% \begin{macrocode} |
| 1797 |
/VecSub { |
| 1798 |
neg 3 -1 roll add 3 1 roll neg add exch |
| 1799 |
} bind def |
| 1800 |
% \end{macrocode} |
| 1801 |
% \end{macro} |
| 1802 |
% |
| 1803 |
% \begin{macro}{VecScale} |
| 1804 |
% Scale a vector by a factor \PSvar{fac}. |
| 1805 |
% \begin{pssyntax} |
| 1806 |
% \PSvar{Xa Ya fac} \PSop{VecScale} \PSvar{fac}$\cdot$\PSvar{Xa} \PSvar{fac}$\cdot$\PSvar{Ya} |
| 1807 |
% \end{pssyntax} |
| 1808 |
% \begin{macrocode} |
| 1809 |
/VecScale { |
| 1810 |
dup 4 -1 roll mul 3 1 roll mul |
| 1811 |
} bind def |
| 1812 |
% \end{macrocode} |
| 1813 |
% \end{macro} |
| 1814 |
% |
| 1815 |
% \begin{macro}{ToPnt} |
| 1816 |
% Convert two numbers to a procedure holding the two values. This |
| 1817 |
% representation is used to save coordinate values of nodes and vectors. |
| 1818 |
% \begin{pssyntax} |
| 1819 |
% \PSvar{X Y} \PSop{ToPnt} \PSarray{X Y} |
| 1820 |
% \end{pssyntax} |
| 1821 |
% \begin{macrocode} |
| 1822 |
/ToPnt { |
| 1823 |
[ 3 1 roll ] |
| 1824 |
} bind def |
| 1825 |
% \end{macrocode} |
| 1826 |
% \end{macro} |
| 1827 |
% |
| 1828 |
% \PSvar{MaxPrecision} gives the precision of the curve parameter t for the |
| 1829 |
% intersection. This shouldn't be lower than $10^{-6}$, because |
| 1830 |
% PostScript uses single precision. |
| 1831 |
% \begin{macrocode} |
| 1832 |
/MaxPrecision 1e-6 def |
| 1833 |
% \end{macrocode} |
| 1834 |
% |
| 1835 |
% \PSvar{Epsilon} gives the allowed relative error of the intersection point. |
| 1836 |
% \begin{macrocode} |
| 1837 |
/Epsilon 1e-4 def |
| 1838 |
% \end{macrocode} |
| 1839 |
% |
| 1840 |
% The threshold for curve subdivision, see below. |
| 1841 |
% \begin{macrocode} |
| 1842 |
/MinClippedSizeThreshold 0.8 def |
| 1843 |
% \end{macrocode} |
| 1844 |
% |
| 1845 |
% The predefined intervals for the subdivision of the curves. |
| 1846 |
% \begin{macrocode} |
| 1847 |
/H1Interval [0 0.5] def |
| 1848 |
/H2Interval [0.5 MaxPrecision add 1] def |
| 1849 |
% \end{macrocode} |
| 1850 |
% |
| 1851 |
% \begin{macro}{IntersectBeziers} |
| 1852 |
% The main procedure, which computes the intersection of two bezier |
| 1853 |
% curves of arbitrary order. This, and most of the following |
| 1854 |
% procedures operate on curves, which are stored as arrays of points, |
| 1855 |
% the points are also arrays with two elements -- \PSvar{X} and |
| 1856 |
% \PSvar{Y}. A Bezier curve of $n$-th order is then givesn by |
| 1857 |
% \PSarray{\PSarray{X0 Y0} \PSarray{X1 Y1} \ldots \PSarray{XN YN}}. |
| 1858 |
% |
| 1859 |
% \begin{pssyntax} |
| 1860 |
% \PSarray{curveA} \PSarray{curveB} \PSop{IntersectBeziers} |
| 1861 |
% \PSarray{curveA} \PSarray{tA} \PSarray{curveB} \PSarray{tB} |
| 1862 |
% \end{pssyntax} |
| 1863 |
% \begin{macrocode} |
| 1864 |
/IntersectBeziers { |
| 1865 |
2 copy length 2 eq exch length 2 eq and { |
| 1866 |
IntersectLineSegms |
| 1867 |
}{ |
| 1868 |
2 copy [0 1] [0 1] IterateIntersection |
| 1869 |
} ifelse |
| 1870 |
3 -1 roll exch |
| 1871 |
} bind def |
| 1872 |
% \end{macrocode} |
| 1873 |
% \end{macro} |
| 1874 |
% |
| 1875 |
% \begin{macro}{IntersectLines} |
| 1876 |
% Intersect two lines. |
| 1877 |
% \begin{pssyntax} |
| 1878 |
% \PSarray{lineA} \PSarray{lineB} \PSop{IntersectLines} |
| 1879 |
% \PSarray{lineA} \PSarray{lineB} \PSarray{tA} \PSarray{tB} |
| 1880 |
% \end{pssyntax} |
| 1881 |
% \begin{macrocode} |
| 1882 |
/IntersectLines { |
| 1883 |
(IntersectLines) DebugBegin |
| 1884 |
2 copy |
| 1885 |
exch { aload pop } forall 5 -1 roll { aload pop } forall |
| 1886 |
8 -2 roll 2 copy 10 4 roll 4 2 roll 2 copy 6 2 roll 10 2 roll |
| 1887 |
VecSub |
| 1888 |
6 2 roll 4 2 roll VecSub |
| 1889 |
8 4 roll 4 2 roll VecSub |
| 1890 |
% \end{macrocode} |
| 1891 |
% X3-X4 Y3-Y4 X2-X1 Y2-Y1 X3-X1 Y3-Y1 % b1 b2 a1 a2 c1 c2 |
| 1892 |
% \begin{macrocode} |
| 1893 |
6 copy 12 -4 roll |
| 1894 |
neg 4 -1 roll mul 3 1 roll mul add |
| 1895 |
dup 0 eq { |
| 1896 |
% \end{macrocode} |
| 1897 |
% no intersections |
| 1898 |
% \begin{macrocode} |
| 1899 |
9 { pop } repeat [] [] |
| 1900 |
} { |
| 1901 |
dup 10 1 roll 5 1 roll |
| 1902 |
4 -1 roll mul 3 1 roll mul sub exch div |
| 1903 |
6 1 roll 4 -1 roll mul 3 1 roll mul sub exch div |
| 1904 |
[ exch ] exch [ exch ] |
| 1905 |
} ifelse |
| 1906 |
DebugEnd |
| 1907 |
} bind def |
| 1908 |
% \end{macrocode} |
| 1909 |
% \end{macro} |
| 1910 |
% |
| 1911 |
% \begin{macro}{IntersectLineSegms} |
| 1912 |
% Intersect two line segments. This uses the output of |
| 1913 |
% \PSop{IntersectLines} and checks if both line parameters are in the |
| 1914 |
% range [0,1]. |
| 1915 |
% \begin{pssyntax} |
| 1916 |
% \PSarray{lineA} \PSarray{lineB} \PSop{IntersectLineSegms} |
| 1917 |
% \PSarray{lineA} \PSarray{lineB} \PSarray{tA} \PSarray{tB} |
| 1918 |
% \end{pssyntax} |
| 1919 |
% \begin{macrocode} |
| 1920 |
/IntersectLineSegms { |
| 1921 |
IntersectLines |
| 1922 |
dup length 0 eq not { |
| 1923 |
% \end{macrocode} |
| 1924 |
% IntersectLines has found an intersection |
| 1925 |
% \begin{macrocode} |
| 1926 |
0 get exch 0 get |
| 1927 |
2 copy 2 copy 0 ge exch 0 ge and 3 1 roll 1 le exch 1 le and and { |
| 1928 |
[ exch ] exch [ exch ] |
| 1929 |
} { |
| 1930 |
pop pop [] [] |
| 1931 |
} ifelse |
| 1932 |
} if |
| 1933 |
} bind def |
| 1934 |
% \end{macrocode} |
| 1935 |
% \end{macro} |
| 1936 |
% \begin{macro}{IntersectLineSegmLine} |
| 1937 |
% Intersect a line segment with a line. This uses |
| 1938 |
% \PSop{IntersectLines} and checks if the line parameter of the line |
| 1939 |
% segment is in the range [0,1]. |
| 1940 |
% \begin{pssyntax} |
| 1941 |
% \PSarray{lineA} \PSarray{lineSegmB} \PSop{IntersectLineLineSegm} |
| 1942 |
% \PSarray{lineA} \PSarray{tA} \PSarray{lineSegmB} \PSarray{tB} |
| 1943 |
% \end{pssyntax} |
| 1944 |
% \begin{macrocode} |
| 1945 |
/IntersectLineLineSegm { |
| 1946 |
tx@IntersectDict begin IntersectLines end |
| 1947 |
dup length 0 eq not { |
| 1948 |
% \end{macrocode} |
| 1949 |
% IntersectLines has found an intersection |
| 1950 |
% \begin{macrocode} |
| 1951 |
0 get dup dup 0 ge exch 1 le and { |
| 1952 |
[ exch ] |
| 1953 |
} { |
| 1954 |
pop pop [] [] |
| 1955 |
} ifelse |
| 1956 |
} if |
| 1957 |
3 -1 roll exch |
| 1958 |
} bind def |
| 1959 |
% \end{macrocode} |
| 1960 |
% \end{macro} |
| 1961 |
% |
| 1962 |
% \begin{macro}{IntersectLinePath} |
| 1963 |
% Compute the first intersection of a line with a path. If an intersection was |
| 1964 |
% found, also the respective path segment remains on the stack for |
| 1965 |
% later computations. |
| 1966 |
% \begin{pssyntax} |
| 1967 |
% \PSarray{lineA} \PSarray{pathB} \PSop{IntersectLinePath} |
| 1968 |
% \PSarray{segment} \PSvar{t} \PSarray{intersection} |
| 1969 |
% \end{pssyntax} |
| 1970 |
% \begin{macrocode} |
| 1971 |
/IntersectLinePath { |
| 1972 |
(IntersectLinePath) DebugBegin |
| 1973 |
3 dict begin |
| 1974 |
PreparePath |
| 1975 |
% \end{macrocode} |
| 1976 |
% First elongate lineA such, that it could intersect with any segment in pathB |
| 1977 |
% \begin{macrocode} |
| 1978 |
2 copy ElongateLine exch 3 -1 roll pop |
| 1979 |
/isect [] def |
| 1980 |
/t -1 def |
| 1981 |
/n -1 def |
| 1982 |
{ |
| 1983 |
/n n 1 add def |
| 1984 |
2 copy IntersectBeziers |
| 1985 |
dup 5 1 roll LoadIntersectionPoints |
| 1986 |
dup length 0 gt { |
| 1987 |
% \end{macrocode} |
| 1988 |
% one intersection found, clean up and exit |
| 1989 |
% \begin{macrocode} |
| 1990 |
/isect exch def |
| 1991 |
0 get aload pop add 0.5 mul n add /t exch def |
| 1992 |
exch pop |
| 1993 |
exit |
| 1994 |
} { |
| 1995 |
pop pop pop |
| 1996 |
} ifelse |
| 1997 |
} forall |
| 1998 |
t isect |
| 1999 |
end |
| 2000 |
DebugEnd |
| 2001 |
} bind def |
| 2002 |
% \end{macrocode} |
| 2003 |
% \end{macro} |
| 2004 |
% |
| 2005 |
% \begin{macro}{ElongateLine} |
| 2006 |
% Elongate \PSarray{line} to potentially intersect with every segment |
| 2007 |
% in \PSarray{path}. |
| 2008 |
% \begin{pssyntax} |
| 2009 |
% \PSarray{lineA} \PSarray{path} \PSop{ElongateLine} \PSarray{lineA'} |
| 2010 |
% \end{pssyntax} |
| 2011 |
% \begin{macrocode} |
| 2012 |
/ElongateLine { |
| 2013 |
exch { aload pop } forall |
| 2014 |
4 2 roll 2 copy 6 2 roll |
| 2015 |
VecSub 0 5 1 roll |
| 2016 |
6 -1 roll { |
| 2017 |
% \end{macrocode} |
| 2018 |
% 0 x0 y0 dx dy [segm\_i] |
| 2019 |
% \begin{macrocode} |
| 2020 |
{ |
| 2021 |
aload pop |
| 2022 |
% \end{macrocode} |
| 2023 |
% max x0 y0 dx dy P\_ij.x P\_ij.y |
| 2024 |
% \begin{macrocode} |
| 2025 |
6 2 roll 4 copy 10 4 roll |
| 2026 |
6 2 roll VecSub 4 2 roll |
| 2027 |
tx@EcldDict begin Project end |
| 2028 |
tx@Dict begin Pyth end |
| 2029 |
6 -1 roll 2 copy |
| 2030 |
gt { pop } { exch pop } ifelse |
| 2031 |
5 1 roll |
| 2032 |
} forall |
| 2033 |
} forall |
| 2034 |
% \end{macrocode} |
| 2035 |
% dmax x0 y0 dx dy |
| 2036 |
% \begin{macrocode} |
| 2037 |
% for a line |
| 2038 |
5 -1 roll VecScale 4 copy VecSub ToPnt 5 1 roll VecAdd ToPnt ToPnt |
| 2039 |
% for a ray |
| 2040 |
%4 2 roll 2 copy ToPnt 6 1 roll 4 2 roll 5 -1 roll 1.1 mul VecScale VecAdd ToPnt ToPnt |
| 2041 |
} bind def |
| 2042 |
% \end{macrocode} |
| 2043 |
% \end{macro} |
| 2044 |
% |
| 2045 |
% \begin{macro}{IntersectPaths} |
| 2046 |
% \begin{pssyntax} |
| 2047 |
% \PSarray{pathA} \PSarray{pathB} \PSop{IntersectPaths} |
| 2048 |
% \PSarray{intersections} \PSarray{pathA} \PSarray{tA} \PSarray{pathB} \PSarray{tB} |
| 2049 |
% \end{pssyntax} |
| 2050 |
% \begin{macrocode} |
| 2051 |
/IntersectPaths { |
| 2052 |
(IntersectPaths) DebugBegin |
| 2053 |
6 dict begin |
| 2054 |
2 copy exch PreparePath dup length /nA exch def |
| 2055 |
exch PreparePath dup length /nB exch def |
| 2056 |
/isect [] def |
| 2057 |
/tA [] def /tB [] def |
| 2058 |
{ % [pathA] [Bi] |
| 2059 |
/nB nB 1 sub def |
| 2060 |
exch dup 3 1 roll % [pathA] [Bi] [pathA] |
| 2061 |
{ |
| 2062 |
/nA nA 1 sub def |
| 2063 |
exch dup 3 1 roll % [pathA] [Bi] [Aj] [Bi] |
| 2064 |
IntersectBeziers % [curveA] [tA] [curveB] [tB] |
| 2065 |
4 copy LoadIntersectionPoints |
| 2066 |
[ exch isect aload pop ] /isect exch def |
| 2067 |
exch pop 3 -1 roll pop |
| 2068 |
[ tB aload length 2 add -1 roll TArray { nB add } forall ] /tB exch def |
| 2069 |
[ tA aload length 2 add -1 roll TArray { nA add } forall ] /tA exch def |
| 2070 |
} forall |
| 2071 |
pop % remove [Bi] |
| 2072 |
dup length /nA exch def |
| 2073 |
} forall |
| 2074 |
pop % remove [pathA] |
| 2075 |
[ isect { aload pop } forall ] 3 1 roll tA exch tB |
| 2076 |
end |
| 2077 |
DebugEnd |
| 2078 |
} bind def |
| 2079 |
% \end{macrocode} |
| 2080 |
% \end{macro} |
| 2081 |
% |
| 2082 |
% \begin{macro}{IntersectCurvePath} |
| 2083 |
% \begin{pssyntax} |
| 2084 |
% \PSarray{curveA} \PSarray{pathB} \PSop{IntersectCurvePath} |
| 2085 |
% \PSarray{intersections} \PSarray{curveA} \PSarray{tA} \PSarray{pathB} \PSarray{tB} |
| 2086 |
% \end{pssyntax} |
| 2087 |
% \begin{macrocode} |
| 2088 |
/IntersectCurvePath { |
| 2089 |
(IntersectCurvePath) DebugBegin |
| 2090 |
6 dict begin |
| 2091 |
2 copy PreparePath dup length /n exch def |
| 2092 |
/isect [] def |
| 2093 |
/tA [] def /tB [] def |
| 2094 |
{ |
| 2095 |
/n n 1 sub def |
| 2096 |
exch dup 3 -1 roll |
| 2097 |
IntersectBeziers |
| 2098 |
4 copy LoadIntersectionPoints |
| 2099 |
[ exch isect aload pop ] /isect exch def |
| 2100 |
pop 3 -1 roll pop |
| 2101 |
[ tB aload length 2 add -1 roll TArray { n add } forall ] /tB exch def |
| 2102 |
[ tA aload length 2 add -1 roll TArray aload pop ] /tA exch def |
| 2103 |
} forall |
| 2104 |
pop |
| 2105 |
[ isect { aload pop } forall ] 3 1 roll tA exch tB |
| 2106 |
end |
| 2107 |
DebugEnd |
| 2108 |
} bind def |
| 2109 |
/IntersectPathCurve { |
| 2110 |
exch IntersectCurvePath 4 2 roll |
| 2111 |
} bind def |
| 2112 |
% \end{macrocode} |
| 2113 |
% \end{macro} |
| 2114 |
% |
| 2115 |
% \begin{macro}{MergeAndSort} |
| 2116 |
% Merge and sort two arrays. That may be point arrays or simple |
| 2117 |
% arrays. Both arrays must be of the same type, but that is not |
| 2118 |
% checked. |
| 2119 |
% \begin{macrocode} |
| 2120 |
/MergeAndSortArrays { |
| 2121 |
[ 3 1 roll aload pop counttomark -1 roll aload pop ] |
| 2122 |
dup length 0 gt { |
| 2123 |
dup dup 0 get type /arraytype eq { |
| 2124 |
hulldict /comp get |
| 2125 |
} { |
| 2126 |
/lt |
| 2127 |
} ifelse |
| 2128 |
exch quicksort |
| 2129 |
} if |
| 2130 |
} bind def |
| 2131 |
% \end{macrocode} |
| 2132 |
% \end{macro} |
| 2133 |
% |
| 2134 |
% \begin{macro}{SaveIntersection} |
| 2135 |
% \begin{pssyntax} |
| 2136 |
% \PSarray{intersectionpoints} \PSarray{A} \PSarray{tA} \PSarray{B} \PSarray{tB} |
| 2137 |
% \PSname{nameA} \PSname{nameB} \PSname{isectname} \PSvar{add?} |
| 2138 |
% \PSop{SaveIntersection} |
| 2139 |
% \end{pssyntax} |
| 2140 |
% \begin{macrocode} |
| 2141 |
/SaveIntersection { |
| 2142 |
(SaveIntersection) DebugBegin |
| 2143 |
exch dup 3 1 roll % isectname add? isectname |
| 2144 |
currentdict exch known and { |
| 2145 |
% \end{macrocode} |
| 2146 |
% Want to add the new intersections to an existing intersection. Merge |
| 2147 |
% the new arrays with the existing ones and resort the \PSvar{Points} |
| 2148 |
% and \PSvar{\ldots @t} arrays. |
| 2149 |
% \begin{macrocode} |
| 2150 |
load begin % pnts A tA B tB /A /B |
| 2151 |
dup currentdict exch known { % /nameB already saved. |
| 2152 |
4 -1 roll pop % pnts A tA tB /A /B |
| 2153 |
nametostr (@t) strcat cvn dup load 4 -1 roll |
| 2154 |
MergeAndSortArrays def |
| 2155 |
} { |
| 2156 |
dup 5 -1 roll def % pnts A tA B tB /A /B |
| 2157 |
nametostr (@t) strcat cvn 3 -1 roll TArray def |
| 2158 |
} ifelse % pnts A tA /A |
| 2159 |
dup currentdict exch known { % /nameB already saved. |
| 2160 |
3 -1 roll pop |
| 2161 |
nametostr (@t) strcat cvn dup load 3 -1 roll |
| 2162 |
MergeAndSortArrays def |
| 2163 |
} { |
| 2164 |
dup 4 -1 roll def |
| 2165 |
nametostr (@t) strcat cvn exch TArray def |
| 2166 |
} ifelse |
| 2167 |
/Points exch ArrayToPointArray Points ArrayToPointArray |
| 2168 |
MergeAndSortArrays PointArrayToArray def |
| 2169 |
end |
| 2170 |
} { |
| 2171 |
4 dict dup 3 1 roll def |
| 2172 |
begin |
| 2173 |
dup 5 -1 roll def |
| 2174 |
nametostr (@t) strcat cvn 3 -1 roll TArray def |
| 2175 |
dup 4 -1 roll def |
| 2176 |
nametostr (@t) strcat cvn exch TArray def |
| 2177 |
/Points exch def |
| 2178 |
end |
| 2179 |
} ifelse |
| 2180 |
DebugEnd |
| 2181 |
} bind def |
| 2182 |
% \end{macrocode} |
| 2183 |
% \end{macro} |
| 2184 |
% |
| 2185 |
% \begin{macro}{TArray} |
| 2186 |
% The curve parameters \PSvar{t} as determined by |
| 2187 |
% \PSvar{IntersectBeziers} are given in a special array |
| 2188 |
% construct. \PSvar{TArray} creates a simple array with the |
| 2189 |
% \PSvar{t}-values given in ascending order. |
| 2190 |
% |
| 2191 |
% \begin{pssyntax} |
| 2192 |
% \PSarray{\PSarray{t0a t0b} \ldots \PSvar{null}\ldots \PSvar{integer}} |
| 2193 |
% \PSop{TArray} \PSarray{t0 t1 \ldots tN} |
| 2194 |
% \end{pssyntax} |
| 2195 |
% \begin{macrocode} |
| 2196 |
/TArray { |
| 2197 |
dup length 0 gt { |
| 2198 |
dup 0 get type /arraytype eq { |
| 2199 |
[ exch |
| 2200 |
{ %dup type /nulltype eq { pop exit } if |
| 2201 |
aload pop add 0.5 mul |
| 2202 |
} forall ] |
| 2203 |
} if |
| 2204 |
dup /lt exch quicksort |
| 2205 |
} if |
| 2206 |
} bind def |
| 2207 |
% \end{macrocode} |
| 2208 |
% \end{macro} |
| 2209 |
% |
| 2210 |
% We can save arbitrary paths using \PSvar{pathforall}. The saved path |
| 2211 |
% contains the commands \PSname{movetype}, \PSname{linetype} and |
| 2212 |
% \PSname{curvetype}. By default, these are defined as the respective |
| 2213 |
% original procedures. |
| 2214 |
% \begin{macrocode} |
| 2215 |
/InitTracing { |
| 2216 |
/movetype /moveto load def |
| 2217 |
/linetype /lineto load def |
| 2218 |
/curvetype /curveto load def |
| 2219 |
} bind def |
| 2220 |
%^^AInitTracing |
| 2221 |
/GetFullPath { |
| 2222 |
(GetFullPath) DebugBegin |
| 2223 |
{ /movetype counttomark 3 roll } |
| 2224 |
{ /linetype counttomark 3 roll } |
| 2225 |
{ /curvetype counttomark 7 roll }{} pathforall |
| 2226 |
DebugEnd |
| 2227 |
} bind def |
| 2228 |
% \end{macrocode} |
| 2229 |
% |
| 2230 |
% \begin{macro}{ReversePath} |
| 2231 |
% \begin{macrocode} |
| 2232 |
/ReversePath { |
| 2233 |
gsave newpath |
| 2234 |
[ exch aload pop InitTracing |
| 2235 |
{ counttomark 0 eq { exit } if |
| 2236 |
load exec |
| 2237 |
} loop |
| 2238 |
reversepath |
| 2239 |
GetFullPath ] |
| 2240 |
grestore |
| 2241 |
} bind def |
| 2242 |
% \end{macrocode} |
| 2243 |
% \end{macro} |
| 2244 |
% |
| 2245 |
% \begin{macro}{ReverseCurve} |
| 2246 |
% Reverse direction of a bezier curve. |
| 2247 |
% \begin{pssyntax} |
| 2248 |
% \PSarray{\PSarray{X0 Y0} \ldots \PSarray{XN YN}} |
| 2249 |
% \PSop{ReverseCurve} \PSarray{\PSarray{XN YN} \ldots \PSarray{X0 Y0}} |
| 2250 |
% \end{pssyntax} |
| 2251 |
% \begin{macrocode} |
| 2252 |
/ReverseCurve { |
| 2253 |
PointArrayToArray aload pop % [ tstart tstop [ X0 Y0 X1 Y1... |
| 2254 |
counttomark -2 4 { 2 roll } for ] ArrayToPointArray |
| 2255 |
} bind def |
| 2256 |
% \end{macrocode} |
| 2257 |
% \end{macro} |
| 2258 |
% |
| 2259 |
% \begin{macro}{ReverseInterval} |
| 2260 |
% \begin{pssyntax} |
| 2261 |
% \PSarray{path} \PSvar{tstart} \PSvar{tstop} \PSop{ReverseInterval} |
| 2262 |
% \PSarray{path} \PSvar{L-tstop} \PSvar{L-tstart} |
| 2263 |
% \end{pssyntax} |
| 2264 |
% \begin{macrocode} |
| 2265 |
/ReverseInterval { |
| 2266 |
3 -1 roll dup 4 1 roll GetSegmentCount |
| 2267 |
dup 4 1 roll exch sub 3 1 roll sub exch |
| 2268 |
} bind def |
| 2269 |
% \end{macrocode} |
| 2270 |
% \end{macro} |
| 2271 |
% |
| 2272 |
% \begin{macro}{UnifyInterval} |
| 2273 |
% Unifies the interval \PSarray{tstart tstop}. If \PSvar{tstart} is |
| 2274 |
% negative, 0 is used. If \PSvar{tstop} is negative, the curve length |
| 2275 |
% is used. A too large \PSvar{tstop} is also truncated to the curve |
| 2276 |
% length. |
| 2277 |
% \begin{pssyntax} |
| 2278 |
% \PSarray{curve} \PSvar{tstart tstop} \PSop{UnifyInterval} |
| 2279 |
% \PSarray{curve} \PSvar{tstart' tstop} |
| 2280 |
% \end{pssyntax} |
| 2281 |
% \begin{macrocode} |
| 2282 |
/UnifyInterval { |
| 2283 |
exch dup 0 lt { pop 0 } if exch |
| 2284 |
3 -1 roll dup 4 1 roll GetSegmentCount |
| 2285 |
2 copy exch dup 3 1 roll % [curve] tstart tstop cnt tstop cnt tstop |
| 2286 |
lt exch 0 lt or { exch } if pop % (tstop < 0 | cnt < tstop) |
| 2287 |
} bind def |
| 2288 |
% \end{macrocode} |
| 2289 |
% \end{macro} |
| 2290 |
% \begin{macro}{PreparePath} |
| 2291 |
% [ ... /movetype ... /linetype .../curvetype ] |
| 2292 |
% \begin{macrocode} |
| 2293 |
/PreparePath { |
| 2294 |
(PreparePath) DebugBegin |
| 2295 |
[ exch aload pop |
| 2296 |
{ |
| 2297 |
dup type /nametype eq not { exit } if |
| 2298 |
dup /movetype eq { |
| 2299 |
pop ToPnt /@mycp exch def |
| 2300 |
} { |
| 2301 |
dup /linetype eq { |
| 2302 |
pop [ @mycp 4 2 roll 2 copy ToPnt /@mycp exch def ToPnt ] |
| 2303 |
} { |
| 2304 |
pop [ @mycp 8 2 roll 2 copy ToPnt /@mycp exch def |
| 2305 |
ToPnt 5 1 roll ToPnt 4 1 roll ToPnt 3 1 roll ] |
| 2306 |
} ifelse |
| 2307 |
counttomark 1 roll |
| 2308 |
} ifelse |
| 2309 |
} loop ] |
| 2310 |
DebugEnd |
| 2311 |
} bind def |
| 2312 |
% \end{macrocode} |
| 2313 |
% \end{macro} |
| 2314 |
% |
| 2315 |
% \begin{macro}{GetSegmentCount} |
| 2316 |
% Count the number of path or bezier curve segments. Bezier curves |
| 2317 |
% always have the length 1, independent of their order. For paths, |
| 2318 |
% only the \PSname{linetype} and \PSname{curvetype} segments are |
| 2319 |
% counted. |
| 2320 |
% \begin{pssyntax} |
| 2321 |
% \PSarray{CurveOrPath} \PSop{GetSegmentCount} \PSvar{cnt} |
| 2322 |
% \end{pssyntax} |
| 2323 |
% |
| 2324 |
% \begin{macrocode} |
| 2325 |
/GetSegmentCount { |
| 2326 |
(GetSegmentCount) DebugBegin |
| 2327 |
dup IsPath { |
| 2328 |
[ exch aload pop 0 |
| 2329 |
{ |
| 2330 |
counttomark 1 eq { exit } if |
| 2331 |
exch |
| 2332 |
dup /movetype eq { |
| 2333 |
pop 3 1 roll pop pop |
| 2334 |
}{ |
| 2335 |
dup /linetype eq { |
| 2336 |
pop 1 add 3 1 roll pop pop |
| 2337 |
}{ |
| 2338 |
pop 1 add 7 1 roll 6 { pop } repeat |
| 2339 |
} ifelse |
| 2340 |
} ifelse |
| 2341 |
} loop |
| 2342 |
exch pop |
| 2343 |
} { |
| 2344 |
% a Bezier curve is a single segment |
| 2345 |
length 0 gt { 1 } { 0 } ifelse |
| 2346 |
} ifelse |
| 2347 |
DebugEnd |
| 2348 |
} bind def |
| 2349 |
% \end{macrocode} |
| 2350 |
% \end{macro} |
| 2351 |
% |
| 2352 |
% \begin{macro}{LoadLineIntersectionPoints} |
| 2353 |
% \begin{pssyntax} |
| 2354 |
% \PSarray{curve} \PSarray{t} \PSop{LoadLineIntersectionPoints} |
| 2355 |
% \PSarray{I0.x I0.y \ldots IN.x YN.x} |
| 2356 |
% \end{pssyntax} |
| 2357 |
% \begin{macrocode} |
| 2358 |
/LoadLineIntersectionPoints { |
| 2359 |
(LoadLineIntersectionPoints) DebugBegin |
| 2360 |
exch [ exch { aload pop } forall ] |
| 2361 |
tx@Dict begin tx@FuncDict begin 2 dict begin |
| 2362 |
dup length 2 idiv 1 sub /BezierType exch def /Points exch def |
| 2363 |
[ exch { GetBezierCoor } forall ] |
| 2364 |
end end end |
| 2365 |
DebugEnd |
| 2366 |
} bind def |
| 2367 |
% \end{macrocode} |
| 2368 |
% \end{macro} |
| 2369 |
% |
| 2370 |
% \begin{macro}{LoadCurveIntersectionPoints} |
| 2371 |
% Load the intersection points. This loads the same intersection point |
| 2372 |
% from both curves, and chooses the one with the lowest error. |
| 2373 |
% \begin{pssyntax} |
| 2374 |
% \PSarray{curveA} \PSarray{tA} \PSarray{curveB} \PSarray{tB} |
| 2375 |
% \PSop{LoadCurveIntersectionPoints} |
| 2376 |
% \PSarray{I0.x I0.y \ldots IN.x YN.x} |
| 2377 |
% \end{pssyntax} |
| 2378 |
% \begin{macrocode} |
| 2379 |
/LoadCurveIntersectionPoints { |
| 2380 |
(LoadCurveIntersectionPoints) DebugBegin |
| 2381 |
2 { |
| 2382 |
4 2 roll |
| 2383 |
[ exch { aload pop } forall ] |
| 2384 |
exch [ exch { aload pop } forall ] |
| 2385 |
} repeat |
| 2386 |
% \end{macrocode} |
| 2387 |
% [A0.x A0.y ... AM.x AM.y] [tA0a tA0b ... tAMa tAMb] [tB0a tB0b ... tBNa tBNb] [B0.x B0.y ... BN.x BN.y] |
| 2388 |
% \begin{macrocode} |
| 2389 |
tx@Dict begin tx@FuncDict begin 2 dict begin |
| 2390 |
dup length 2 idiv 1 sub /BezierType exch def /Points exch def |
| 2391 |
[ exch { GetBezierCoor } forall ] |
| 2392 |
3 1 roll |
| 2393 |
dup length 2 idiv 1 sub /BezierType exch def /Points exch def |
| 2394 |
[ exch { GetBezierCoor } forall ] |
| 2395 |
end |
| 2396 |
% \end{macrocode} |
| 2397 |
% [IB0.xa IB0.ya IB0.xb IB0.yb ... IBM.yb] [IA0.xa IA0.ya IA0.xb IA0.yb ... IAM.yb] |
| 2398 |
% \begin{macrocode} |
| 2399 |
2 { |
| 2400 |
[ exch aload length 4 idiv { |
| 2401 |
[ 5 1 roll ] counttomark 1 roll |
| 2402 |
} repeat ] |
| 2403 |
exch |
| 2404 |
} repeat |
| 2405 |
% \end{macrocode} |
| 2406 |
% [[IB0.xa ...] ... [... IBM.yb]] [[IA0.xa IA0.ya IA0.xb IA0.yb] ...[IAM.xa ... IAM.yb]] |
| 2407 |
% \begin{macrocode} |
| 2408 |
2 { |
| 2409 |
dup hulldict /comp get exch quicksort exch |
| 2410 |
} repeat |
| 2411 |
2 dict begin |
| 2412 |
/B exch def /A exch def |
| 2413 |
[ 0 1 A length 1 sub { |
| 2414 |
dup A exch get exch B exch get % [IAi] [IBi] |
| 2415 |
2 copy aload pop VecSub Pyth exch |
| 2416 |
aload pop VecSub Pyth lt { exch } if pop |
| 2417 |
aload pop VecAdd 0.5 VecScale |
| 2418 |
} for ] |
| 2419 |
end |
| 2420 |
end end |
| 2421 |
DebugEnd |
| 2422 |
} bind def |
| 2423 |
% \end{macrocode} |
| 2424 |
% \end{macro} |
| 2425 |
% |
| 2426 |
% \begin{macro}{LoadIntersectionPoints} |
| 2427 |
% \begin{macrocode} |
| 2428 |
/LoadIntersectionPoints { |
| 2429 |
(LoadIntersectionPoints) DebugBegin |
| 2430 |
4 copy pop exch pop length 2 eq exch length 2 eq and { |
| 2431 |
pop pop LoadLineIntersectionPoints |
| 2432 |
}{ |
| 2433 |
LoadCurveIntersectionPoints |
| 2434 |
} ifelse |
| 2435 |
DebugEnd |
| 2436 |
} bind def |
| 2437 |
% \end{macrocode} |
| 2438 |
% \end{macro} |
| 2439 |
% |
| 2440 |
% \begin{macro}{IterateIntersection} |
| 2441 |
% Iteration procedure to compute all intersections of CurveA and CurveB. |
| 2442 |
% This contains the |
| 2443 |
% |
| 2444 |
% \begin{pssyntax} |
| 2445 |
% \PSarray{CurveA} \PSarray{CurveB} \PSarray{intervalA} \PSarray{intervalB} |
| 2446 |
% \PSop{IterateIntersection} \PSarray{domsA} \PSarray{domsB} |
| 2447 |
% \end{pssyntax} |
| 2448 |
% \begin{macrocode} |
| 2449 |
/IterateIntersection { |
| 2450 |
(IterateIntersection) DebugBegin |
| 2451 |
12 dict begin |
| 2452 |
/precision MaxPrecision def |
| 2453 |
4 2 roll 2 copy 6 2 roll |
| 2454 |
dup IsPath not { PointArrayToArray } if |
| 2455 |
0 exch { dup type /nametype eq { pop }{ abs max} ifelse } forall |
| 2456 |
exch dup IsPath not { PointArrayToArray } if |
| 2457 |
{ dup type /nametype eq { pop }{ abs max} ifelse } forall |
| 2458 |
Epsilon mul /epsilon exch def |
| 2459 |
% \end{macrocode} |
| 2460 |
% in order to limit recursion |
| 2461 |
% \begin{macrocode} |
| 2462 |
/counter 0 def |
| 2463 |
/depth 0 def |
| 2464 |
/domsA [] def |
| 2465 |
/domsB [] def |
| 2466 |
/domsA /domsB 6 2 roll _IterateIntersection |
| 2467 |
domsB domsA |
| 2468 |
end |
| 2469 |
dup length 0 gt { |
| 2470 |
TArraysRemoveDup |
| 2471 |
} if |
| 2472 |
DebugEnd |
| 2473 |
} bind def |
| 2474 |
% \end{macrocode} |
| 2475 |
% \end{macro} |
| 2476 |
% |
| 2477 |
% \begin{macro}{TArraysRemoveDup} |
| 2478 |
% \begin{macrocode} |
| 2479 |
/TArraysRemoveDup { |
| 2480 |
4 dict begin |
| 2481 |
/tB exch def |
| 2482 |
/tA exch def |
| 2483 |
/j 0 def |
| 2484 |
[ tA 0 get tB 0 get |
| 2485 |
1 1 tA length 1 sub { |
| 2486 |
/i exch def |
| 2487 |
tA j get aload pop tA i get aload pop tx@Dict begin Pyth2 end MaxPrecision gt |
| 2488 |
tB j get aload pop tB i get aload pop tx@Dict begin Pyth2 end MaxPrecision gt and { |
| 2489 |
% keep the current parameter point |
| 2490 |
/j i def |
| 2491 |
tB i get tA i get |
| 2492 |
counttomark 2 idiv 1 add 1 roll |
| 2493 |
} if |
| 2494 |
} for |
| 2495 |
counttomark 2 idiv 1 add [ exch 1 roll ] % [ ... [tB] |
| 2496 |
counttomark 1 add 1 roll ] exch % [tA] [tB] |
| 2497 |
end |
| 2498 |
} bind def |
| 2499 |
% \end{macrocode} |
| 2500 |
% \end{macro} |
| 2501 |
% |
| 2502 |
% \begin{macro}{_IterateIntersection} |
| 2503 |
% This is the iteration part which is called recursively. |
| 2504 |
% |
| 2505 |
% \begin{pssyntax} |
| 2506 |
% \PSname{domsA} \PSname{domsB} \PSarray{CurveA} \PSarray{CurveB} |
| 2507 |
% \PSarray{domA} \PSarray{domB} \PSop{\_IterateIntersection} |
| 2508 |
% \end{pssyntax} |
| 2509 |
% \begin{macrocode} |
| 2510 |
/_IterateIntersection { |
| 2511 |
(_IterateIntersection) DebugBegin |
| 2512 |
CloneVec /domB exch def |
| 2513 |
CloneVec /domA exch def |
| 2514 |
CloneCurve /CurveB exch def |
| 2515 |
CloneCurve /CurveA exch def |
| 2516 |
/iter 0 def |
| 2517 |
/depth depth 1 add def |
| 2518 |
/dom null def |
| 2519 |
/counter counter 1 add def |
| 2520 |
CheckIT { |
| 2521 |
(>> curve subdivision performed: dom(A) = ) domA CurveToString strcat |
| 2522 |
(, dom(B) = ) strcat domB CurveToString strcat ( <<) strcat == |
| 2523 |
} if |
| 2524 |
CurveA IsConstant CurveB IsConstant and { |
| 2525 |
CurveA MiddlePoint ToPnt |
| 2526 |
CurveB MiddlePoint ToPnt AreNear { |
| 2527 |
domA domB 4 -1 roll exch PutInterval PutInterval |
| 2528 |
} { |
| 2529 |
pop pop |
| 2530 |
} ifelse |
| 2531 |
}{ |
| 2532 |
counter 100 lt { |
| 2533 |
% \end{macrocode} |
| 2534 |
% Use a loop to simulate some kind of return to exit at different positions. |
| 2535 |
% \begin{macrocode} |
| 2536 |
{ |
| 2537 |
/iter iter 1 add def |
| 2538 |
iter 100 lt |
| 2539 |
domA Extent precision ge |
| 2540 |
domB Extent precision ge or and not { |
| 2541 |
iter 100 ge { |
| 2542 |
false |
| 2543 |
} { |
| 2544 |
CurveA MiddlePoint ToPnt |
| 2545 |
CurveB MiddlePoint ToPnt AreNear { |
| 2546 |
domA domB true |
| 2547 |
}{ |
| 2548 |
false |
| 2549 |
} ifelse |
| 2550 |
} ifelse |
| 2551 |
exit |
| 2552 |
} if |
| 2553 |
% \end{macrocode} |
| 2554 |
% iter < 100 \&\& (dompA.extent() >= precision || dompB.extent() >= precision) |
| 2555 |
% \begin{macrocode} |
| 2556 |
CheckIT { |
| 2557 |
(counter: ) counter 20 string cvs strcat |
| 2558 |
(, iter: ) iter 20 string cvs strcat strcat |
| 2559 |
(, depth: ) depth 20 string cvs strcat strcat == |
| 2560 |
} if |
| 2561 |
CurveA CurveB ClipCurve /dom exch def |
| 2562 |
|
| 2563 |
CheckIT {(dom : ) dom CurveToString strcat == } if |
| 2564 |
dom IsEmptyInterval { |
| 2565 |
CheckIT { (empty interval, exit) == } if |
| 2566 |
false exit |
| 2567 |
} if |
| 2568 |
% \end{macrocode} |
| 2569 |
% dom[0] > dom[1], invalid. |
| 2570 |
% \begin{macrocode} |
| 2571 |
dom aload pop 2 copy min 3 1 roll max gt { |
| 2572 |
CheckIT { |
| 2573 |
(dom[0] > dom[1], invalid!) == |
| 2574 |
} if |
| 2575 |
false exit |
| 2576 |
} if |
| 2577 |
|
| 2578 |
domB dom MapTo /domB exch def |
| 2579 |
CurveB dom Portion |
| 2580 |
|
| 2581 |
CurveB IsConstant CurveA IsConstant and { |
| 2582 |
CheckIT { |
| 2583 |
(both curves are constant: ) == |
| 2584 |
(C1: [ ) CurveA { CurveToString ( ) strcat strcat } forall (]) strcat == |
| 2585 |
(C2: [ ) CurveB { CurveToString ( ) strcat strcat } forall (]) strcat == |
| 2586 |
} if |
| 2587 |
CurveA MiddlePoint ToPnt |
| 2588 |
CurveB MiddlePoint ToPnt AreNear { |
| 2589 |
domA domB true |
| 2590 |
} { |
| 2591 |
false |
| 2592 |
} ifelse |
| 2593 |
exit |
| 2594 |
} if |
| 2595 |
% \end{macrocode} |
| 2596 |
% If we have clipped less than 20%, we need to subdivide the |
| 2597 |
% curve with the largest domain into two sub-curves. |
| 2598 |
% \begin{macrocode} |
| 2599 |
dom Extent MinClippedSizeThreshold gt { |
| 2600 |
CheckIT { |
| 2601 |
(clipped less than 20% : ) == |
| 2602 |
(angle(A) = ) CurveA dup length 1 sub get aload pop |
| 2603 |
CurveA 0 get aload pop VecSub |
| 2604 |
exch 2 copy 0 eq exch 0 eq and { |
| 2605 |
pop pop (NaN) |
| 2606 |
} { |
| 2607 |
atan 20 string cvs |
| 2608 |
} ifelse strcat == |
| 2609 |
(angle(B) = ) CurveB dup length 1 sub get aload pop |
| 2610 |
CurveB 0 get aload pop VecSub |
| 2611 |
exch 2 copy 0 eq exch 0 eq and { |
| 2612 |
pop pop (NaN) |
| 2613 |
} { |
| 2614 |
atan 20 string cvs |
| 2615 |
} ifelse strcat == |
| 2616 |
(dom : ) == dom == (domB :) == domB == |
| 2617 |
} if |
| 2618 |
% \end{macrocode} |
| 2619 |
% Leave those five values on the stack to revert to the current state after the recursive calls. |
| 2620 |
% \begin{macrocode} |
| 2621 |
CurveA CurveB domA domB iter |
| 2622 |
7 -2 roll 2 copy 9 2 roll 2 copy |
| 2623 |
% \end{macrocode} |
| 2624 |
% On the stack: /domsA /domsB CurveA CurveB domA domB iter /domsA /domsB /domsA /domsB |
| 2625 |
% \begin{macrocode} |
| 2626 |
domA Extent domB Extent gt { |
| 2627 |
CurveA CloneCurve dup H1Interval Portion % pC1 |
| 2628 |
CurveA CloneCurve dup H2Interval Portion % pC2 |
| 2629 |
domA H1Interval MapTo % dompC1 |
| 2630 |
domA H2Interval MapTo % dompC2 |
| 2631 |
% \end{macrocode} |
| 2632 |
% Need on the stack: /domsA /domsB pC2 CurveB dompC2 domB /domsA /domsB pC1 CurveB dompC1 domB |
| 2633 |
% \begin{macrocode} |
| 2634 |
3 -1 roll exch % /domsA /domsB /domsA /domsB pC1 dompC1 pC2 dompC2 |
| 2635 |
CurveB exch domB 8 4 roll % /domsA /domsB pC2 CurveB dompC2 domB /domsA /domsB pC1 dompC1 |
| 2636 |
CurveB exch domB % /domsA /domsB pC2 CurveB dompC2 domB /domsA /domsB pC1 CurveB dompC1 domB |
| 2637 |
} { |
| 2638 |
CurveB CloneCurve dup H1Interval Portion % pC1 |
| 2639 |
CurveB CloneCurve dup H2Interval Portion % pC2 |
| 2640 |
domB H1Interval MapTo % dompC1 |
| 2641 |
domB H2Interval MapTo % dompC2 |
| 2642 |
% \end{macrocode} |
| 2643 |
% Need on the stack: /domsB /domsA pC2 CurveA dompC2 domA /domsB /domsA pC1 CurveA dompC1 domA |
| 2644 |
% \begin{macrocode} |
| 2645 |
8 -2 roll exch 8 2 roll 6 -2 roll exch 6 2 roll % /domsB /domsA /domsB /domsA pC1 pC2 dompC1 dompC2 |
| 2646 |
3 -1 roll exch % /domsB /domsA /domsB /domsA pC1 dompC1 pC2 dompC2 |
| 2647 |
CurveA exch domA 8 4 roll % /domsB /domsA pC2 CurveA dompC2 domA /domsB /domsA pC1 dompC1 |
| 2648 |
CurveA exch domA % /domsB /domsA pC2 CurveA dompC2 domA /domsB /domsA pC1 CurveA dompC1 domA |
| 2649 |
} ifelse |
| 2650 |
|
| 2651 |
_IterateIntersection |
| 2652 |
_IterateIntersection |
| 2653 |
% \end{macrocode} |
| 2654 |
% Restore the state before the recursive calls. |
| 2655 |
% \begin{macrocode} |
| 2656 |
/iter exch def |
| 2657 |
/domB exch def |
| 2658 |
/domA exch def |
| 2659 |
/CurveB exch def |
| 2660 |
/CurveA exch def |
| 2661 |
false exit |
| 2662 |
} if |
| 2663 |
CurveA CurveB /CurveA exch def /CurveB exch def |
| 2664 |
domA domB /domA exch def /domB exch def |
| 2665 |
% \end{macrocode} |
| 2666 |
% exchange /domsA and /domsB on the stack! |
| 2667 |
% \begin{macrocode} |
| 2668 |
exch |
| 2669 |
} loop |
| 2670 |
% \end{macrocode} |
| 2671 |
% boolean on stack |
| 2672 |
% \begin{macrocode} |
| 2673 |
{ |
| 2674 |
4 -1 roll exch PutInterval PutInterval |
| 2675 |
CheckIT { |
| 2676 |
(found an intersection ============================) == |
| 2677 |
} if |
| 2678 |
} { pop pop } ifelse |
| 2679 |
} { |
| 2680 |
pop pop |
| 2681 |
} ifelse |
| 2682 |
} ifelse |
| 2683 |
/depth depth 1 sub def |
| 2684 |
DebugEnd |
| 2685 |
} bind def |
| 2686 |
% \end{macrocode} |
| 2687 |
% \end{macro} |
| 2688 |
% |
| 2689 |
% \begin{macro}{PutInterval} |
| 2690 |
% Add a new interval \PSarray{newinterval} to the array stored in |
| 2691 |
% \PSname{/Intervals}. The new interval is "cloned" before storing it. |
| 2692 |
% \begin{pssyntax} |
| 2693 |
% \PSname{Intervals} \PSarray{newinterval} \PSop{PutInterval} |
| 2694 |
% \end{pssyntax} |
| 2695 |
% \begin{macrocode} |
| 2696 |
/PutInterval { |
| 2697 |
CloneVec [ exch 3 -1 roll dup 4 1 roll load aload pop ] def |
| 2698 |
} bind def |
| 2699 |
% \end{macrocode} |
| 2700 |
% \end{macro} |
| 2701 |
% |
| 2702 |
% \begin{macro}{IsEmptyInterval} |
| 2703 |
% Check if an interval is empty, which is represented by a [1 0] interval. |
| 2704 |
% \begin{pssyntax} |
| 2705 |
% \PSarray{interval} \PSop{IsEmptyInterval} \PSvar{boolean} |
| 2706 |
% \end{pssyntax} |
| 2707 |
% \begin{macrocode} |
| 2708 |
/IsEmptyInterval { |
| 2709 |
aload pop 0 eq exch 1 eq and |
| 2710 |
} bind def |
| 2711 |
% \end{macrocode} |
| 2712 |
% \end{macro} |
| 2713 |
% |
| 2714 |
% \begin{macro}{ToUnitInterval} |
| 2715 |
% Limit an interval \PSvar{a b} to the unit interval \PSarray{0 1}. |
| 2716 |
% \begin{pssyntax} |
| 2717 |
% \PSvar{a b} \PSop{ToUnitInterval} \PSarray{a|0 b|1} |
| 2718 |
% \end{pssyntax} |
| 2719 |
% \begin{macrocode} |
| 2720 |
/ToUnitInterval { |
| 2721 |
ToUnitRange exch ToUnitRange 2 copy gt { |
| 2722 |
exch |
| 2723 |
} if |
| 2724 |
ToPnt |
| 2725 |
} bind def |
| 2726 |
% \end{macrocode} |
| 2727 |
% \end{macro} |
| 2728 |
% \begin{macro}{ToUnitRange} |
| 2729 |
% Limit a number to the range \PSarray{0 1}. |
| 2730 |
% \begin{macrocode} |
| 2731 |
/ToUnitRange { |
| 2732 |
dup 0 lt { |
| 2733 |
pop 0 |
| 2734 |
}{ |
| 2735 |
dup 1 gt { |
| 2736 |
pop 1 |
| 2737 |
} if |
| 2738 |
} ifelse |
| 2739 |
} bind def |
| 2740 |
% \end{macrocode} |
| 2741 |
% \end{macro} |
| 2742 |
% |
| 2743 |
% \begin{macro}{CloneCurve} |
| 2744 |
% Does a deep copy of the array \PSarray{Curve}. This also involved deep copies of the contained point arrays. |
| 2745 |
% \begin{pssyntax} |
| 2746 |
% \PSarray{Curve} \PSop{CloneCurve} \PSarray{newCurve} |
| 2747 |
% \end{pssyntax} |
| 2748 |
% \begin{macrocode} |
| 2749 |
/CloneCurve { |
| 2750 |
[ exch { |
| 2751 |
CloneVec |
| 2752 |
} forall ] |
| 2753 |
} bind def |
| 2754 |
% \end{macrocode} |
| 2755 |
% \end{macro} |
| 2756 |
% |
| 2757 |
% \begin{macro}{CloneVec} |
| 2758 |
% Does a deep copy of the vector \PSarray{X Y} |
| 2759 |
% \begin{pssyntax} |
| 2760 |
% \PSarray{X Y} \PSop{CloneVec} \PSarray{Xnew Ynew} |
| 2761 |
% \end{pssyntax} |
| 2762 |
% \begin{macrocode} |
| 2763 |
/CloneVec { |
| 2764 |
aload pop ToPnt |
| 2765 |
} bind def |
| 2766 |
% \end{macrocode} |
| 2767 |
% \end{macro} |
| 2768 |
% |
| 2769 |
% \begin{macro}{MapTo} |
| 2770 |
% Map the sub-interval \PSarray{I} in \PSarray{0 1} into the interval \PSarray{J}. Returns a new array. |
| 2771 |
% \begin{pssyntax} |
| 2772 |
% \PSarray{J} \PSarray{I} \PSop{MapTo} \PSarray{Jnew} |
| 2773 |
% \end{pssyntax} |
| 2774 |
% \begin{macrocode} |
| 2775 |
/MapTo { |
| 2776 |
(MapTo) DebugBegin |
| 2777 |
exch aload 0 get 3 1 roll exch sub 2 copy % [I] J0 Jextent J0 Jextent |
| 2778 |
5 -1 roll aload aload pop % J0 Jextent J0 Jextent I0 I1 I0 I1 |
| 2779 |
min 4 -1 roll mul % J0 Jextent J0 I0 I1 min(I0,I1)*Jextent |
| 2780 |
4 -1 roll add [ exch % J0 Jextent I0 I1 [ J0new |
| 2781 |
6 2 roll max mul add ] |
| 2782 |
DebugEnd |
| 2783 |
} bind def |
| 2784 |
% \end{macrocode} |
| 2785 |
% \end{macro} |
| 2786 |
% |
| 2787 |
% \begin{macro}{Portion} |
| 2788 |
% Compute the portion of the Bezier curve \PSarray{CurveB} wrt the interval \PSarray{I}. |
| 2789 |
% \begin{pssyntax} |
| 2790 |
% \PSarray{CurveB} \PSarray{I} \PSop{Portion} \PSarray{CurvePartB} |
| 2791 |
% \end{pssyntax} |
| 2792 |
% \begin{macrocode} |
| 2793 |
/Portion { |
| 2794 |
(Portion) DebugBegin |
| 2795 |
dup Min 0 eq { % [CurveB] [I] |
| 2796 |
% I.min() == 0 |
| 2797 |
Max dup 1 eq {% [CurveB] I.max() |
| 2798 |
% I.max() == 1 |
| 2799 |
pop pop |
| 2800 |
} { % [CurveB] I.max() |
| 2801 |
LeftPortion |
| 2802 |
} ifelse |
| 2803 |
} { % [CurveB] [I] |
| 2804 |
2 copy Min % [CurveB] [I] [CurveB] I.min() |
| 2805 |
RightPortion |
| 2806 |
dup Max 1 eq { |
| 2807 |
% I.max() == 1 |
| 2808 |
pop pop |
| 2809 |
} {% [CurveB] [I] |
| 2810 |
dup aload pop exch sub 1 3 -1 roll Min sub div % [CurveB] (I1-I0)/(1-I.min()) |
| 2811 |
LeftPortion |
| 2812 |
} ifelse |
| 2813 |
} ifelse |
| 2814 |
DebugEnd |
| 2815 |
} bind def |
| 2816 |
% \end{macrocode} |
| 2817 |
% \end{macro} |
| 2818 |
% |
| 2819 |
% \begin{macro}{LeftPortion} |
| 2820 |
% Compute the portion of the Bezier curve \PSarray{CurveB} wrt the |
| 2821 |
% interval \PSarray{0 t}. |
| 2822 |
% \begin{pssyntax} |
| 2823 |
% \PSarray{CurveB} \PSvar{t} \PSop{LeftPortion} \PSarray{CurvePartB} |
| 2824 |
% \end{pssyntax} |
| 2825 |
% \begin{macrocode} |
| 2826 |
/LeftPortion { |
| 2827 |
(LeftPortion) DebugBegin |
| 2828 |
exch dup length 1 sub dup 4 1 roll % L-1 t [CurveB] L-1 |
| 2829 |
1 1 3 -1 roll { % L-1 t [CurveB] i |
| 2830 |
4 -1 roll dup 5 1 roll % L-1 t [CurveB] i L-1 |
| 2831 |
-1 3 -1 roll % L-1 t [CurveB] L-1 -1 i |
| 2832 |
{ % L-1 t [CurveB] j |
| 2833 |
2 copy 5 copy % L-1 t [CurveB] j [CurveB] j t [CurveB] j [CurveB] j |
| 2834 |
1 sub get 3 1 roll get % L-1 t [CurveB] j [CurveB] j t B[j-1] B[j] |
| 2835 |
Lerp put pop % L-1 t [CurveB] |
| 2836 |
} for |
| 2837 |
} for |
| 2838 |
pop pop pop |
| 2839 |
DebugEnd |
| 2840 |
} bind def |
| 2841 |
% \end{macrocode} |
| 2842 |
% \end{macro} |
| 2843 |
% |
| 2844 |
% \begin{macro}{RightPortion} |
| 2845 |
% Compute the portion of the Bezier curve \PSarray{CurveB} wrt the |
| 2846 |
% interval \PSarray{t 1}. |
| 2847 |
% \begin{pssyntax} |
| 2848 |
% \PSarray{CurveB} \PSvar{t} \PSop{RightPortion} \PSarray{CurvePartB} |
| 2849 |
% \end{pssyntax} |
| 2850 |
% \begin{macrocode} |
| 2851 |
/RightPortion { |
| 2852 |
(RightPortion) DebugBegin |
| 2853 |
exch dup length 1 sub dup 4 1 roll % L-1 t [CurveB] L-1 |
| 2854 |
1 1 3 -1 roll {% L-1 t [CurveB] i |
| 2855 |
4 -1 roll dup 5 1 roll % L-1 t [CurveB] i L-1 |
| 2856 |
exch sub 0 1 3 -1 roll % L-1 t [CurveB] 0 1 L-i-1 |
| 2857 |
{% L-1 t [CurveB] j |
| 2858 |
2 copy 5 copy |
| 2859 |
get 3 1 roll 1 add get Lerp put pop |
| 2860 |
} for |
| 2861 |
} for |
| 2862 |
pop pop pop |
| 2863 |
DebugEnd |
| 2864 |
} bind def |
| 2865 |
% \end{macrocode} |
| 2866 |
% \end{macro} |
| 2867 |
% |
| 2868 |
% \begin{macro}{Lerp} |
| 2869 |
% Given two points and a parameter \PSvar{t} $\in$ \PSarray{0 1}, return a point |
| 2870 |
% proportionally from \PSarray{A} to \PSarray{B} by \PSvar{t}. Akin to 1 degree Bezier. |
| 2871 |
% \begin{pssyntax} |
| 2872 |
% \PSvar{t} \PSarray{A} \PSarray{B} \PSop{Lerp} \PSarray{newpoint} |
| 2873 |
% \end{pssyntax} |
| 2874 |
% \begin{macrocode} |
| 2875 |
/Lerp { |
| 2876 |
(Lerp) DebugBegin |
| 2877 |
3 -1 roll dup 1 exch sub 3 1 roll % [A] (1-t) [B] t |
| 2878 |
exch aload pop 3 -1 roll VecScale % [A] (1-t) B.x*t B.y*t |
| 2879 |
4 2 roll |
| 2880 |
exch aload pop 3 -1 roll VecScale VecAdd ToPnt % [A.x*(1-t)+B.x*t A.y*(1-t)+B.y*t] |
| 2881 |
DebugEnd |
| 2882 |
} bind def |
| 2883 |
% \end{macrocode} |
| 2884 |
% \end{macro} |
| 2885 |
% |
| 2886 |
% \begin{macro}{IsConstant} |
| 2887 |
% Test if all points of a curve are near to each other. This is used as termination criterium for the intersection procedure. |
| 2888 |
% \begin{pssyntax} |
| 2889 |
% \PSarray{Curve} \PSop{IsConstant} \PSvar{boolean} |
| 2890 |
% \end{pssyntax} |
| 2891 |
% \begin{macrocode} |
| 2892 |
/IsConstant { |
| 2893 |
aload length [ exch 1 roll ] true 3 1 roll |
| 2894 |
{ |
| 2895 |
exch dup 4 1 roll |
| 2896 |
AreNear and exch |
| 2897 |
} forall |
| 2898 |
pop |
| 2899 |
} bind def |
| 2900 |
% \end{macrocode} |
| 2901 |
% \end{macro} |
| 2902 |
% \begin{macro}{AreNear} |
| 2903 |
% Test if two points are near to each other. |
| 2904 |
% \begin{pssyntax} |
| 2905 |
% \PSarray{P1} \PSarray{P2} \PSop{AreNear} \PSvar{boolean} |
| 2906 |
% \end{pssyntax} |
| 2907 |
% \begin{macrocode} |
| 2908 |
/AreNear { |
| 2909 |
(AreNear) DebugBegin |
| 2910 |
aload pop 3 -1 roll aload pop |
| 2911 |
VecSub abs epsilon lt exch abs epsilon lt and |
| 2912 |
DebugEnd |
| 2913 |
} bind def |
| 2914 |
% \end{macrocode} |
| 2915 |
% \end{macro} |
| 2916 |
% |
| 2917 |
% \begin{macro}{Min} |
| 2918 |
% Get the minimum value of the vector \PSarray{P}. |
| 2919 |
% \begin{pssyntax} |
| 2920 |
% \PSarray{P} \PSop{Min} \PSvar{minimum} |
| 2921 |
% \end{pssyntax} |
| 2922 |
% \begin{macrocode} |
| 2923 |
/Min { |
| 2924 |
aload pop min |
| 2925 |
} bind def |
| 2926 |
% \end{macrocode} |
| 2927 |
% \end{macro} |
| 2928 |
% \begin{macro}{Min} |
| 2929 |
% Get the maximum value of the vector \PSarray{P}. |
| 2930 |
% \begin{pssyntax} |
| 2931 |
% \PSarray{P} \PSop{Max} \PSvar{maximum} |
| 2932 |
% \end{pssyntax} |
| 2933 |
% \begin{macrocode} |
| 2934 |
/Max { |
| 2935 |
aload pop max |
| 2936 |
} bind def |
| 2937 |
% \end{macrocode} |
| 2938 |
% \end{macro} |
| 2939 |
% \begin{macro}{Min} |
| 2940 |
% Get the extent of the interval \PSarray{I}. |
| 2941 |
% \begin{pssyntax} |
| 2942 |
% \PSarray{I} \PSop{Extent} \PSvar{I1-I0} |
| 2943 |
% \end{pssyntax} |
| 2944 |
% \begin{macrocode} |
| 2945 |
/Extent { |
| 2946 |
aload pop exch sub |
| 2947 |
} bind def |
| 2948 |
% \end{macrocode} |
| 2949 |
% \end{macro} |
| 2950 |
% |
| 2951 |
% \begin{macro}{MiddlePoint} |
| 2952 |
% Compute the middle point of the first and last point of \PSarray{Curve}. |
| 2953 |
% \begin{pssyntax} |
| 2954 |
% \PSarray{Curve} \PSop{MiddlePoint} \PSvar{X Y} |
| 2955 |
% \end{pssyntax} |
| 2956 |
% \begin{macrocode} |
| 2957 |
/MiddlePoint { |
| 2958 |
dup dup length 1 sub get aload pop |
| 2959 |
3 -1 roll 0 get aload pop |
| 2960 |
VecAdd 0.5 VecScale |
| 2961 |
} bind def |
| 2962 |
% \end{macrocode} |
| 2963 |
% \end{macro} |
| 2964 |
% |
| 2965 |
% \begin{macro}{OrthogonalOrientationLine} |
| 2966 |
% \begin{pssyntax} |
| 2967 |
% \PSvar{MiddlePointA} \PSarray{CurveB} \PSop{OrthogonalOrientationLine} \PSvar{A B C} |
| 2968 |
% \end{pssyntax} |
| 2969 |
% \begin{macrocode} |
| 2970 |
/OrthogonalOrientationLine { |
| 2971 |
(OrthogonalOrientationLine) DebugBegin |
| 2972 |
dup dup length 1 sub get aload pop 3 -1 roll 0 get aload pop VecSub |
| 2973 |
% \end{macrocode} |
| 2974 |
% rotate by +90 degrees |
| 2975 |
% \begin{macrocode} |
| 2976 |
neg exch |
| 2977 |
4 2 roll 2 copy 6 2 roll VecAdd |
| 2978 |
ImplicitLine |
| 2979 |
DebugEnd |
| 2980 |
} bind def |
| 2981 |
% \end{macrocode} |
| 2982 |
% \end{macro} |
| 2983 |
% |
| 2984 |
% \begin{macro}{PickOrientationLine} |
| 2985 |
% Pick an orientation line for a Bezier curve. This uses the first |
| 2986 |
% point and the lastmost point, which is not near to it. |
| 2987 |
% \begin{pssyntax} |
| 2988 |
% \PSarray{Curve} \PSop{PickOrientationLine} \PSvar{A B C} |
| 2989 |
% \end{pssyntax} |
| 2990 |
% \begin{macrocode} |
| 2991 |
/PickOrientationLine { |
| 2992 |
(PickOrientationLine) DebugBegin |
| 2993 |
dup dup length 1 sub exch 0 get% [Curve] L-1 P0 |
| 2994 |
exch -1 1 {% [Curve] P0 i |
| 2995 |
3 -1 roll dup 4 1 roll exch get % [Curve] P0 Pi |
| 2996 |
2 copy AreNear { |
| 2997 |
pop |
| 2998 |
} { |
| 2999 |
exit |
| 3000 |
} ifelse |
| 3001 |
} for |
| 3002 |
3 -1 roll pop |
| 3003 |
exch aload pop 3 -1 roll aload pop ImplicitLine |
| 3004 |
DebugEnd |
| 3005 |
} bind def |
| 3006 |
% \end{macrocode} |
| 3007 |
% \end{macro} |
| 3008 |
% |
| 3009 |
% \begin{macro}{ImplicitLine} |
| 3010 |
% Compute the coefficients \PSvar{A}, \PSvar{B}, \PSvar{C} of the normalized implicit equation |
| 3011 |
% of the line which goes through the points \PSarray{Xi Yi} and \PSarray{Xj Yj}. |
| 3012 |
% |
| 3013 |
% \begin{pssyntax} |
| 3014 |
% \PSvar{Xi Yi Xj Yj} \PSop{ImplicitLine} \PSvar{A B C} |
| 3015 |
% \end{pssyntax} |
| 3016 |
% \begin{macrocode} |
| 3017 |
/ImplicitLine { |
| 3018 |
4 copy % Xi Yi Xj Yj Xi Yi Xj Yj |
| 3019 |
3 -1 roll sub 7 1 roll sub 5 1 roll % Yj-Yi Xi-Xj Xi Yi Xj Yj |
| 3020 |
% Yi*Xj - Xi*Yj |
| 3021 |
4 -1 roll mul neg % Yj-Yi Xi-Xj Yi Xj -Yj*Xi |
| 3022 |
3 1 roll mul add % Yj-Yi Xi-Xj Yi*Xj-Yj*Xi | l0 l1 l2 |
| 3023 |
3 1 roll 2 copy tx@Dict begin Pyth end dup dup % l2 l0 l1 L L L |
| 3024 |
5 -1 roll exch % l2 l1 L L l0 L |
| 3025 |
div 5 1 roll % l0/L l2 l1 L L |
| 3026 |
3 1 roll div % l0/L l2 L l1/L |
| 3027 |
3 1 roll div % l0/L l1/L l2/L |
| 3028 |
} bind def |
| 3029 |
% \end{macrocode} |
| 3030 |
% \end{macro} |
| 3031 |
% |
| 3032 |
% \begin{macro}{distance} |
| 3033 |
% Compute the distance of point \PSarray{X Y} from the implicit line given |
| 3034 |
% by $Ax + By + C = 0,\quad (A^2+B^2 = 1)$. |
| 3035 |
% \begin{pssyntax} |
| 3036 |
% \PSvar{X Y A B C} \PSop{distance} \PSvar{d} |
| 3037 |
% \end{pssyntax} |
| 3038 |
% \begin{macrocode} |
| 3039 |
/distance { |
| 3040 |
5 1 roll 3 -1 roll mul 3 1 roll mul add add |
| 3041 |
} bind def |
| 3042 |
% \end{macrocode} |
| 3043 |
% \end{macro} |
| 3044 |
% |
| 3045 |
% \begin{macro}{ArrayToPointArray} |
| 3046 |
% \begin{pssyntax} |
| 3047 |
% \PSarray{A.x A.y ... N.x N.y} \PSop{ArrayToPointArray} \PSarray{\PSarray{A.x A.y} \ldots \PSarray{N.x N.y}} |
| 3048 |
% \end{pssyntax} |
| 3049 |
% \begin{macrocode} |
| 3050 |
/ArrayToPointArray { |
| 3051 |
aload length dup 2 idiv { |
| 3052 |
3 1 roll [ 3 1 roll ] exch |
| 3053 |
dup 1 sub 3 1 roll 1 roll |
| 3054 |
} repeat 1 add [ exch 1 roll ] |
| 3055 |
} bind def |
| 3056 |
% \end{macrocode} |
| 3057 |
% \end{macro} |
| 3058 |
% |
| 3059 |
% \begin{macro}{PointArrayToArray} |
| 3060 |
% \begin{pssyntax} |
| 3061 |
% \PSarray{\PSarray{A.x A.y} \ldots \PSarray{N.x N.y}} \PSop{PointArrayToArray} \PSarray{A.x A.y ... N.x N.y} |
| 3062 |
% \end{pssyntax} |
| 3063 |
% \begin{macrocode} |
| 3064 |
/PointArrayToArray { |
| 3065 |
aload length dup { |
| 3066 |
1 add dup 3 -1 roll aload pop 4 -1 roll 1 add 2 roll |
| 3067 |
} repeat 1 add [ exch 1 roll ] |
| 3068 |
} bind def |
| 3069 |
% \end{macrocode} |
| 3070 |
% \end{macro} |
| 3071 |
% |
| 3072 |
% \begin{macro}{ClipCurve} |
| 3073 |
% Clip the Bezier curve B with respect to the Bezier curve A for |
| 3074 |
% individuating intersection points. The new parameter interval for the |
| 3075 |
% clipped curve is pushed on the stack. |
| 3076 |
% \begin{pssyntax} |
| 3077 |
% \PSarray{CurveA} \PSarray{CurveB} \PSop{ClipCurve} \PSarray{newinterval} |
| 3078 |
% \end{pssyntax} |
| 3079 |
% \begin{macrocode} |
| 3080 |
/ClipCurve { |
| 3081 |
(ClipCurve) DebugBegin |
| 3082 |
4 dict begin |
| 3083 |
/CurveB exch def /CurveA exch def |
| 3084 |
CurveA IsConstant { |
| 3085 |
CurveA MiddlePoint CurveB OrthogonalOrientationLine |
| 3086 |
} { |
| 3087 |
CurveA PickOrientationLine |
| 3088 |
} ifelse |
| 3089 |
CheckIT { |
| 3090 |
3 copy exch 3 -1 roll (OrientationLine : ) |
| 3091 |
3 { exch 20 string cvs ( ) strcat strcat } repeat == |
| 3092 |
} if |
| 3093 |
CurveA FatLineBounds |
| 3094 |
CheckIT { dup (FatLineBounds : ) exch aload pop exch 20 string cvs (, ) strcat exch 20 string cvs strcat strcat == } if |
| 3095 |
CurveB ClipCurveInterval |
| 3096 |
end |
| 3097 |
DebugEnd |
| 3098 |
} bind def |
| 3099 |
% \end{macrocode} |
| 3100 |
% \end{macro} |
| 3101 |
% |
| 3102 |
% \begin{macro}{FatLineBounds} |
| 3103 |
% Compute the boundary of the fat line given by \PSvar{A B C} |
| 3104 |
% \begin{pssyntax} |
| 3105 |
% \PSvar{A B C} \PSarray{Curve} \PSop{FatLineBounds} \PSvar{A B C} \PSarray{dmin dmax} |
| 3106 |
% \end{pssyntax} |
| 3107 |
% \begin{macrocode} |
| 3108 |
/FatLineBounds { |
| 3109 |
(FatLineBounds) DebugBegin |
| 3110 |
/dmin 0 def /dmax 0 def |
| 3111 |
{ |
| 3112 |
4 copy aload pop 5 2 roll distance |
| 3113 |
dup dmin lt { dup /dmin exch def } if |
| 3114 |
dup dmax gt { dup /dmax exch def } if |
| 3115 |
pop pop |
| 3116 |
} forall |
| 3117 |
[dmin dmax] |
| 3118 |
DebugEnd |
| 3119 |
} bind def |
| 3120 |
% \end{macrocode} |
| 3121 |
% \end{macro} |
| 3122 |
% |
| 3123 |
% \begin{macro}{ClipCurveInterval} |
| 3124 |
% Clip the Bezier curve wrt the fat line defined by the orientation |
| 3125 |
% line (given by \PSvar{A B C}) and the interval range |
| 3126 |
% \PSarray{bound}. The new parameter interval \PSarray{newinterval} |
| 3127 |
% for the clipped curve is pushed on the stack. |
| 3128 |
% \begin{pssyntax} |
| 3129 |
% \PSvar{A B C} \PSarray{bound} \PSarray{curve} \PSop{ClipCurveInterval} \PSarray{newinterval} |
| 3130 |
% \end{pssyntax} |
| 3131 |
% \begin{macrocode} |
| 3132 |
/ClipCurveInterval { |
| 3133 |
(ClipCurveInterval) DebugBegin |
| 3134 |
15 dict begin |
| 3135 |
/curve exch def |
| 3136 |
aload pop 2 copy min /boundMin exch def max /boundMax exch def |
| 3137 |
[ 4 1 roll ] cvx /fatline exch def |
| 3138 |
% number of sub-intervals |
| 3139 |
/n curve length 1 sub def |
| 3140 |
% distance curve control points |
| 3141 |
/D n 1 add array def |
| 3142 |
0 1 n { % i |
| 3143 |
dup curve exch get aload pop % i Pi.x Pi.y |
| 3144 |
fatline distance % distance d of Point i from the orientation line, on stack; i d |
| 3145 |
exch dup n div % d i i/n |
| 3146 |
[ exch 4 -1 roll ] % i [ i/n d ] |
| 3147 |
D 3 1 roll put |
| 3148 |
} for |
| 3149 |
D ConvexHull /D exch def |
| 3150 |
% \end{macrocode} |
| 3151 |
% get the x-coordinate of the i-th point, i getX -> D[i][X] |
| 3152 |
% \begin{macrocode} |
| 3153 |
/getX { D exch get 0 get } def |
| 3154 |
% \end{macrocode} |
| 3155 |
% get the y-coordinate of the i-th point, i getY -> D[i][Y] |
| 3156 |
% \begin{macrocode} |
| 3157 |
/getY { D exch get 1 get } def |
| 3158 |
/tmin 1 def /tmax 0 def |
| 3159 |
0 getY dup |
| 3160 |
boundMin lt /plower exch def |
| 3161 |
boundMax gt /phigher exch def |
| 3162 |
plower phigher or not { |
| 3163 |
% \end{macrocode} |
| 3164 |
% inside the fat line |
| 3165 |
% \begin{macrocode} |
| 3166 |
tmin 0 getX gt { /tmin 0 getX def } if |
| 3167 |
tmax 0 getX lt { /tmax 0 getX def } if |
| 3168 |
} if |
| 3169 |
1 1 D length 1 sub { |
| 3170 |
/i exch def |
| 3171 |
/clower i getY boundMin lt def |
| 3172 |
/chigher i getY boundMax gt def |
| 3173 |
clower chigher or not { |
| 3174 |
% \end{macrocode} |
| 3175 |
% inside the fat line |
| 3176 |
% \begin{macrocode} |
| 3177 |
tmin i getX gt { /tmin i getX def } if |
| 3178 |
tmax i getX lt { /tmax i getX def } if |
| 3179 |
} if |
| 3180 |
clower plower eq not { |
| 3181 |
% \end{macrocode} |
| 3182 |
% cross the lower bound |
| 3183 |
% \begin{macrocode} |
| 3184 |
boundMin i 1 sub i D Intersect % t on stack |
| 3185 |
dup tmin lt { dup /tmin exch def } if |
| 3186 |
dup tmax gt { dup /tmax exch def } if |
| 3187 |
pop |
| 3188 |
/plower clower def |
| 3189 |
} if |
| 3190 |
chigher phigher eq not { |
| 3191 |
% \end{macrocode} |
| 3192 |
% cross the upper bound |
| 3193 |
% \begin{macrocode} |
| 3194 |
boundMax i 1 sub i D Intersect |
| 3195 |
dup tmin lt { dup /tmin exch def } if |
| 3196 |
dup tmax gt { dup /tmax exch def } if |
| 3197 |
pop |
| 3198 |
/phigher chigher def |
| 3199 |
} if |
| 3200 |
} for |
| 3201 |
% \end{macrocode} |
| 3202 |
% we have to test the closing segment for intersection |
| 3203 |
% \begin{macrocode} |
| 3204 |
/i D length 1 sub def |
| 3205 |
/clower 0 getY boundMin lt def |
| 3206 |
/chigher 0 getY boundMax gt def |
| 3207 |
clower plower eq not { |
| 3208 |
% \end{macrocode} |
| 3209 |
% cross the lower bound |
| 3210 |
% \begin{macrocode} |
| 3211 |
boundMin i 0 D Intersect |
| 3212 |
dup tmin lt { dup /tmin exch def } if |
| 3213 |
dup tmax gt { dup /tmax exch def } if |
| 3214 |
pop |
| 3215 |
} if |
| 3216 |
chigher phigher eq not { |
| 3217 |
% \end{macrocode} |
| 3218 |
% cross the lower bound |
| 3219 |
% \begin{macrocode} |
| 3220 |
boundMax i 0 D Intersect |
| 3221 |
dup tmin lt { dup /tmin exch def } if |
| 3222 |
dup tmax gt { dup /tmax exch def } if |
| 3223 |
pop |
| 3224 |
} if |
| 3225 |
[tmin tmax] |
| 3226 |
end |
| 3227 |
DebugEnd |
| 3228 |
} bind def |
| 3229 |
% \end{macrocode} |
| 3230 |
% \end{macro} |
| 3231 |
% |
| 3232 |
% \begin{macro}{Intersect} |
| 3233 |
% Get the x component of the intersection point between the line |
| 3234 |
% passing through $i$-th and $j$-th points of \PSarray{Curve} and the |
| 3235 |
% horizonal line through \PSvar{y}. |
| 3236 |
% \begin{pssyntax} |
| 3237 |
% \PSvar{y i j} \PSarray{Curve} \PSop{Intersect} \PSvar{Xisect} |
| 3238 |
% \end{pssyntax} |
| 3239 |
% \begin{macrocode} |
| 3240 |
/Intersect { |
| 3241 |
dup 4 -1 roll get aload pop |
| 3242 |
4 2 roll exch get aload pop |
| 3243 |
% \end{macrocode} |
| 3244 |
% On the stack: \PSvar{y Xi Yi Xj Yj}, Compute (Xj - Xi) * (y - Yi)/(Yj - Yi) + Xi |
| 3245 |
% |
| 3246 |
% We are sure, that Yi != Yj, because this procedure is called only |
| 3247 |
% when the lower or upper bound is crossed. |
| 3248 |
% \begin{macrocode} |
| 3249 |
4 2 roll 2 copy 6 2 roll VecSub |
| 3250 |
5 2 roll |
| 3251 |
neg 3 -1 roll add |
| 3252 |
3 -1 roll div |
| 3253 |
3 -1 roll mul add |
| 3254 |
} bind def |
| 3255 |
% \end{macrocode} |
| 3256 |
% \end{macro} |
| 3257 |
% |
| 3258 |
% \begin{macro}{IsPath} |
| 3259 |
% Check if an array is a path. A path is represented as array, which |
| 3260 |
% contains other arrays which represent native Postscript |
| 3261 |
% operations. Those can be \PSarray{X Y /@m}, \PSarray{X Y /@l}, or |
| 3262 |
% \PSarray{X1 Y1 X2 Y2 X3 Y3 /@c}. |
| 3263 |
% |
| 3264 |
% \begin{pssyntax} |
| 3265 |
% \PSarray{array} \PSop{IsPath} \PSvar{boolean} |
| 3266 |
% \end{pssyntax} |
| 3267 |
% \begin{macrocode} |
| 3268 |
/IsPath { |
| 3269 |
dup length 1 sub get type /nametype eq { true } { false } ifelse |
| 3270 |
} bind def |
| 3271 |
% \end{macrocode} |
| 3272 |
% \end{macro} |
| 3273 |
% |
| 3274 |
% \begin{macro}{ShowPathPortion} |
| 3275 |
% \begin{pssyntax} |
| 3276 |
% \PSarray{path} \PSvar{tstart tstop} \PSop{ShowPathPortion} |
| 3277 |
% \end{pssyntax} |
| 3278 |
% \begin{macrocode} |
| 3279 |
/ShowPathPortion { |
| 3280 |
(ShowPathPortion) DebugBegin |
| 3281 |
8 dict begin |
| 3282 |
/tstop exch def |
| 3283 |
/tstart exch def |
| 3284 |
/savecp { ToPnt cvx /@cp exch def } def |
| 3285 |
InitTracing |
| 3286 |
/n 0 def |
| 3287 |
mark exch aload pop |
| 3288 |
{ |
| 3289 |
counttomark 0 eq n tstop ge or { cleartomark exit } if |
| 3290 |
dup /movetype eq not { /n n 1 add def } if |
| 3291 |
dup /movetype eq { |
| 3292 |
pop savecp |
| 3293 |
} { |
| 3294 |
tstart n ge { |
| 3295 |
% \end{macrocode} |
| 3296 |
% current path section is before tstop |
| 3297 |
% \begin{macrocode} |
| 3298 |
/curvetype eq { 6 2 roll 4 { pop } repeat } if |
| 3299 |
savecp |
| 3300 |
} { |
| 3301 |
tstart n 1 sub gt tstop n lt or { |
| 3302 |
% \end{macrocode} |
| 3303 |
% draw a truncated segment |
| 3304 |
% \begin{macrocode} |
| 3305 |
tstart n sub 1 add tstop n sub 1 add |
| 3306 |
ToUnitInterval exch |
| 3307 |
/linetype eq { |
| 3308 |
3 1 roll ToPnt |
| 3309 |
tstart n 1 sub gt { @cp ToPnt } { currentpoint ToPnt } ifelse exch ToPnt |
| 3310 |
dup 3 -1 roll Portion |
| 3311 |
aload pop exch |
| 3312 |
tstart n 1 sub gt { |
| 3313 |
% \end{macrocode} |
| 3314 |
% This is the start segment, move to the starting point, as it lies in the middle of the segment. |
| 3315 |
% \begin{macrocode} |
| 3316 |
exch aload pop 3 -1 roll aload pop ArrowA |
| 3317 |
tstop n le { |
| 3318 |
% \end{macrocode} |
| 3319 |
% only a single segment, draw also the ending arrow |
| 3320 |
% \begin{macrocode} |
| 3321 |
currentpoint 4 2 roll ArrowB linetype pop pop |
| 3322 |
} { |
| 3323 |
% \end{macrocode} |
| 3324 |
% other segments to follow |
| 3325 |
% \begin{macrocode} |
| 3326 |
linetype |
| 3327 |
} ifelse |
| 3328 |
} { |
| 3329 |
% \end{macrocode} |
| 3330 |
% this is the last segment |
| 3331 |
% \begin{macrocode} |
| 3332 |
pop aload pop currentpoint 4 2 roll ArrowB linetype pop pop |
| 3333 |
} ifelse |
| 3334 |
} { |
| 3335 |
7 1 roll |
| 3336 |
[ tstart n 1 sub gt { @cp }{ currentpoint } ifelse |
| 3337 |
9 3 roll ] ArrayToPointArray |
| 3338 |
dup 3 -1 roll |
| 3339 |
Portion |
| 3340 |
{ aload pop } forall |
| 3341 |
tstart n 1 sub gt { |
| 3342 |
8 -4 roll 4 2 roll ArrowA 6 2 roll |
| 3343 |
} { |
| 3344 |
8 -2 roll pop pop |
| 3345 |
} ifelse |
| 3346 |
tstop n le { ArrowB } if |
| 3347 |
curvetype |
| 3348 |
} ifelse |
| 3349 |
}{ |
| 3350 |
% \end{macrocode} |
| 3351 |
% full segment |
| 3352 |
% \begin{macrocode} |
| 3353 |
tstart n 1 sub eq { |
| 3354 |
% \end{macrocode} |
| 3355 |
% the first segment |
| 3356 |
% \begin{macrocode} |
| 3357 |
/linetype eq { |
| 3358 |
@cp ArrowA |
| 3359 |
tstop n eq { |
| 3360 |
% \end{macrocode} |
| 3361 |
% a single, full segment |
| 3362 |
% \begin{macrocode} |
| 3363 |
currentpoint 4 2 roll ArrowB linetype pop pop |
| 3364 |
} { |
| 3365 |
% \end{macrocode} |
| 3366 |
% not the last segment |
| 3367 |
% \begin{macrocode} |
| 3368 |
linetype |
| 3369 |
} ifelse |
| 3370 |
} { |
| 3371 |
6 -2 roll @cp ArrowA 6 2 roll |
| 3372 |
tstop n eq { |
| 3373 |
% \end{macrocode} |
| 3374 |
% single, full curve segment |
| 3375 |
% \begin{macrocode} |
| 3376 |
ArrowB |
| 3377 |
} if |
| 3378 |
curvetype |
| 3379 |
} ifelse |
| 3380 |
} { |
| 3381 |
% \end{macrocode} |
| 3382 |
% not the first segment |
| 3383 |
% \begin{macrocode} |
| 3384 |
/linetype eq { |
| 3385 |
tstop n eq { |
| 3386 |
% \end{macrocode} |
| 3387 |
% last segment but not a single one |
| 3388 |
% \begin{macrocode} |
| 3389 |
currentpoint 4 2 roll ArrowB linetype pop pop |
| 3390 |
}{ |
| 3391 |
% \end{macrocode} |
| 3392 |
% full middle segment |
| 3393 |
% \begin{macrocode} |
| 3394 |
linetype |
| 3395 |
} ifelse |
| 3396 |
} { |
| 3397 |
tstop n eq { |
| 3398 |
% \end{macrocode} |
| 3399 |
% last curveto segment, not a single one |
| 3400 |
% \begin{macrocode} |
| 3401 |
ArrowB |
| 3402 |
} if |
| 3403 |
curvetype |
| 3404 |
} ifelse |
| 3405 |
} ifelse |
| 3406 |
} ifelse |
| 3407 |
} ifelse |
| 3408 |
} ifelse |
| 3409 |
} loop |
| 3410 |
end |
| 3411 |
DebugEnd |
| 3412 |
} bind def |
| 3413 |
% \end{macrocode} |
| 3414 |
% \end{macro} |
| 3415 |
% |
| 3416 |
% \begin{macro}{GetCurvePoint} |
| 3417 |
% Get the coordinates of the curve point at \PSvar{t}. |
| 3418 |
% \begin{pssyntax} |
| 3419 |
% \PSvar{t} \PSarray{curve} \PSop{GetCurvePoint} \PSvar{X Y} |
| 3420 |
% \end{pssyntax} |
| 3421 |
% \begin{macrocode} |
| 3422 |
/GetCurvePoint { |
| 3423 |
dup IsPath { |
| 3424 |
5 dict begin |
| 3425 |
exch dup /tstart exch def |
| 3426 |
1 add cvi /tstop exch def |
| 3427 |
/savecp { ToPnt cvx /@cp exch def } def |
| 3428 |
/n 0 def |
| 3429 |
mark exch aload pop |
| 3430 |
{ |
| 3431 |
counttomark 0 eq n tstop ge or { cleartomark exit } if |
| 3432 |
dup /movetype eq not { /n n 1 add def } if |
| 3433 |
dup /movetype eq { |
| 3434 |
pop savecp |
| 3435 |
} { |
| 3436 |
tstart n ge { |
| 3437 |
% \end{macrocode} |
| 3438 |
% current path section is before tstop |
| 3439 |
% \begin{macrocode} |
| 3440 |
/curvetype eq { 6 2 roll 4 { pop } repeat } if |
| 3441 |
savecp |
| 3442 |
} { |
| 3443 |
tstart n 1 sub gt { |
| 3444 |
tstart n sub 1 add tstop n sub 1 add |
| 3445 |
ToUnitInterval exch |
| 3446 |
/linetype eq { |
| 3447 |
3 1 roll ToPnt |
| 3448 |
tstart n 1 sub gt { @cp ToPnt } { currentpoint ToPnt } ifelse exch ToPnt |
| 3449 |
dup 3 -1 roll Portion |
| 3450 |
} { |
| 3451 |
7 1 roll |
| 3452 |
[ @cp 9 3 roll ] ArrayToPointArray |
| 3453 |
dup 3 -1 roll |
| 3454 |
Portion |
| 3455 |
} ifelse |
| 3456 |
0 get aload pop |
| 3457 |
}{ |
| 3458 |
% \end{macrocode} |
| 3459 |
% full segment |
| 3460 |
% \begin{macrocode} |
| 3461 |
/curvetype eq { |
| 3462 |
pop pop pop pop |
| 3463 |
} if |
| 3464 |
} ifelse |
| 3465 |
counttomark 1 add 2 roll cleartomark exit |
| 3466 |
} ifelse |
| 3467 |
} ifelse |
| 3468 |
} loop |
| 3469 |
end |
| 3470 |
} { |
| 3471 |
exch dup 0 eq { |
| 3472 |
pop 0 get aload pop |
| 3473 |
} { |
| 3474 |
0 exch ToUnitInterval exch dup 3 -1 roll Portion |
| 3475 |
dup length 1 sub get aload pop |
| 3476 |
} ifelse |
| 3477 |
} ifelse |
| 3478 |
} bind def |
| 3479 |
% \end{macrocode} |
| 3480 |
% \end{macro} |
| 3481 |
% \begin{macro}{TraceCurveOrPath} |
| 3482 |
% \begin{pssyntax} |
| 3483 |
% \PSarray{curve} \PSvar{tstart tstop} \PSproc{drawcurve} |
| 3484 |
% \PSop{TraceCurveOrPath} |
| 3485 |
% \end{pssyntax} |
| 3486 |
% \begin{macrocode} |
| 3487 |
/TraceCurveOrPath { |
| 3488 |
4 1 roll |
| 3489 |
UnifyInterval |
| 3490 |
3 -1 roll dup IsPath { |
| 3491 |
4 -1 roll pop |
| 3492 |
3 1 roll 2 copy gt { |
| 3493 |
% \end{macrocode} |
| 3494 |
% reverse the path, draw everything and resave the path |
| 3495 |
% \begin{macrocode} |
| 3496 |
ReverseInterval |
| 3497 |
3 -1 roll ReversePath 3 1 roll |
| 3498 |
} if |
| 3499 |
ShowPathPortion |
| 3500 |
}{ % tstart tstop [curve] |
| 3501 |
mark exch 4 2 roll % [ [curve] tstart tstop |
| 3502 |
2 copy gt { % tstart > tstop |
| 3503 |
% \end{macrocode} |
| 3504 |
% Exchange tstart and tstop and reverse the curve array |
| 3505 |
% \begin{macrocode} |
| 3506 |
exch |
| 3507 |
[ 4 -1 roll ReverseCurve 3 1 roll % [ [curve'] tstart tstop |
| 3508 |
} if |
| 3509 |
ToUnitInterval exch dup 3 -1 roll Portion |
| 3510 |
{ aload pop } forall |
| 3511 |
% \end{macrocode} |
| 3512 |
% reverse the point order |
| 3513 |
% \begin{macrocode} |
| 3514 |
counttomark -2 4 { 2 roll } for |
| 3515 |
counttomark 2 sub 2 idiv |
| 3516 |
counttomark 2 add -1 roll exec |
| 3517 |
} ifelse |
| 3518 |
} bind def |
| 3519 |
% \end{macrocode} |
| 3520 |
% \end{macro} |
| 3521 |
% |
| 3522 |
% \begin{macrocode} |
| 3523 |
% Graham Scal algorithm to compute the convex hull of a set of |
| 3524 |
% points. Code written by Bill Casselman, |
| 3525 |
% http://www.math.ubc.ca/~cass/graphics/text/www/ |
| 3526 |
% |
| 3527 |
% [[X1 Y1] [X2 Y2] ... [Xn Yn]] hull -> [[...] ... [...]] |
| 3528 |
% |
| 3529 |
/hulldict 32 dict def |
| 3530 |
hulldict begin |
| 3531 |
|
| 3532 |
% u - v |
| 3533 |
/vsub { 2 dict begin |
| 3534 |
/v exch def |
| 3535 |
/u exch def |
| 3536 |
[ |
| 3537 |
u 0 get v 0 get sub |
| 3538 |
u 1 get v 1 get sub |
| 3539 |
] |
| 3540 |
end } def |
| 3541 |
|
| 3542 |
% u - v rotated 90 degrees |
| 3543 |
/vperp { 2 dict begin |
| 3544 |
/v exch def |
| 3545 |
/u exch def |
| 3546 |
[ |
| 3547 |
v 1 get u 1 get sub |
| 3548 |
u 0 get v 0 get sub |
| 3549 |
] |
| 3550 |
end } def |
| 3551 |
|
| 3552 |
/dot { 2 dict begin |
| 3553 |
/v exch def |
| 3554 |
/u exch def |
| 3555 |
v 0 get u 0 get mul |
| 3556 |
v 1 get u 1 get mul |
| 3557 |
add |
| 3558 |
end } def |
| 3559 |
|
| 3560 |
% P Q |
| 3561 |
% tests whether P < Q in lexicographic order |
| 3562 |
% i.e xP < xQ, or yP < yQ if xP = yP |
| 3563 |
/comp { 2 dict begin |
| 3564 |
/Q exch def |
| 3565 |
/P exch def |
| 3566 |
P 0 get Q 0 get lt |
| 3567 |
P 0 get Q 0 get eq |
| 3568 |
P 1 get Q 1 get lt |
| 3569 |
and |
| 3570 |
or |
| 3571 |
end } def |
| 3572 |
|
| 3573 |
end |
| 3574 |
|
| 3575 |
% args: an array of points C |
| 3576 |
% effect: returns the array of points on the boundary of |
| 3577 |
% the convex hull of C, in clockwise order |
| 3578 |
|
| 3579 |
/ConvexHull { |
| 3580 |
(ConvexHull) DebugBegin |
| 3581 |
hulldict begin |
| 3582 |
/C exch def |
| 3583 |
/comp C quicksort |
| 3584 |
/n C length def |
| 3585 |
% Q might circle around to the start |
| 3586 |
/Q n 1 add array def |
| 3587 |
Q 0 C 0 get put |
| 3588 |
Q 1 C 1 get put |
| 3589 |
/i 2 def |
| 3590 |
/k 2 def |
| 3591 |
% i is next point in C to be looked at |
| 3592 |
% k is next point in Q to be added |
| 3593 |
% [ Q[0] Q[1] ... ] |
| 3594 |
% scan the points to make the top hull |
| 3595 |
n 2 sub { |
| 3596 |
% P is the current point at right |
| 3597 |
/P C i get def |
| 3598 |
/i i 1 add def |
| 3599 |
{ |
| 3600 |
% if k = 1 then just add P |
| 3601 |
k 2 lt { exit } if |
| 3602 |
% now k is 2 or more |
| 3603 |
% look at Q[k-2] Q[k-1] P: a left turn (or in a line)? |
| 3604 |
% yes if (P - Q[k-1])*(Q[k-1] - Q[k-2])^perp >= 0 |
| 3605 |
P Q k 1 sub get vsub |
| 3606 |
Q k 1 sub get Q k 2 sub get vperp |
| 3607 |
dot 0 lt { |
| 3608 |
% not a left turn |
| 3609 |
exit |
| 3610 |
} if |
| 3611 |
/k k 1 sub def |
| 3612 |
} loop |
| 3613 |
Q k P put |
| 3614 |
/k k 1 add def |
| 3615 |
} repeat |
| 3616 |
|
| 3617 |
% done with top half |
| 3618 |
% K is where the right hand point is |
| 3619 |
/K k 1 sub def |
| 3620 |
|
| 3621 |
/i n 2 sub def |
| 3622 |
Q k C i get put |
| 3623 |
/i i 1 sub def |
| 3624 |
/k k 1 add def |
| 3625 |
n 2 sub { |
| 3626 |
% P is the current point at right |
| 3627 |
/P C i get def |
| 3628 |
/i i 1 sub def |
| 3629 |
{ |
| 3630 |
% in this pass k is always 2 or more |
| 3631 |
k K 2 add lt { exit } if |
| 3632 |
% look at Q[k-2] Q[k-1] P: a left turn (or in a line)? |
| 3633 |
% yes if (P - Q[k-1])*(Q[k-1] - Q[k-2])^perp >= 0 |
| 3634 |
P Q k 1 sub get vsub |
| 3635 |
Q k 1 sub get Q k 2 sub get vperp |
| 3636 |
dot 0 lt { |
| 3637 |
% not a left turn |
| 3638 |
exit |
| 3639 |
} if |
| 3640 |
/k k 1 sub def |
| 3641 |
} loop |
| 3642 |
Q k P put |
| 3643 |
/k k 1 add def |
| 3644 |
} repeat |
| 3645 |
|
| 3646 |
% strip Q down to [ Q[0] Q[1] ... Q[k-2] ] |
| 3647 |
% excluding the doubled initial point |
| 3648 |
[ 0 1 k 2 sub { |
| 3649 |
Q exch get |
| 3650 |
} for ] |
| 3651 |
end |
| 3652 |
DebugEnd |
| 3653 |
} def |
| 3654 |
|
| 3655 |
/qsortdict 8 dict def |
| 3656 |
|
| 3657 |
qsortdict begin |
| 3658 |
|
| 3659 |
% args: /comp a L R x |
| 3660 |
% effect: effects a partition into two pieces [L j] [i R] |
| 3661 |
% leaves i j on stack |
| 3662 |
|
| 3663 |
/partition { 8 dict begin |
| 3664 |
/x exch def |
| 3665 |
/j exch def |
| 3666 |
/i exch def |
| 3667 |
/a exch def |
| 3668 |
dup type /nametype eq { load } if /comp exch def |
| 3669 |
{ |
| 3670 |
{ |
| 3671 |
a i get x comp exec not { |
| 3672 |
exit |
| 3673 |
} if |
| 3674 |
/i i 1 add def |
| 3675 |
} loop |
| 3676 |
{ |
| 3677 |
x a j get comp exec not { |
| 3678 |
exit |
| 3679 |
} if |
| 3680 |
/j j 1 sub def |
| 3681 |
} loop |
| 3682 |
|
| 3683 |
i j le { |
| 3684 |
% swap a[i] a[j] |
| 3685 |
a j a i get |
| 3686 |
a i a j get |
| 3687 |
put put |
| 3688 |
/i i 1 add def |
| 3689 |
/j j 1 sub def |
| 3690 |
} if |
| 3691 |
i j gt { |
| 3692 |
exit |
| 3693 |
} if |
| 3694 |
} loop |
| 3695 |
i j |
| 3696 |
end } def |
| 3697 |
|
| 3698 |
% args: /comp a L R |
| 3699 |
% effect: sorts a[L .. R] according to comp |
| 3700 |
/subsort { |
| 3701 |
% /c a L R |
| 3702 |
[ 3 1 roll ] 3 copy |
| 3703 |
% /c a [L R] /c a [L R] |
| 3704 |
aload aload pop |
| 3705 |
% /c a [L R] /c a L R L R |
| 3706 |
add 2 idiv |
| 3707 |
% /c a [L R] /c a L R (L+R)/2 |
| 3708 |
3 index exch get |
| 3709 |
% /c a [L R] /c a L R x |
| 3710 |
partition |
| 3711 |
% /c a [L R] i j |
| 3712 |
% if j > L subsort(a, L, j) |
| 3713 |
dup |
| 3714 |
% /c a [L R] i j j |
| 3715 |
3 index 0 get gt { |
| 3716 |
% /c a [L R] i j |
| 3717 |
5 copy |
| 3718 |
% /c a [L R] i j /c a [L R] i j |
| 3719 |
exch pop |
| 3720 |
% /c a [L R] i j /c a [L R] j |
| 3721 |
exch 0 get exch |
| 3722 |
% ... /c a L j |
| 3723 |
subsort |
| 3724 |
} if |
| 3725 |
% /c a [L R] i j |
| 3726 |
pop dup |
| 3727 |
% /c a [L R] i i |
| 3728 |
% if i < R subsort(a, i, R) |
| 3729 |
2 index 1 get lt { |
| 3730 |
% /c a [L R] i |
| 3731 |
exch 1 get |
| 3732 |
% /c a i R |
| 3733 |
subsort |
| 3734 |
}{ |
| 3735 |
4 { pop } repeat |
| 3736 |
} ifelse |
| 3737 |
} def |
| 3738 |
|
| 3739 |
end % qsortdict |
| 3740 |
|
| 3741 |
% args: /comp a |
| 3742 |
% effect: sorts the array a |
| 3743 |
% comp returns truth of x < y for entries in a |
| 3744 |
|
| 3745 |
/quicksort { qsortdict begin |
| 3746 |
dup length 1 gt { |
| 3747 |
% /comp a |
| 3748 |
dup |
| 3749 |
% /comp a a |
| 3750 |
length 1 sub |
| 3751 |
% /comp a n-1 |
| 3752 |
0 exch subsort |
| 3753 |
} { |
| 3754 |
pop pop |
| 3755 |
} ifelse |
| 3756 |
end } def |
| 3757 |
% \end{macrocode} |
| 3758 |
% |
| 3759 |
% Debugging stuff |
| 3760 |
% \begin{macrocode} |
| 3761 |
/debug { |
| 3762 |
dup 1 add copy {==} repeat pop |
| 3763 |
} bind def |
| 3764 |
/DebugIT false def |
| 3765 |
/CheckIT false def |
| 3766 |
/DebugDepth 0 def |
| 3767 |
/DebugBegin { |
| 3768 |
DebugIT { |
| 3769 |
/DebugProcName exch def |
| 3770 |
DebugDepth 2 mul string |
| 3771 |
0 1 DebugDepth 2 mul 1 sub { |
| 3772 |
dup 2 mod 0 eq { (|) }{( )} ifelse |
| 3773 |
3 -1 roll dup 4 2 roll |
| 3774 |
putinterval |
| 3775 |
} for |
| 3776 |
DebugProcName strcat == |
| 3777 |
/DebugDepth DebugDepth 1 add def |
| 3778 |
}{ |
| 3779 |
pop |
| 3780 |
} ifelse |
| 3781 |
} bind def |
| 3782 |
/DebugEnd { |
| 3783 |
DebugIT { |
| 3784 |
/DebugDepth DebugDepth 1 sub def |
| 3785 |
DebugDepth 2 mul 2 add string |
| 3786 |
0 1 DebugDepth 2 mul 1 sub { |
| 3787 |
dup 2 mod 0 eq { (|) }{ ( ) } ifelse |
| 3788 |
3 -1 roll dup 4 2 roll |
| 3789 |
putinterval |
| 3790 |
} for |
| 3791 |
dup DebugDepth 2 mul (+-) putinterval |
| 3792 |
( done) strcat == |
| 3793 |
} if |
| 3794 |
} bind def |
| 3795 |
/strcat { |
| 3796 |
exch 2 copy |
| 3797 |
length exch length add |
| 3798 |
string dup dup 5 2 roll |
| 3799 |
copy length exch |
| 3800 |
putinterval |
| 3801 |
} bind def |
| 3802 |
/nametostr { |
| 3803 |
dup length string cvs |
| 3804 |
} bind def |
| 3805 |
/ShowCurve { |
| 3806 |
{ aload pop } forall |
| 3807 |
8 -2 roll moveto curveto |
| 3808 |
} bind def |
| 3809 |
/CurveToString { |
| 3810 |
(CurveToString) DebugBegin |
| 3811 |
aload pop ([) 3 -1 roll 20 string cvs strcat (, ) strcat exch 20 string cvs strcat (]) strcat |
| 3812 |
DebugEnd |
| 3813 |
} bind def |
| 3814 |
end % tx@IntersectDict |
| 3815 |
% \end{macrocode} |
| 3816 |
%</prolog> |
| 3817 |
% \Finale |
| 3818 |
% \endinput |