diff options
author | Karl Berry <karl@freefriends.org> | 2011-08-01 00:47:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-08-01 00:47:16 +0000 |
commit | aec2bbc3994991ebc6c5f4dbc90ad15c55f1a1fb (patch) | |
tree | 8940f33f6b173fb5cc630cc58ed4b791ad29e3fe /Master/texmf-dist/tex/generic/pgfplots/libs | |
parent | 868233e6288b5e35a7d7aabd79bf8e56a802bc12 (diff) |
pgfplots 1.5 (29jul11)
git-svn-id: svn://tug.org/texlive/trunk@23292 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/libs')
9 files changed, 5541 insertions, 43 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex index 58664dc323d..c45b5a613f0 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex @@ -55,6 +55,7 @@ /pgfplots/surf shading/south west corner/.initial={\pgfpointorigin},% /pgfplots/surf shading/north east corner/.initial={\pgfqpoint{6cm}{6cm}},% /pgfplots/surf shading/anchor/.initial=\pgfpointorigin,% + /pgfplots/surf shading/shading type/.initial=5,% triangles in form of lattice /pgfplots/surf shading/precision/.is choice, /pgfplots/surf shading/precision/pdf/.code={% % Lossless coordinate output. @@ -77,6 +78,7 @@ /pgfplots/surf shading/precision/ps},% /pgfplots/surf shading/precision/ps,% /pgfplots/surf shading/cols/.initial=,% + /pgfplots/surf shading/colorspace/.initial=rgb,% rgb or cmyk /pgfplots/surf shading/colormap/.initial={% << /FunctionType 2 @@ -124,22 +126,57 @@ 0 \pgfplotscolormappdfmax % map [0,2^BitsPerComponent-1] linearly to [0 1] for parametric color data }% \def\pgfplotslibrarysurf@count{0}% +\newcount\c@pgfplotslibrarysurf@no % driver specific: \def\pgfplotslibrarysurf@initstream{} \def\pgfplotslibrarysurf@advancestreamlen#1{}% \def\pgfplotslibrarysurfstreamstart{% - \pgfplotsapplistXnewempty\pgfplotslibrarysurf@binarystream@accum + \pgfplotslibrarysurf@translate@colorspace + \let\pgfplotslibrarysurf@colorspace=\pgfplotsretval + \pgfkeysgetvalue{/pgfplots/surf shading/shading type}\pgfplotslibrarysurf@type + \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum \pgfplotslibrarysurf@initstream \ifx\pgfplotslibrarysurf@filter@encode\pgfutil@empty \else \pgfkeysalso{/pgfplots/bin/\pgfplotslibrarysurf@filter@encode}% \fi + \ifcase\pgfplotslibrarysurf@type\relax + % 0 + \pgfplotslibrarysurf@initstream@wrongtype + \or% 1 + \pgfplotslibrarysurf@initstream@wrongtype + \or% 2 + \pgfplotslibrarysurf@initstream@wrongtype + \or% 3 + \or% 4 + % ok, triangle meshes. + \def\pgfplotslibrarysurf@edgeflag{\pgfplotscharno{0}}% + \or% 5 triangles in lattice form. disable edge flag: + \let\pgfplotslibrarysurf@edgeflag=\pgfutil@empty + \or% 6 coons patches: + \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty + \global\c@pgfplotslibrarysurf@no=0 + \def\pgfplotslibrarysurf@cubicpatch@numverts{12}% + \let\pgfplotslibrarysurfstreamcoord=\pgfplotslibrarysurfstreamcoord@cubicpatch + \def\pgfplotslibrarysurf@edgeflag{\pgfplotscharno{0}}% + \or% 7 full tensor product cubic bezier patches: + \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty + \global\c@pgfplotslibrarysurf@no=0 + \def\pgfplotslibrarysurf@cubicpatch@numverts{16}% + \let\pgfplotslibrarysurfstreamcoord=\pgfplotslibrarysurfstreamcoord@cubicpatch + \def\pgfplotslibrarysurf@edgeflag{\pgfplotscharno{0}}% + \else + \pgfplotslibrarysurf@initstream@wrongtype + \fi +}% +\def\pgfplotslibrarysurf@initstream@wrongtype{% + \pgfplots@error{CRITICAL: shader=interp: got unsupported pdf shading type '\pgfplotslibrarysurf@type'. This may correct your pdf!}% }% \def\pgfplotslibrarysurfstreamend{% - \pgfplotsapplistXlet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum - \pgfplotsapplistXnewempty\pgfplotslibrarysurf@binarystream@accum + \pgfplotsapplistXgloballet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum + \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum }% % #1: a pgf point. @@ -195,11 +232,131 @@ \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa %\message{\pgfplotsbinaryresult.}% \t@pgfplots@tokc=\expandafter{\pgfplotsbinaryresult}% - \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% - \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum + \edef\pgfplots@loc@TMPa{\pgfplotslibrarysurf@edgeflag\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsapplistXglobalpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum \pgfplotslibrarysurf@advancestreamlen{10}% } +\def\pgfplotslibrarysurf@translate@colorspace{% + \pgfkeysgetvalue{/pgfplots/surf shading/colorspace}\pgfplots@loc@TMPd + \edef\pgfplots@loc@TMPd{\pgfplots@loc@TMPd}% + \def\pgfplots@loc@TMPa{rgb}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{RGB}% + \else + \def\pgfplots@loc@TMPa{cmyk}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{CMYK}% + \else + \def\pgfplots@loc@TMPa{cmy}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{CMY}% + \else + \pgfplots@error{Sorry, the 'surfshading' lib failed to recognise the '/pgfplots/surf shading=\pgfplots@loc@TMPd\space choice... maybe you misspelled it?}% + \def\pgfplotsretval{RGB}% + \fi + \fi + \fi +}% + +% special routine for coons type patches and cubic tensor product type +% patches. It has FIRST all vertices, +% THEN the cdata. Furthermore, it only has 4 CDATA points, but a total +% of 12 vertices. +% +% #1: a pgf point. +% #2: a color coordinate in the range [0,1000] +\def\pgfplotslibrarysurfstreamcoord@cubicpatch#1#2{% + \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercoordinate% + %\pgf@process{#1}% this here causes `{retaining \pgf@x}' messages and pollutes the save stack! Avoid it. See \tracingrestores=2 + #1% + % The idea is to map + % the low-level point coordinates LINEARLY into [0,2^{8*<bytes>}]. + % + % This is what the pdf standard expects for surface shadings. + % + % To do that, we simply map + % [-16384,16384] linearly into [0,2^{32}] + % and write the resulting integer in big endian binary format to + % the pdf low level stream. + % + % The decode procedure tells the pdf viewer how to invert that + % stuff. + % + \pgf@xa=\pgf@x + \pgf@sys@bp@correct\pgf@xa% + \pgfplotsbinaryencodedimenmaplinearly\pgf@xa +%\message{POINT \the\c@pgfplots@scanlineindex: ENCODING(x=\the\pgf@x)=\pgfplotsbinaryresult.}\advance\c@pgfplots@scanlineindex by1 + \t@pgfplots@toka=\expandafter{\pgfplotsbinaryresult}% + \pgf@ya=\pgf@y + \pgf@sys@bp@correct\pgf@ya% + \pgfplotsbinaryencodedimenmaplinearly\pgf@ya +%\message{ENCODING(y=\the\pgf@y)=\pgfplotsbinaryresult.}% + \t@pgfplots@tokb=\expandafter{\pgfplotsbinaryresult}% + \def\pgfplotslibrarysurf@cubicpatch@hascdata{0}% + \ifnum\c@pgfplotslibrarysurf@no=0 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + % prepend edge flag. it is a new patch. + \t@pgfplots@toka=\expandafter{\expandafter\pgfplotslibrarysurf@edgeflag\the\t@pgfplots@toka}% + \else + \ifnum\c@pgfplotslibrarysurf@no=3 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + \else + \ifnum\c@pgfplotslibrarysurf@no=6 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + \else + \ifnum\c@pgfplotslibrarysurf@no=9 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + \fi + \fi + \fi + \fi + \if1\pgfplotslibrarysurf@cubicpatch@hascdata + {% + % read fixed point input (in the range [0,1000]). + \pgf@xa=#2pt + % convert to integer (= *65536): + \c@pgf@counta=\pgf@xa + % provide map [0,1000] -> [0,2^16-1] + \divide\c@pgf@counta by1000 + % now, we have \c@pgf@counta in [0,2^16]. Simply strip it into + % the required range, that's ok. + \ifnum\c@pgf@counta<0 + \c@pgf@counta=0 + \else + \ifnum\c@pgf@counta>65535 + \c@pgf@counta=65535 + \fi + \fi + % Now, we have CDATA in the range [0,65535] + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + %\message{ENCODING(C=\pgfplots@glob@TMPa\space for \the\pgf@xa)=}% + }% + \pgfplotsbinarysetbytes2% + \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa + %\message{\pgfplotsbinaryresult.}% + \t@pgfplots@tokc=\expandafter{\pgfplotslibrarysurf@cubicpatch@cdata}% + \xdef\pgfplotslibrarysurf@cubicpatch@cdata{% + \the\t@pgfplots@tokc + \pgfplotsbinaryresult + }% + \fi + \global\advance\c@pgfplotslibrarysurf@no by1 + % + \ifnum\pgfplotslibrarysurf@cubicpatch@numverts=\c@pgfplotslibrarysurf@no %finalize patch. + \t@pgfplots@tokc=\expandafter{\pgfplotslibrarysurf@cubicpatch@cdata}% + \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty + \global\c@pgfplotslibrarysurf@no=0 + \else + \t@pgfplots@tokc={}% + \fi + % edge flag is already in \t@pgfplots@toka (if this is the first + % vertex) + \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsapplistXglobalpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum + %\pgfplotslibrarysurf@advancestreamlen{10}% +} + \def\pgfplotslibrarysurfactivateshadefill{% \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa% \expandafter\pgfutil@addpdfresource@patterns\expandafter{\pgfplots@loc@TMPa}%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex index 06bade77b9e..4f414535eec 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex @@ -36,18 +36,22 @@ \def\use@@pgfplotslibrary#1{% \edef\pgf@list{#1}% \pgfutil@for\pgf@temp:=\pgf@list\do{% - \expandafter\ifx\csname pgfp@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% - \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} - \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} - \catcode`\@=11 - \catcode`\|=12 - \pgfplots@iffileexists{tikzlibrarypgfplots.\pgf@temp.code.tex}{% - \input tikzlibrarypgfplots.\pgf@temp.code.tex}{% - \input pgflibrarypgfplots.\pgf@temp.code.tex}% - \catcode`\@=\csname tikz@library@#1@atcode\endcsname - \catcode`\|=\csname tikz@library@#1@barcode\endcsname - \fi% + \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% + \ifx\pgf@temp\pgfutil@empty + \else + \expandafter\ifx\csname pgfp@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \pgfplots@iffileexists{tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input pgflibrarypgfplots.\pgf@temp.code.tex}% + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \fi% + \fi }% } diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex new file mode 100644 index 00000000000..d6060e15e2b --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex @@ -0,0 +1,99 @@ +%-------------------------------------------- +% +% Package pgfplots, library for additional colormaps, especially those +% related to matlab (tm). +% +% Copyright 2011 by Christian Feuersänger and Patrick Häcker. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +% + +\pgfplotsset{ + /pgfplots/colormap/autumn/.style={ + /pgfplots/colormap={autumn}{rgb255=(255,0,0) rgb255=(255,255,0)} + }, + /pgfplots/colormap/bled/.style={ + /pgfplots/colormap={bled}{rgb255=(0,0,0) rgb255=(43,43,0) rgb255=(0,85,0) rgb255=(0,128,128) rgb255=(0,0,170) rgb255=(213,0,213) rgb255=(255,0,0)} + }, + /pgfplots/colormap/bright/.style={ + /pgfplots/colormap={bright}{rgb255=(0,0,0) rgb255=(78,3,100) rgb255=(2,74,255) rgb255=(255,21,181) rgb255=(255,113,26) rgb255=(147,213,114) rgb255=(230,255,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/cold/.style={ + /pgfplots/colormap={cold}{rgb255=(0,0,0) rgb255=(0,0,255) rgb255=(0,255,255) rgb255=(255,255,255)} + }, + /pgfplots/colormap/copper/.style={ + /pgfplots/colormap={copper}{[1cm]rgb255(0cm)=(0,0,0) rgb255(4cm)=(255,159,101) rgb255(5cm)=(255,199,127)} + }, + /pgfplots/colormap/copper2/.style={ + /pgfplots/colormap={copper2}{rgb255=(0,0,0) rgb255=(68,62,63) rgb255=(170,112,95) rgb255=(207,194,138) rgb255=(255,255,255)} + }, + /pgfplots/colormap/earth/.style={ + /pgfplots/colormap={earth}{rgb255=(0,0,0) rgb255=(0,28,15) rgb255=(42,39,6) rgb255=(28,73,33) rgb255=(67,85,24) rgb255=(68,112,46) rgb255=(81,129,83) rgb255=(124,137,87) rgb255=(153,147,122) rgb255=(145,173,164) rgb255=(144,202,180) rgb255=(171,220,177) rgb255=(218,229,168) rgb255=(255,235,199) rgb255=(255,255,255)} + }, + /pgfplots/colormap/gray/.style={ + /pgfplots/colormap={gray}{rgb255=(0,0,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/hsv/.style={ + /pgfplots/colormap={hsv}{rgb255=(255,0,0) rgb255=(255,255,0) rgb255=(0,255,0) rgb255=(0,255,255) rgb255=(0,0,255) rgb255=(255,0,255) rgb255=(255,0,0)} + }, + /pgfplots/colormap/hsv2/.style={ + /pgfplots/colormap={hsv2}{rgb255=(0,0,0) rgb255=(128,0,128) rgb255=(0,0,230) rgb255=(0,255,255) rgb255=(0,255,0) rgb255=(255,255,0) rgb255=(255,0,0)} + }, + /pgfplots/colormap/pastel/.style={ + /pgfplots/colormap={pastel}{rgb255=(0,0,0) rgb255=(120,0,5) rgb255=(0,91,172) rgb255=(215,35,217) rgb255=(120,172,78) rgb255=(255,176,24) rgb255=(230,255,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/pink/.style={ + /pgfplots/colormap={pink}{rgb255=(0,0,0) rgb255=(12,16,46) rgb255=(62,22,43) rgb255=(53,53,65) rgb255=(79,72,58) rgb255=(122,80,67) rgb255=(147,91,102) rgb255=(147,115,140) rgb255=(144,145,154) rgb255=(173,163,146) rgb255=(216,171,149) rgb255=(250,179,179) rgb255=(255,198,227) rgb255=(246,229,255) rgb255=(255,255,255)} + }, + /pgfplots/colormap/sepia/.style={ + /pgfplots/colormap={sepia}{rgb255(0cm)=(0,0,0) rgb255(1cm)=(26,13,0) rgb255(18cm)=(255,230,204) rgb255(20cm)=(255,255,255)} + }, + /pgfplots/colormap/bone/.style={ + /pgfplots/colormap={bone}{[1cm]rgb255(0cm)=(0,0,0) rgb255(3cm)=(84,84,116) rgb255(6cm)=(167,199,199) rgb255(8cm)=(255,255,255)} +}, + %-------------------------------------------------- + % % mesh width is too fine for these: + % /pgfplots/colormap/dusk/.style={ + % /pgfplots/colormap={dusk}{ + % [1cm]rgb255(0cm)=(0,0,0) + % rgb255(114cm)=(0,0,128) rgb255(701cm)=(0,128,128) + % rgb255(1000cm)=(128,128,128) rgb255(1299cm)=(255,128,128) + % rgb255(1886cm)=(255,255,128) rgb255(2000cm)=(255,255,255)} + % }, + % /pgfplots/colormap/hicontrast/.style={ + % /pgfplots/colormap={hicontrast}{ + % [1cm]rgb255(0cm)=(0,0,0) rgb255(114cm)=(0,0,255) rgb255(299cm)=(255,0,0) rgb255(413cm)=(255,0,255) + % rgb255(587cm)=(0,255,0) rgb255(701cm)=(0,255,255) rgb255(886cm)=(255,255,0) + % rgb255(1000cm)=(255,255,255)} + % }, + %-------------------------------------------------- + /pgfplots/colormap/spring/.style={ + /pgfplots/colormap={spring}{rgb255=(255,0,255) rgb255=(255,255,0)} + }, + /pgfplots/colormap/summer/.style={ + /pgfplots/colormap={summer}{rgb255=(0,128,102) rgb255=(255,255,102)} + }, + /pgfplots/colormap/temp/.style={ + /pgfplots/colormap={temp}{rgb255=(36,0,217) rgb255=(25,29,247) rgb255=(41,87,255) rgb255=(61,135,255) rgb255=(87,176,255) rgb255=(117,211,255) rgb255=(153,235,255) rgb255=(189,249,255) rgb255=(235,255,255) rgb255=(255,255,235) rgb255=(255,242,189) rgb255=(255,214,153) rgb255=(255,172,117) rgb255=(255,120,87) rgb255=(255,61,61) rgb255=(247,40,54) rgb255=(217,22,48) rgb255=(166,0,33)} + }, + /pgfplots/colormap/thermal/.style={ + /pgfplots/colormap={thermal}{rgb255=(0,0,0) rgb255=(77,0,179) rgb255=(255,51,0) rgb255=(255,255,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/winter/.style={ + /pgfplots/colormap={winter}{rgb255=(0,0,255) rgb255=(0,255,128)} + }, +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex index 8ac9a7631c0..7e7e5232fc0 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex @@ -52,6 +52,12 @@ \advance\pgf@xa by-\the\c@pgf@countb pt \ifdim\pgf@xa>0.5pt \advance\c@pgf@countb by1 + \ifnum\c@pgf@countb=60 + \c@pgf@countb=#4 % + \advance\c@pgf@countb by1 + \edef#4{\the\c@pgf@countb}% + \c@pgf@countb=0 + \fi \fi \edef#5{\the\c@pgf@countb}% } @@ -94,8 +100,8 @@ \let\pgfplots@calender@ZEROSHIFT=\pgfmathresult }, date ZERO=2006-01-01, - /pgfplots/date coordinates in/.style={ - /pgfplots/#1 coord trafo/.code={% + /pgfplots/date coordinates in/.code={% + \pgfkeysdef{/pgfplots/#1 coord trafo}{% \begingroup \edef\pgfplotstempjuliandate{##1}% % check if we also have a TIME like '2006-01-01 11:21' @@ -126,8 +132,8 @@ \fi \pgfmath@smuggleone\pgfmathresult \endgroup - }, - /pgfplots/#1 coord inv trafo/.code={% + }% + \pgfkeysdef{/pgfplots/#1 coord inv trafo}{% \begingroup \pgfplotslibdateplot@number@to@julian@and@time##1\julianto{\c@pgf@counta}\hourto\Hour\minuteto\Minute% \advance\c@pgf@counta by\pgfplots@calender@ZEROSHIFT\relax @@ -152,12 +158,43 @@ \def\Second{0}% \def\second{00}% \edef\lowlevel{##1}% - \edef\pgfmathresult{\year-\month-\day}% - }, - /pgfplots/#1ticklabel={\tick},% - /pgfplots/scaled #1 ticks=false, - /pgfplots/plot coordinates/math parser=false,% + \pgfkeysifdefined{/pgfplots/date default inv/#1}{% + \edef\pgfmathresult{\pgfkeysvalueof{/pgfplots/date default inv/#1}}% + }{% + \edef\pgfmathresult{\year-\month-\day\space\hour:\minute:\second}% + }% + }% + \pgfkeysifdefined{/pgfplots/#1ticklabel/.@cmd}{% + \pgfkeysalso{% + /pgfplots/#1ticklabel={\tick},% + /pgfplots/scaled #1 ticks=false,% + /pgfplots/plot coordinates/math parser=false,% + }% + }{% + % OK. The style can be used for other coordinates as well + % (like hist/data) + }% + % + \pgfkeysifdefined{/pgfplots/#1 is expr}{% + \pgfkeyssetvalue{/pgfplots/#1 is expr}{0}% + }{}% + % + % Allow a callback (optional) + \pgfkeysifdefined{/pgfplots/#1/@execute on coord trafo changed/.@cmd}{% + \pgfkeysalso {/pgfplots/#1/@execute on coord trafo changed}% + }{}% }, /pgfplots/date coordinates in/.value required, + % + % #1: the argument for 'data coordinates in={#1} + % #2: the default for the inverse transformation. If there is + % none, a default will be chosen automatically (with full + % information) + /pgfplots/date coordinates default inverse/.style 2 args={% + /pgfplots/date default inv/#1/.initial=#2, + }, + /pgfplots/date coordinates default inverse={x}{\year-\month-\day}, + /pgfplots/date coordinates default inverse={y}{\year-\month-\day}, + /pgfplots/date coordinates default inverse={z}{\year-\month-\day}, } diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex index 5086fef9d47..32b0e5f32ee 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex @@ -56,38 +56,58 @@ /pgfplots/group/shared labels=false, /pgfplots/group/xticklabels at/.is choice, /pgfplots/group/xticklabels at/all/.code=\def\pgfplots@group@xticklabels{all}, - /pgfplots/group/xticklabels at/edge top/.code=\def\pgfplots@group@xticklabels{upper}, + /pgfplots/group/xticklabels at/edge top/.code=\def\pgfplots@group@xticklabels{top}, /pgfplots/group/xticklabels at/edge bottom/.code=\def\pgfplots@group@xticklabels{lower}, + /pgfplots/group/xticklabels at/edge left/.code=\def\pgfplots@group@xticklabels{left}, % TODO + /pgfplots/group/xticklabels at/edge right/.code=\def\pgfplots@group@xticklabels{right}, % TODO /pgfplots/group/xticklabels at=all, /pgfplots/group/yticklabels at/.is choice, /pgfplots/group/yticklabels at/all/.code=\def\pgfplots@group@yticklabels{all}, /pgfplots/group/yticklabels at/edge left/.code=\def\pgfplots@group@yticklabels{left}, /pgfplots/group/yticklabels at/edge right/.code=\def\pgfplots@group@yticklabels{right}, + /pgfplots/group/yticklabels at/edge top/.code=\def\pgfplots@group@yticklabels{top}, % TODO + /pgfplots/group/yticklabels at/edge bottom/.code=\def\pgfplots@group@yticklabels{bottom}, % TODO /pgfplots/group/yticklabels at=all, /pgfplots/group/xlabels at/.is choice, /pgfplots/group/xlabels at/all/.code=\def\pgfplots@group@xlabels{all}, - /pgfplots/group/xlabels at/edge top/.code=\def\pgfplots@group@xlabels{upper}, + /pgfplots/group/xlabels at/edge top/.code=\def\pgfplots@group@xlabels{top}, /pgfplots/group/xlabels at/edge bottom/.code=\def\pgfplots@group@xlabels{lower}, + /pgfplots/group/xlabels at/edge right/.code=\def\pgfplots@group@xlabels{right}, % TODO + /pgfplots/group/xlabels at/edge left/.code=\def\pgfplots@group@xlabels{left},% TODO /pgfplots/group/xlabels at=all, /pgfplots/group/ylabels at/.is choice, /pgfplots/group/ylabels at/all/.code=\def\pgfplots@group@ylabels{all}, /pgfplots/group/ylabels at/edge left/.code=\def\pgfplots@group@ylabels{left}, /pgfplots/group/ylabels at/edge right/.code=\def\pgfplots@group@ylabels{right}, + /pgfplots/group/ylabels at/edge top/.code=\def\pgfplots@group@ylabels{top}, % TODO + /pgfplots/group/ylabels at/edge bottom/.code=\def\pgfplots@group@ylabels{bottom}, % TODO /pgfplots/group/ylabels at=all, /pgfplots/group/x descriptions at/.is choice, - /pgfplots/group/x descriptions at/all/.style= - {/pgfplots/group/xlabels at=all,/pgfplots/group/xticklabels at=all}, - /pgfplots/group/x descriptions at/edge bottom/.style= - {/pgfplots/group/xlabels at=edge bottom, /pgfplots/group/xticklabels at=edge bottom}, - /pgfplots/group/x descriptions at/edge top/.style= - {/pgfplots/group/xlabels at=edge top, /pgfplots/group/xticklabels at=edge top}, + /pgfplots/group/x descriptions at/all/.style={ + /pgfplots/group/xlabels at=all, + /pgfplots/group/xticklabels at=all + }, + /pgfplots/group/x descriptions at/edge bottom/.style={ + /pgfplots/group/xlabels at=edge bottom, + /pgfplots/group/xticklabels at=edge bottom + }, + /pgfplots/group/x descriptions at/edge top/.style={ + /pgfplots/group/xlabels at=edge top, + /pgfplots/group/xticklabels at=edge top + }, /pgfplots/group/y descriptions at/.is choice, - /pgfplots/group/y descriptions at/all/.style= - {/pgfplots/group/ylabels at=all, /pgfplots/group/yticklabels at=all}, - /pgfplots/group/y descriptions at/edge left/.style= - {/pgfplots/group/ylabels at=edge left, /pgfplots/group/yticklabels at=edge left}, - /pgfplots/group/y descriptions at/edge right/.style= - {/pgfplots/group/ylabels at=edge right, /pgfplots/group/yticklabels at=edge right}, + /pgfplots/group/y descriptions at/all/.style={ + /pgfplots/group/ylabels at=all, + /pgfplots/group/yticklabels at=all + }, + /pgfplots/group/y descriptions at/edge left/.style={ + /pgfplots/group/ylabels at=edge left, + /pgfplots/group/yticklabels at=edge left + }, + /pgfplots/group/y descriptions at/edge right/.style={ + /pgfplots/group/ylabels at=edge right, + /pgfplots/group/yticklabels at=edge right + }, /pgfplots/group/group name/.store in=\pgfplots@group@name, /pgfplots/group/empty plot/.style={/pgfplots/hide axis=true}, } @@ -200,9 +220,9 @@ }% \fi% \else - \def\pgfplots@loc@TMPb{upper}% + \def\pgfplots@loc@TMPb{top}% \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% - % xlabels at=upper + % xlabels at=top \ifnum1<\pgfplots@group@rows\relax \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% @@ -264,7 +284,7 @@ % \def\pgfplots@group@determine@ticklabels{% \def\pgfplots@loc@TMPa{all} - \def\pgfplots@loc@TMPb{upper} + \def\pgfplots@loc@TMPb{top} \def\pgfplots@loc@TMPc{lower} \ifx\pgfplots@loc@TMPa\pgfplots@group@xticklabels% % Do nothing as all should have xticklabels diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex new file mode 100644 index 00000000000..4076e37281c --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex @@ -0,0 +1,1783 @@ +%-------------------------------------------- +% +% Package pgfplots, library for higher order patch plots. +% It contains advanced patch plots like quadratic triangles, +% biquadratic quadrilaterals, coons patches and others. +% The basic implementation for patches supports already line, triangle +% and rectangle (=2 triangles) patches. +% +% Copyright 2007/2008/2009 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + + % NOTES: + % In general, a Bezier spline C:[0,1] -> \R of order n fulfills + % C'(0) = n ( P_1 - P_0 ), + % C'(1) = n ( P_n - P_{n-1} ). + % For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know + % the derivatives at t=0 and t=1. + % + % + % +%-------------------------------------------------- +% 4-point Lagrange interpolation on {0,1/3,2/3,1}: +% C(x) = +% a * (1/3 - x)/(1/3) * (2/3-x)/(2/3) * (1-x) + +% b * (0 - x)/(0 - 1/3) * (2/3-x)/(2/3-1/3) * (1-x)/(1-1/3) + +% c * (0 - x)/(0 - 2/3) * (1/3-x)/(1/3-2/3) * (1-x)/(1-2/3) + +% d * (0 - x)/(0 - 1) * (1/3-x)/(1/3-1) * (2/3-x) /(2/3-1) +% +% +% Derivative: +% +% (-9*c + 2*d + 72*c*x - 18*d*x - 81*c*x^2 + 27*d*x^2 + +% a*(-11 + 36*x - 27*x^2) + 9*b*(2 - 10*x + 9*x^2))/2 +% +% bezier control points are +% P1 = (-5*a)/6 + 3*b - (3*c)/2 + d/3 +% = -0.833333 a + 3. b - 1.5 c + 0.333333 d +% +% P2 = 0.333333 (0.5 (2. a - 9. b + 18. c - 11. d) + 3. d) +% = 0.333333 a - 1.5 b + 3. c - 0.833333 d +%-------------------------------------------------- + + + +\pgfplotsdeclarepatchclass{quadratic spline}{% + allow matrix=0, + uses view depth=0, + new=\def\pgfplotspatchclass@qspline@no{A}, + set next vertex={% + % EXPECTED ORDERING: first 2 corners, then 1 mid nodes + % (interpolatory). + % defines \pgfplotspatchclass@qspline@A ... \pgfplotspatchclass@qspline@C (3 points) + \expandafter\edef\csname pgfplotspatchclass@qspline@\pgfplotspatchclass@qspline@no\endcsname{#1}% + \if C\pgfplotspatchclass@qspline@no + \def\pgfplotspatchclass@qspline@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@qspline@no\csname pgfpptchindexnext@\pgfplotspatchclass@qspline@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@C\endvertex #1% + }, + fill path={% + \begingroup + % Draw the patch boundary using a bezier curves. + % + % Since I have lagrange points to describe the patch (i.e. + % points the patch passes through), I have to convert the + % lagrange representation to bezier. + % + % Furthermore, I convert to *cubic* bezier since pdf only + % supports cubic curves. + % + % See the docs for 'biquadratic::fill path' for more details, + % in does the same. + \def\pgfplots@edge{% + \ifx\pgfplotspatchclass@qspline@A\PA + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% + \fi + \pgfpathcurveto {% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{% + \expandafter\pgfplotspointpatchvertex\PC\endvertex + }% + }% + \let\PA=\pgfplotspatchclass@qspline@A + \let\PB=\pgfplotspatchclass@qspline@C + \let\PC=\pgfplotspatchclass@qspline@B + \pgfplots@edge + \endgroup + }, + triangulate class=line, + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{line}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@B}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + recursive refine@={% + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@C\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qspline@AC + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@AC}% + #1% + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@C\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qspline@CB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@CB}% + #1% + % + },% + get pdf shading type=0, + get num vertices=3, +}% + +\pgfplotsdeclarepatchclass{cubic spline}{% + allow matrix=0, + uses view depth=0, + new=\def\pgfplotspatchclass@cspline@no{A}, + set next vertex={% + % EXPECTED ORDERING: first 2 corners, then 1 mid nodes + % (interpolatory). + % defines \pgfplotspatchclass@cspline@A ... \pgfplotspatchclass@cspline@D (4 points) + \expandafter\edef\csname pgfplotspatchclass@cspline@\pgfplotspatchclass@cspline@no\endcsname{#1}% + \if D\pgfplotspatchclass@cspline@no + \def\pgfplotspatchclass@cspline@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@cspline@no\csname pgfpptchindexnext@\pgfplotspatchclass@cspline@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@D\endvertex #1% + }, + fill path={% + % Draw the patch boundary using a bezier curve. + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@A\endvertex}% + % switch basis from lagrange to bezier (see formular on top of + % this file) + \pgfpathcurveto {% + \begingroup + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@A\times{-0.833333}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@C\times{3}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@D\times{-1.5}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@B\times{0.3333333}% + \pgfplotspatchvertexfinish\pgfplots@loc@TMPa + \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex + \endgroup + }{% + \begingroup + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@A\times{0.333333}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@C\times{-1.5}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@D\times{3}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@B\times{-0.833333}% + \pgfplotspatchvertexfinish\pgfplots@loc@TMPa + \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex + \endgroup + }{% + \expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@B\endvertex + }% + }, + triangulate class=line, + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{line}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@B}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + recursive refine@={% + % The 4-point lagrangian interpolation formular is shown on + % the top of this page. What I do here is simply to evaluate + % C(i*1/9) for i =0,...,9: + % 0 + % 0.493827 A +0.740741 C -0.296296 D +0.0617284 B + % 0.17284 A +1.03704 C -0.259259 D +0.0493827 B + % 1/3 + % -0.0617284 A +0.740741 C +0.37037 D -0.0493827 B + % -0.0493827 A +0.37037 C +0.740741 D -0.0617284 B + % 2/3 + % 0.0493827 A -0.259259 C +1.03704 D +0.17284 B + % 0.0617284 A -0.296296 C +0.740741 D +0.493827 B + % 1 + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.740741}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{-0.296296}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.17284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{1.03704}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{-0.259259}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}% + #1% + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{-0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{-0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.740741}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.37037}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{-0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{-0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.37037}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.740741}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}% + #1% + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.17284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{-0.259259}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{+1.03704}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{-0.296296}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.740741}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}% + #1% + }, + get pdf shading type=0, + get num vertices=4, +}% + +% make a linearized sequence around the edge of the quad.triangle. +% note the ordering: first 3 corners, then 3 mid nodes: +\def\pgfplots@qtri@next@A{D}% +\def\pgfplots@qtri@next@B{E}% +\def\pgfplots@qtri@next@C{F}% +\def\pgfplots@qtri@next@D{B}% +\def\pgfplots@qtri@next@E{C}% +\def\pgfplots@qtri@next@F{A}% + +\def\pgfplots@qtri@rnext@A{F}% +\def\pgfplots@qtri@rnext@B{D}% +\def\pgfplots@qtri@rnext@C{E}% +\def\pgfplots@qtri@rnext@D{A}% +\def\pgfplots@qtri@rnext@E{B}% +\def\pgfplots@qtri@rnext@F{C}% + +\def\pgfplotspatchclass@qtri@recursiverefine@newnames{% + \let\pgfplotspatchclass@qtri@A@=\pgfplotspatchclass@qtri@A% + \let\pgfplotspatchclass@qtri@B@=\pgfplotspatchclass@qtri@B% + \let\pgfplotspatchclass@qtri@C@=\pgfplotspatchclass@qtri@C% + \let\pgfplotspatchclass@qtri@D@=\pgfplotspatchclass@qtri@D% + \let\pgfplotspatchclass@qtri@E@=\pgfplotspatchclass@qtri@E% + \let\pgfplotspatchclass@qtri@F@=\pgfplotspatchclass@qtri@F% +}% + + +% A 3-point interpolatory patch which draws quadratic polynomial +% splines (functions f(x), x 1d). +\pgfplotsdeclarepatchclass{triangle quadr}{% + allow matrix=0, + uses view depth=1, + new=\def\pgfplotspatchclass@qtri@no{A}\let\pgfplotspatchclass@qtrie@AB\relax, + set next vertex={% + % EXPECTED ORDERING: first 3 corners, then 3 mid nodes. + % defines \pgfplotspatchclass@qtri@A ... \pgfplotspatchclass@qtri@F (6 points) + \expandafter\edef\csname pgfplotspatchclass@qtri@\pgfplotspatchclass@qtri@no\endcsname{#1}% + \if F\pgfplotspatchclass@qtri@no + \def\pgfplotspatchclass@qtri@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@qtri@no\csname pgfpptchindexnext@\pgfplotspatchclass@qtri@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@F\endvertex #1% + }, + fill path={% + \begingroup + % Draw the patch boundary using three bezier curves. + % + % Since I have lagrange points to describe the patch (i.e. + % points the patch passes through), I have to convert the + % lagrange representation to bezier. + % + % Furthermore, I convert to *cubic* bezier since pdf only + % supports cubic curves. + % + % See the docs for 'biquadratic::fill path' for more details, + % in does the same. + \def\pgfplots@edge{% + \ifx\pgfplotspatchclass@qtri@A\PA + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% + \fi + \pgfpathcurveto {% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{% + \expandafter\pgfplotspointpatchvertex\PC\endvertex + }% + }% + \let\PA=\pgfplotspatchclass@qtri@A + \let\PB=\pgfplotspatchclass@qtri@D + \let\PC=\pgfplotspatchclass@qtri@B + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@qtri@B + \let\PB=\pgfplotspatchclass@qtri@E + \let\PC=\pgfplotspatchclass@qtri@C + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@qtri@C + \let\PB=\pgfplotspatchclass@qtri@F + \let\PC=\pgfplotspatchclass@qtri@A + \pgfplots@edge + \endgroup + \pgfpathclose + }, + %-------------------------------------------------- + % stroke path={% + % \ifx\pgfplotspatchclass@qtrie@AB\relax + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}% + % \pgfpathclose + % \else + % \if1\pgfplotspatchclass@qtrie@AB + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}% + % \fi + % \if1\pgfplotspatchclass@qtrie@BC + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}% + % \fi + % \if1\pgfplotspatchclass@qtrie@CA + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}% + % \fi + % \fi + % }, + %-------------------------------------------------- + stream to shader={% + % create a degenerate coons patch: + \begingroup +%\message{EDGE INIT^^J}% + % this defines \Pcur and \Pnextseq : + \pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth + % + \pgfutil@namelet{Pstart}{pgfplotspatchclass@qtri@\Pcur}% + % + % see the docus for "fill path" about these 1.33333 and -0.33333 factors + \def\pgfplots@coonsedge{% +%\message{EDGE \Pcur^^J}% + \expandafter\let\expandafter\PA\csname pgfplotspatchclass@qtri@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@qtri@\Pnextseq next@\Pcur\endcsname}% +%\message{---> \Pcur^^J}% + \expandafter\let\expandafter\PB\csname pgfplotspatchclass@qtri@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@qtri@\Pnextseq next@\Pcur\endcsname}% +%\message{---> \Pcur^^J}% + \expandafter\let\expandafter\PC\csname pgfplotspatchclass@qtri@\Pcur\endcsname + \ifx\PA\Pstart + \expandafter\pgfplotspatchvertex\PA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + % degenerate: the "edge" \PA -- \PA collabses into one + % point. + % Per construction, the "edge" is the FOREGROUND. +%\message{STREAMING COLLAPSED EDGE AT START POINT^^J}% + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{}% + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{}% + \ifx\PC\Pstart + \else + \expandafter\pgfplotspatchvertex\PC\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + }% + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + % + \endgroup + },% + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + % Ok. Now create 4 triangles. The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}% + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}00% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}% + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + set edge visible={% + \ifcase#1 + \edef\pgfplotspatchclass@qtrie@AB{#2}% + \or + \edef\pgfplotspatchclass@qtrie@BC{#2}% + \or + \edef\pgfplotspatchclass@qtrie@CA{#2}% + \fi + }, + serialize except vertices={% + \ifx\pgfplotspatchclass@qtrie@AB\relax + \let\pgfplotsretval\pgfutil@empty% + \else + \edef\pgfplotsretval{% + \noexpand\def\noexpand\pgfplotspatchclass@qtrie@AB{\pgfplotspatchclass@qtrie@AB}% + \noexpand\def\noexpand\pgfplotspatchclass@qtrie@BC{\pgfplotspatchclass@qtrie@BC}% + \noexpand\def\noexpand\pgfplotspatchclass@qtrie@CA{\pgfplotspatchclass@qtrie@CA}% + }% + \fi + },% + deserialize except vertices=% + \let\pgfplotspatchclass@qtrie@AB\relax + #1, + recursive refine@={% + \pgfplotspatchclass@qtri@recursiverefine@newnames + % + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20% + %-------------------------------------------------- + % The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + % + % I used the reference triangle and shape functions as listed in + % http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/ + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@AD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DF + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@AF + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@A@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@AF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@AD}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DF}% + % + #1\pgfplotspatchclass@qtri@recursiverefine@newnames + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DF + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DE + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EF + % + % + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}00% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}10% + %-------------------------------------------------- + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DE}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EF}% + % % + % %-------------------------------------------------- + % % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % %-------------------------------------------------- + #1\pgfplotspatchclass@qtri@recursiverefine@newnames + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DE + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@BE + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@B@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DB}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@BE}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DE}% + % + #1\pgfplotspatchclass@qtri@recursiverefine@newnames + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EC + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EF + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@CF + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@C@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EC}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@CF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EF}% + % + #1% + % + },% + get pdf shading type=6, + get num vertices=6, +}% + + +% see +% \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth +% and its documentation. +% +% POSTCONDITION: +% \Pcur and \Pnextseq are defined. +\def\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth{% + \def\Pcur{A}% + \def\Pnextseq{}% + % + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex + \ifx\pgfplotspatchvertexdepth\pgfutil@empty + \else + % ah. We have view depth. Use it! + % The idea here is as follows. + % According to pdf standard, the COONS Shading is + % generated in the unit cube and then mapped to the + % shading. If u,v in [0,1] are the coordinates in the unit + % cube, pixel values for v=1 overwrite values for v=0. + % If pixel values have the same v, u=1 overwrites u=0. + % In other words, the loop is + % for v= 0 to Nv + % for u = 0 to Nu + % shade pixel for (u,v) + % + % BB-------CC <--v=1 + % | | + % | | + % | | + % AA-------DD <--v=0 + % | | + % u=0 u=1 + % + % + % IDEA: re-order the sequence of vertices such that z + % buffering is obtained. + % + % APPROACH: + % the edge BB--CC collapses into just one point, namely + % the FOREGROUND point (i.e. it is drawn on top of + % everything else). + % + % The AA point is the second nearest foreground point. + % The sequence is chosen such that AA,BB is the first + % edge. + % + % What is to do (besides determining the vertices for AA + % and BB)? Well, make sure, that we can arrange them in + % the desired order. This involves a periodic "next vertex" + % algorithm which might either go forward + % or backward. + % + % sort according to depth. + % To do so, prepare macros \PA,\PB,\PC for use in + % \pgfplotsutilsortthree. FORMAT: + % \PA={<sortkey>pt <originalindex>} + \edef\PA{\pgfplotspatchvertexdepth pt A}% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex + \edef\PB{\pgfplotspatchvertexdepth pt B}% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex + \edef\PC{\pgfplotspatchvertexdepth pt C}% + \pgfplotsutilsortthree\PA\PB\PC + \def\toCHAR##1pt ##2{##2}% get original index + % + \edef\Pcur{\expandafter\toCHAR\PB}%% + \edef\Pnext{\csname pgfplots@qtri@next@\Pcur\endcsname}% + \edef\Pnext{\csname pgfplots@qtri@next@\Pnext\endcsname}% + \if\Pnext\PA + % ok, next(next(AA)) = BB. + % that means we have to advance forward. + \def\Pnextseq{}% + \else + % well, since we have a triangle, there only remains + % the backwards direction. + \def\Pnextseq{r}% + \fi +%\message{FOREGROUND VERTEX = \PA.^^J}% +%\message{SECOND NEAREST VERTEX = \PB.^^J}% + \fi +} +\def\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth@no@op{% + \def\Pcur{A}% + \def\Pnextseq{}% +} + +% bilinear is the same as 'rectangle', but it uses a different shader. +\pgfplotsdeclarepatchclass{bilinear}{% + allow matrix=1, + new=\def\pgfplotspatchclass@rect@no{0}, + set next vertex={% + \ifcase\pgfplotspatchclass@rect@no\relax + \edef\pgfplotspatchclass@rect@A{#1}% + \def\pgfplotspatchclass@rect@no{1}% + \or + \edef\pgfplotspatchclass@rect@B{#1}% + \def\pgfplotspatchclass@rect@no{2}% + \or + \edef\pgfplotspatchclass@rect@C{#1}% + \def\pgfplotspatchclass@rect@no{3}% + \or + \edef\pgfplotspatchclass@rect@D{#1}% + \def\pgfplotspatchclass@rect@no{0}% + \pgfplotspatchready% + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex #1% + }, + stream to shader={% + % create a coons patch: + \begingroup + \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + {pgfplotspatchclass@rect@}{\Pcur}{\Pnextseq}% + % + \pgfutil@namelet{Pstart}{pgfplotspatchclass@rect@\Pcur}% + \def\pgfplots@coonsedge{% +%\message{EDGE \Pcur^^J}% + \expandafter\let\expandafter\PA\csname pgfplotspatchclass@rect@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% +%\message{---> \Pcur^^J}% + \expandafter\let\expandafter\PB\csname pgfplotspatchclass@rect@\Pcur\endcsname + \ifx\PA\Pstart + \expandafter\pgfplotspatchvertex\PA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + % + % CONTROL POINT A+1/3(B-A) + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{0.6666666}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + {\pgfqpointscale{0.3333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + }{}% + % CONTROL POINT A+2/3(B-A) + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{0.3333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + {\pgfqpointscale{0.6666666}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + }{}% + \ifx\PB\Pstart + \else + \expandafter\pgfplotspatchvertex\PB\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + }% + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \endgroup + },% + fill path={% + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@A\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@B\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@C\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@D\endvertex}% + \pgfpathclose + }, + triangulate={% + \pgfplotscoordmath{meta}{parsenumber}{0.25}% + \let\pgfplots@loc@scale=\pgfmathresult + % + \pgf@xa=0pt + \pgf@ya=0pt + \pgf@yb=0pt + \pgfplotscoordmath{meta}{zero}% + \def\pgfplots@loc@accum@mean{% + \advance\pgf@xa by\pgfplotspatchvertexx\relax + \advance\pgf@ya by\pgfplotspatchvertexy\relax + \pgfplotscoordmath{meta}{op}{add}{{\pgfmathresult}{\pgfplotspatchvertexmeta}}% + \ifx\pgfplotspatchvertexdepth\pgfutil@empty + \else + \advance\pgf@yb by\pgfplotspatchvertexdepth pt\relax + \fi + }% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex \pgfplots@loc@accum@mean% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex \pgfplots@loc@accum@mean% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex \pgfplots@loc@accum@mean% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex \pgfplots@loc@accum@mean% + % + \divide\pgf@xa by4 + \divide\pgf@ya by4 + \divide\pgf@yb by4 + \pgfplotscoordmath{meta}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@scale}}% + \edef\pgfplotspatchclass@rect@M{{\the\pgf@xa}{\the\pgf@ya}{\pgfmathresult}\ifx\pgfplotspatchvertexdepth\pgfutil@empty\else \pgf@sys@tonumber\pgf@yb\fi}% + % + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + % Ok. Now create 4 triangles. The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + recursive refine@={% + \pgfplotspatchclass@rect@refine@{#1}% + },% + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=6, + get num vertices=4, +}% + +\pgfplotsdeclarepatchclass{rectangle}{% + recursive refine@={% + \pgfplotspatchclass@rect@refine@{#1}% + },% +} +\def\pgfplotspatchclass@rect@refine@#1{% + \pgfplotspatchclass@rect@recursiverefine@newnames + % + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20% + %-------------------------------------------------- + % The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@M + % + \expandafter\pgfplotspatchclass@rect@refine@@\expandafter{\pgfplotspatchclass@rect@M}{#1}% +} +\def\pgfplotspatchclass@rect@refine@@#1#2{% + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@AB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@DA + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@AB}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@DA}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@AB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@BC + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@AB}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@BC}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@CD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@BC + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@BC}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@CD}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@CD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@DA + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@CD}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@DA}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % +}% + +\def\pgfplotspatchclass@rect@recursiverefine@newnames{% + \let\pgfplotspatchclass@rect@A@=\pgfplotspatchclass@rect@A% + \let\pgfplotspatchclass@rect@B@=\pgfplotspatchclass@rect@B% + \let\pgfplotspatchclass@rect@C@=\pgfplotspatchclass@rect@C% + \let\pgfplotspatchclass@rect@D@=\pgfplotspatchclass@rect@D% +}% + +\def\pgfplots@biquad@next@A{E} +\def\pgfplots@biquad@next@B{F} +\def\pgfplots@biquad@next@C{G} +\def\pgfplots@biquad@next@D{H} +\def\pgfplots@biquad@next@E{B} +\def\pgfplots@biquad@next@F{C} +\def\pgfplots@biquad@next@G{D} +\def\pgfplots@biquad@next@H{A} + + +\def\pgfplots@biquad@rnext@A{H} +\def\pgfplots@biquad@rnext@B{E} +\def\pgfplots@biquad@rnext@C{F} +\def\pgfplots@biquad@rnext@D{G} +\def\pgfplots@biquad@rnext@E{A} +\def\pgfplots@biquad@rnext@F{B} +\def\pgfplots@biquad@rnext@G{C} +\def\pgfplots@biquad@rnext@H{D} + +\def\pgfplotspatchclass@biquad@recursiverefine@newnames{% + \let\pgfplotspatchclass@biquad@A@=\pgfplotspatchclass@biquad@A% + \let\pgfplotspatchclass@biquad@B@=\pgfplotspatchclass@biquad@B% + \let\pgfplotspatchclass@biquad@C@=\pgfplotspatchclass@biquad@C% + \let\pgfplotspatchclass@biquad@D@=\pgfplotspatchclass@biquad@D% + \let\pgfplotspatchclass@biquad@E@=\pgfplotspatchclass@biquad@E% + \let\pgfplotspatchclass@biquad@F@=\pgfplotspatchclass@biquad@F% + \let\pgfplotspatchclass@biquad@G@=\pgfplotspatchclass@biquad@G% + \let\pgfplotspatchclass@biquad@H@=\pgfplotspatchclass@biquad@H% + \let\pgfplotspatchclass@biquad@I@=\pgfplotspatchclass@biquad@I% +}% + + +% mathematica shape functions parameterized in +% (xi,eta) in [-1,1]x[-1,1]: +%f[xi_, eta_] = +% a*1/4*(1 - xi) (1 - eta) xi*eta + +% b 1/4 (-1 - xi) (1 - eta) xi*eta + +% c* 1/4 (-1 - xi) (-1 - eta) xi*eta + +% d *1/4 (1 - xi) (-1 - eta) xi*eta + +% e * 1/2 (xi^2 - 1) (1 - eta) eta + +% f*1/2 (-1 - xi) (eta^2 - 1) xi + +% g* -1/2 (1 - xi^2) (-1 - eta) eta + +% h* -1/2 (1 - xi) (1 - eta^2) xi + +% i*(1 - xi^2) (1 - eta^2) +% here, a,b,...,i are the 9 nodes. +\pgfplotsdeclarepatchclass{biquadratic}{% + allow matrix=0, + new=\def\pgfplotspatchclass@biquad@no{A}\let\pgfplotspatchclass@biquade@AB\relax, + set next vertex={% + % defines \pgfplotspatchclass@biquad@A ... \pgfplotspatchclass@biquad@I (9 points) + \expandafter\edef\csname pgfplotspatchclass@biquad@\pgfplotspatchclass@biquad@no\endcsname{#1}% + \if I\pgfplotspatchclass@biquad@no + \def\pgfplotspatchclass@biquad@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@biquad@no\csname pgfpptchindexnext@\pgfplotspatchclass@biquad@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@F\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@H\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@I\endvertex #1% + }, + fill path={% + \begingroup + % Visualize the patch boundary using four bezier curves. + % + % This involves a change from Lagrange to bezier + % representation of the boundary curves. + % + % Furthermore, pdf supports only **cubic** bezier curves. What + % I am doing here is + % a) change of basis from 3-point lagrange ---> 3 point quadratic bezier + % b) expression 3 point quadratic bezier ----> 4 point cubic bezier + % + % INPUT: + % 3 langrange points (i.e. the patch passes through them) + % \PA,\PB,\PC (start,middle,end) + % + % OUTPUT: + % \PA,bezier control 1, bezier control 2, \PC. + % + \def\pgfplots@edge{% + \ifx\pgfplotspatchclass@biquad@A\PA + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% + \fi + \pgfpathcurveto {% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{% + \expandafter\pgfplotspointpatchvertex\PC\endvertex + }% + }% + \let\PA=\pgfplotspatchclass@biquad@A + \let\PB=\pgfplotspatchclass@biquad@E + \let\PC=\pgfplotspatchclass@biquad@B + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@biquad@B + \let\PB=\pgfplotspatchclass@biquad@F + \let\PC=\pgfplotspatchclass@biquad@C + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@biquad@C + \let\PB=\pgfplotspatchclass@biquad@G + \let\PC=\pgfplotspatchclass@biquad@D + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@biquad@D + \let\PB=\pgfplotspatchclass@biquad@H + \let\PC=\pgfplotspatchclass@biquad@A + \pgfplots@edge + \endgroup + \pgfpathclose + }, + %-------------------------------------------------- + % stroke path={% + % \ifx\pgfplotspatchclass@biquade@AB\relax + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}% + % \pgfpathclose + % \else + % \if1\pgfplotspatchclass@biquade@AB + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}% + % \fi + % \if1\pgfplotspatchclass@biquade@BC + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}% + % \fi + % \if1\pgfplotspatchclass@biquade@CA + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}% + % \fi + % \fi + % }, + %-------------------------------------------------- + stream to shader={% + \begingroup + \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + {pgfplotspatchclass@biquad@}{\Pcur}{\Pnextseq}% + % + \let\Pstartidx\Pcur% + \pgfutil@namelet{Pstart}{pgfplotspatchclass@biquad@\Pcur}% + % + % create a tensor cubic bezier patch. + % + % Again, the outer boundary involves a map from 3 point lagrange + % representation to 4 point cubic bezier. + % + % The main complication arises to support the INNER node (\pgfplotspatchclass@biquad@I) . + % We need the four inner bezier control points to get it + % correctly. + % + % this here handles only the OUTER shaper. It is the same as + % for 'fill path'. + % See 'fill path' for docs. + % + \pgfplotspatchclass@biquad@coonsedge + % + \pgfplotspatchclass@biquad@coonsedge + % + \pgfplotspatchclass@biquad@coonsedge + % + \pgfplotspatchclass@biquad@coonsedge + % + % FIXME: + % \pgfplotspatchclass@biquad@innercontrolpoints + % + \endgroup + },% + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + % Ok. Now create 4 triangles. The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + %-------------------------------------------------- + % set edge visible={% + % \ifcase#1 + % \edef\pgfplotspatchclass@biquade@AB{#2}% + % \or + % \edef\pgfplotspatchclass@biquade@BC{#2}% + % \or + % \edef\pgfplotspatchclass@biquade@CA{#2}% + % \fi + % }, + %-------------------------------------------------- + serialize except vertices={% + \ifx\pgfplotspatchclass@biquade@AB\relax + \let\pgfplotsretval\pgfutil@empty% + \else + \edef\pgfplotsretval{% + \noexpand\def\noexpand\pgfplotspatchclass@biquade@AB{\pgfplotspatchclass@biquade@AB}% + \noexpand\def\noexpand\pgfplotspatchclass@biquade@BC{\pgfplotspatchclass@biquade@BC}% + \noexpand\def\noexpand\pgfplotspatchclass@biquade@CA{\pgfplotspatchclass@biquade@CA}% + }% + \fi + },% + deserialize except vertices=% + \let\pgfplotspatchclass@biquade@AB\relax + #1, + recursive refine@={% + \pgfplotspatchclass@biquad@recursiverefine@newnames + % + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20% + %-------------------------------------------------- + % The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + % + % I used the reference triangle and shape functions as listed in + % http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/, + % see above for the definition of f[xi,eta] + % + % N[{f[-1/2, -1], f[0, -1/2], f[-1/2, 0], f[-1, -1/2], f[-1/2, -1/2]}] + % {0.375` a - 0.125` b + 0.75` e, + % 0.375` e - 0.125` g + 0.75` i, + % -0.125` f + 0.375` h + 0.75` i, + % 0.375` a - 0.125` d + 0.75` h, + % 0.140625` a - 0.046875` b + 0.015625` c - 0.046875` d + + % 0.28125` e - 0.09375` f - 0.09375` g + 0.28125` h + + % 0.5625` i} + %-------------------------------------------------- + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AE + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AH + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AEIH + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AE}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AH}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AEIH}% + % + #1\pgfplotspatchclass@biquad@recursiverefine@newnames + % + % N[{f[1/2, -1], f[1, -1/2], f[1/2, 0], f[1/2, -1/2]}] + % {-0.125` a + 0.375` b + 0.75` e, + % 0.375` b - 0.125` c + 0.75` f, + % 0.375` f - 0.125` h + 0.75` i, + % -0.046875 a + 0.140625 b - 0.046875 c + 0.015625 d + 0.28125 e + 0.28125 f - 0.09375 g - 0.09375 h + 0.5625 i} + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@BF + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FI + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EBFI + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EB}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@BF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EBFI}% + % + #1\pgfplotspatchclass@biquad@recursiverefine@newnames + % + % + % N[ {f[1, 1/2], f[1/2, 1], f[0, 1/2], f[1/2, 1/2]}] + % {-0.125` b + 0.375` c + 0.75` f, + % 0.375` c - 0.125` d + 0.75` g, + % -0.125` e + 0.375` g + 0.75` i, + % 0.015625` a - 0.046875` b + 0.140625` c - 0.046875` d - 0.09375` e + 0.28125` f + 0.28125` g - 0.09375` h + 0.5625` i} + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FC + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@CG + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FI + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@IFCG + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FC}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@CG}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@IFCG}% + % + #1\pgfplotspatchclass@biquad@recursiverefine@newnames + % + % + % N[{f[-1/2, 1], f[-1, 1/2], f[-1/2, 1/2]}] + % {-0.125 c + 0.375 d + 0.75 g, + % -0.125 a + 0.375 d + 0.75 h, + % -0.046875 a + 0.015625 b - 0.046875 c + 0.140625 d - 0.09375 e - 0.09375 f + 0.28125 g + 0.28125 h + 0.5625 i} + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@DH + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HIGD + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GD}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@DH}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HIGD}% + % + #1% + % + },% + get pdf shading type=6, + get num vertices=9, +}% + +% see docs in 'biquadratic::stream to shader' for details. +% PRECONDITION: to be used inside of 'stream to shader'. +\def\pgfplotspatchclass@biquad@coonsedge{% +%\message{EDGE \Pcur^^J}% + \expandafter\let\expandafter\PA\csname pgfplotspatchclass@biquad@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@biquad@\Pnextseq next@\Pcur\endcsname}% + \expandafter\let\expandafter\PB\csname pgfplotspatchclass@biquad@\Pcur\endcsname +%\message{---> \Pcur^^J}% + \edef\Pcur{\csname pgfplots@biquad@\Pnextseq next@\Pcur\endcsname}% + \expandafter\let\expandafter\PC\csname pgfplotspatchclass@biquad@\Pcur\endcsname +%\message{---> \Pcur^^J}% + \ifx\PA\Pstart + \expandafter\pgfplotspatchvertex\PA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{}% + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{}% + \ifx\PC\Pstart + \else + \expandafter\pgfplotspatchvertex\PC\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi +}% +\def\pgfplotspatchclass@biquad@innercontrolpoints{% + \begingroup + % + % This here computes the FOUR INNER CONTROL POINTS of a tensor + % cubic bezier patch (Shading Type 7). + % + % + % the following point coordinates have been acquired from + % biquadratic::recursive refine. See above for documentation. + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@A\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@B\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@AE + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@F\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@H\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@HI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@A\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@B\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@EB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@F\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@H\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@FI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@C\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@D\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@CG + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@C\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@D\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@GD + % + % + \let\PA=\pgfplotspatchclass@biquad@AE + \let\PB=\pgfplotspatchclass@biquad@HI + \let\PC=\pgfplotspatchclass@biquad@GD + \pgfplotspatchclass@biquad@innercontrolpoints@PREPARE\pgfplotspatchclass@biquad@@A\pgfplotspatchclass@biquad@@D + % + \let\PA=\pgfplotspatchclass@biquad@EB + \let\PB=\pgfplotspatchclass@biquad@FI + \let\PC=\pgfplotspatchclass@biquad@CG + \pgfplotspatchclass@biquad@innercontrolpoints@PREPARE\pgfplotspatchclass@biquad@@B\pgfplotspatchclass@biquad@@C + % + % + \let\Pcur=\Pstartidx + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + % + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + % + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + % + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + \endgroup +}% +\def\pgfplotspatchclass@biquad@innercontrolpoints@PREPARE#1#2{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + \edef#1{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + % + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + \edef#2{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + % +\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PA\endvertex}{1pt}\pgfusepath{fill}% +\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PB\endvertex}{1pt}\pgfusepath{fill}% +\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PC\endvertex}{1pt}\pgfusepath{fill}% +\pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% +\pgfpathcurveto{#1}{#2}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}% +\pgfusepath{stroke}% +} + +% Direct interface to coons patches (pdf shading type 6). +% See manual and/or pdf reference +\pgfplotsdeclarepatchclass{coons}{% + allow matrix=0, + new=\def\pgfplotspatchclass@coons@no{A}, + set next vertex={% + % defines \pgfplotspatchclass@coons@A ... \pgfplotspatchclass@coons@L (12 points) + \expandafter\edef\csname pgfplotspatchclass@coons@\pgfplotspatchclass@coons@no\endcsname{#1}% + \if L\pgfplotspatchclass@coons@no + \def\pgfplotspatchclass@coons@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@coons@no\csname pgfpptchindexnext@\pgfplotspatchclass@coons@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@F\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@H\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@I\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@J\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@K\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@L\endvertex #1% + }, + foreach cdata vertex={% + % 0, 3, 6, 9 + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@J\endvertex #1% + }, + fill path={% + \pgfpathmoveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@A\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@B\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@C\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@D\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@E\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@F\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@G\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@H\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@I\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@J\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@K\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@L\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@A\endvertex}% + \pgfpathclose + }, + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=6, + get num vertices=12, + get num cdata vertices=4, +}% + +% Direct interface to tensor product bezier patches (pdf shading type 7). +% See manual and/or pdf reference +\pgfplotsdeclarepatchclass{tensor bezier}{% + allow matrix=0, + new=\def\pgfplotspatchclass@tensor@no{A}, + set next vertex={% + % defines \pgfplotspatchclass@tensor@A ... \pgfplotspatchclass@tensor@P (16 points) + \expandafter\edef\csname pgfplotspatchclass@tensor@\pgfplotspatchclass@tensor@no\endcsname{#1}% + \if P\pgfplotspatchclass@tensor@no + \def\pgfplotspatchclass@tensor@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@tensor@no\csname pgfpptchindexnext@\pgfplotspatchclass@tensor@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@F\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@H\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@I\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@J\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@K\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@L\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@M\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@N\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@O\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@P\endvertex #1% + }, + foreach cdata vertex={% + % 0, 3, 6, 9 + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@J\endvertex #1% + }, + fill path={% + \pgfpathmoveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@A\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@B\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@C\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@D\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@E\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@F\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@G\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@H\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@I\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@J\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@K\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@L\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@A\endvertex}% + \pgfpathclose + }, + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=7, + get num vertices=16, + get num cdata vertices=4, +}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex new file mode 100644 index 00000000000..7502dac1c36 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex @@ -0,0 +1,733 @@ +%-------------------------------------------- +% +% Package pgfplots, library for polar coordinates. +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +% A polar axis lives in (ANGLE,LENGTH). +% That is +% x == ANGLE +% y == LENGTH +% +% + +\pgfplotsdefineaxistype[polar]{polar}{% + \pgfplots@polaraxis@activate +}% + +\newif\ifpgfplots@polaraxis@rellimits + +\pgfplotsset{ + /pgfplots/every polar axis/.style={ + grid=major, + xtick pos=right, + ytick pos=right, + every axis title shift=1.2\baselineskip, + legend style={anchor=center}, + }, + /pgfplots/xticklabel in circle/.style={ + xtick align=inside, + xticklabel style={ + rotate=90, + sloped like x axis={% + execute for upside down={\tikzset{anchor=north east}}, + %allow upside down, + reset nontranslations=false}, + anchor=south west, + %font=\tiny, + } + }, +} + +\def\pgfplots@polaraxis@activate{% + \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy + \let\pgfplotsqpointxy=\pgfplotsqpointxy@polaraxis + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy +% \def\pgfplotsqpointxyz##1##2##3{\pgfplotsqpointxy{##1}{##2}}% FIXME + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@polaraxis + \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}% + \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}% + \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@polaraxis + \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@polar% + \let\pgfplots@check@invalid@range=\pgfplots@check@invalid@range@polar + \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@polaraxis + \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@polar + \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@polar% + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@polar + \let\pgfplotsaxisifcontainspoint=\pgfplotsaxisifcontainspoint@polar + \let\pgfplots@prepare@axis@API=\pgfplots@prepare@axis@API@polar + \def\axisdefaultheight{\axisdefaultwidth}% + \let\pgfplots@initsizes=\pgfplots@initsizes@polar + \let\pgfplots@limits@ready=\pgfplots@limits@ready@polar + \let\pgfplots@assign@default@tick@foraxis@normalizetickdist=\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar + \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@polar + \let\pgfplots@enlarge@limit@for=\pgfplots@enlarge@limit@for@polar + \def\pgfplots@xtick@disable@last@tick{0}% + \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@polar% + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar + % + % this here is set *before* 'every polar axis' is invoked. + \pgfplotsset{ + enlarge x limits=false, + }% + \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{% + \pgfplots@notify@options@are@set + \pgfplotsset{separate axis lines}% + }% + \def\pgfplots@xticklabel@pos{}% + \def\pgfplots@yticklabel@pos{}% + \def\pgfplots@zticklabel@pos{}% + \def\pgfplots@init@ticklabelaxisspecfor##1##2{}% + \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}% + \def\pgfplots@xticklabelaxisspec{v10}% + \def\pgfplots@yticklabelaxisspec{0v0}% + \def\pgfplots@zticklabelaxisspec{00v}% + % + % cartesian cs + \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}% + % +}% + +\let\pgfplots@prepare@axis@API@orig=\pgfplots@prepare@axis@API +\def\pgfplots@prepare@axis@API@polar{% + \pgfplots@prepare@axis@API@orig + \let\pgfplotsaxisupdatelimitsforcoordinatetwodim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar + \let\pgfplotsaxisupdatelimitsforcoordinatethreedim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar +}% + +\def\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar#1#2#3{% + % + % + % Update limits: + % I do not respect x limits (since they are periodic). + % Consequently, I do not respect the clip limits options here (I + % suppose it is useless) + % + % for y (radius) limits, I always use the ABSOLUTE value: + \pgfmathfloatabs@{#2}% + \let\pgfplots@loc@limit=\pgfmathresult + % + \ifpgfplots@autocompute@ymax + \ifpgfplots@yislinear + \pgfplotsmathfloatmax{\pgfplots@ymax}{\pgfplots@loc@limit}% + \global\let\pgfplots@ymax=\pgfmathresult + \else + \pgfplotsmathmax{\pgfplots@ymax}{\pgfplots@loc@limit}% + \global\let\pgfplots@ymax=\pgfmathresult + \fi + \fi + % + % Compute data range: + \pgfplotsmathfloatmin{\pgfplots@data@xmin}{#1}% + \global\let\pgfplots@data@xmin=\pgfmathresult + \pgfplotsmathfloatmax{\pgfplots@data@xmax}{#1}% + \global\let\pgfplots@data@xmax=\pgfmathresult + \pgfplotsmathfloatmin{\pgfplots@data@ymin}{#2}% + \global\let\pgfplots@data@ymin=\pgfmathresult + \pgfplotsmathfloatmax{\pgfplots@data@ymax}{#2}% + \global\let\pgfplots@data@ymax=\pgfmathresult +%\pgfplots@message{Updated limits: (\pgfplots@xmin,\pgfplots@ymin) rectangle (\pgfplots@xmax,\pgfplots@ymax).}% +% +%\tracingmacros=0\tracingcommands=0 +}% +\def\pgfplotsaxisifcontainspoint@polar#1#2{% + \pgfmath@basic@mod@{\pgfplots@current@point@x}{360}% + \pgf@xa=\pgfmathresult pt % + % + \pgf@ya=\pgfplots@current@point@y pt % + \ifdim\pgf@ya<0pt + % absolute value: + \pgf@ya=-\pgf@ya + \fi + % + % I assume that \pgfplots@[xyz]min@reg and min@reg are registers + % containing the limits. + \pgfplots@loop@CONTINUEfalse + \ifdim\pgf@ya<\pgfplots@ymin@reg + \else + \ifdim\pgf@ya>\pgfplots@ymax@reg + \else + \if1\b@pgfplots@polar@limit@around@zero + % check condition + % x <= max || x >= min + % <=> ! (x > max && x < min) + \pgfplots@loop@CONTINUEtrue + \ifdim\pgf@xa>\pgfplots@xmax@mod pt % + \ifdim\pgf@xa<\pgfplots@xmin@mod pt % + \pgfplots@loop@CONTINUEfalse + \fi + \fi + \else + \ifdim\pgf@xa<\pgfplots@xmin@mod pt % + \else + \ifdim\pgf@xa>\pgfplots@xmax@mod pt % + \else + \pgfplots@loop@CONTINUEtrue + \fi + \fi + \fi + \fi + \fi + \ifpgfplots@loop@CONTINUE + \def\pgfplots@loc@TMPa{#1}% + \else + \def\pgfplots@loc@TMPa{#2}% + \fi + \pgfplots@loc@TMPa% +} + +\def\pgfplots@check@invalid@range@polar{% + % + % A polar axis allows \addplot3, but it ignores the third + % coordinate. + \pgfplots@threedimfalse + % + \pgfplots@limits@are@computedtrue + \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin + \pgfplotscoordmath{x}{zero}% + \let\pgfplots@xmin=\pgfmathresult + \fi + \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax + \pgfplotscoordmath{x}{parsenumber}{360}% + \let\pgfplots@xmax=\pgfmathresult + \fi + \ifx\pgfplots@ymin\pgfplots@invalidrange@ymin + \pgfplotscoordmath{y}{zero}% + \let\pgfplots@ymin=\pgfmathresult + \fi + \ifx\pgfplots@ymax\pgfplots@invalidrange@ymax + \pgfplots@limits@are@computedfalse + \fi + \ifpgfplots@limits@are@computed + \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmin + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \fi + \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmax + \global\let\pgfplots@data@xmax=\pgfplots@xmax + \fi + \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymin + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \fi + \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymax + \global\let\pgfplots@data@ymax=\pgfplots@ymax + \fi + \ifpgfplots@clip@limits + \else + % there is a rare change that min > max. + % Handle that ... + \pgfplotscoordmath{x}{min}{\pgfplots@xmin}{\pgfplots@xmax}% + \global\let\pgfplots@xmin=\pgfmathresult + \pgfplotscoordmath{x}{max}{\pgfplots@xmin}{\pgfplots@xmax}% + \global\let\pgfplots@xmax=\pgfmathresult + % + \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}% + \global\let\pgfplots@ymax=\pgfmathresult + % + \ifpgfplots@threedim + \pgfplotscoordmath{z}{min}{\pgfplots@zmin}{\pgfplots@zmax}% + \global\let\pgfplots@zmin=\pgfmathresult + \pgfplotscoordmath{z}{max}{\pgfplots@zmin}{\pgfplots@zmax}% + \global\let\pgfplots@zmax=\pgfmathresult + \fi + \fi + \else + \pgfplots@handle@invalid@range + \fi +}% + +\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{% + \pgfpointxy@orig{#1}{#2}% +}% +\def\pgfplotscoordmathnotifydatascalesetfor@polar#1{% + \def\pgfplotscoordmathnotifydatascalesetfor##1{}% + \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}% + \def\pgfplotscoordmathnotifydatascalesetfor@@{x}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}% + \else + \def\pgfplotscoordmathnotifydatascalesetfor@@{y}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}% + \fi + \fi + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar +}% + +% #1: the "a" value on the oriented surf +% #2: the "b" value. +% #3: the shift along the normal. +% +\def\pgfplotspointonorientedsurfaceabwithbshift@polaraxis#1#2#3{% + % implement the shift in "b" direction explicitly: + % + \pgfplotspointonorientedsurfaceab{#1}{#2}% + \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + \pgfpointadd + {\pgfplots@loc@TMPe}% + {% + \begingroup + % I need a '-' here because for polaraxis axes, the "b" axis + % points to the *outside* instead of the inside. + \pgf@xa=-#3\relax + \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}% + % oh. a reversed axis. + \pgf@xa=-\pgf@xa + \fi + \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfqpointscale{\pgfplots@loc@TMPa}{% + \if x\pgfplotspointonorientedsurfaceB + % the angle. + % FIXME : datascaling! + % FIXME : aspect ratios! + \pgfmath@basic@sin@{#2}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{#2}% + \pgf@y=\pgfmathresult pt + \else + % the length. + % FIXME : datascaling! + % FIXME : aspect ratios! + % perhaps pgfpointpolarxy? + \if y\pgfplotspointonorientedsurfaceB + \pgfqpointpolar{#1}{1pt}% + \else + \pgfpointorigin + \fi + \fi + }% + }% +} + + +\def\pgfplotsqpointxy@polaraxis#1#2{% + \pgf@process{% + \pgfplotsmathpoltocartbasic{#1}{#2}\x\y + \pgfqpointxy@orig\x\y +%\message{pgfplotsqpointxy{#1}{#2} ---> (\x,\y) ---> (\the\pgf@x,\the\pgf@y)}% + }% +}% +\def\pgfplots@clippath@prepare@for@axistype@polaraxis{% + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto + {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymax}% + \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax} + {\pgfqpointxy@orig{\pgfplots@ymax}{0}}% + {\pgfqpointxy@orig{0}{\pgfplots@ymax}}% + \if1\pgfplots@xtick@disable@last@tick + % we have min angle = max angle. + \ifdim\pgfplots@ymin pt=0pt + \else + \pgfseteorule + \pgfpathmoveto + {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymin}% + \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax} + {\pgfqpointxy@orig{\pgfplots@ymin}{0}}% + {\pgfqpointxy@orig{0}{\pgfplots@ymin}}% + \fi + \else + % we have min angle != max angle. + \ifdim\pgfplots@ymin pt=0pt + % Ok, then pass through origin: + \pgfpathlineto\pgfplotspointaxisorigin + \else + % complicated special case. + \pgfpathlineto + {\pgfplotsqpointxy\pgfplots@xmax\pgfplots@ymin}% + \pgfpatharcaxes{\pgfplots@xmax}{\pgfplots@xmin} + {\pgfqpointxy@orig{\pgfplots@ymin}{0}}% + {\pgfqpointxy@orig{0}{\pgfplots@ymin}}% + \fi + \pgfpathclose + \fi + \pgfplots@clippath@use@{##1}% + }% +}% + +\def\pgfplotspointouternormalvectorofaxis@polaraxis#1#2#3\relax{% + \if v#1% + \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}% + % in direction of the length. + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + % FIXME : datascaling! + % FIXME : aspect ratios! + % perhaps pgfpointpolarxy? + \pgfqpointpolar{\pgfplotsretval}{1pt}% + \else + \if v#2% + \if#10% + \def\pgfplotsretval{\pgfplots@xmin}% + \else + \def\pgfplotsretval{\pgfplots@xmax}% + \fi + % in direction of the angle. + % FIXME : datascaling! + % FIXME : aspect ratios! + \pgfmath@basic@sin@{\pgfplotsretval}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{\pgfplotsretval}% + \pgf@y=\pgfmathresult pt + \else + \pgfqpoint{0pt}{1pt}% + \fi + \fi + %\pgf@process{\pgfpointnormalised{}}% + \pgf@process{}% + \endgroup +}% + +\def\pgfplotspoint@initialisation@axes@polar{% + % + \begingroup + \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% + \xdef\pgfplotspointminminmin{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % + \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}% + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % + % the length of the "angle" axis is 2*pi*r . + % The radius, however, is the length of (0,ymax) which is (0pt,\pgf@xx*ymax): + \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{\pgfplots@ymax}% + \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r + \if0\pgfplots@xtick@disable@last@tick + % oh: minangle != maxangle. We have a partial circle. + % compute the arc length (<360 deg) + \pgf@xa=\pgfplots@xmax pt + \advance\pgf@xa by-\pgfplots@xmin pt + \divide\pgf@xa by360 + \ifdim\pgf@xa<1pt + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}% + \pgfmathmultiply@{\pgfmathresult}{\pgfplots@loc@TMPa}% + \fi + \fi + \xdef\pgfplotspointxaxislength{\pgfmathresult pt}% + % + \pgfpointdiff + {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}% + {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \xdef\pgfplotspointyaxislength{\pgfmathresult pt}% + % + \global\let\pgfplotspointzaxis=\pgfpointorigin + \gdef\pgfplotspointzaxislength{0pt}% + \endgroup + % +} +\let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units +\def\pgfplotspoint@initialisation@units@polar{% + \def\pgfplotspointunitx{% + \pgfplotspointouternormalvectorofaxisgetv{v10}% angle varying, radius at outer pos + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + \pgfmath@basic@sin@{\pgfplotsretval}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{\pgfplotsretval}% + \pgf@y=\pgfmathresult pt + }% + \def\pgfplotsunitxlength{1}% + \def\pgfplotsunitxinvlength{1}% + % + \def\pgfplotspointunity{% + \pgfqpointpolar{\pgfplots@xmin}{1pt}% + }% + \def\pgfplotsunitylength{1}% + \def\pgfplotsunityinvlength{1}% +}% + +\def\pgfplots@drawgridlines@onorientedsurf@fromto@polar#1{% + \if x\pgfplotspointonorientedsurfaceA + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + \else + \if y\pgfplotspointonorientedsurfaceA\relax + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgf@x=#1\pgf@xx + \pgf@y=#1\pgf@yy + \edef\pgfplots@loc@TMPa{\the\pgf@x\space and \the\pgf@y}% + \def\pgfplots@loc@TMPb{\pgfpatharc{\pgfplots@xmin}{\pgfplots@xmax}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \else + \fi + \fi +}% + +\def\pgfplots@initsizes@polar{% + % I copy-pasted most of this code, up to just one position where + % I introduced the modified scaling for polar axes + %---------------------------------- + % INIT. + % + % + \pgfmath@basic@mod@{\pgfplots@xmin}{360}% + \let\pgfplots@xmin@mod=\pgfmathresult + \pgfmath@basic@mod@{\pgfplots@xmax}{360}% + \let\pgfplots@xmax@mod=\pgfmathresult + \ifdim\pgfplots@xmax@mod pt<\pgfplots@xmin@mod pt + \def\b@pgfplots@polar@limit@around@zero{1}% + \else + \def\b@pgfplots@polar@limit@around@zero{0}% + \fi + % + \pgfplots@xmin@reg=\pgfplots@xmin pt % + \pgfplots@xmax@reg=\pgfplots@xmax pt % + % + % + \pgfplots@ymin@reg=\pgfplots@ymin pt % + \pgfplots@ymax@reg=\pgfplots@ymax pt % + \ifpgfplots@threedim + \pgfplots@zmin@reg=\pgfplots@zmin pt % + \pgfplots@zmax@reg=\pgfplots@zmax pt % + \fi + % + % + %----------------------------------------- + % PROCESS THE 'width' and 'height' options + %----------------------------------------- + % + % + \pgfkeysgetvalue{/pgfplots/view/az}{\pgfplots@view@az}% + \pgfkeysgetvalue{/pgfplots/view/el}{\pgfplots@view@el}% + \ifpgfplots@threedim + \def\pgfplots@tmpZscale{1pt}% + \else + \def\pgfplots@tmpZscale{0pt}% + \let\pgfplots@view@el=\pgfutil@empty + \let\pgfplots@view@az=\pgfutil@empty + \fi + \ifx\pgfplots@view@az\pgfutil@empty + %\let\pgfplots@rectangle@width=\pgfutil@empty + %\let\pgfplots@rectangle@height=\pgfutil@empty + \def\pgfplots@view@dir@threedim@x{0}% + \def\pgfplots@view@dir@threedim@y{0}% + \def\pgfplots@view@dir@threedim@z{1}% + % + % FIXME HERE COMES THE polar MODIFICATION + %-------------------------------------------------- + % \pgfpointdiff + % {\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}} + % {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + %-------------------------------------------------- + % instead of scaling from (min) (max), we only need the UPPER + % bound -- in both, x and y directions (since we have a cycle. + % Furthermore, we need it twice since we are interested in the + % diameter, not the radius. + \global\pgf@x=\pgfplots@ymax pt % radius + \global\multiply\pgf@x by2 % diameter + \global\pgf@y=\pgf@x % same for y + % + % only used temporarily in this macro to compute the correct + % length for unit vectors: + \edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}% + \edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}% + % + \ifx\pgfplots@x\pgfutil@empty + \ifx\pgfplots@width\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! WIDTH NOT SET}% + \fi + \pgfplots@initsizes@getXscale\pgfplots@initsizes@axisdiag@x\into\pgfplots@tmpXscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@width=\pgfplots@width + %\fi + \else + \def\pgfplots@tmpXscale{1}% + \fi + % + \ifx\pgfplots@y\pgfutil@empty + \ifx\pgfplots@height\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! HEIGHT NOT SET}% + \fi + \pgfplots@initsizes@getYscale\pgfplots@initsizes@axisdiag@y\into\pgfplots@tmpYscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@height=\pgfplots@height + %\fi + \else + \def\pgfplots@tmpYscale{1}% + \fi + % + \edef\pgfplots@tmpXscale{\pgfplots@tmpXscale pt}% + \edef\pgfplots@tmpYscale{\pgfplots@tmpYscale pt}% + % + \pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}% + \pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}% + \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}% + \else + % 3D case is currently always initialised by `view': + \let\pgfplots@x=\pgfutil@empty + \let\pgfplots@y=\pgfutil@empty + \let\pgfplots@z=\pgfutil@empty + \pgfplotssetaxesfromazel{\pgfplots@view@az}{\pgfplots@view@el}{\pgfplots@tmp@xisaxisparallel}% + \if1\pgfplots@tmp@xisaxisparallel% + \def\pgfplots@tmp@yisaxisparallel{1}% + \fi + \fi +%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }% + % + \let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure + \let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure + % + \pgfplotsmath@ifzero{\pgfplots@x@veclength}{\pgfplots@hide@xtrue\pgfplots@shownothingof@xtrue}{}% + \pgfplotsmath@ifzero{\pgfplots@y@veclength}{\pgfplots@hide@ytrue\pgfplots@shownothingof@ytrue}{}% + \ifpgfplots@threedim + \pgfplotsmath@ifzero{\pgfplots@z@veclength}{\pgfplots@hide@ztrue\pgfplots@shownothingof@ztrue}{}% + \else + \if1\pgfplots@tmp@xisaxisparallel% + \if1\pgfplots@tmp@yisaxisparallel% + % Optimize for axis-parallel case! + % puh. Did not make any measureable difference!? Ok... + \let\pgfplotsqpointxy=\pgfplotsqpointxy@orthogonal + \fi + \fi + \fi + % + % FIXME : unit vector ratio / axis equal +} + +\def\pgfplots@handle@invalid@range@defaultlimits@polar{% + \def\pgfplots@loc@TMPa{0}% + \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin + \def\pgfplots@loc@TMPa{1}% + \fi + \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax + \def\pgfplots@loc@TMPa{1}% + \fi + \if\pgfplots@loc@TMPa1% + \pgfplotscoordmath{x}{parsenumber}{0}% + \global\let\pgfplots@xmin=\pgfmathresult + \pgfplotscoordmath{x}{parsenumber}{360}% + \global\let\pgfplots@xmax=\pgfmathresult + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \global\let\pgfplots@data@xmax=\pgfplots@xmax + \fi + % + \pgfplotscoordmath{y}{parsenumber}{0}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{parsenumber}{1}% + \global\let\pgfplots@ymax=\pgfmathresult + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \global\let\pgfplots@data@ymax=\pgfplots@ymax +} + +\let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@ +\def\pgfplots@show@ticklabel@@polar#1#2{% + \def\pgfmathresult{#2}% + \if#1x% + \ifdim#2pt>360pt + \pgfmath@basic@mod@{#2}{360}% + \fi + \fi + \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% +}% + +\let\pgfplots@xtick@check@tickshow@orig=\pgfplots@xtick@check@tickshow% +\def\pgfplots@xtick@check@tickshow@polar{% + \if1\pgfplots@xtick@disable@last@tick + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@xmax pt} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{% + \pgfplots@xtick@check@tickshow@orig + }% + \else + \pgfplots@xtick@check@tickshow@orig + \fi +} + +\let\pgfplots@enlarge@limit@for@orig=\pgfplots@enlarge@limit@for +\def\pgfplots@enlarge@limit@for@polar#1{% + \if#1x% + % ignore 'enlarge x limits' (degrees). + \else + % allow 'enlarge y limits', but only for UPPER radius + \def\bool@pgfplots@loc@enlargelimits@min{0}% + \pgfplots@enlarge@limit@for@orig{#1}% + \fi +}% + +\let\pgfplots@assign@default@tick@foraxis@normalizetickdist@orig=\pgfplots@assign@default@tick@foraxis@normalizetickdist +\def\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar#1#2{% + \if#1x% + % special handling for the angles: + \begingroup + \pgfmathfloattofixed{#2}% + \let\H=\pgf@xb + \H=\pgfmathresult pt + % only allow step sizes of + % 90, 45, 30, 15, 10, 5. + % + % Prefer the LARGER step size during the snap-to-nearest. + % The following decision boundaries are heuristics and have no + % mathematical foundation. + \ifdim\H>67pt + \H=90pt + \else + \ifdim\H>30pt + \H=45pt + \else + \ifdim\H>18pt + \H=30pt + \else + \ifdim\H>10pt + \H=15pt + \else + \ifdim\H>6pt + \H=10pt + \else + \H=5pt + \fi + \fi + \fi + \fi + \fi + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\H}% + \pgfmathfloatparsenumber{\pgfplots@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \else + \pgfplots@assign@default@tick@foraxis@normalizetickdist@orig{#1}{#2}% + \fi +}% + +\let\pgfplots@limits@ready@orig=\pgfplots@limits@ready +\def\pgfplots@limits@ready@polar{% + \pgfplots@limits@ready@orig + % + % Avoid tick labels at upper *and* lower angle range if both are the + % same: + \pgfmath@basic@subtract@{\pgfplots@xmax}{\pgfplots@xmin}% + \pgfmath@basic@mod@{\pgfmathresult}{360}% + \pgfplotsmath@ifapproxequal@dim + {\pgfmathresult pt}{0pt}% + {0.002pt} + {% + \def\pgfplots@xtick@disable@last@tick{1}% + }{% + }% + % +}% +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex new file mode 100644 index 00000000000..7d24c53216d --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex @@ -0,0 +1,1761 @@ +%-------------------------------------------- +% +% Package pgfplots, library for smith charts. +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +% A smithchart maps the complex halfplane +% H subset \C, +% H := [0,infty] x [-infty,infty] +% =~ \{ z = a+ j *b | a >=0, b \in \R } +% +% to the unit circle. +% +% A number z = a+jb is mapped to r(z) = (z-1) / (z+1) which is, per +% definition, in the 2d unit circle. +% +% Grid lines (i.e. a==const or b==const) are mapped on circles. +% +% In PGFPlots, the a=Re(z) is the x axis and b = Im(z) is the y axis. +% +% - CARTESIAN INPUT +% - tick/grid coordinates are from +% - input coordinates can be either from H or (perhaps preferred) from +% the unit circle. +% this "preferred" needs to be discussed. +% - the transformed data range is the unit circle (or a sequeezed variant) +% - in order to compute limits etc., I should accept data in H. this +% should simplify the logic to determine ticks etc considerably. +% problem: this transformation appears to be quite difficult (?) +% -> r(z) = (z-1)/(z+1) +% in complex arithmetics (but the G-tutorial.pdf says something +% about these circle equations!?) +% +% www.amanogawa.com/archive/docs/G-tutorial.pdf +% +% +% Idea: +% - work on H +% - transform whereever necessary +% - implement all pgfplots wrinkles in analogy to polar axes +% - provide support for normalized input coords (combined with +% untransformed limits or something like that) + +\pgfplotsdefineaxistype{smithchart}{% + \pgfplots@smithchartaxis@activate +}% + +\newif\ifpgfplotspointisinsmithchartCS +\newif\ifpgfplots@smithchart@showorigin +\newif\ifpgfplots@smithchart@mirrored + +\pgfplotsset{ + /pgfplots/xgrid each nth passes y/.initial=,% format: CSV list, each entry of the form '<at> | <at> ':' <eachnth> | <at> 'if <' <xvalue> | <at> ':' <eachnth> 'if <' <xvalue>' + /pgfplots/xgrid each nth passes y start/.initial=0, + /pgfplots/ygrid each nth passes x/.initial=, + /pgfplots/ygrid each nth passes x start/.initial=0, + % + /pgfplots/xgrid stop at y/.initial=,% individual stop map of the form '<xpos> ':' <stopaty>', separated by white space + /pgfplots/ygrid stop at x/.initial=, + % + % FIXME : this is undocumented: + /pgfplots/smithchart mirrored/.is if=pgfplots@smithchart@mirrored, + /pgfplots/smithchart mirrored/.default=true, + % + % this boolean may only be used inside of \addplot. It will be + % ignored otherwise. + /pgfplots/is smithchart cs/.is if=pgfplotspointisinsmithchartCS, + /pgfplots/is smithchart cs/.default=true, + /pgfplots/show origin/.is if=pgfplots@smithchart@showorigin, + /pgfplots/show origin/.default=true, + /pgfplots/show origin code/.code={% + \path[draw=black,fill=white] (0pt,0pt) circle (2.5pt); + \path[fill=black] (0pt,0pt) circle (0.5pt); + }, + /pgfplots/every smithchart axis/.style={ + grid=both, + xmin=0, + xmax=16000,% FIXME : more is not possible because some code uses the \pgfplots@xmin@reg registers... (ticks) + ymin=-16000,ymax=16000, + scaled ticks=false, % never draw the \cdot 10^4 labels + major tick style={draw=black}, + xtick align=center, + ytick align=center, + every axis title shift=1.2\baselineskip, + legend style={anchor=center}, + }, + /pgfplots/default smithchart xtick/.code=, + /pgfplots/default smithchart ytick/.code=, + /pgfplots/default smithchart xytick/.code=, + /pgfplots/smithchart ticks by size/.code 2 args={% + \ifdim#1<14cm + \pgfkeysalso{/pgfplots/few smithchart ticks}% + \else + \ifdim#1<20cm + \pgfkeysalso{/pgfplots/many smithchart ticks}% + \else + \pgfkeysalso{/pgfplots/dense smithchart ticks}% + \fi + \fi + }, + /pgfplots/few smithchart ticks*/.style={ + default smithchart xtick/.style={ + xtick={0.2,0.5,1,2,5}, + }, + default smithchart ytick/.style={ + ytick={% + 0,% + 0.2, 0.5, 1, 2, 5,% + -0.2,-0.5,-1,-2,-5}, + }, + default smithchart xytick/.style={ + xgrid each nth passes y={2}, + ygrid each nth passes x={2}, + }, + }, + /pgfplots/few smithchart ticks/.style={/pgfplots/few smithchart ticks*}, + /pgfplots/few smithchart ticks*,% use it as initial config + /pgfplots/many smithchart ticks*/.style={ + default smithchart xtick/.style={ + xtick={ + 0.1,0.2,0.3,0.4,0.5,1,1.5,2,3,4,5,10,20% + }, + minor xtick={0.6,0.7,0.8,0.9,1.1,1.2,1.3,1.4,1.6,1.7,1.8,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50}, + }, + default smithchart ytick/.style={ + ytick={% + 0,% + 0.1,0.2,...,1,1.5,2,3,4,5,10,20,% + -0.1,-0.2,...,-1,-1.5,-2,-3,-4,-5,-10,-20% + }, + minor ytick={% + 1.1,1.2,1.3,1.4,1.6,1.7,1.8,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50,% + -1.1,-1.2,-1.3,-1.4,-1.6,-1.7,-1.8,-1.9,-2.2,-2.4,-2.6,-2.8,-3.2,-3.4,-3.6,-3.8,-4.5,-6,-7,-8,-9,-50% + }, + }, + default smithchart xytick/.style={ + xgrid each nth passes y={1,2,4,5,10,20}, + ygrid each nth passes x={1,2,3,5,10:3,20:3}, + }, + }, + /pgfplots/many smithchart ticks/.style={ + many smithchart ticks*, + every axis title shift=6pt, + yticklabel in circle, + show origin=true, + }, + /pgfplots/dense smithchart ticks*/.style={ + default smithchart xtick/.style={ + %ygrid each nth passes x start=0, + xtick={ + 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.2,1.4,1.6,1.8,2,3,4,5,10,20% + }, + minor xtick={% + 0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,% + 0.22,0.24,0.26,0.28,0.32,0.34,0.36,0.38,0.42,0.44,0.46,0.48,% + 0.52,% + 0.55,0.65,0.75,0.85,0.95,% + %0.6,0.7,0.8,0.9,% + 1.1,1.3,1.5,1.7,1.9,% + 2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50}, + }, + default smithchart ytick/.style={ + ytick={% + 0,% + 0.1,0.2,...,1,1.2,1.4,1.6,1.8,2,3,4,5,10,20,% + -0.1,-0.2,...,-1,-1.2,-1.4,-1.6,-1.8,-2,-3,-4,-5,-10,-20% + }, + minor ytick={% + 0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,% + 0.22,0.24,0.26,0.28,0.32,0.34,0.36,0.38,0.42,0.44,0.46,0.48,% + 0.55,0.65,0.75,0.85,0.95,% + 1.1,1.3,1.5,1.7,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50,% + -0.01,-0.02,-0.03,-0.04,-0.05,-0.06,-0.07,-0.08,-0.09,-0.11,-0.12,-0.13,-0.14,-0.15,-0.16,-0.17,-0.18,-0.19,% + -0.22,-0.24,-0.26,-0.28,-0.32,-0.34,-0.36,-0.38,-0.42,-0.44,-0.46,-0.48,% + -0.55,-0.65,-0.75,-0.85,-0.95,% + -1.1,-1.3,-1.5,-1.7,-1.9,-2.2,-2.4,-2.6,-2.8,-3.2,-3.4,-3.6,-3.8,-4.5,-6,-7,-8,-9,-50% + }, + }, + default smithchart xytick/.style={ + xgrid each nth passes y={0.2 if < 0.2001,0.5 if < 0.50001,1 if < 1.001,2,4,5,10,20}, + ygrid each nth passes x={0.2 if < 0.2001,0.52 if < 0.52001,1 if < 1.001,2,3,5,10:3,20:3}, + }, + }, + /pgfplots/dense smithchart ticks/.style={ + yticklabel in circle, + every axis title shift=6pt, + dense smithchart ticks*, + show origin=true, + every major grid/.style={black!60}, + }, + /pgfplots/yticklabel in circle/.style={ + ytick align=inside, + yticklabel style={ + rotate=90, + sloped like y axis={% + execute for upside down={\tikzset{anchor=north east}}, + %allow upside down, + reset nontranslations=false}, + anchor=south west, + %font=\tiny, + } + }, +} + +\def\pgfplots@smithchartaxis@activate{% + \def\axisdefaultwidth{207pt}% + \def\axisdefaultheight{207pt}% + \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy + \let\pgfplotsqpointxy=\pgfplotsqpointxy@smithchartaxis + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy + \def\pgfplotsqpointxyz##1##2##3{\pgfplotsqpointxy{##1}{##2}}% FIXME + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@smithchartaxis + \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}% + \def\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf##1{}% + \let\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf=\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf@smithchartaxis + \def\pgfplots@visphase@notify@changeofcanvaslimits##1{}% + \def\pgfplots@avoid@empty@axis@range@for##1{}% + \def\pgfplotsaxisifcontainspoint##1##2{##1}% + \let\pgfplots@set@default@size@options=\pgfplots@set@default@size@options@smithchart% + % + \def\b@pgfplots@smithchart@defaultticks@x{0}% + \def\b@pgfplots@smithchart@defaultticks@y{0}% + \let\pgfplots@assign@default@tick@foraxis=\pgfplots@assign@default@tick@foraxis@smithchart + \def\pgfplots@checkisuniformLINEARtick##1##2{% + % don't do anything here. I suppose it is useless and is a + % waste of time for many ticks. + \global\pgfplots@isuniformtickfalse + }% + \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@smithchartaxis + % + % invalid range: do not clear plots. simply assign default limits. + \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@smithchart% + \def\pgfplots@handle@invalid@range{\pgfplots@handle@invalid@range@defaultlimits}% + % + \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@smithchartaxis + \let\pgfplots@draw@axis@is@prepared=\pgfplots@draw@axis@is@prepared@smithchartaxis + \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@smithchart + \let\pgfplots@drawaxis@innerlines@onorientedsurf=\pgfplots@drawaxis@innerlines@onorientedsurf@smithchart + \let\pgfplots@drawaxis@outerlines@separate@onorientedsurf=\pgfplots@drawaxis@outerlines@separate@onorientedsurf@smithchartaxis + \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@smithchart% + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@smithchart + \expandafter\def\expandafter\pgfplots@create@axis@descriptions@\expandafter{% + \pgfplots@create@axis@descriptions@ + \ifpgfplots@smithchart@showorigin + \pgfkeysvalueof{/pgfplots/show origin code/.@cmd}\pgfeov% + \fi + }% + \def\axisdefaultheight{\axisdefaultwidth}% + \let\pgfplots@initsizes=\pgfplots@initsizes@smithchart + %\let\pgfplots@limits@ready=\pgfplots@limits@ready@smithchart + %\let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@smithchart + %\def\pgfplots@xtick@disable@last@tick{0}% + \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@smithchart% + \let\pgfplots@ytick@check@tickshow=\pgfplots@ytick@check@tickshow@smithchart% + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@smithchart + % + \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{% + \pgfplots@notify@options@are@set + \pgfplotsset{% + separate axis lines,% + is smithchart cs=false,% + xtick pos=left, + ytick pos=left, + axis x line*=center, + disabledatascaling, + }% + \def\pgfplots@xtickposnum{2}% + % + \ifx\pgfplots@xtick\pgfutil@empty + \def\b@pgfplots@smithchart@defaultticks@x{1}% + \fi + \ifx\pgfplots@ytick\pgfutil@empty + \def\b@pgfplots@smithchart@defaultticks@y{1}% + \fi + \pgfplotscoordmath{default}{parsenumber}{0.002}% + \let\pgfplots@almost@zero@thresh=\pgfmathresult + }% + \def\pgfplots@xticklabel@pos{}% + \def\pgfplots@yticklabel@pos{}% + \def\pgfplots@zticklabel@pos{}% + \def\pgfplots@init@ticklabelaxisspecfor##1##2{}% + \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}% + \def\pgfplotspointonorientedsurfaceabmatchaxisline@warn##1{}% clear warning. It works for smith charts. + \def\pgfplots@xticklabelaxisspec{v20}% + \def\pgfplots@yticklabelaxisspec{0v0}% + \def\pgfplots@zticklabelaxisspec{00v}% + % + % cartesian cs + \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}% + % + % + % Special treatment for + % \pgfplots@prepare@tick@coordlists@for: make sure we don't need + % to use the register arithmetics in \pgfplots@xmin@reg and its + % variants! I want an UNRESTRICTED max data range! + \def\pgfplots@prepare@tick@coordlists@for@assign##1=##2{\edef##1{##2}}% + \def\pgfplots@prepare@tick@coordlists@for@advance##1by##2{% + % THIS IS NEVER USED (at the time of this writing). + \edef\pgfplots@loc@TMPa{##2}% + \pgfplotscoordmath{default}{parsenumber}{##1}% + \pgfplotscoordmath{default}{op}{add}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let##1=\pgfmathresult + }% + \def\pgfplots@prepare@tick@coordlists@for@tofixed##1{\edef\pgfmathresult{##1}}% + \def\pgfplots@prepare@tick@coordlists@for@handletolerance##1{}% does not apply to smithcharts. + \def\pgfplots@prepare@tick@coordlists@for@checktickmin##1{% + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tmpa}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1tickmin\endcsname}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplotscoordmath{default}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{% + \pgfplots@tickshowfalse + }{% + }% + }% + \def\pgfplots@prepare@tick@coordlists@for@checktickmax##1{% + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tmpa}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1tickmin\endcsname}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplotscoordmath{default}{if less than}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPa}{% + \pgfplots@tickshowfalse + }{% + }% + }% + \def\pgfplots@prepare@tick@coordlists@for@checkdatalimits##1{}% I won't do this here. Smithcharts are somewhat special. +}% + +\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{% + \pgfpointxy@orig{#1}{#2}% +}% +\def\pgfplotscoordmathnotifydatascalesetfor@smithchart#1{% + \def\pgfplotscoordmathnotifydatascalesetfor##1{}% + \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}% + \def\pgfplotscoordmathnotifydatascalesetfor@@{x}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}% + \else + \def\pgfplotscoordmathnotifydatascalesetfor@@{y}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}% + \fi + \fi + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@smithchart +}% + +% #1: the "a" value on the oriented surf +% #2: the "b" value. +% #3: the shift along the normal. +% +\def\pgfplotspointonorientedsurfaceabwithbshift@smithchartaxis#1#2#3{% + % implement the shift in "b" direction explicitly: + \pgfpointadd + {\pgfplotspointonorientedsurfaceab{#1}{#2}}% + {% + \pgfplotspointonorientedsurfaceabtolinespec{v}{0}% + \afterassignment\pgfplots@gobble@until@relax + \pgf@xa=-#3\relax + \edef\pgfplots@shift@no@unit{\pgf@sys@tonumber\pgf@xa}% + \pgfqpointscale + {\pgfplots@shift@no@unit} + {\expandafter\pgfplotspointouternormalvectorofaxis\expandafter{\pgfplotsretval}}% + }% +} + + +% Computes the complex division +% (A + j B) / (C + j D) = (A C + B D + j (B C - A D) ) / (C^2 + D^2) +% and assigns the result to \pgfmathresult and \pgfmathresultim . Here +% 'j = sqrt{-1}' is the imaginary unit. +% +% #1 : A +% #2 : B +% #3 : C +% #4 : D +% +% The arithmetics is performed in \pgfplotscoordmath{default} (which +% uses the floating point unit in the initial configuration) +% +% Numbers are expected to be already parsed (i.e. you need to invoke +% \pgfplotscoordmath{default}{parsenumber}{#1}% +% \let\A=\pgfmathresult +% before) +\def\pgfplotscoordmathcomplexdivision#1#2#3#4{% + \begingroup + \edef\pgfplots@A{#1}% + \edef\pgfplots@B{#2}% + \edef\pgfplots@C{#3}% + \edef\pgfplots@D{#4}% + % + % + % ok, compute it: + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@A}{\pgfplots@C}}% + \let\pgfplots@AC=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@A}{\pgfplots@D}}% + \let\pgfplots@AD=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@B}{\pgfplots@D}}% + \let\pgfplots@BD=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@B}{\pgfplots@C}}% + \let\pgfplots@BC=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@C}{\pgfplots@C}}% + \let\pgfplots@CC=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@D}{\pgfplots@D}}% + \let\pgfplots@DD=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@CC}{\pgfplots@DD}}% + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}% + \let\pgfplots@scale=\pgfmathresult + % + % + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@AC}{\pgfplots@BD}}% + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@scale}}% + \let\pgfplots@x=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@BC}{\pgfplots@AD}}% + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@scale}}% + \let\pgfplots@y=\pgfmathresult + % + \xdef\pgfplots@glob@TMPa{% + \noexpand\def\noexpand\pgfmathresult{\pgfplots@x}% + \noexpand\def\noexpand\pgfmathresultim{\pgfplots@y}% + }% + \endgroup + \pgfplots@glob@TMPa +}% + +\def\pgfplotsqpointxy@smithchartaxis#1#2{% + \pgf@process{% + \ifpgfplotspointisinsmithchartCS + \def\pgfplots@x{#1}% + \def\pgfplots@y{#2}% + \else + % compute rx + j* ry = (#1 + j * #2 -1) / (#1 + j*#2 + 1) + % + % I write + % #1 - 1 + j * #2 = A + j * B + % 1 + #1 + j * #2 = C + j * D + % + % -> rx + j * ry = (A + j B) / (C + j D) = (A C + B D + j (B C - A D) ) / (C^2 + D^2) + \pgfplotscoordmath{default}{parsenumber}{#1}% + \let\pgfplots@x=\pgfmathresult + % + \pgfplotscoordmath{default}{parsenumber}{#2}% + \let\pgfplots@D=\pgfmathresult + % + \pgfplotscoordmath{default}{one}% + \let\pgfplots@one=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@one}{\pgfplots@x}}% + \let\pgfplots@C=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@x}{\pgfplots@one}}% + \let\pgfplots@A=\pgfmathresult + % + \let\pgfplots@B=\pgfplots@D + % + \pgfplotscoordmathcomplexdivision\pgfplots@A\pgfplots@B\pgfplots@C\pgfplots@D + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let\pgfplots@x=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfmathresultim}% + \let\pgfplots@y=\pgfmathresult + \fi + % + \pgfplotsqpointxy@smithchart@canvas\pgfplots@x\pgfplots@y +%\message{pgfplotsqpointxy{#1}{#2} ---> (\pgfplots@x,\pgfplots@y) ---> (\the\pgf@x,\the\pgf@y)}% + }% +}% + +\def\pgfplotsqpointxy@smithchart@canvas#1#2{% + \ifpgfplots@smithchart@mirrored + \pgfqpointxy@orig{-#1}{#2}% + \else + \pgfqpointxy@orig{#1}{#2}% + \fi +}% + +\def\pgfplots@clippath@prepare@for@axistype@smithchartaxis{% + \def\pgfplots@clippath@install##1{% + \pgfpathellipse + {\pgfplotsqpointxy@smithchart@canvas{0}{0}} + {\pgfplotsqpointxy@smithchart@canvas{1}{0}} + {\pgfplotsqpointxy@smithchart@canvas{0}{1}}% + \pgfplots@clippath@use@{##1}% + }% +}% + +\def\pgfplotspointouternormalvectorofaxis@smithchartaxis#1#2#3\relax{% + \if v#1% + \pgfqpoint{0pt}{1pt}% + \else + \if v#2% + \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}% + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + \pgfpointdiff + {\pgfplotsqpointxy@smithchart@canvas{0}{0}}% + {\pgfplotsqpointxy{0}{\pgfplotsretval}}% + \pgfpointnormalised{}% + \else + \pgfqpoint{0pt}{1pt}% + \fi + \fi + \pgf@process{}% + \endgroup +}% + +\def\pgfplotspoint@initialisation@axes@smithchart{% + \begingroup + %\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% + \gdef\pgfplotspointminminmin{\pgfplotsqpointxy@smithchart@canvas{0}{0}}% + % + % the "x" axis is the diameter of the circle (for fixed y=0) + \pgf@x=2\pgf@xx + \pgf@y=0pt + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \xdef\pgfplotspointxaxislength{\pgfmathresult pt}% + % + \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}% + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % + % the length of the "y" axis is 2*pi*r (for fixed x=0, the outer + % circle). + % The radius is the length of (0,1) which is (0pt,\pgf@xx1): + \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{1}% + \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r + \xdef\pgfplotspointyaxislength{\pgfmathresult pt}% + % + \global\let\pgfplotspointzaxis=\pgfpointorigin + \gdef\pgfplotspointzaxislength{0pt}% + \endgroup + % + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xx}% + \pgfmathdivide@{16000}{\pgfplots@loc@TMPa}% + \let\pgfplots@smithchart@axis@max@xradius@for@ycircle=\pgfmathresult + % + \ifdim\pgf@xx=\pgf@yy + \def\pgfplots@smithchart@axis@ratioxy{1}% + \def\pgfplots@smithchart@axis@ratioyx{1}% + \let\pgfplots@smithchart@axis@max@yradius@for@ycircle=\pgfplots@smithchart@axis@max@xradius@for@ycircle + \else + \edef\pgfplots@loc@TMPb{\pgf@sys@tonumber\pgf@yy}% + \pgfmathdivide@\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \let\pgfplots@smithchart@axis@ratioxy=\pgfmathresult + \pgfmathdivide@\pgfplots@loc@TMPb\pgfplots@loc@TMPa + \let\pgfplots@smithchart@axis@ratioyx=\pgfmathresult + % + \pgfmathdivide@{16000}{\pgfplots@loc@TMPb}% + \let\pgfplots@smithchart@axis@max@yradius@for@ycircle=\pgfmathresult + \fi +} +\let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units +\def\pgfplotspoint@initialisation@units@smithchart{% + \pgfplotspoint@initialisation@units@orig + \def\pgfplotspointunity{% + \pgfplotspointouternormalvectorofaxisgetv{0v0}% x=0 (outer circle) and v varies (the yticks) + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + \pgfpointnormalised{\pgfplotsqpointxy{0}{\ifx\pgfplotsretval\pgfutil@empty 0\else\pgfplotsretval\fi}}% + \pgf@xa=-\pgf@y + \global\pgf@y=\pgf@x + \global\pgf@x=\pgf@xa + }% + \def\pgfplotsunitylength{1}% + \def\pgfplotsunityinvlength{1}% +}% + +\def\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf@smithchartaxis#1{% + %\pgfplots@clippath@install{\pgfusepath{clip}}% +}% + +% At this time, the minor/major tick lists are initialised. +\def\pgfplots@draw@axis@is@prepared@smithchartaxis{% + \pgfplots@gridlines@init@grid@stop@points@for xy% + \pgfplots@gridlines@init@grid@stop@points@for yx% + % + % and finalize x: + \def\pgfplots@finalize@constraints{1}% + \pgfplots@gridlines@init@grid@stop@points@for@computethem{x}{y}{\pgfplots@finalize@constraints}% +}% + + +% Initialises the '#1grid each nth passes #2' and '#1grid stop at #2' +% features. All it does is to prepare the +% method \pgfplots@get@current@grid@stop@point. +% +% The method is quite involved. Please refer to the manual for what it +% is supposed to do, and refer to the code comments below for +% implementational details. +% +% #1 either x or y +% #2 either x or y +\def\pgfplots@gridlines@init@grid@stop@points@for#1#2{% + % + \expandafter\let\csname pgfplots@#1grid@stop@points\endcsname=\relax + % + \pgfkeysgetvalue{/pgfplots/#1grid each nth passes #2}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + % we have no "xticknum -> xtickpos" lookup table yet. + \expandafter\def\csname b@pgfplots@#2ticknum@to@pos@lookup\endcsname{0}% + % + \pgfplotslistnewempty\pgfplots@loc@TMPd + % normalise the argument for 'ygrid each nth passes x': each list element + % should be of the form '<xtickpos>:<n>' where <n> means that each + % <n>th arc can pass. + \expandafter\pgfplotsutilforeachcommasep\pgfplots@loc@TMPa\as\entry{% + \expandafter\pgfplots@gridlines@init@grid@stop@points@for@normalise\entry\relax#1#2% + \expandafter\pgfplotslistpushback\entry\to\pgfplots@loc@TMPd + }% + \expandafter\let\csname pgfplots@#1grid@stop@points\endcsname=\pgfplots@loc@TMPd + % + % Ok. + % + % Now, the 'ygrid each nth passes x' feature relies *crucially* on grid line + % indices (for the 'each nth' feature). + % + % I sort the arcs according to their absolute magnitude and assign + % indices into the resulting arrays to normalize that stuff. + % + % The array is of the form + % A[i] = entry of \pgfplots@prepared@tick@positions@* + % and contains *both*, major and minor grid lines. + \pgfplotsarraynewempty\pgfplots@gridlines + \pgfplotscoordmath{default}{zero}% + \edef\elem{{-1}{\pgfmathresult}}% require 0 to be zero for symmetry even if there is no such tick pos + \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines + \pgfplots@if{pgfplots@#1majorgrids}{% + % insert all major tick positions, using their absolute value. + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}% + \pgfplotscoordmath{default}{op}{abs}{{\pgfmathresult}}% + \edef\elem{{\pgfplots@ticknum}{\pgfmathresult}}% + \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines + }% + }{}% + \pgfplots@if{pgfplots@#1minorgrids}{% + % now the same for minor grid positions: + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}% + \pgfplotscoordmath{default}{op}{abs}{{\pgfmathresult}}% + \edef\elem{{\pgfplots@ticknum}{\pgfmathresult}}% + \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines + }% + }{}% + % sort the array! + \pgfkeysgetvalue{/pgfplots/smithchart@sortlt/.@cmd}\pgfplots@loc@TMPa + \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplots@loc@TMPa + \pgfplotsarraysort\pgfplots@gridlines + % + % ok. Now it is sorted. + % + % I finally need a lookup + % \pgfplots@ticknum --> sort index. + % If the associated values have the same absolute value, the same + % sort index should be assigned. + % + % For example, the array might be associated to the following tick + % positions, sorted by absolute value: + % 0.0, 1.0, -1.0, 3.0, -3.0, 4.0, -4.0, 5.0, -5.0 + % What I want is that + % 0.0 gets sort index 0 + % 1.0 and -1.0 get sort index 1 + % 3.0 and -3.0 get sort index 2 + % 4.0 and -4.0 get sort index 3 + % and so on. The array contains only absolute values, so that's + % not too difficult to check. + % + % Since each of the tick positions can be (uniquely) identified by + % its associated \pgfplots@ticknum value, I map \pgfplots@ticknum + % to the sort index. + \countdef\c@sortindex=\c@pgf@counta + \c@sortindex=\pgfkeysvalueof{/pgfplots/#1grid each nth passes #2 start} % this is assigned to the '0.0' gridline (if any) + \def\pgfplots@lasttickpos{}% + \pgfplotsarrayforeachungrouped\pgfplots@gridlines\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \ifx\pgfplots@lasttickpos\pgfutil@empty + \else + \ifx\pgfplots@lasttickpos\pgfplots@tick + \else + \advance\c@sortindex by1 + \fi + \fi + \expandafter\edef\csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname{\the\c@sortindex}% +%\message{\pgfplots@ticknum\space(abs(tickpos) = \pgfplots@tick)---> sort index \csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname^^J}% + \let\pgfplots@lasttickpos=\pgfplots@tick + }% + % + % unfortunately, I can't free the \pgfplots@gridlines array + % without extensive overhead :-( + \fi + % + \expandafter\let\csname b@pgfplots@#1gridline@stopmap\endcsname\relax + \pgfkeysgetvalue{/pgfplots/#1grid stop at #2}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa,}% this inserts the final comma and handles any active ':' sign (for french babel) + \def\pgfplots@loc@TMPb{\pgfplots@gridlines@init@stop@maps #1#2}% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI% + \fi + % + % + % Now, compute all final stop positions. Also prepare the cross + % dependencies between x grids and y grids here (such that there + % is no grid line stopping in white space) + % + \if#1x% + \def\pgfplots@finalize@constraints{0}% we have to wait until y stop points are known. + \else + \def\pgfplots@finalize@constraints{1}% + \fi + \pgfplots@gridlines@init@grid@stop@points@for@computethem{#1}{#2}{\pgfplots@finalize@constraints}% +}% +% #1,#2,#3 the arguments for +% \pgfplots@gridlines@preparation@get@current@grid@stop@point +\def\pgfplots@gridlines@init@grid@stop@points@for@computethem#1#2#3{% + % + \expandafter\pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}\let\pgfplots@tick=\pgfmathresult + \pgfplots@gridlines@preparation@get@current@grid@stop@point{#1}{#2}{\pgfplots@tick}{#3}% + \if1#3% + \pgfplots@gridlines@let{#1}{\pgfplots@tick@prepared}=\pgfplotsretval + \fi + }% + \expandafter\pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}\let\pgfplots@tick=\pgfmathresult + \pgfplots@gridlines@preparation@get@current@grid@stop@point{#1}{#2}{\pgfplots@tick}{#3}% + \if1#3% + \pgfplots@gridlines@let{#1}{\pgfplots@tick@prepared}=\pgfplotsretval + \fi + }% + \expandafter\def\csname b@pgfplots@#1gridline@stopmap\endcsname{1}% +} + +\def\pgfplots@gridlines@init@stop@maps#1#2{% + \pgfutil@ifnextchar\pgfplots@EOI{% + \pgfutil@gobble + }{% + \pgfutil@ifnextchar,{% + \pgfplots@gridlines@init@stop@maps@next@@#1#2% + }{% + \pgfplots@gridlines@init@stop@maps@next#1#2% + }% + }% +}% +\def\pgfplots@gridlines@init@stop@maps@next#1#2#3:#4,{% + \pgfplotscoordmath{default}{parsenumber}{#4}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplots@gridlines@stopmap@prepare{#3}% + \pgfplots@gridlines@let{#1}{\pgfmathresult}=\pgfplots@loc@TMPa + \expandafter\def\csname b@pgfplots@#1gridline@stopmap\endcsname{1}% + % + \pgfplots@gridlines@init@stop@maps #1#2% +} +% just eat one empty comma: +\def\pgfplots@gridlines@init@stop@maps@next@@#1#2,{\pgfplots@gridlines@init@stop@maps #1#2}% +\def\pgfplots@gridlines@let#1#2=#3{% + \expandafter\let\csname pgfplots@#1gridline@stopmap@#2\endcsname=#3% + \if#1y% + % support symmetry: + % add -\pgfmathresult to the map. + % To disable this symmetry, use 'ygrid stop at x={0.2:4 -0.2:5} + % you can also use an empty value '-0.2:{}', that's also ok. + \expandafter\let\csname pgfplots@#1gridline@stopmap@-#2\endcsname=#3% + \fi +}% + +\def\pgfplots@gridlines@stopmap@prepare@digits{2}% +\def\pgfplots@gridlines@stopmap@prepare#1{% + \begingroup + \pgfmathfloatparsenumber{#1}% + \let\pgfmathfloat@round@precision=\pgfplots@gridlines@stopmap@prepare@digits% + \pgfmathfloatroundzerofill\pgfmathresult + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfplots@gridlines@stopmap@trunc@#1.#2#3#4\relax{% + \def\pgfmathresult{#1.#2#3}% +}% + +\pgfkeysdefargs{/pgfplots/smithchart@sortlt}{#1#2#3#4}{% + \expandafter\pgfplots@prepared@tick@pos@unpack#1% + \let\pgfplots@A=\pgfplots@tick + \expandafter\pgfplots@prepared@tick@pos@unpack#2% + \let\pgfplots@B=\pgfplots@tick + \pgfplotscoordmath{default}{if less than}{\pgfplots@A}{\pgfplots@B}{#3}{#4}% +}% + +% initialise a lookuptable from ticknumber -> tick position (sort +% of an array) +% +% This is only invoked if it is needed (if 'arc +% limits={[index]4,[index]2}' or something like that is used, see the +% manual). +% +% #1 either x or y +% #2 either x or y +\def\pgfplots@gridlines@init@grid@stop@points@for@init@ticknum@lookup#1#2{% + \c@pgf@counta=0 + \pgfplots@if{pgfplots@#1majorgrids}{% + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#2\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \expandafter\let\csname pgfplots@#2tick@num@to@pos@\the\c@pgf@counta\endcsname=\pgfplots@tick + \advance\c@pgf@counta by1 + }% + }{}% + \pgfplots@if{pgfplots@#1minorgrids}{% + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#2\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \expandafter\let\csname pgfplots@#2tick@num@to@pos@\the\c@pgf@counta\endcsname=\pgfplots@tick + \advance\c@pgf@counta by1 + }% + }{}% + \expandafter\def\csname b@pgfplots@#2ticknum@to@pos@lookup\endcsname{1}% +}% +\def\pgfplots@gridlines@init@grid@stop@points@for@normalise#1\relax#2#3{% + \def\b@pgfplots@haslt{0}% + % + \pgfutil@in@{if <}{#1}% + \ifpgfutil@in@ + % strip the white space between 'if' and '<': + \def\pgfplots@loc@TMPa##1if <##2\relax{\edef\entry{##1if<##2}}% + \expandafter\pgfplots@loc@TMPa\entry\relax + \def\b@pgfplots@haslt{1}% + \fi + % + \pgfutil@in@{if<}{#1}% + \ifpgfutil@in@ + \def\b@pgfplots@haslt{1}% + \fi + % + \pgfutil@in@:{#1}% + \ifpgfutil@in@ + \def\b@pgfplots@hascolon{1}% + \else + \def\b@pgfplots@hascolon{0}% + \fi + % + \if1\b@pgfplots@hascolon + \edef\entry{\entry\if0\b@pgfplots@haslt if<\fi}% + \else + \if1\b@pgfplots@haslt + \expandafter\pgfplots@gridlines@stop@at@unpack@@@\entry\relax + \edef\entry{\pgfplots@grid@stop@at:2if<\pgfplots@grid@stop@at@iflt}% + \else + \edef\entry{\entry:2if<}% + \fi% + \fi% + % + \pgfutil@in@{[index]}{#1}% + \ifpgfutil@in@ + \if0\csname b@pgfplots@#3ticknum@to@pos@lookup\endcsname + \pgfplots@gridlines@init@grid@stop@points@for@init@ticknum@lookup#2#3% + \fi + \expandafter\pgfplots@gridlines@stop@at@unpack\entry\relax + \pgfutil@ifundefined{pgfplots@#3tick@num@to@pos@\pgfplots@grid@stop@at}{% + \pgfplots@warning{There is no #3tick with index '\pgfplots@grid@stop@at'. Skipping it.}% + \let\entry=\pgfutil@empty + }{% + \edef\entry{\csname pgfplots@#3tick@num@to@pos@\pgfplots@grid@stop@at\endcsname:\pgfplots@grid@stop@at@eachnth}% + }% + \fi + % + \expandafter\pgfplots@gridlines@stop@at@unpack\entry\relax + \pgfplotscoordmath{default}{parsenumber}\pgfplots@grid@stop@at + \let\pgfplots@grid@stop@at=\pgfmathresult + \ifx\pgfplots@grid@stop@at@iflt\pgfutil@empty + \else + \pgfplotscoordmath{default}{parsenumber}\pgfplots@grid@stop@at@iflt + \let\pgfplots@grid@stop@at@iflt=\pgfmathresult + \fi + \edef\entry{\pgfplots@grid@stop@at:\pgfplots@grid@stop@at@eachnth if<\pgfplots@grid@stop@at@iflt}% +}% +\def\pgfplots@gridlines@stop@at@unpack@@@#1if<#2\relax{% + \def\pgfplots@grid@stop@at{#1}% + \def\pgfplots@grid@stop@at@iflt{#2}% +}% +\def\pgfplots@gridlines@stop@at@unpack#1:#2if<#3\relax{% + \def\pgfplots@grid@stop@at{#1}% + \def\pgfplots@grid@stop@at@eachnth{#2}% + \def\pgfplots@grid@stop@at@iflt{#3}% +}% + +% Returns the xtick position which should end the current arc. +% +% This is an INTERNAL preparation method. See +% \pgfplots@get@current@grid@stop@point for the final one. +% +% Note that arcs correspond to ygrid lines. +% +% #1 either x or y +% #2 either x or y +% #3 the value of the current grid line +% #4 a boolean which expands either to 0 or to 1. +% The \pgfplots@get@current@grid@stop@point@handle@constraints method +% will be invoked if and only if #4=1 +% +% @POSTCONDITION On output, +% - \pgfplotsretval will be filled with the +% result. If the result is empty, no restriction is imposed. +% Otherwise, it contains the #2tick value at which the current #1grid shall end. +% The result is already processed with +% \pgfplotscoordmath{default}{parsenumber}{<value>} +% - \pgfplots@tick@prepared contains a rounded representation of #3. +% +% The method relies on the 'ygrid each nth passes x' feature, more specifically the +% stuff prepared by \pgfplots@gridlines@init@grid@stop@points@for +\def\pgfplots@gridlines@preparation@get@current@grid@stop@point#1#2#3#4{% + \def\pgfplotsretval{}% + % + \pgfplots@gridlines@stopmap@prepare{#3}% + \let\pgfplots@tick@prepared=\pgfmathresult + \pgfmathfloatabs@\pgfplots@tick@prepared + \let\pgfplots@tick@prepared@abs=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{abs}{{#3}}% + \let\pgfplots@tick@abs=\pgfmathresult + % + % first: check the '#1grid stop at #2': + \expandafter\ifx\csname b@pgfplots@#1gridline@stopmap\endcsname\relax% + % ok. there is no such thing. + \else + % ah - process it! + \pgfutil@ifundefined{pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared}{% + }{% + \edef\pgfplotsretval{\csname pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared\endcsname}% + }% + \fi + % + \ifx\pgfplotsretval\pgfutil@empty + % the individual map failed. Ok, then check for the '#1grid each nth passes #2' + \expandafter\ifx\csname pgfplots@#1grid@stop@points\endcsname\relax + \else + % \pgfplots@ticknum is defined in this context here. + \pgfutil@ifundefined{pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum}{% + \pgfplots@warning{Sorry, I can't get the current arc limit for #1grid no \#\pgfplots@ticknum\space(value \pgfplots@tick). This seems like an internal error!?}% + }{% + % get the sort index for the current tick (which is + % uniquely identified by its \pgfplots@ticknum) + \expandafter\let\expandafter\pgfplots@k\csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname + % + \expandafter\pgfplotslistforeachungrouped\csname pgfplots@#1grid@stop@points\endcsname\as\pgfplots@loc@TMPa{% + \ifx\pgfplotsretval\pgfutil@empty + % we found no final limit so far. proceed. + \expandafter\pgfplots@gridlines@stop@at@unpack\pgfplots@loc@TMPa\relax + \ifx\pgfplots@grid@stop@at@iflt\pgfutil@empty + \pgfplots@loop@CONTINUEtrue + \else + \pgfplotscoordmath{default}{if less than}{\pgfplots@tick@abs}{\pgfplots@grid@stop@at@iflt}{% + \pgfplots@loop@CONTINUEtrue + }{% + \pgfplots@loop@CONTINUEfalse + }% + \fi + % + \ifpgfplots@loop@CONTINUE + \pgfplotsmathmodint\pgfplots@k\pgfplots@grid@stop@at@eachnth + \ifnum\pgfmathresult=0 + \c@pgf@counta=\pgfplots@k + \divide\c@pgf@counta by\pgfplots@grid@stop@at@eachnth\relax + \edef\pgfplots@k{\the\c@pgf@counta}% + \else + % found the final limit. + % + % Now, check the constraints which couple + % X and Y. + \let\pgfplotsretval=\pgfplots@grid@stop@at + \if1#4% + \pgfplots@get@current@grid@stop@point@handle@constraints #1#2{#3}% + \fi + \fi + \fi + \fi + }% + }% + \fi + \fi + \ifx\pgfplotsretval\pgfutil@empty + \else + \expandafter\let\csname pgfplots@final@stop@point@for@#1tick@\pgfplots@tick@prepared\endcsname=\pgfplotsretval +%\message{#1 grid line: storing end value for '#3' END[\pgfplots@tick@prepared] = \pgfplotsretval.^^J}% + \fi +}% + +% PRECONDITION +% \pgfplotsretval contains a non-zero constraint for the ygrid at #1. +% +% POSTCONDITION +% either \pgfplotsretval is unchanged, or it is reset to +% \pgfutil@empty if constraints are violated. +% +% The constraints are ONLY effective if BOTH, incomplete x- and y grid +% lines are in effect. In that case, it should never happen that a +% single grid line ends in a dead-end somewhere in white space. +% +% I enforce two constraints which apply only to ygrid to fix this +% issue (this may be improved later). +% +% The idea is simple: +% 1. suppose the grid line 'x=1' stops at 'y=5'. +% Suppose further that the y grid line 'y=0.95' should stop at 'x=1'. +% Is that acceptable? Yes, because |y| < 5. +% Now, suppose an y grid line with |y| > 5 should stop at 'x=1'. +% Is this allowed? NO! Because it would become a dead end since +% the 'x=1' line ends at 'y=5'! +% +% So, whenever we consider ygrids and stop point candidates "x=X", +% acquire the value Q where the x (!) grid line "x=X" stops. +% If |y| > Q, the candidate "x=X" is rejected. +% +% 2. There might still be the case that x grid lines have dead-ends. +% The current solution applies the idea first to all y grid lines, +% and once the y grid lines are ready, it applies the same idea to +% x grid lines. +% +% Uncomment the routine(s) and run the test cases to see what happens. +\def\pgfplots@get@current@grid@stop@point@handle@constraints#1#2#3{% + \ifx\pgfplotsretval\pgfutil@empty + \else + \pgfplots@gridlines@stopmap@prepare{\pgfplotsretval}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % +%\message{checking ending '#1=#3' at '#2=\pgfplotsretval'. '#2=\pgfplots@loc@TMPa' stops}% + \pgfutil@ifundefined{pgfplots@final@stop@point@for@#2tick@\pgfplots@loc@TMPa}{% + % no constraint. Ok. +%\message{ nowhere. No constraint.^^J}% + }{% +%\message{ at \pgfplots@loc@TMPa. Feasible: }% + % Oh, a constraint. That means + % further work. + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@final@stop@point@for@#2tick@\pgfmathresult\endcsname + \pgfplotscoordmath{default}{op}{abs}{{#3}}% + \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@loc@TMPa}{% + % ok, we can use the found + % stop value. +%\message{YES.^^J}% + }{% +%\message{NO.^^J}% + % no, the stop value is + % invalid; it would stop in + % white space! + \let\pgfplotsretval=\pgfutil@empty + }% + }% + \fi +}% + +% Returns the xtick position which should end the current arc. +% +% Note that arcs correspond to ygrid lines. +% +% #1 either x or y +% #2 either x or y +% #3 the value of the current grid line +% +% @POSTCONDITION On output, \pgfplotsretval will be filled with the +% result. If the result is empty, no restriction is imposed. +% Otherwise, it contains the #2tick value at which the current #1grid shall end. +% The result is already processed with +% \pgfplotscoordmath{default}{parsenumber}{<value>} +% +% The method relies on the 'ygrid each nth passes x' feature, more specifically the +% stuff prepared by \pgfplots@gridlines@init@grid@stop@points@for +% +% Note that all work has already been done by +% \pgfplots@gridlines@init@grid@stop@points@for. We only need to query +% the result at this point. +% @see \pgfplots@gridlines@init@grid@stop@points@for +% @see \pgfplots@gridlines@preparation@get@current@grid@stop@point +\def\pgfplots@get@current@grid@stop@point#1#2#3{% + \def\pgfplotsretval{}% + % + % check the '#1grid stop at #2': + \expandafter\ifx\csname b@pgfplots@#1gridline@stopmap\endcsname\relax% + % ok. there is no such thing. + \else + % + \pgfplots@gridlines@stopmap@prepare{#3}% + \let\pgfplots@tick@prepared=\pgfmathresult + \pgfmathfloatabs@\pgfplots@tick@prepared + \let\pgfplots@tick@prepared@abs=\pgfmathresult + % + % ah - process it! + \pgfutil@ifundefined{pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared}{% + \let\pgfplotsretval\pgfutil@empty + }{% + \edef\pgfplotsretval{\csname pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared\endcsname}% + }% + \fi + % +}% + + +\def\pgfplots@smithchart@draw@xcircle#1{% + \pgfplotscoordmath{default}{one}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % + \pgfplotscoordmath{default}{parsenumber}{#1}% + \let\pgfplots@x=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@loc@TMPa}{\pgfplots@x}}% + \let\pgfplots@radius@inverse=\pgfmathresult + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}% + \let\pgfplots@radius=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@x}}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let\pgfplots@center=\pgfmathresult + % + \pgfplotscoordmath{default}{tofixed}{\pgfplots@radius}% + \let\pgfplots@radius=\pgfmathresult + % + \pgfplotscoordmath{default}{tofixed}{\pgfplots@radius@inverse}% + \let\pgfplots@radius@inverse=\pgfmathresult + % + % This here would suffice in case 'xgrid each nth passes y={}': +% \pgfpathellipse +% {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@center}{0}} +% {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@radius}{0}} +% {\pgfplotsqpointxy@smithchart@canvas{0}{\pgfplots@radius}}% + % + % but we also check for the 'xgrid each nth passes y' feature: + \pgfplots@get@current@grid@stop@point xy{\pgfplots@x}% + \let\pgfplots@arc@ends@at@y@arc@value\pgfplotsretval% + % + \ifx\pgfplots@arc@ends@at@y@arc@value\pgfutil@empty + % Ok. There is no specific end point -- simply use the + % (1,0) point (i.e. draw the full circle). + % + \pgfmathadd@{\pgfplots@center}{\pgfplots@radius}% + \let\pgfplots@start=\pgfmathresult% + \def\pgfplots@startim{0}% + \def\pgfplots@startangle{0}% + \let\pgfplots@end=\pgfplots@start + \let\pgfplots@endim=\pgfplots@startim + \def\pgfplots@endangle{360}% + \else + % Ok. The arc should end before it reaches the (1,0) + % point. Determine the exact position and the + % corresponding arc end angle. + % + % In general, the intersection between the circle for + % fixed x=A and fixed y=B is given by + % + % p + j * q = (A + j * B -1 ) / ( A + j*B +1) + % see http://www.siart.de/lehre/tutorien.xhtml#smishort + \pgfplotscoordmath{default}{one}% + \let\pgfplots@one=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{-1}% + \let\pgfplots@mone=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@x}{\pgfplots@mone}}% + \let\pgfplots@A@mone=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@x}{\pgfplots@one}}% + \let\pgfplots@A@one=\pgfmathresult + % oh - we should only draw a partial arc. + % Well, then compute its end point and the + % corresponding end angle. + \pgfplotscoordmathcomplexdivision + {\pgfplots@A@mone}{\pgfplots@arc@ends@at@y@arc@value}% + {\pgfplots@A@one}{\pgfplots@arc@ends@at@y@arc@value}% + \let\pgfplots@start=\pgfmathresult + \let\pgfplots@startim=\pgfmathresultim + \pgfplotscoordmath{default}{tofixed}{\pgfplots@start}% + \let\pgfplots@start=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfplots@startim}% + \let\pgfplots@startim=\pgfmathresult + % + \pgfplots@compute@angle@of@point@in@circle\pgfplots@start\pgfplots@startim{\pgfplots@center}{\pgfplots@radius}{\pgfplots@radius@inverse}% + \let\pgfplots@startangle=\pgfmathresult + \pgfmathsubtract@{360}{\pgfplots@startangle}% + \let\pgfplots@endangle=\pgfmathresult + \let\pgfplots@end=\pgfplots@start + \edef\pgfplots@endim{-\pgfplots@startim}% + \ifdim\pgfplots@startangle pt>\pgfplots@endangle pt + \let\pgfplots@loc@TMPa=\pgfplots@startangle + \let\pgfplots@startangle=\pgfplots@endangle + \let\pgfplots@endangle=\pgfplots@loc@TMPa + \fi + \fi + % +%\message{X grid line \#\csname pgfplots@ticknum\endcsname \space at '#1': center = (\pgfplots@center,0); radius = \pgfplots@radius\space(start angle \pgfplots@startangle, end angle = \pgfplots@endangle; stops at y = \pgfplots@arc@ends@at@y@arc@value).^^J}% + % + % Now, compute the arc. + % + % first, compute the absolute x/y radii: + \pgf@xa=\pgfplots@radius\pgf@xx + \pgf@xb=\pgfplots@radius\pgf@yy + \edef\pgfplots@mirror@sign{\ifpgfplots@smithchart@mirrored -\fi}% + \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{\pgfplots@start}{\pgfplots@startim}}% + % note that the case startangle > endangle is + % automatically correct; patharc handles that. + %\edef\pgfplots@loc@TMPa{{\pgfplots@startangle}{\pgfplots@endangle}{\pgfplots@mirror@sign\the\pgf@xa\space and \the\pgf@xb}}% + %\expandafter\pgfpatharc\pgfplots@loc@TMPa + % + % prefer \pgfpatharctoprecomputed. It is faster and more accurate + \edef\pgfplots@loc@TMPa{% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@center}{0}}% + {\pgfplots@startangle}% + {\pgfplots@endangle}% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@end}{\pgfplots@endim}}% + {\pgfplots@mirror@sign\the\pgf@xa}% + {\the\pgf@xb}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioxy}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioyx}% + }% + \expandafter\pgfpatharctoprecomputed\pgfplots@loc@TMPa +} + +\def\pgfplots@smithchart@draw@yarc#1{% + \pgfplotscoordmath{default}{parsenumber}{#1}% + \let\pgfplots@y\pgfmathresult + \pgfplotscoordmath{default}{op}{abs}{{\pgfplots@y}}% + \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@almost@zero@thresh}{% + \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{-1}{0}}% + \pgfpathlineto{\pgfplotsqpointxy@smithchart@canvas{1}{0}}% + }{% + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplots@y}}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let\pgfplots@signedradius=\pgfmathresult + % + \pgfplotscoordmath{default}{tofixed}{\pgfplots@y}% + \ifdim\pgfplots@signedradius pt<0pt + \def\pgfplots@radius@sign{-}% + \edef\pgfplots@radius@inverse{-\pgfmathresult}% + \edef\pgfplots@radius{-\pgfplots@signedradius}% + \else + \def\pgfplots@radius@sign{}% + \edef\pgfplots@radius@inverse{\pgfmathresult}% + \let\pgfplots@radius=\pgfplots@signedradius + \fi + % this here is the correct, complete circle -- together + % with a clip path, you get what you want: + %\pgfpathellipse + % {\pgfplotsqpointxy@smithchart@canvas{1}{\pgfplots@signedradius}} + % {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@signedradius}{0}} + % {\pgfplotsqpointxy@smithchart@canvas{0}{\pgfplots@signedradius}}% + % But I only want the arc (probably stopped earlier to + % improve qualtity of the chart) + % + % compute start point for the arc. + % + % To do so, we need to compute the intersection between + % the circle for fixed x=0 and the circle for y=#1. + % + % In general, the intersection between the circle for + % fixed x=A and fixed y=B is given by + % + % p + j * q = (A + j * B -1 ) / ( A + j*B +1) + % see http://www.siart.de/lehre/tutorien.xhtml#smishort + % + % inserting A = 0 and B = #1 yields the result + % p=\pgfplots@start + % q=\pgfplots@startim + % as follows: + \pgfplotscoordmath{default}{one}% + \let\pgfplots@one=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{-1}% + \let\pgfplots@mone=\pgfmathresult + \pgfplotscoordmathcomplexdivision{\pgfplots@mone}{\pgfplots@y}{\pgfplots@one}{\pgfplots@y}% + \let\pgfplots@start=\pgfmathresult + \let\pgfplots@startim=\pgfmathresultim + \pgfplotscoordmath{default}{tofixed}{\pgfplots@start}% + \let\pgfplots@start=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfplots@startim}% + \let\pgfplots@startim=\pgfmathresult + % + \pgfplots@compute@angle@of@point@in@circle\pgfplots@start\pgfplots@startim{1}{\pgfplots@signedradius}{\pgfplots@radius@inverse}% + \let\pgfplots@startangle=\pgfmathresult + % + % + % compute end angle. + \pgfplots@get@current@grid@stop@point yx{\pgfplots@y}% + \let\pgfplots@arc@ends@at@x@circle@value\pgfplotsretval% + % + \ifx\pgfplots@arc@ends@at@x@circle@value\pgfutil@empty + % Ok. There is no specific end point -- simply use the + % (1,0) point (i.e. draw the full arc). + % + % The "0 degree" angle in my circles is in the direction + % of (1,0) . + \ifdim\pgfplots@startim pt>0pt + % ok; this arc belongs to the upper hemisphere. + \def\pgfplots@endangle{270}% + \else + % ok; this arc belongs to the lower hemisphere. + \def\pgfplots@endangle{90}% + \fi + \def\pgfplots@end{1}% + \def\pgfplots@endim{0}% + \else + % Ok. The arc should end before it reaches the (1,0) + % point. Determine the exact position and the + % corresponding arc end angle. + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@arc@ends@at@x@circle@value}{\pgfplots@mone}}% + \let\pgfplots@A@mone=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@arc@ends@at@x@circle@value}{\pgfplots@one}}% + \let\pgfplots@A@one=\pgfmathresult + % oh - we should only draw a partial arc. + % Well, then compute its end point and the + % corresponding end angle. + \pgfplotscoordmathcomplexdivision{\pgfplots@A@mone}{\pgfplots@y}{\pgfplots@A@one}{\pgfplots@y}% + \let\pgfplots@end=\pgfmathresult + \let\pgfplots@endim=\pgfmathresultim + \pgfplotscoordmath{default}{tofixed}{\pgfplots@end}% + \let\pgfplots@end=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfplots@endim}% + \let\pgfplots@endim=\pgfmathresult + % + \pgfplots@compute@angle@of@point@in@circle\pgfplots@end\pgfplots@endim{1}{\pgfplots@signedradius}{\pgfplots@radius@inverse}% + \let\pgfplots@endangle=\pgfmathresult + \fi + % + % + % + % Now, compute the arc. + % + % first, compute the absolute x/y radii: + % + % Note that for small y (like y=0.01), the arc is almost a + % straight line. Consequently, the ellipsis radius will be much larger + % than 16000, violating TeX's number range. + % + % To avoid that, I clip it to the highest allowed value. + % The final radius is + % \pgfplots@radius * \pgf@xx and \pgfplots@radius * \pgf@yy. + % the clipped value thus needs to respect the magnitude of \pgf@xx and \pgf@yy. + \ifdim\pgfplots@radius pt<\pgfplots@smithchart@axis@max@xradius@for@ycircle pt + \let\pgfplots@radius@x\pgfplots@radius + \else + \let\pgfplots@radius@x=\pgfplots@smithchart@axis@max@xradius@for@ycircle + \fi + \ifdim\pgfplots@radius pt<\pgfplots@smithchart@axis@max@yradius@for@ycircle pt + \let\pgfplots@radius@y\pgfplots@radius + \else + \let\pgfplots@radius@y=\pgfplots@smithchart@axis@max@yradius@for@ycircle + \fi +%\message{Y grid line \#\csname pgfplots@ticknum\endcsname\space at '#1': center = (1,\pgfplots@signedradius); signedradius = \pgfplots@signedradius\space clipped radii = \pgfplots@radius@x*\the\pgf@xx\space and \pgfplots@radius@y*\the\pgf@yy\space ( start angle \pgfplots@startangle, end angle \pgfplots@endangle, arc limit: \ifx\pgfplots@arc@ends@at@x@circle@value\pgfutil@empty NONE\else \pgfplots@arc@ends@at@x@circle@value\fi)^^J}% + \pgf@xa=\pgfplots@radius@x\pgf@xx + \pgf@xb=\pgfplots@radius@y\pgf@yy + \edef\pgfplots@mirror@sign{\ifpgfplots@smithchart@mirrored -\fi}% + \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{\pgfplots@start}{\pgfplots@startim}}% + % note that the case startangle > endangle is + % automatically correct; patharc handles that. + %\edef\pgfplots@loc@TMPa{{\pgfplots@startangle}{\pgfplots@endangle}{\pgfplots@mirror@sign\the\pgf@xa\space and \the\pgf@xb}}% + %\expandafter\pgfpatharc\pgfplots@loc@TMPa + % + % prefer \pgfpatharctoprecomputed. It is faster and more accurate + \ifdim\pgfplots@startangle pt>\pgfplots@endangle pt + \let\pgfplots@loc@TMPa=\pgfplots@startangle +% \let\pgfplots@startangle=\pgfplots@endangle +% \let\pgfplots@endangle=\pgfplots@loc@TMPa + \fi + \edef\pgfplots@loc@TMPa{% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{1}{\pgfplots@radius@sign\pgfplots@radius@y}}% + {\pgfplots@startangle}% + {\pgfplots@endangle}% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@end}{\pgfplots@endim}}% + {\pgfplots@mirror@sign\the\pgf@xa}% + {\the\pgf@xb}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioxy}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioyx}% + }% + \expandafter\pgfpatharctoprecomputed\pgfplots@loc@TMPa + }% +} + +\def\pgfplots@drawgridlines@onorientedsurf@fromto@smithchart#1{% + \if x\pgfplotspointonorientedsurfaceA + \pgfplots@smithchart@draw@xcircle{#1}% + \else + \pgfplots@smithchart@draw@yarc{#1}% + \fi +}% + +% Given a circle with center point (#3,#4), we search for the angle +% of the point (#1,#2). The point is expected to be on the circle. +% The resulting angle is returned in \pgfmathresult +% +% #1 x coordinate of the point for which an angle is searched +% #2 y coordinate of the point for which an angle is searched +% #3 x coordinate of the circle's center point +% #4 y coordinate of the circle's center point +% #5 is either empty or it is expected to contain the inverse radius, 1/r +% this information is available in my context, so I don't recompute +% it. +% +% All coordinates are expected in standard TeX precision (numbers +% without unit) +\def\pgfplots@compute@angle@of@point@in@circle#1#2#3#4#5{% + % + % 1. compute diff vector from center=(1,\pgfplots@signedradius) to start: + \pgfmathsubtract@{#1}{#3}% + \let\pgfplots@D\pgfmathresult + \pgfmathsubtract@{#2}{#4}% + \let\pgfplots@Dim\pgfmathresult + % + % 2. compute the start angle. + % It is related to the angle between the point (1,0) and + % diff, which, in turn is given by + % < (1,0), (D,Dim) > = cos(alpha) ||(D,Dim)|| + % < (1,0), (D,Dim) > = D + % + % Note that ||(D,Dim)|| = r, the radius of the involved circle + % around (#3,#4). If 1/r is already available, use it! Saves a lot + % of time. + % + \def\pgfplots@loc@TMPa{#5}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfmathveclen\pgfplots@D\pgfplots@Dim + \let\pgfplots@veclen=\pgfmathresult + \pgfmathreciprocal@\pgfplots@veclen + \let\pgfplots@inverseveclen=\pgfmathresult + \else + % oh, good -- we already have 1/||(D,Dim)||. Use it. + \def\pgfplots@inverseveclen{#5}% +%\message{using already available inverseveclen '#5' }% + \fi + \pgfmathmultiply@{\pgfplots@D}{\pgfplots@inverseveclen}% +%\message{D= (\pgfplots@D,\pgfplots@Dim).. acos(\pgfplots@D * \pgfplots@inverseveclen) = acos(\pgfmathresult)}% + \pgfmathacos@{\pgfmathresult}% the '-' comes from D<0 . +%\message{= \pgfmathresult^^J}% + \let\pgfplots@tmpangle\pgfmathresult% + % ok. tmpangle is per definition less than 180; it is the + % smaller angle between (1,0) and (D,Dim). + % + % compute the angle relative to (1,0): + \ifdim\pgfplots@Dim pt<0pt + \pgfmathsubtract@{360}{\pgfplots@tmpangle}% + \fi +}% + +\def\pgfplots@drawaxis@innerlines@onorientedsurf@smithchart#1#2#3{% + \if2\csname pgfplots@#1axislinesnum\endcsname + \draw[/pgfplots/every inner #1 axis line,% + decorate,% + #1discont,% + decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}] + \pgfextra + \csname pgfplotspointonorientedsurfaceabsetupforset#3\endcsname{\csname pgfplots@logical@ZERO@#3\endcsname}{2}% + \if#1x% + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{0}% + \else + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}% + \fi + \endpgfextra + ; + \fi +}% +\def\pgfplots@drawaxis@outerlines@separate@onorientedsurf@smithchartaxis#1#2{% + \if2\csname pgfplots@#1axislinesnum\endcsname + % centered axis lines handled elsewhere. + \else + \scope[/pgfplots/every outer #1 axis line, + #1discont,decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}] + \if#1x + \draw decorate { + \pgfextra + % exchange roles of A <-> B axes: + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{0}% + \endpgfextra + }; + \else + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% + \draw decorate { + \pgfextra + % exchange roles of A <-> B axes: + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2min\endcsname}% + \endpgfextra + }; + }{}% + %-------------------------------------------------- + % \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% + % \draw decorate { + % \pgfextra + % % exchange roles of A <-> B axes: + % \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + % \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2max\endcsname}% + % \endpgfextra + % }; + % }{}% + %-------------------------------------------------- + \fi + \endscope + \fi +}% + +\def\pgfplots@initsizes@smithchart{% + % I copy-pasted most of this code, up to just one position where + % I introduced the modified scaling for smithchart axes + %---------------------------------- + % INIT. + % + % + \def\pgfplots@minmax@reg@forbidden{\pgfplots@error{Sorry, an internal logic error occured during smithchart processing (a routine tried to access \string\pgfplots@xmin@reg\space or its variants). Please report this as bug, sorry}}% + \iffalse + \pgfplots@xmin@reg=\pgfplots@xmin pt % + \pgfplots@xmax@reg=\pgfplots@xmax pt % + \pgfplots@ymin@reg=\pgfplots@ymin pt % + \pgfplots@ymax@reg=\pgfplots@ymax pt % + \ifpgfplots@threedim + \pgfplots@zmin@reg=\pgfplots@zmin pt % + \pgfplots@zmax@reg=\pgfplots@zmax pt % + \fi + \else + \let\pgfplots@xmin@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@xmax@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@ymin@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@ymax@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@zmin@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@zmax@reg=\pgfplots@minmax@reg@forbidden + \fi + % + % + %----------------------------------------- + % PROCESS THE 'width' and 'height' options + %----------------------------------------- + % + % + \pgfkeysgetvalue{/pgfplots/view/az}{\pgfplots@view@az}% + \pgfkeysgetvalue{/pgfplots/view/el}{\pgfplots@view@el}% + \ifpgfplots@threedim + \def\pgfplots@tmpZscale{1pt}% + \else + \def\pgfplots@tmpZscale{0pt}% + \let\pgfplots@view@el=\pgfutil@empty + \let\pgfplots@view@az=\pgfutil@empty + \fi + \ifx\pgfplots@view@az\pgfutil@empty + %\let\pgfplots@rectangle@width=\pgfutil@empty + %\let\pgfplots@rectangle@height=\pgfutil@empty + \def\pgfplots@view@dir@threedim@x{0}% + \def\pgfplots@view@dir@threedim@y{0}% + \def\pgfplots@view@dir@threedim@z{1}% + % + % FIXME HERE COMES THE smithchart MODIFICATION + %-------------------------------------------------- + % \pgfpointdiff + % {\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}} + % {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + %-------------------------------------------------- + % instead of scaling from (min) (max), we only need the UPPER + % bound -- in both, x and y directions (since we have a cycle. + % Furthermore, we need it twice since we are interested in the + % diameter, not the radius. + \global\pgf@x=2 pt % radius + \global\pgf@y=\pgf@x % same for y + % + % only used temporarily in this macro to compute the correct + % length for unit vectors: + \edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}% + \edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}% + % + \ifx\pgfplots@x\pgfutil@empty + \ifx\pgfplots@width\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! WIDTH NOT SET}% + \fi + \pgfplots@initsizes@getXscale\pgfplots@initsizes@axisdiag@x\into\pgfplots@tmpXscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@width=\pgfplots@width + %\fi + \else + \def\pgfplots@tmpXscale{1}% + \fi + % + \ifx\pgfplots@y\pgfutil@empty + \ifx\pgfplots@height\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! HEIGHT NOT SET}% + \fi + \pgfplots@initsizes@getYscale\pgfplots@initsizes@axisdiag@y\into\pgfplots@tmpYscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@height=\pgfplots@height + %\fi + \else + \def\pgfplots@tmpYscale{1}% + \fi + % + \edef\pgfplots@tmpXscale{\pgfplots@tmpXscale pt}% + \edef\pgfplots@tmpYscale{\pgfplots@tmpYscale pt}% + % + \pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}% + \pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}% + \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}% + \else + % 3D case is currently always initialised by `view': + \let\pgfplots@x=\pgfutil@empty + \let\pgfplots@y=\pgfutil@empty + \let\pgfplots@z=\pgfutil@empty + \pgfplotssetaxesfromazel{\pgfplots@view@az}{\pgfplots@view@el}{\pgfplots@tmp@xisaxisparallel}% + \if1\pgfplots@tmp@xisaxisparallel% + \def\pgfplots@tmp@yisaxisparallel{1}% + \fi + \fi +%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }% + % + \let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure + \let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure + % + \pgfplotsmath@ifzero{\pgfplots@x@veclength}{\pgfplots@hide@xtrue\pgfplots@shownothingof@xtrue}{}% + \pgfplotsmath@ifzero{\pgfplots@y@veclength}{\pgfplots@hide@ytrue\pgfplots@shownothingof@ytrue}{}% + \ifpgfplots@threedim + \pgfplotsmath@ifzero{\pgfplots@z@veclength}{\pgfplots@hide@ztrue\pgfplots@shownothingof@ztrue}{}% + \else + \if1\pgfplots@tmp@xisaxisparallel% + \if1\pgfplots@tmp@yisaxisparallel% + % Optimize for axis-parallel case! + % puh. Did not make any measureable difference!? Ok... + \let\pgfplotsqpointxy=\pgfplotsqpointxy@orthogonal + \fi + \fi + \fi + % + % FIXME : unit vector ratio / axis equal + % +} + +\def\pgfplots@handle@invalid@range@defaultlimits@smithchart{% + \pgfplotscoordmath{x}{parsenumber}{0}% + \global\let\pgfplots@xmin=\pgfmathresult + \pgfplotscoordmath{x}{parsenumber}{16000}% + \global\let\pgfplots@xmax=\pgfmathresult + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \global\let\pgfplots@data@xmax=\pgfplots@xmax + % + \pgfplotscoordmath{y}{parsenumber}{0}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{parsenumber}{16000}% + \global\let\pgfplots@ymax=\pgfmathresult + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \global\let\pgfplots@data@ymax=\pgfplots@ymax + \pgfplotsset{enlargelimits=false}% +} + +\let\pgfplots@set@default@size@options@standard=\pgfplots@set@default@size@options +\def\pgfplots@set@default@size@options@smithchart{% + \pgfplots@set@default@size@options@standard + \pgfplotsset{smithchart ticks by size={\pgfkeysvalueof{/pgfplots/width}}{\pgfkeysvalueof{/pgfplots/height}}}% + % + \if1\b@pgfplots@smithchart@defaultticks@x + \if1\b@pgfplots@smithchart@defaultticks@y + \pgfplotsset{default smithchart xytick}% + \fi + \fi +} +\def\pgfplots@assign@default@tick@foraxis@smithchart#1{% + % do nothing here. I don't know the algorithm yet... but for + % smithcharts, it may be sufficient to simply predefine several + % sets of ticks, depending on the final size. + % + % This is realized in + % \pgfplots@set@default@size@options@smithchart (which is invoked + % before the ticks are processed). + \pgfplots@determinedefaultvalues@needs@check@uniformtickfalse + \expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfutil@empty + % + \pgfplotsset{default smithchart #1tick}% + % ok, I expect the '#1tick' key to be set now. Process it. + % Note that the earlier processing of pgfplots has been bypassed + % at this point -- we need to preprocess the tick list *here*: + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname + \expandafter\pgfplots@assign@default@tick@foraxis@smithchart@\expandafter{\pgfplots@loc@TMPa}% + \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplotsretval + % + \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \expandafter\pgfplots@assign@default@tick@foraxis@smithchart@\expandafter{\pgfplots@loc@TMPa}% + \pgfkeyslet{/pgfplots/minor #1tick}\pgfplotsretval + \fi + % +}% +% #1: a \foreach list +% on output, \pgfplotsretval contains a parsed list of positions +\def\pgfplots@assign@default@tick@foraxis@smithchart@#1{% + \pgfplotsapplistXXglobalnewempty + \gdef\pgfplots@loc@TMPd{1}% + \foreach \pgfplots@loc@TMPb in {#1} {% + \ifx\pgfplots@loc@TMPb\pgfutil@empty + \else + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% per convention... + \edef\pgfmathresult{\if0\pgfplots@loc@TMPd,\fi\pgfmathresult}% + \gdef\pgfplots@loc@TMPd{0}% + \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfmathresult}% + \fi + }% + \pgfplotsapplistXXgloballet\pgfplotsretval + \pgfplotsapplistXXglobalclear +}% + +\let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@ +\def\pgfplots@show@ticklabel@@smithchart#1#2{% + \def\pgfmathresult{#2}% + \if#1x% + \ifdim#2pt>360pt + \pgfmath@basic@mod@{#2}{360}% + \fi + \fi + \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% +}% + +\def\pgfplots@xtick@check@tickshow@smithchart{% + \pgfplots@tickshowtrue +} +\def\pgfplots@ytick@check@tickshow@smithchart{% + \pgfplots@tickshowtrue +} + +\let\pgfplots@limits@ready@orig=\pgfplots@limits@ready +\def\pgfplots@limits@ready@smithchart{% + \pgfplots@limits@ready@orig + % + % Avoid tick labels at upper *and* lower angle range if both are the + % same: + \pgfmath@basic@sin@{\pgfplots@xmin}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmath@basic@sin@{\pgfplots@xmax}% + \pgfplotsmath@ifapproxequal@dim + {\pgfmathresult pt}{\pgfplots@loc@TMPa pt}% + {0.002pt} + {% + \def\pgfplots@xtick@disable@last@tick{1}% + }{% + }% +}% + +\def\smithchart{\smithchartaxis} +\def\endsmithchart{\endsmithchartaxis} + +\def\startsmithchart{\smithchart}% +\def\stopsmithchart{\endsmithchart}% +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex new file mode 100644 index 00000000000..dfb520af190 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex @@ -0,0 +1,904 @@ +%-------------------------------------------- +% +% Package pgfplots, library for ternary plots (triangular axes). +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +% +% This is a library to draw ternary diagrams. +% +% A ternary diagram visualizes percentages of three components in a +% triangle. +% +% Sometimes there is also contour data drawn on top of the ternary +% diagram, i.e. data (x,y,z, T(x,y,z) ), but I can't do that yet. +% +% How to read a ternary diagram: http://csmres.jmu.edu/geollab/fichter/SedRx/readternary.html +% +% Another usage example: http://www.sv.vt.edu/classes/MSE2094_NoteBook/96ClassProj/experimental/ternary2.html +% +% Drawing ternary diagrams: http://staff.aist.go.jp/a.noda/programs/ternary/ternary-en.html +% +% computing these coordinates: http://www.gamedev.net/community/forums/topic.asp?topic_id=451357 +% + +\pgfplotsdefineaxistype{ternary}{% + \pgfplots@ternary@activate +}% + +\newif\ifpgfplots@ternary@rellimits + + +\pgfplotsset{ + /pgfplots/ternary limits relative/.is if=pgfplots@ternary@rellimits, + /pgfplots/ternary limits relative=true, + /pgfplots/ternary limits relative/.default=true, + /pgfplots/ternary relative limits/.style={/pgfplots/ternary limits relative=#1}, + /pgfplots/ternary start x/.initial=, % FIXME : implement + /pgfplots/ternary start y/.initial=, + /pgfplots/ternary start z/.initial=, + /pgfplots/every ternary axis/.style={ + /pgfplots/tick align=outside, + grid=major, + xticklabel style={anchor=west}, + % yticklabel style={anchor=south east}, + % zticklabel style={anchor=north}, + /pgfplots/every 3d description/.style={}, + /pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every axis z label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every x tick scale label/.style={at={(xticklabel cs:0.95,5pt)},anchor=near xticklabel,inner sep=0pt}, + /pgfplots/every y tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt}, + /pgfplots/every z tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt}, + /pgfplots/every axis title shift=15pt, + /pgfplots/every axis legend/.style={% + cells={anchor=center}, + inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em}, + shape=rectangle,% + fill=white,% + draw=black, + at={(1.03,1.03)}, + anchor=north west,% + }, + annot/point format 3d/.initial={(\%.2f, \%.2f, \%.2f)}, + }, +} + +\def\pgfplots@ternary@activate{% + \let\pgfplotsqpointxy=\pgfplotsqpointxy@ternary + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy + \let\pgfplotsqpointxyz=\pgfplotsqpointxyz@ternary + \let\pgfplots@draw@axis=\pgfplots@draw@axis@ternary + \def\pgfplots@drawaxis@outerlines@separate@onorientedsurf##1##2{}% + \def\pgfplots@drawaxis@innerlines@onorientedsurf##1##2##3{}% + \let\pgfplots@draw@axis@post=\pgfplots@draw@axis@post@ternary + \let\pgfplots@initsizes=\pgfplots@initsizes@ternary + \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@ternary + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@ternary + \let\pgfplots@initsizes@setunitvector=\pgfplots@initsizes@setunitvector@ternary + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@ternary + \let\pgfplots@prepare@ZERO@coordinates=\pgfplots@prepare@ZERO@coordinates@ternary + \let\pgfplotsgetnormalforcurrentview=\relax + \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}% + \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@ternary + % + \pgfkeys{/pgfplots/oriented surf installed/.add={}{% + \let\pgfplotspointonorientedsurfaceab@ternary@orig=\pgfplotspointonorientedsurfaceab + \let\pgfplotspointonorientedsurfaceab=\pgfplotspointonorientedsurfaceab@ternary + }}% + \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@ternary + \pgfkeyssetvalue{/pgfplots/view/az}{}% + \pgfkeyssetvalue{/pgfplots/view/el}{}% + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + % + \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{\pgfplots@notify@options@are@set + \ifpgfplots@ternary@rellimits + \pgfplotsset{scaled ticks=false,ticklabel style={/pgf/number format/precision=0}}% + \let\pgfplots@show@ticklabel@orig=\pgfplots@show@ticklabel@ + \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@ternary@relative + \fi + }% + % + % this here is set *before* 'every ternary axis' is invoked. + \pgfplotsset{ + /pgfplots/footnotesize/.append style= {/pgfplots/every axis title shift=15pt},% + /pgfplots/tiny/.append style= {/pgfplots/every axis title shift=15pt},% + enlargelimits=false, + xmin=0,xmax=1, + ymin=0,ymax=1, + zmin=0,zmax=1, + annot/point format/.style={/pgfplots/annot/point format 3d={##1}}, + }% + \def\pgfplots@xticklabel@pos{}% + \def\pgfplots@yticklabel@pos{}% + \def\pgfplots@zticklabel@pos{}% + %\def\pgfplots@xaxislinesnum{1}% + %\def\pgfplots@yaxislinesnum{3}% + %\def\pgfplots@zaxislinesnum{3}% + \def\pgfplotsifaxissurfaceisforeground##1##2##3{##2}% + \def\pgfplots@init@ticklabelaxisspecfor##1##2{}% + \def\pgfplots@xticklabelaxisspec{v00}% + \def\pgfplots@yticklabelaxisspec{0v0}% + \def\pgfplots@zticklabelaxisspec{00v}% + \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{% + \pgfplotspointonorientedsurfaceabtolinespec v##1% + \edef\pgfplots@loc@TMPe{\csname pgfplots@\pgfplotspointonorientedsurfaceA ticklabelaxisspec\endcsname}% + \ifx\pgfplots@loc@TMPe\pgfplotsretval +%\message{pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{##1}---> TRUE.}% + ##2% + \else +%\message{pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{##1}---> FALSE.}% + ##3% + \fi + }% + \def\pgfplots@ifgridlines@onorientedsurf@should@be@drawn##1##2{% + ##1% FIXME + }% + \def\pgfplotspointonorientedsurfaceabmatchaxisline##1##2{% + \pgfplotspointonorientedsurfaceabtolinespec v0% FIXME that's just a bad guess! + \edef\pgfplots@loc@TMPe{##1}% + \ifx\pgfplots@loc@TMPe\pgfplotsretval + \def##2{0}% + \else + \def##2{}% + \fi + }% + \let\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn=\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@% + % + % + % cartesian cs + \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end} +}% + +\def\pgfplots@show@ticklabel@ternary@relative#1#2{% + \csname pgfplots@ternary@map@to@unit@#1\endcsname{#2}% + \pgfmathfloatparsenumber\pgfmathresult + \pgfmathfloatshift@\pgfmathresult{2}% + \let\tick=\pgfmathresult +}% + +\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{% + \pgfpointxy@orig{#1}{#2}% +}% + +% This here is *the* key point why ternary axes can be processed with +% almost the same code as rectangular axes. +% +% Recall that rectangular axes are drawn using "oriented surfaces", +% the complete code is based on them. The "a" axis is the direction in +% which we have tick positions and the "b" axis is the direction in +% which tick lines (or grid lines) shall be drawn). +% +% Now, ternary axes do not directly fit into the "oriented surface" +% framework. But they have a lot of structure which allows to use it +% with a specialed "pointonorientedsurfaceab" routine: by noting that +% - there are only three axes, +% - the axis containing tick lines (and grid lines) *always* has one +% component set to 0 (lower limit), and the remaining two components +% sum to 1. Thus, we can simply use one value (for example the "a" +% value) and compute the remaining one, +% - \pgfplotspointonorientedsurfaceab is *always* invoked with +% b set to either the lower or the upper limit. +% The lower limit is easy, see above. The upper limit is mainly used +% for grid lines, more precisely it denotes the target point of the grid line. +% I use special handling to find this target point (by exchanging +% coordinate components, see the implementation). +% +% #1: the "a" value on the oriented surf +% #2: the "b" value. Note that *only* the lower *or* the upper limit +% on the "b" axis are supported here! +% +\def\pgfplotspointonorientedsurfaceab@ternary#1#2{% + \let\pgfplotspointonorientedsurfaceab@ternary@fixedx=\pgfplotspointonorientedsurfaceabsetupfor@fixedx + \let\pgfplotspointonorientedsurfaceab@ternary@fixedy=\pgfplotspointonorientedsurfaceabsetupfor@fixedy + \let\pgfplotspointonorientedsurfaceab@ternary@fixedz=\pgfplotspointonorientedsurfaceabsetupfor@fixedz + % +%\message{\string\pgfplotspointonorientedsurfaceab{#1}{#2} -----> }% + \ifpgfplots@ternary@next@is@unitinterval + \edef\pgfplotspointonorientedsurfaceab@ternary@A{#1}% + \edef\pgfplotspointonorientedsurfaceab@ternary@B{#2}% + \else + \csname pgfplots@ternary@map@to@unit@\pgfplotspointonorientedsurfaceA\endcsname{#1}% + \let\pgfplotspointonorientedsurfaceab@ternary@A=\pgfmathresult + % + \csname pgfplots@ternary@map@to@unit@\pgfplotspointonorientedsurfaceB\endcsname{#2}% + \let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfmathresult + \fi + \if0\pgfplotspointonorientedsurfacespecsymbol + \else + \pgfplots@error{Internal processing error: only \string\pgfplotspointonorientedsurfaceab\space for ternary axes works only for oriented surfs fixed to LOWER or UPPER axis limits.}% + \fi +%\message{A=\pgfplotspointonorientedsurfaceab@ternary@A; B=\pgfplotspointonorientedsurfaceab@ternary@B -----> }% + \ifdim\pgfplotspointonorientedsurfaceab@ternary@B pt=0pt + \pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}% + \let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfmathresult + \expandafter\def\csname pgfplotspointonorientedsurfaceabsetupfor@fixed\pgfplotspointonorientedsurfaceN\endcsname{0}% + \else + %\let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceab@ternary@A + %\pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}% + %\let\pgfplotspointonorientedsurfaceab@ternary@A=\pgfmathresult + %\let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfplots@loc@TMPa + \pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}% + \def\pgfplotspointonorientedsurfaceab@ternary@B{0}% + \expandafter\let\csname pgfplotspointonorientedsurfaceabsetupfor@fixed\pgfplotspointonorientedsurfaceN\endcsname=\pgfmathresult% + \fi + % + \global\pgfplots@ternary@next@is@unitintervaltrue +%\message{\string\pgfplotspointonorientedsurfaceab@orig{\pgfplotspointonorientedsurfaceab@ternary@A}{\pgfplotspointonorientedsurfaceab@ternary@B}[fixedsymbol=\pgfplotspointonorientedsurfacespecsymbol; a=\pgfplotspointonorientedsurfaceA,b=\pgfplotspointonorientedsurfaceB.]}% + \pgfplotspointonorientedsurfaceab@ternary@orig + {\pgfplotspointonorientedsurfaceab@ternary@A}% + {\pgfplotspointonorientedsurfaceab@ternary@B}% + % + \let\pgfplotspointonorientedsurfaceabsetupfor@fixedx=\pgfplotspointonorientedsurfaceab@ternary@fixedx + \let\pgfplotspointonorientedsurfaceabsetupfor@fixedy=\pgfplotspointonorientedsurfaceab@ternary@fixedy + \let\pgfplotspointonorientedsurfaceabsetupfor@fixedz=\pgfplotspointonorientedsurfaceab@ternary@fixedz +}% + +\def\pgfplotspointonorientedsurfaceabwithbshift@ternary#1#2#3{% + % implement the shift in "b" direction explicitly: + % + \pgfplotspointonorientedsurfaceab@ternary{#1}{#2}% + \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + \pgfpointadd + {\pgfplots@loc@TMPe}% + {% + \begingroup + % I need a '-' here because for ternary axes, the "b" axis + % points to the *outside* instead of the inside. + \pgf@xa=-#3\relax + \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}% + % oh. a reversed axis. + \pgf@xa=-\pgf@xa + \fi + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}% + \pgfmath@basic@multiply@{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}{\pgfplots@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfqpointscale{\pgfplots@loc@TMPa}{\csname pgfplotspointunit\pgfplotspointonorientedsurfaceB\endcsname}% + }% +} + + +\let\pgfplots@initsizes@ternary@orig=\pgfplots@initsizes +\def\pgfplots@initsizes@ternary{% + \ifpgfplots@threedim + \else + \pgfplots@error{Sorry, 'axis type=ternary' needs a three dimensional axes. Make sure you supplied three dimensional coordinates (using \string\addplot3, for example). This error is critical; I can't recover}% + \fi +%\message{ternary with limits x=[\pgfplots@xmin:\pgfplots@xmax], y=[\pgfplots@ymin:\pgfplots@ymax]; z=[\pgfplots@zmin:\pgfplots@zmax].}% + \pgfplots@ternary@init@map@to@unit x + \pgfplots@ternary@init@map@to@unit y + \pgfplots@ternary@init@map@to@unit z + % + \pgfplots@initsizes@get@width@withoutlabels + \pgf@x=\pgfmathresult + \edef\pgfplots@width@ternary{\pgf@sys@tonumber\pgf@x}% + % + \pgfplots@initsizes@ternary@orig + % +}% + +\def\pgfplots@ternary@init@map@to@unit#1{% + \begingroup + \pgfmath@basic@subtract@ + {\csname pgfplots@#1max\endcsname} + {\csname pgfplots@#1min\endcsname}% + \pgfmath@basic@reciprocal@\pgfmathresult + \let\pgfplots@map@to@unit@scale=\pgfmathresult + % + \expandafter\xdef\csname pgfplots@ternary@map@to@unit@#1\endcsname##1{% + \noexpand\pgfmath@basic@subtract@{##1}{\csname pgfplots@#1min\endcsname}% + \noexpand\pgfmath@basic@multiply@{\noexpand\pgfmathresult}{\pgfplots@map@to@unit@scale}% + }% + \endgroup +} + +\def\pgfplots@initsizes@setunitvector@ternary#1#2#3#4{% + % ternary axis are DIFFERENT here. + % They don't use the (xx,xy), (yx,yy), (zx,zy) vectors, so we can + % use them to realize *cartesian* coordinates. + % + % Thus, any \draw (0,0) inside of a ternary axis will yield + % cartesian coordinates. + % + % The relevant quantities to *draw* the diagram are the three + % axis, they are also prepared here. + % + \def#4{0}% whether we have (#1,0) or (0,#1) + \ifcase#2% + \pgfsetxvec{% + \pgfqpoint{\pgfplots@width@ternary pt}{0pt}% + }% + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}% + \or + \pgfsetyvec{% + \pgfqpoint{0pt}{\pgfplots@width@ternary pt}% + }% + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}% + \or + \pgfsetzvec{% + \pgfpointorigin + }% + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}% + \fi + \expandafter\xdef\csname pgfplotspoint#1axis\endcsname{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + }% + \expandafter\xdef\csname pgfplotspoint#1axislength\endcsname{\pgfplots@x@veclength pt}% + % +%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}% +}% + +\newif\ifpgfplots@ternary@next@is@unitinterval + +% Deduce z = 1-x-y after transformation to relative coordinates. +\def\pgfplotsqpointxy@ternary#1#2{% + \pgf@process{% + \ifpgfplots@ternary@next@is@unitinterval + \dimen1=#1pt + \dimen2=#2pt + \else + \pgfplots@ternary@map@to@unit@x{#1}% + \dimen1=\pgfmathresult pt + % + \pgfplots@ternary@map@to@unit@y{#2}% + \dimen2=\pgfmathresult pt + \fi + \dimen4=\dimen1 + \advance\dimen4 by\dimen2 + \dimen3=1pt + \advance\dimen3 by-\dimen4 + % + \global\pgfplots@ternary@next@is@unitintervalfalse + \pgfplotsqpointxyz@ternary@ + }% +}% +% gx(x,y,z) = 0.5 * (x + 2*z)/(x+y+z) +% gy(x,y,z) = (sqrt(3) / 2) * x / (x+y+z) +\def\pgfplotsqpointxyz@ternary#1#2#3{% + \pgf@process{% + \ifpgfplots@ternary@next@is@unitinterval + \dimen1=#1pt + \dimen2=#2pt + \dimen3=#3pt + \else + \pgfplots@ternary@map@to@unit@x{#1}% + \dimen1=\pgfmathresult pt + % + \pgfplots@ternary@map@to@unit@y{#2}% + \dimen2=\pgfmathresult pt + % + \pgfplots@ternary@map@to@unit@z{#3}% + \dimen3=\pgfmathresult pt + \fi + \global\pgfplots@ternary@next@is@unitintervalfalse + % + \pgfplotsqpointxyz@ternary@ + }% +}% +\def\pgfplotsqpointxyz@ternary@{% + %\dimen1=#1 + %\dimen2=#2 + %\dimen3=#3 + % FIXME . I didn't understand that stuff. + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reversed + %\multiply\dimen1 by-1 + %\advance\dimen1 by1pt + %\dimen1=#2 + %\dimen2=#3 + %\dimen3=#1 + \fi + %-------------------------------------------------- + % \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reversed + % \multiply\dimen2 by-1 + % \advance\dimen2 by1pt + % \fi + % \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reversed + % \multiply\dimen3 by-1 + % \advance\dimen3 by1pt + % \fi + %-------------------------------------------------- + \pgfplotsqpointxyz@ternary@@% +}% +\def\pgfplotsqpointxyz@ternary@@{% + % Disable renormalization!? + %\dimen4=\dimen1 + %\advance\dimen4 by\dimen2 + %\advance\dimen4 by\dimen3 + %\edef\pgfplots@ternary@sum{\pgf@sys@tonumber{\dimen4}}% + %\pgfmathapproxequalto@{1}{\pgfplots@ternary@sum}% + \pgfmathcomparisontrue + \ifpgfmathcomparison + \let\pgfplots@ternary@scale=\pgfplots@width@ternary + \else + \pgfmath@basic@divide@ + {\pgfplots@width@ternary}% + {\pgfplots@ternary@sum}% + \let\pgfplots@ternary@scale=\pgfmathresult + \fi + % + \dimen4=2\dimen3 + \advance\dimen4 by \dimen1 + \divide\dimen4 by2 + \pgf@x=\pgfplots@ternary@scale\dimen4 + % + \dimen4=\dimen1 + \dimen4=0.866025403784\dimen4 % *= sqrt(3)/2 + \pgf@y=\pgfplots@ternary@scale\dimen4 + % +}% +\def\pgfplotspoint@initialisation@units@ternary{% + \let\pgfplotspointunitx\pgfplotspointxaxis + \let\pgfplotspointunity\pgfplotspointyaxis + \let\pgfplotsunitxlength=\pgfplots@x@veclength + \let\pgfplotsunitylength=\pgfplots@y@veclength + \let\pgfplotsunitxinvlength=\pgfplots@x@inverseveclength + \let\pgfplotsunityinvlength=\pgfplots@y@inverseveclength + \ifpgfplots@threedim + \let\pgfplotspointunitz=\pgfplotspointzaxis + \let\pgfplotsunitzlength=\pgfplots@z@veclength + \let\pgfplotsunitzinvlength=\pgfplots@z@inverseveclength + \fi +}% + +% POSTCONDITION: the macros +% \pgfplotspointminminmin +% \pgfplotspoint[xyz]axis +% \pgfplotspoint[xyz]axislength +% are defined (globally). +\def\pgfplotspoint@initialisation@axes@ternary{% + \xdef\pgfplotspointminminmin{\noexpand\pgfpointorigin}% + % + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}% + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse + \pgfqpointscale{-1}{}% + \fi + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@x@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@x@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@x@inverseveclength\endcsname=\pgfmathresult + }% + \xdef\pgfplotspointxaxislength{\pgfplots@x@veclength pt}% + % + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}% + \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse + \pgfqpointscale{-1}{}% + \fi + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@y@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@y@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@y@inverseveclength\endcsname=\pgfmathresult + }% + \xdef\pgfplotspointyaxislength{\pgfplots@y@veclength pt}% + % + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}% + \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse + \pgfqpointscale{-1}{}% + \fi + \xdef\pgfplotspointzaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@z@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@z@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@z@inverseveclength\endcsname=\pgfmathresult + }% + \xdef\pgfplotspointzaxislength{\pgfplots@z@veclength pt}% + % +} +\def\pgfplots@prepare@ZERO@coordinates@ternary{% + \ifpgfplots@xislinear + \ifpgfplots@apply@datatrafo@x + \pgfplotscoordmath{x}{parsenumber}{0}% + \pgfplotscoordmath{x}{datascaletrafo}{\pgfmathresult}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \else + \gdef\pgfplots@logical@ZERO@x{0}% + \fi + \pgfplotsmathmax{\pgfplots@logical@ZERO@x}{\pgfplots@xmin}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@x}{\pgfplots@xmax}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \else + \global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin% + \fi + % + \ifpgfplots@yislinear + \ifpgfplots@apply@datatrafo@y + \pgfplotscoordmath{y}{parsenumber}{0}% + \pgfplotscoordmath{y}{datascaletrafo}{\pgfmathresult}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \else + \gdef\pgfplots@logical@ZERO@y{0}% + \fi + \pgfplotsmathmax{\pgfplots@logical@ZERO@y}{\pgfplots@ymin}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@y}{\pgfplots@ymax}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \else + \global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin% + \fi + % + \ifpgfplots@threedim + \ifpgfplots@zislinear + \ifpgfplots@apply@datatrafo@z + \pgfplotscoordmath{z}{parsenumber}{0}% + \pgfplotscoordmath{z}{datascaletrafo}{\pgfmathresult}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \else + \gdef\pgfplots@logical@ZERO@z{0}% + \fi + \pgfplotsmathmax{\pgfplots@logical@ZERO@z}{\pgfplots@zmin}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@z}{\pgfplots@zmax}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \else + \global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin% + \fi + \fi + % + % + \global\pgfplots@ternary@next@is@unitintervaltrue + \pgfplotsqpointxyz100% + \xdef\pgfplots@ZERO@x{\the\pgf@x}% + \xdef\pgfplots@ZERO@y{\the\pgf@y}% + \xdef\pgfplotspointaxisorigin{\noexpand\pgf@x=\pgfplots@ZERO@x\space\noexpand\pgf@y=\pgfplots@ZERO@y\space}% +}% + + +\def\pgfplots@draw@axis@ternary{% + % + % this should become the line for varying y: + \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}% + \pgfplots@draw@axis@insurface yxz + % + % this should become the line for varying z: + \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}% + \pgfplots@draw@axis@insurface zyx + % + % + % this should become the line for varying x: + \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}% + \pgfplots@draw@axis@insurface xzy + % + \pgfplots@ternary@draw@axislines +}% +\def\pgfplots@ternary@draw@axislines{% + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse + \pgfplots@separate@axis@linestrue + \fi + \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse + \pgfplots@separate@axis@linestrue + \fi + \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse + \pgfplots@separate@axis@linestrue + \fi + \ifpgfplots@separate@axis@lines + \scope[/pgfplots/every outer x axis line, + xdiscont,decoration={pre length=\csname xdisstart\endcsname, post length=\csname xdisend\endcsname}] + \draw decorate { + \pgfextra + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \else + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \fi + \endpgfextra + }; + \endscope + % + \scope[/pgfplots/every outer y axis line, + ydiscont,decoration={pre length=\csname ydisstart\endcsname, post length=\csname ydisend\endcsname}] + \draw decorate { + \pgfextra + \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \else + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \fi + \endpgfextra + }; + \endscope + % + \scope[/pgfplots/every outer z axis line, + zdiscont,decoration={pre length=\csname zdisstart\endcsname, post length=\csname zdisend\endcsname}] + \draw decorate { + \pgfextra + \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \else + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \fi + \endpgfextra + }; + \endscope + \else + \draw[ + /pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-( + /pgfplots/every outer y axis line] + \pgfextra{% + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathclose + }; + \fi +}% +\def\pgfplots@clippath@prepare@for@axistype@ternary{% + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% +}% + +\def\pgfplots@draw@axis@post@ternary{% + % do nothing. There is no 3d box to draw here. +}% + +\def\pgfplotspointouternormalvectorofaxis@ternary#1#2#3\relax{% + \edef\pgfplots@loc@TMPa{\if r\pgfkeysvalueof{/pgfplots/x dir/value}-\fi}% reverse + \edef\pgfplots@loc@TMPb{\if r\pgfkeysvalueof{/pgfplots/y dir/value}-\fi}% reverse + \edef\pgfplots@loc@TMPc{\if r\pgfkeysvalueof{/pgfplots/z dir/value}-\fi}% reverse + \if v#1% + \pgfpointadd + {\pgfqpointscale{\pgfplots@loc@TMPb-1}{\pgfplotspointyaxis}}% + {\pgfqpointscale{\pgfplots@loc@TMPc}{\pgfplotspointzaxis}}% + \else + \if v#2% + \pgfpointadd + {\pgfqpointscale{\pgfplots@loc@TMPa}{\pgfplotspointxaxis}}% + {\pgfqpointscale{\pgfplots@loc@TMPc-1}{\pgfplotspointzaxis}}% + \else + \pgfpointadd + {\pgfqpointscale{\pgfplots@loc@TMPa-1}{\pgfplotspointxaxis}}% + {\pgfqpointscale{\pgfplots@loc@TMPb}{\pgfplotspointyaxis}}% + \fi + \fi + \pgf@process{\pgfpointnormalised{}}% + \endgroup +}% + + +\def\pgfplotsclickable@check@enable@axistype@ternaryaxis{% + \def\pgfplotsretval{1}% +}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% tieline plots +% +\pgfplotsset{ + tieline/.code={% + \let\tikz@plot@handler=\pgfplotsplothandlertieline + \pgfkeysifdefined{/pgfplots/table/tie end x}{}{% + % provide these keys locally: + \pgfkeyslet{/pgfplots/table/tie end x}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end y}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end z}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end x index}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end y index}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end z index}\pgfutil@empty% + }% + \pgfqkeys{/pgfplots/tieline}{#1}% + }, + tieline/every tieline/.style={}, + tieline/tieline style/.style={/pgfplots/tieline/every tieline/.append style={#1}}, + tieline/every curve/.style={}, + tieline/curve style/.style={/pgfplots/tieline/every curve/.append style={#1}}, + tieline/each nth tie/.initial=, +} +\def\pgfplotsplothandlertieline{% + \pgfplotsresetplothandler + \let\pgf@plotstreamstart=\pgfplotsplothandlervisbegin@tieline + \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@tieline + \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@tieline + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@tieline +}% +\def\pgfplotsplothandlervisbegin@tieline{% + \pgfplotsapplistXnewempty\pgfp@binodal@A + \pgfplotsapplistXnewempty\pgfp@ties + \pgfplotsprependlistXnewempty{pgfp@binodal@B@reverse} + \def\b@pgfplotsplothandlersurveystart@tieline@even{1}% + % + \global\let\pgf@plotstreampoint=\pgfplotsplothandlervis@streampoint@tieline + \global\let\pgf@plotstreamend=\pgfplotsplothandlervis@streamend@tieline + % + \pgfkeysgetvalue{/pgfplots/tieline/each nth tie}\pgfplots@eachnth@tie + \ifx\pgfplots@eachnth@tie\pgfutil@empty + \def\pgfplots@eachnth@tie{1}% + \fi + \let\c@pgfplots@tiecounter=\c@pgfplotstable@counta + \c@pgfplots@tiecounter=0 +}% +\def\pgfplotsplothandlervis@streampoint@tieline#1{% + \pgf@process{#1}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplots@stream@withmeta@ + {\pgfplots@current@point@coordindex}% + {\the\pgf@x}{\the\pgf@y}% + {\pgfplots@current@point@meta}% + }% + \if1\b@pgfplotsplothandlersurveystart@tieline@even + \let\pgfplotsplothandlervis@streampoint@tieline@last=\pgfplots@loc@TMPa + \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfp@binodal@A + \def\b@pgfplotsplothandlersurveystart@tieline@even{0}% + \else + \expandafter\pgfplotsprependlistXpushfront\pgfplots@loc@TMPa\to{pgfp@binodal@B@reverse}% + % + \advance\c@pgfplots@tiecounter by1 + \ifnum\pgfplots@eachnth@tie=\c@pgfplots@tiecounter + \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% + \t@pgfplots@tokb=\expandafter{\pgfplotsplothandlervis@streampoint@tieline@last}% + \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\noexpand\pgfplotsplothandlertieline@finishtie}% + \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfp@ties + \c@pgfplots@tiecounter=0 + \fi + % + \def\b@pgfplotsplothandlersurveystart@tieline@even{1}% + \fi +}% +\def\pgfplotsplothandlervis@streamend@tieline{% + \begingroup + \pgfplots@drawmodes@appendtrue + \path[/pgfplots/tieline/every curve]% + \pgfextra + \ifx\tikz@plot@handler\pgfplotsplothandlertieline + \let\tikz@plot@handler\pgfplothandlerlineto + \fi + \pgfplotsresetplothandler + \tikz@plot@handler + \pgf@plotstreamstart + % + \pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfp@binodal@A + \pgfplots@loc@TMPa + \pgfplotsapplistXnewempty\pgfp@binodal@A + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={pgfp@binodal@B@reverse}% + \pgfplots@loc@TMPa + \pgfplotsprependlistXnewempty{pgfp@binodal@B@reverse}% + % + \pgf@plotstreamend + \endpgfextra; + \endgroup + % + % + \pgfplotsset{/pgfplots/tieline/every tieline}% + \ifx\tikz@plot@handler\pgfplotsplothandlertieline + \let\tikz@plot@handler\pgfplothandlerlineto + \fi + \pgfplotsresetplothandler + \tikz@plot@handler + \pgf@plotstreamstart + % + \def\pgfplotsplothandlertieline@finishtie{% + \pgfplotsplothandlervisualizejump + }% + \pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfp@ties + \pgfplots@loc@TMPa + \pgfplotsapplistXnewempty\pgfp@ties + % + \pgf@plotstreamend +}% + +\def\pgfplotsplothandlersurveystart@tieline{% + \def\pgfplots@loc@TMPa{table}% + \ifx\pgfplotssurveyphaseinputclass\pgfplots@loc@TMPa + \else + \pgfplots@error{Sorry, 'tieline' plots are currently only supported for \string\addplot\space table}% + \fi + \def\b@pgfplotsplothandlersurveystart@tieline@init{0}% +}% +\def\pgfplotsplothandlersurveyend@tieline{% +}% + +\def\pgfplotsplothandlersurveypoint@tieline@init{% + \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor x\pgfplotsplothandlertieline@Bx + \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor y\pgfplotsplothandlertieline@By + \ifpgfplots@curplot@threedim + \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor z\pgfplotsplothandlertieline@Bz + \fi + % + \def\b@pgfplotsplothandlersurveystart@tieline@init{1}% +}% +\def\pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor#1#2{% + \let#2=\relax + \pgfkeysgetvalue{/pgfplots/table/tie end #1}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfkeysgetvalue{/pgfplots/table/tie end #1 index}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \edef#2{\noexpand\getthisrowno{\pgfplots@loc@TMPa}\noexpand\pgfmathresult}% + \fi + \else + \edef#2{\noexpand\getthisrow{\pgfplots@loc@TMPa}\noexpand\pgfmathresult}% + \fi + \ifx#2\relax + \pgfplotsplothandlersurveypoint@tieline@init@find@colindex@for #1\pgfplots@loc@ind + \c@pgf@countd=\pgfplots@loc@ind\relax + \advance\c@pgf@countd by3 + \ifnum\c@pgf@countd<\pgfplotstablecols\relax + \else + \c@pgf@countd=0 + \pgfplots@error{Sorry, I can't find the 'tie end #1 index' automatically. Please provide 'table[tie end #1={<colname>}]' or 'table[tie end #1 index=<col index>]' manually and verify the all, x,y and z components are correct}% + \fi + \edef\pgfplots@loc@ind{\the\c@pgf@countd}% + \pgfkeyslet{/pgfplots/table/tie end #1 index}\pgfplots@loc@ind + \edef#2{\noexpand\getthisrowno{\pgfplots@loc@ind}\noexpand\pgfmathresult}% + \fi +}% + +\def\pgfplotsplothandlersurveypoint@tieline@init@find@colindex@for#1#2{% + \pgfkeysgetvalue{/pgfplots/table/#1}{\pgfplots@loc@TMPa}% + \pgfkeysgetvalue{/pgfplots/table/#1 index}{\pgfplots@loc@TMPb}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \let#2=\pgfplots@loc@TMPb + \else + \def\pgfplots@loc@TMPb{\expandafter\pgfplotstablegetcolumnindexforname\expandafter{\pgfplots@loc@TMPa}\of}% + \expandafter\pgfplots@loc@TMPb\pgfplotstablename\to#2% + \fi +}% + +\def\pgfplotsplothandlersurveypoint@tieline{% + \if0\b@pgfplotsplothandlersurveystart@tieline@init + \pgfplotsplothandlersurveypoint@tieline@init + \fi + \pgfplotsplothandlersurveypoint@default + % + \pgfplotsplothandlertieline@Bx\let\pgfplots@current@point@x=\pgfmathresult + \pgfplotsplothandlertieline@By\let\pgfplots@current@point@y=\pgfmathresult + \ifpgfplots@curplot@threedim + \pgfplotsplothandlertieline@Bz\let\pgfplots@current@point@z=\pgfmathresult + \fi + \pgfplotsplothandlersurveypoint@default +}% +\endinput |