diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib')
5 files changed, 670 insertions, 155 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_leq.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_leq.code.tex new file mode 100644 index 00000000000..8be16c806a4 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_leq.code.tex @@ -0,0 +1,279 @@ +% ====================================================== +% compatibility with PGF 3.0.1a +% ====================================================== +% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% It contains a couple of patches such that selected changes which +%%% are also part of PGF/TikZ (and can be found in the development +%%% version of PGF/TikZ) are available within pgfplots. +%%% +%%% this file contains solvers which have been written by Christian Feuersaenger (primarily, but not only, for pgfplots) + +% Solves a linear equation system of size 2x2 using gauss elimination. +% +% It employs TeX register arithmetics to do so. +% #1: should contain 4 sets of braces with matrix entries, +% {<a11>}{<a12>} +% {<a21>}{<a22>} +% where each entry should be a number without unit. +% It is acceptable if '#1' is a macro which expands to the expected +% format. +% #2: should contain 2 sets of braces with the right-hand-side, +% {<r1>}{<r2>} +% where each entry should be a number without unit. +% It is acceptable if '#2' is a macro which expands to the expected +% format. +% +% It will assign \pgfmathresult to contain two sets of braces with the +% result. +% +% Example: +% \pgfutilsolvetwotwoleq{ +% {0.24}{1} +% {-0.97}{0} +% }{ +% {-7} +% {18} +% } +% -> yields \pgfmathresult={−18.55618}{−2.54642} +% +% The algorithm employs column pivotisation. +% +% If the matrix is singular, the routine will return {}. +\def\pgfutilsolvetwotwoleq#1#2{% + \begingroup + \dimendef\aa=0 + \dimendef\ab=1 + \dimendef\ba=2 + \dimendef\bb=3 + \dimendef\ra=4 + \dimendef\rb=5 + \dimendef\tmpa=6 + \dimendef\tmpb=7 + \edef\pgf@temp{#1}% + \expandafter\pgfutilsolvetwotwoleq@A\pgf@temp + \edef\pgf@temp{#2}% + \expandafter\pgfutilsolvetwotwoleq@r\pgf@temp + % + \pgfutilsolvetwotwoleq@ifislarger\aa\ba{% + % identity "permutation": + \def\Pa{a}% + \def\Pb{b}% + }{% + % permutation matrix: switch rows! + \def\Pa{b}% + \def\Pb{a}% + }% + % \pivot := 1/aa + \tmpa=\csname m\Pa a\endcsname pt % + \ifdim\tmpa<0pt \tmpa=-\tmpa\fi + \ifdim\tmpa<0.0001pt + % singular matrix! + \let\pgfmathresult=\pgfutil@empty + \else + \pgfmathreciprocal@ + {\csname m\Pa a\endcsname}% + \let\pivot=\pgfmathresult + % + % \factor := 1/aa * ba + \csname \Pb a\endcsname=\pivot\csname \Pb a\endcsname + \edef\factor{\expandafter\pgf@sys@tonumber\csname \Pb a\endcsname}% + % + % bb -= ba/aa * ab + \tmpa=-\factor\csname \Pa b\endcsname + \advance\csname \Pb b\endcsname by\tmpa + % + % rb -= ba/aa * ra + \tmpa=-\factor\csname r\Pa\endcsname + \advance\csname r\Pb\endcsname by\tmpa + % + \tmpa=\csname \Pb b\endcsname% + \ifdim\tmpa<0pt \tmpa=-\tmpa\fi + \ifdim\tmpa<0.0001pt + % singular matrix! + \let\pgfmathresult=\pgfutil@empty + \else + % xb := rb / bb (the modified rb and modified bb!) + \pgfmathdivide@ + {\expandafter\pgf@sys@tonumber\csname r\Pb\endcsname} + {\expandafter\pgf@sys@tonumber\csname \Pb b\endcsname}% + \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult + % + % ra := ra - xb * ab + \tmpa=\csname pgfmathresult\Pb\endcsname\csname \Pa b\endcsname + \advance\csname r\Pa\endcsname by-\tmpa + % + % xa := 1/aa * ra (the modified ra!) + \tmpa=\pivot\csname r\Pa\endcsname + \expandafter\edef\csname pgfmathresult\Pa\endcsname{\pgf@sys@tonumber\tmpa}% + % + \edef\pgfmathresult{% + {\csname pgfmathresult\Pa\endcsname}% + {\csname pgfmathresult\Pb\endcsname}% + }% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfutilsolvetwotwoleq@ifislarger#1#2#3#4{% + \tmpa=#1 + \ifdim\tmpa<0pt + \multiply\tmpa by-1 + \fi + \tmpb=#2 + \ifdim\tmpb<0pt + \multiply\tmpb by-1 + \fi + \ifdim\tmpa>\tmpb + #3% + \else + #4% + \fi +}% + +\def\pgfutilsolvetwotwoleqfloat@ifislarger#1#2#3#4{% + \pgfmathfloatabs@{#1}\let\tmpa=\pgfmathresult + \pgfmathfloatabs@{#2}\let\tmpb=\pgfmathresult + \pgfmathfloatlessthan@{\tmpb}{\tmpa}% + \ifpgfmathfloatcomparison + #3% + \else + #4% + \fi +}% +\def\pgfutilsolvetwotwoleq@A#1#2#3#4{% + \def\maa{#1}\def\mab{#2}% + \def\mba{#3}\def\mbb{#3}% + \aa=#1pt \ab=#2pt + \ba=#3pt \bb=#4pt +} +\def\pgfutilsolvetwotwoleq@r#1#2{% + \ra=#1pt \rb=#2pt +}% +\def\pgfutilsolvetwotwoleqfloat@A#1#2#3#4{% + \pgfmathfloatparsenumber{#1}\let\maa=\pgfmathresult + \pgfmathfloatparsenumber{#2}\let\mab=\pgfmathresult + \pgfmathfloatparsenumber{#3}\let\mba=\pgfmathresult + \pgfmathfloatparsenumber{#4}\let\mbb=\pgfmathresult +} +\def\pgfutilsolvetwotwoleqfloat@r#1#2{% + \pgfmathfloatparsenumber{#1}\let\ra=\pgfmathresult + \pgfmathfloatparsenumber{#2}\let\rb=\pgfmathresult +}% + +% Same as \pgfutilsolvetwotwoleq, but using floating point +% arithmetics. The return value is still in fixed point. +\def\pgfutilsolvetwotwoleqfloat#1#2{% + \begingroup + \pgfmathfloatcreate{1}{1.0}{-4}% FIXME : use a smaller threshold for FPU? + \let\thresh=\pgfmathresult + % + \edef\pgf@temp{#1}% + \expandafter\pgfutilsolvetwotwoleqfloat@A\pgf@temp + \edef\pgf@temp{#2}% + \expandafter\pgfutilsolvetwotwoleqfloat@r\pgf@temp + % + \pgfutilsolvetwotwoleqfloat@ifislarger\maa\mba{% + % identity "permutation": + \def\Pa{a}% + \def\Pb{b}% + }{% + % permutation matrix: switch rows! + \def\Pa{b}% + \def\Pb{a}% + }% + % \pivot := 1/aa + \expandafter\pgfmathfloatabs@\expandafter{\csname m\Pa a\endcsname}% + \let\tmpa=\pgfmathresult + \pgfmathfloatlessthan@{\tmpa}{\thresh}% + \ifpgfmathfloatcomparison + % singular matrix! + \let\pgfmathresult=\pgfutil@empty + \else + \expandafter\pgfmathfloatreciprocal@\expandafter{\csname m\Pa a\endcsname}% + \let\pivot=\pgfmathresult + % + % \factor := 1/aa * ba + \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pb a\endcsname}{\pivot}% + \let\factor=\pgfmathresult + \expandafter\let\csname m\Pb a\endcsname=\factor + % + % bb -= ba/aa * ab + \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pa b\endcsname}{\factor}% + \let\tmpa=\pgfmathresult + \expandafter\pgfmathfloatsubtract@\expandafter{\csname m\Pb b\endcsname}{\tmpa}% + \expandafter\let\csname m\Pb b\endcsname=\pgfmathresult + % + % rb -= ba/aa * ra + \expandafter\pgfmathfloatmultiply@\expandafter{\csname r\Pa\endcsname}{\factor}% + \let\tmpa=\pgfmathresult + \expandafter\pgfmathfloatsubtract@\expandafter{\csname r\Pb\endcsname}{\tmpa}% + \expandafter\let\csname r\Pb\endcsname=\pgfmathresult + % + \expandafter\pgfmathfloatabs@\expandafter{\csname m\Pb b\endcsname}% + \let\tmpa=\pgfmathresult + \pgfmathfloatlessthan@{\tmpa}{\thresh}% + \ifpgfmathfloatcomparison + % singular matrix! + \let\pgfmathresult=\pgfutil@empty + \else + % xb := rb / bb (the modified rb and modified bb!) + \edef\pgf@marshal{ + \noexpand\pgfmathfloatdivide@ + {\csname r\Pb\endcsname} + {\csname m\Pb b\endcsname}% + }% + \pgf@marshal + \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult + \let\tmpa=\pgfmathresult + % + % ra := ra - xb * ab + \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pa b\endcsname}{\tmpa}% + \let\tmpa=\pgfmathresult + \expandafter\pgfmathfloatsubtract@\expandafter{\csname r\Pa\endcsname}{\tmpa}% + \expandafter\let\csname r\Pa\endcsname=\pgfmathresult + % + % xa := 1/aa * ra (the modified ra!) + \expandafter\pgfmathfloatmultiply@\expandafter{\csname r\Pa\endcsname}{\pivot}% + \expandafter\let\csname pgfmathresult\Pa\endcsname=\pgfmathresult + % + \edef\pgfmathresult{% + {\csname pgfmathresult\Pa\endcsname}% + {\csname pgfmathresult\Pb\endcsname}% + }% + \expandafter\pgfutilsolvetwotwoleqfloat@to@pgf@range\pgfmathresult + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + + +\def\pgfutilsolvetwotwoleqfloat@to@pgf@range#1#2{% + \pgfmathfloatcreate{1}{1.6}{4}\let\pgfutilsolvetwotwoleqfloat@to@pgf@range@max=\pgfmathresult + \pgfmathfloatabs@{#1}% + \expandafter\pgfmathfloatlessthan@\expandafter{\pgfmathresult}{\pgfutilsolvetwotwoleqfloat@to@pgf@range@max}% + \ifpgfmathfloatcomparison + \pgfmathfloatabs@{#2}% + \expandafter\pgfmathfloatlessthan@\expandafter{\pgfmathresult}{\pgfutilsolvetwotwoleqfloat@to@pgf@range@max}% + \ifpgfmathfloatcomparison + % ok. + \pgfmathfloattofixed{#1}\let\tmpa=\pgfmathresult + \pgfmathfloattofixed{#2}% + \edef\pgfmathresult{{\tmpa}{\pgfmathresult}}% + \else + % singular (because PGF cannot represent its result + \let\pgfmathresult=\pgfutil@empty + \fi + \else + % singular (because PGF cannot represent its result + \let\pgfmathresult=\pgfutil@empty + \fi +}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex index ab19ee35f13..b68c50eac2c 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex @@ -114,8 +114,7 @@ \fi - -\pgfutil@ifundefined{pgfmathfloatatan2}{ +\pgfutil@ifundefined{pgfmathfloat@stack@push@operand@single@str}{ \gdef\pgfplots@glob@TMPa{1}% } {}% @@ -323,5 +322,40 @@ % ok, plot function is up-to-date }% +\def\pgfmathfloatmod@broken#1#2{% + \begingroup + \pgfmathfloatdivide@{#1}{#2}% + \pgfmathfloatint@{\pgfmathresult}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\ifx\pgfmathfloatmod@\pgfmathfloatmod@broken + \def\pgfmathfloatmod@#1#2{% + \begingroup + \pgfmathfloattoint{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloattoint{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \c@pgfmath@counta=\pgfmathfloat@loc@TMPa\relax + \divide\c@pgfmath@counta by\pgfmathfloat@loc@TMPb\relax + \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}% + % + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + } +\fi + +\pgfutil@IfUndefined{pgfutilsolvetwotwoleqfloat}{% + \input pgfplotsoldpgfsupp_leq.code.tex +}{}% \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex index 39ec3b33cb7..1c9cfe742dd 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex @@ -19,7 +19,7 @@ % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: % This file comes without any warranty as the rest of pgfplots; there is no obligation for help. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 31. Dez 19:01:21 CET 2015 %%% +%%% Date of this copy: Fr 10. Nov 17:18:26 CET 2017 %%% @@ -90,7 +90,7 @@ \pgfmathfloatparsenumber{#1}% \fi \let\pgfmathfloatscale=\pgfmathresult% - },% + },% % determines the output format of each complete expression parsing % process. If 'scale results' is active, 'fixed' is assumed % automatically. @@ -192,7 +192,7 @@ \pgfutil@namelet{#1}{#2}% } \def\pgfmathfloat@install@unimplemented#1{% - \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath@#1@\endcsname% + \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath#1@\endcsname% \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}% } \def\pgfmathfloat@plots@install{% @@ -288,6 +288,7 @@ \expandafter\pgfmathfloat@install\csname pgfmathatan2@\endcsname=\pgfmathfloatatantwo@ \pgfmathfloat@install@unimplemented{isprime}% \pgfmathfloat@install@unimplemented{iseven}% + \pgfmathfloat@install@unimplemented{isodd}% \pgfmathfloat@install@unimplemented{gcd}% \pgfmathfloat@install@unimplemented{frac}% \pgfmathfloat@install@unimplemented{random}% @@ -325,6 +326,7 @@ \let\pgfmath@basic@parse@exponent=\pgfmath@parse@exponent% \let\pgfmath@basic@stack@push@operand=\pgfmath@stack@push@operand \pgfmathfloat@install\pgfmath@stack@push@operand=\pgfmathfloat@stack@push@operand + \pgfmathfloat@install\pgfmath@parse@operand@quote=\pgfmathfloat@parse@operand@quote \pgfmathfloat@install\pgfmath@parse@exponent=\pgfmathfloat@parse@float@or@exponent % \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse% @@ -350,7 +352,7 @@ \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1\endcsname{% \noexpand\let\noexpand\pgfmath@parsepostgroup\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname% \noexpand\expandafter\noexpand\pgfmath@parse@}% - \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname{% + \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname{% \noexpand\expandafter\expandafter\noexpand\csname pgfmath#1@\endcsname\noexpand\expandafter{\noexpand\pgfmathresult}% \noexpand\pgfmath@postfunction% }% @@ -510,6 +512,14 @@ \pgfmath@parse@@operator% }% +\def\pgfmathfloat@parse@operand@quote#1"{% + \edef\pgfmathresult{\pgfmath@fpu@stringmarker #1}% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +} + +\def\pgfmath@fpu@stringmarker{@@str@@:}% + % This extends the functionality of the basic level operand stack: it % assures every element on the stack is a float. \def\pgfmathfloat@stack@push@operand#1{% @@ -526,10 +536,19 @@ \ifpgfutil@in@ \pgfmath@basic@stack@push@operand{#1}% \else - \pgfmathfloatparsenumber{#1}% - \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \expandafter\pgfutil@in@\expandafter{\pgfmath@fpu@stringmarker}{#1}% + \ifpgfutil@in@ + \pgfmathfloat@stack@push@operand@single@str#1\relax + \else + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \fi \fi }% + +\expandafter\def\expandafter\pgfmathfloat@stack@push@operand@single@str\pgfmath@fpu@stringmarker #1\relax{% + \pgfmath@basic@stack@push@operand{#1}% +}% \def\pgfmathfloat@stack@push@operand@GOBBLE#1\relax{}% \def\pgfmathfloat@stack@push@operand@list#1{% \expandafter\pgfutil@in@ \pgfmathfloat@POSTFLAGSCHAR{#1}% @@ -1636,8 +1655,14 @@ % \def\pgfmathfloatmod@#1#2{% \begingroup - \pgfmathfloatdivide@{#1}{#2}% - \pgfmathfloatint@{\pgfmathresult}% + \pgfmathfloattoint{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloattoint{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \c@pgfmath@counta=\pgfmathfloat@loc@TMPa\relax + \divide\c@pgfmath@counta by\pgfmathfloat@loc@TMPb\relax + \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}% + % \let\pgfmathfloat@loc@TMPa=\pgfmathresult \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% \let\pgfmathfloat@loc@TMPb=\pgfmathresult @@ -1651,15 +1676,20 @@ % A modification of \pgfmathfloatmod@ where #3 = 1/#2 is already % known. This may be faster. \def\pgfmathfloatmodknowsinverse@#1#2#3{% - \begingroup - \pgfmathfloatmultiply@{#1}{#3}% - \pgfmathfloatint@{\pgfmathresult}% - \let\pgfmathfloat@loc@TMPa=\pgfmathresult - \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% - \let\pgfmathfloat@loc@TMPb=\pgfmathresult - \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% - \pgfmath@smuggleone\pgfmathresult - \endgroup + \pgfmathfloatmod@{#1}{#2}% + %-------------------------------------------------- + % \begingroup + % % FIXME : is this function correct? \pgfmathfloatmod had a + % % rounding flaw... + % \pgfmathfloatmultiply@{#1}{#3}% + % \pgfmathfloatint@{\pgfmathresult}% + % \let\pgfmathfloat@loc@TMPa=\pgfmathresult + % \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + % \let\pgfmathfloat@loc@TMPb=\pgfmathresult + % \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + % \pgfmath@smuggleone\pgfmathresult + % \endgroup + %-------------------------------------------------- } \let\pgfmathfloatmodknowsinverse=\pgfmathfloatmodknowsinverse@ @@ -2119,7 +2149,7 @@ \ifnum0=\c@pgfmath@counta % ah: 0^0 \pgfmathfloatcreate{1}{1.0}{0}% - \else + \else % ah: 0^x with x!=0: \pgfmathfloatcreate{0}{0.0}{0}% \fi diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex index a3888007fd7..e6cb9e3bca7 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex @@ -19,7 +19,7 @@ % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: % This file comes without any warranty as the rest of pgfplots; there is no obligation for help. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Fr 14. Feb 21:37:39 CET 2014 %%% +%%% Date of this copy: Di 14. Nov 22:41:45 CET 2017 %%% @@ -76,7 +76,7 @@ % Example: \pgfintersectiongetsolutionsegmentindices{0}{\first}{\second} % % -> \first may be 0 if point #0 is in the 0'th segment -% -> \second may be 42 if point #0 is in the 42'th segment +% -> \second may be 42 if point #0 is in the 42'th segment % % The "segment index" is actually close to the "time" of the solution. % If a solution is at "time" 42.2, it will have segment index 42. @@ -132,7 +132,7 @@ \def\pgf@temp##1##2##3##4{% \edef#2{##3}% \edef#3{##4}% - % + % % check for fallback to segment indices: \ifx#2\pgfutil@empty \edef#2{##1}\fi \ifx#3\pgfutil@empty \edef#3{##2}\fi @@ -147,7 +147,7 @@ \begingroup% \pgftransforminvert% \pgfpointorigin% - \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgf@pos@transform@glob \global\pgf@x=\pgf@x% \global\pgf@y=\pgf@y% \endgroup% @@ -161,7 +161,7 @@ \long\def\pgfintersectionofpaths#1#2{% \begingroup% \pgfinterruptpath% - #1% + #1% \pgfgetpath\pgf@intersect@path@a% \global\let\pgf@intersect@path@temp=\pgf@intersect@path@a% \endpgfinterruptpath% @@ -170,7 +170,7 @@ % \begingroup% \pgfinterruptpath% - #2% + #2% \pgfgetpath\pgf@intersect@path@b% \global\let\pgf@intersect@path@temp=\pgf@intersect@path@b% \endpgfinterruptpath% @@ -220,9 +220,9 @@ % % However, \pgf@intersect@time@offset and % \pgf@intersect@time@offset@b are *always* valid. In fact,they - % resemble a part of the time: it holds + % resemble a part of the time: it holds % 0 <= \pgf@intersect@time@a < 1 - % and \pgf@intersect@time@offset > 0. + % and \pgf@intersect@time@offset > 0. % % If we have an intersection in segment 42 of path A, % \pgf@intersect@time@offset will be 42. The time inside of that @@ -377,8 +377,7 @@ \pgf@iflinesintersect{#1}{#2}{#3}{#4}% {% \pgfextract@process\pgf@intersect@solution@candidate{% - \pgfpointintersectionoflines{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}% - {\pgfpoint@intersect@start@b}{\pgfpoint@intersect@end@b}% + % pgf@x and pgf@y are already assigned by \pgf@iflinesintersect }% \pgf@ifsolution@duplicate{\pgf@intersect@solution@candidate}{% % ah - we a duplicate. Apparently, we have a hit on an @@ -402,7 +401,7 @@ \pgf@marshal% \pgfmathdivide@{\pgfmathresult}{\pgf@intersect@length@a}% \pgf@x=\pgfmathresult pt\relax% - \advance\pgf@x by\pgf@intersect@time@offset pt\relax% + \advance\pgf@x by\pgf@intersect@time@offset pt\relax% \edef\pgf@intersect@time@a{\pgfmath@tonumber{\pgf@x}}% \expandafter\global\expandafter\let\csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname= \pgf@intersect@time@a @@ -413,7 +412,8 @@ \pgf@intersection@store@properties{pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions}% }% % - }{}% + }{% + }% } % Test if two lines L1 and L2 intersect. @@ -435,16 +435,16 @@ % % t = |x4-x3 x3-x1| / |x4-x3 x2-x1| % |y4-y3 y3-y1| |y4-y3 y2-y1| -% +% % with 0<=s,t<=1 -% +% % s and t do not need to be calculated: % % Let s = A / C and t = B / C -% +% % Then 0<=s<=1 if !(C=0) && ((A=0) || ((A>0) && !(C<A)) || ((A<0) && !(C>A))) % 0<=t<=1 if !(C=0) && ((B=0) || ((B>0) && !(C<B)) || ((B<0) && !(C>B))) -% +% \newif\ifpgf@s \newif\ifpgf@t \def\pgfiflinesintersect#1#2#3#4{% @@ -454,95 +454,199 @@ \endgroup% } +% queried by pgfplots. Do not delete, only increase. +\def\pgf@intersections@version{2}% + +% #1,#2: line 1 +% #3,#4: line 2 \def\pgf@iflinesintersect#1#2#3#4{% - #4\relax% - \pgf@xc=\pgf@x% - \pgf@yc=\pgf@y% - #3\relax% - \advance\pgf@xc by-\pgf@x% - \advance\pgf@yc by-\pgf@y% - \pgf@xb=\pgf@x% - \pgf@yb=\pgf@y% - #2\relax% + % first: check bounding boxes -- but somewhat increased such that we do not + % exclude "visible" hits due to rounding issues (i.e. use an upper bound): + \pgf@intersect@boundingbox@reset% + \pgf@intersect@boundingbox@update{#1}% + \pgf@intersect@boundingbox@update{#2}% + \pgf@intersect@boundingbox@assign@b% + % + \pgf@intersect@boundingbox@reset% + \pgf@intersect@boundingbox@update{#3}% + \pgf@intersect@boundingbox@update{#4}% + \pgf@intersect@boundingbox@assign@a% + % + \pgf@intersect@boundingbox@a% + \pgf@intersect@boundingbox@b% + % + \pgf@intersect@boundingbox@ifoverlap@upperbound{% + \pgf@iflinesintersect@{#1}{#2}{#3}{#4}% + }{% + \let\pgf@intersect@next=\pgfutil@secondoftwo% + }% + \pgf@intersect@next% +}% + +% a helper routine which simply defines \pgf@intersect@next. +% +% In principle, this routine is capable of computing the entire intersection... but we only invoke it after checking for bounding box overlaps. This has two reasons: +% 1. robustness. almost-parallel lines could cause "dimension too large" when solving the linear equation system +% XXX : I still needed to replace the linear solver by one using the FPU. Perhaps I do not need the BB check anymore? +% 2. performance. I hope it is faster to first check for BB (but this is not sure in TeX) +% +% #1,#2: line 1 +% #3,#4: line 2 +\def\pgf@iflinesintersect@#1#2#3#4{% + % we have two lines of sorts + % l_1(s) := #1 + s * (#2 - #1), 0<= s <= 1 + % and + % l_2(t) := #3 + t * (#4 - #3), 0<= t <= 1 + % -> + % set up LGS + % ( #2 - #1 ) *s + (#3-#4) * t = #3-#1 + % we have a hit if 0<= s,t <= 1 . + #1\relax% \pgf@xa=\pgf@x% \pgf@ya=\pgf@y% - #1\relax% - \advance\pgf@xa by-\pgf@x% - \advance\pgf@ya by-\pgf@y% - \advance\pgf@xb by-\pgf@x% - \advance\pgf@yb by-\pgf@y% + #2\relax% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + #3\relax% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + #4\relax% % - % xc = x4-x3; yc=y4-y3; - % xb = x3-x1; yb=y3-y1; - % xa = x2-x1; ya=y2-y1; + % will be overwritten, remember it: + \edef\pgf@intersect@A{% + \pgf@xa=\the\pgf@xa\space + \pgf@ya=\the\pgf@ya\space + }% % + % B := (2-1) + \advance\pgf@xb by-\pgf@xa + \advance\pgf@yb by-\pgf@ya % - % Normalise a little. 16384 may not be a robust choice. + % A := (3-1) + \advance\pgf@xa by-\pgf@xc + \advance\pgf@ya by-\pgf@yc + \pgf@xa=-\pgf@xa + \pgf@ya=-\pgf@ya % - \c@pgf@counta=\pgf@xa\divide\c@pgf@counta by16384\relax% - \c@pgf@countb=\pgf@xb\divide\c@pgf@countb by16384\relax% - \c@pgf@countc=\pgf@ya\divide\c@pgf@countc by16384\relax% - \c@pgf@countd=\pgf@yb\divide\c@pgf@countd by16384\relax% - \multiply\c@pgf@counta by\c@pgf@countd% - \multiply\c@pgf@countc by\c@pgf@countb% - \advance\c@pgf@counta by-\c@pgf@countc% - \pgfutil@tempcnta=\c@pgf@counta% + % C := (3-4) + \advance\pgf@xc by-\pgf@x + \advance\pgf@yc by-\pgf@y % - \c@pgf@counta=\pgf@xc\divide\c@pgf@counta by16384\relax% - \c@pgf@countc=\pgf@yc\divide\c@pgf@countc by16384\relax% - \multiply\c@pgf@countd by\c@pgf@counta% - \multiply\c@pgf@countb by\c@pgf@countc% - \advance\c@pgf@countd by-\c@pgf@countb% - \pgfutil@tempcntb=\c@pgf@countd% + \begingroup + % compute the |.|_1 norm of each of lines. We need to compute + % tolerance factors in order to decide if we have an intersection. + % line 1: compute |#2 - #1|_1 : + \ifdim\pgf@xb<0sp \pgf@xb=-\pgf@xb\fi + \ifdim\pgf@yb<0sp \pgf@yb=-\pgf@yb\fi + \advance\pgf@xb by\pgf@yb + \xdef\pgf@intersect@len@a{\pgf@sys@tonumber\pgf@xb}% % - \c@pgf@countb=\pgf@xa\divide\c@pgf@countb by16384\relax% - \c@pgf@countd=\pgf@ya\divide\c@pgf@countd by16384\relax% - \multiply\c@pgf@counta by\c@pgf@countd% - \multiply\c@pgf@countc by\c@pgf@countb% - \advance\c@pgf@counta by-\c@pgf@countc% + % line 2: compute |#3 - #4|_1 : + \ifdim\pgf@xc<0sp \pgf@xc=-\pgf@xc\fi + \ifdim\pgf@yc<0sp \pgf@yc=-\pgf@yc\fi + \advance\pgf@xc by\pgf@yc + \xdef\pgf@intersect@len@b{\pgf@sys@tonumber\pgf@xc}% + \endgroup + % + \edef\pgf@marshal{% + \noexpand\pgfutilsolvetwotwoleqfloat{% + {\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@xc}% + {\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@yc}% + }{% + {\pgf@sys@tonumber\pgf@xa}% + {\pgf@sys@tonumber\pgf@ya}% + }% + }% + \pgf@marshal % - \pgf@sfalse% - \pgf@tfalse% - \ifnum\c@pgf@counta=0\relax% - \else% - \ifnum\pgfutil@tempcnta=0\relax% - \pgf@strue% - \else% - \ifnum\pgfutil@tempcnta>0\relax% - \ifnum\c@pgf@counta<\pgfutil@tempcnta% - \else% - \pgf@strue% - \fi% - \else% - \ifnum\c@pgf@counta>\pgfutil@tempcnta% - \else% - \pgf@strue% - \fi% - \fi% - \fi% - \ifnum\pgfutil@tempcntb=0\relax% - \pgf@ttrue% - \else% - \ifnum\pgfutil@tempcntb>0\relax% - \ifnum\c@pgf@counta<\pgfutil@tempcntb% - \else% - \pgf@ttrue% - \fi% - \else% - \ifnum\c@pgf@counta>\pgfutil@tempcntb% - \else% - \pgf@ttrue% - \fi% - \fi% - \fi% - \fi% \let\pgf@intersect@next=\pgfutil@secondoftwo% - \ifpgf@s% - \ifpgf@t% + \ifx\pgfmathresult\pgfutil@empty + % matrix was singular. + \else + \def\pgf@marshal##1##2{% + \global\pgf@x=##1pt % + \global\pgf@y=##2pt % + }% + \expandafter\pgf@marshal\pgfmathresult + % + \def\pgf@marshal{XXXX}% this should never be read + % FIRST: check line 1: + \ifdim\pgf@x<0sp + % let it count as hit if + % || l_1(s) - l_1(0) || < eps + % <=> |s| * ||#2 - #1|| < eps + % and, since s< 0 here: + % <=> -s * ||#2 - #1|| < eps + \pgf@xa=-\pgf@intersect@len@a\pgf@x + \ifdim\pgf@xa<\pgfintersectiontolerance\relax + % close enough to first endpoint of line 1: + \def\pgf@marshal{1}% + \else + \def\pgf@marshal{0}% + \fi + \else + \ifdim\pgf@x>1pt + % let it count as hit if + % || l_1(s) - l_1(1) || < eps + % <=> |s-1| * ||#2 - #1|| < eps + % and, since s > 1 here: + % <=> s * ||#2 - #1|| - ||#2 - #1|| < eps + \pgf@xa=\pgf@intersect@len@a\pgf@x + \advance\pgf@xa by-\pgf@intersect@len@a pt % + \ifdim\pgf@xa<\pgfintersectiontolerance\relax + % close enough to second endpoint of line 1: + \def\pgf@marshal{1}% + \else + \def\pgf@marshal{0}% + \fi + \else + % 0<= s <= 1: we have an intersection within line 1. + \def\pgf@marshal{1}% + \fi + \fi + % + % SECOND: check line 2: + \if1\pgf@marshal + \ifdim\pgf@y<0sp + % see remarks for line 1. same applies here. + \pgf@xa=-\pgf@intersect@len@b\pgf@y + \ifdim\pgf@xa<\pgfintersectiontolerance\relax + % close enough to first endpoint of line 2: + \def\pgf@marshal{1}% + \else + \def\pgf@marshal{0}% + \fi + \else + \ifdim\pgf@y>1pt + % see remarks for line 1. same applies here. + \pgf@xa=\pgf@intersect@len@b\pgf@y + \advance\pgf@xa by-\pgf@intersect@len@b pt % + \ifdim\pgf@xa<\pgfintersectiontolerance\relax + % close enough to second endpoint of line 2: + \def\pgf@marshal{1}% + \else + \def\pgf@marshal{0}% + \fi + \else + % 0<= t <= 1: we have an intersection within line 2. + \def\pgf@marshal{1}% + \fi + \fi + \fi + % + \if1\pgf@marshal + % Ok, compute the intersection point and return it: + % we use (x,y) = A + s * (B-A) + % keep in mind that (s,t) == (\pgf@x,\pgf@y) + \pgf@intersect@A + \pgf@yc=\pgf@x + \global\pgf@x=\pgf@sys@tonumber\pgf@xb\pgf@yc + \global\pgf@y=\pgf@sys@tonumber\pgf@yb\pgf@yc + \global\advance\pgf@x by \pgf@xa + \global\advance\pgf@y by \pgf@ya \let\pgf@intersect@next=\pgfutil@firstoftwo% - \fi% - \fi% - \pgf@intersect@next% + \fi + \fi } @@ -601,17 +705,18 @@ \def\pgfintersectiontolerance{0.1pt} +\def\pgfintersectiontoleranceupperbound{1pt} \def\pgfintersectiontolerancefactor{0.1} % Find the intersections of two bezier curves. -% +% % #1 - #4 = curve 1. % #5 - #8 = curve 2. % #9 = the solution number. % -% There is no guarantee of ordering of solutions. If there are +% There is no guarantee of ordering of solutions. If there are % no solutions, the origin is returned. % \def\pgfpointintersectionofcurves#1#2#3#4#5#6#7#8#9{% @@ -625,7 +730,7 @@ % Return any intersection points of two curves C1 and C2. % No order can be guaranteed for the solutions. % -% #1, #2, #3, #4 - the points on C1 +% #1, #2, #3, #4 - the points on C1 % #5, #6, #7, #8 - the points on C2 % % Returns: @@ -639,7 +744,7 @@ % S = {}; % intersection'(C1,C2); % return S; -% +% % intersection'(C1,C2) % B1 = boundingbox(C1); % B2 = boundingbox(C2); @@ -677,42 +782,114 @@ \endgroup% } +\def\pgf@intersect@boundingbox@assign@a{% + \edef\pgf@intersect@boundingbox@a{% + % lower left: + \noexpand\pgf@xb=\the\pgf@xa\space% + \noexpand\pgf@yb=\the\pgf@ya\space% + % upper right: + \noexpand\pgf@xc=\the\pgf@xb\space% + \noexpand\pgf@yc=\the\pgf@yb\space% + }% +} +\def\pgf@intersect@boundingbox@assign@b{% + \edef\pgf@intersect@boundingbox@b{% + % lower left: + \noexpand\global\noexpand\pgf@x=\the\pgf@xa\space% + \noexpand\global\noexpand\pgf@y=\the\pgf@ya\space% + % upper right: + \noexpand\pgf@xa=\the\pgf@xb\space% + \noexpand\pgf@ya=\the\pgf@yb\space% + }% +} + +% see \pgf@intersect@boundingbox@assign@a and \pgf@intersect@boundingbox@assign@b for the naming conventions +\def\pgf@intersect@boundingbox@ifoverlap{% + \def\pgf@intersect@next{\pgfutil@secondoftwo}% + % + \ifdim\pgf@xa<\pgf@xb% + \else% + \ifdim\pgf@x>\pgf@xc% + \else% + \ifdim\pgf@ya<\pgf@yb% + \else% + \ifdim\pgf@y>\pgf@yc% + \else% + \def\pgf@intersect@next{\pgfutil@firstoftwo}% + \fi + \fi + \fi + \fi + \pgf@intersect@next +}% +\def\pgf@intersect@boundingbox@ifoverlap@upperbound{% + \begingroup + \def\pgf@intersect@next{\pgfutil@secondoftwo}% + % + \advance\pgf@xa by+\pgfintersectiontolerance\relax + \ifdim\pgf@xa<\pgf@xb% + \else% + \global\advance\pgf@x by-\pgfintersectiontolerance\relax + \ifdim\pgf@x>\pgf@xc% + \else% + \advance\pgf@ya by\pgfintersectiontolerance\relax + \ifdim\pgf@ya<\pgf@yb% + \else% + \global\advance\pgf@y by-\pgfintersectiontolerance\relax + \ifdim\pgf@y>\pgf@yc% + \else% + \def\pgf@intersect@next{\pgfutil@firstoftwo}% + \fi + \fi + \fi + \fi + \expandafter + \endgroup + \pgf@intersect@next +}% +\def\pgf@intersect@boundingbox@ifoverlap@UNUSED{% + \let\pgf@intersect@next=\pgfutil@secondoftwo% + \ifdim\pgf@xa<\pgf@xb% + \else% + \ifdim\pgf@x>\pgf@xc% + \else% + \ifdim\pgf@ya<\pgf@yb% + \else% + \ifdim\pgf@y>\pgf@yc% + \else% + \let\pgf@intersect@next=\pgfutil@firstoftwo% + \fi + \fi + \fi + \fi + \pgf@intersect@next +}% \def\pgf@@intersectionofcurves#1#2#3#4#5#6#7#8{% \pgf@intersect@boundingbox@reset% \pgf@intersect@boundingbox@update{#1}% \pgf@intersect@boundingbox@update{#2}% \pgf@intersect@boundingbox@update{#3}% \pgf@intersect@boundingbox@update{#4}% - % (\pgf@xa, \pgf@ya) is lower-left - % (\pgf@xb, \pgf@yb) is upper-right - \edef\pgf@intersect@boundingbox@b{% - \noexpand\pgf@x=\the\pgf@xa% - \noexpand\pgf@y=\the\pgf@ya% - \noexpand\pgf@xa=\the\pgf@xb% - \noexpand\pgf@ya=\the\pgf@yb% - }% + \pgf@intersect@boundingbox@assign@b% + % \pgf@intersect@boundingbox@reset% \pgf@intersect@boundingbox@update{#5}% \pgf@intersect@boundingbox@update{#6}% \pgf@intersect@boundingbox@update{#7}% \pgf@intersect@boundingbox@update{#8}% - \edef\pgf@intersect@boundingbox@a{% - \noexpand\pgf@xb=\the\pgf@xa% - \noexpand\pgf@yb=\the\pgf@ya% - \noexpand\pgf@xc=\the\pgf@xb% - \noexpand\pgf@yc=\the\pgf@yb% - }% + \pgf@intersect@boundingbox@assign@a% + % \pgf@intersect@boundingbox@a% \pgf@intersect@boundingbox@b% - % check if the two bounding boxes overlap: - \ifdim\pgf@xa<\pgf@xb% - \else% - \ifdim\pgf@x>\pgf@xc% - \else% - \ifdim\pgf@ya<\pgf@yb% - \else% - \ifdim\pgf@y>\pgf@yc% - \else% + % + \pgf@intersect@boundingbox@ifoverlap{% + \pgf@@@intersectionofcurves{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}% + }{% + % no overlap -- no intersection. + }% +} + +\def\pgf@@@intersectionofcurves#1#2#3#4#5#6#7#8{% % compute DIFFERENCE vectors: \advance\pgf@xc by-\pgf@xb% \advance\pgf@yc by-\pgf@yb% @@ -761,8 +938,8 @@ \pgf@intersect@solution@candidate% \ifpgf@intersect@sort% \expandafter\xdef% - \csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname% - {\pgf@intersect@time@a}% + \csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname% + {\pgf@intersect@time@a}% \fi% \endgroup }% @@ -774,10 +951,6 @@ \else% \pgf@intersect@subdivide@curve{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}% \fi% - \fi% - \fi% - \fi% - \fi% } \def\pgf@intersect@subdivide@curve@b#1#2#3#4#5#6#7#8{% @@ -855,7 +1028,7 @@ \def\pgf@curve@subdivide@left#1#2#3#4{% % - % The left curve (from t=0 to t=.5) + % The left curve (from t=0 to t=.5) % \begingroup #1\relax% @@ -898,7 +1071,7 @@ \def\pgf@curve@subdivide@right#1#2#3#4{% % - % The right curve (from t=0.5 to t=1) + % The right curve (from t=0.5 to t=1) % \begingroup #1\relax% @@ -942,7 +1115,7 @@ % A solution S1 is considered a duplicate of S2, if -% +% % |x1 - x2|f < q and |y1 - y2|f < q % % where q is a small value (tolerance). @@ -956,7 +1129,7 @@ \let\pgf@intersect@next=\pgfutil@secondoftwo% \pgfmathloop% \ifnum\pgfmathcounter>\pgf@intersect@solutions\relax% - \else% + \else% \pgf@ifsolution@duplicate@{\pgfmathcounter}% \repeatpgfmathloop% \pgf@intersect@next% @@ -985,8 +1158,7 @@ \def\pgfintersectionsolutionsortbytime{% \pgf@intersect@solutions@sortfinishtrue% \pgfmathloop% - \ifnum\pgfmathcounter=\pgfintersectionsolutions\relax% - \else% + \ifnum\pgfmathcounter<\pgfintersectionsolutions\relax% \pgfutil@tempcnta=\pgfmathcounter% \advance\pgfutil@tempcnta by1\relax% \ifdim\csname pgf@intersect@solution@\pgfmathcounter @time@a\endcsname pt>% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex index 9a36660282b..5ba17bc2d0e 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex @@ -19,7 +19,7 @@ % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: % This file comes without any warranty as the rest of pgfplots; there is no obligation for help. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Di 30. Dez 15:31:24 CET 2014 %%% +%%% Date of this copy: Fr 10. Nov 17:18:26 CET 2017 %%% @@ -1691,7 +1691,7 @@ \endgroup \let#3=\pgfmathfloat@glob@TMP }% - + % Changes the current number pretty printer to #1. % @@ -1858,7 +1858,7 @@ \fi \fi } - + % takes the current input and decides whether trailing zeros shall be % discarded or more zeros need to be filled in. \def\pgfmathroundto@impl@finish@with@truncation{% |