summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex335
1 files changed, 333 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex
index 12d308255bd..dad89e7c7e1 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex
@@ -2,13 +2,14 @@
% ======================================================
% compatibility with PGF 2.0
% ======================================================
+\def\pgfutil@gobble@until@relax#1\relax{}
\expandafter\ifx\csname w@pgf@writea\endcsname\relax
-\newwrite\w@pgf@writea
+\csname newwrite\endcsname\w@pgf@writea
\fi
\expandafter\ifx\csname r@pgf@reada\endcsname\relax
-\newread\r@pgf@reada
+\csname newread\endcsname\r@pgf@reada
\fi
\let\pgfutil@inputcheck=\r@pgf@reada
@@ -442,3 +443,333 @@
\global\pgf@picmaxy=-16000pt\relax%
\global\pgf@picminy=16000pt\relax%
}%
+
+% from pgfcorepathconstruct.code.tex:
+
+
+\def\pgfpatharctomaxstepsize{45}
+
+% A specialized arc operation for an arc on an (axis--parallel) ellipse.
+%
+% In contrast to \pgfpatharc, it explicitly interpolates start- and end points.
+%
+% In contrast to \pgfpatharcto, this routine is numerically stable and
+% quite fast since it relies on a lot of precomputed information.
+%
+% #1 center of ellipse
+% #2 angle of last path position inside of the ellipse
+% #3 end angle
+% #4 end point (a \pgfpoint)
+% #5 xradius
+% #6 yradius
+% #7 the ratio xradius/yradius of the ellipse
+% #8 the ratio yradius/xradius of the ellipse
+% Example:
+% \def\cx{1cm}% center x
+% \def\cy{1cm}% center y
+% \def\startangle{0}%
+% \def\endangle{45}%
+% \def\a{5cm}% xradius
+% \def\b{10cm}% yradius
+% \pgfmathparse{\a/\b}\let\abratio=\pgfmathresult
+% \pgfmathparse{\b/\a}\let\baratio=\pgfmathresult
+%
+% \pgfpathmoveto{\pgfpoint{\cx+\a*cos(\startangle)}{\cy+\b*sin(\startangle)}}%
+% \pgfpatharctoprecomputed
+% {\pgfpoint{\cx}{\cy}}
+% {\startangle}
+% {\endangle}
+% {\pgfpoint{\cx+\a*cos(\endangle)}{\cy+\b*sin(\endangle)}}%
+% {\a}
+% {\b}
+% {\abratio}
+% {\baratio}
+%
+\def\pgfpatharctoprecomputed#1#2#3#4#5#6#7#8{%
+ \begingroup
+ % Implementation idea:
+ %
+ % let
+ % m = center (#1)
+ % \gamma_0 = start angle
+ % \gamma_1 = end angle
+ % a = x radius
+ % b = y radius
+ %
+ % an axis parallel ellipse is parameterized by
+ % C(\gamma) = m + ( a cos(\gamma), b sin(\gamma) ), \gamma in [0,360].
+ %
+ % Now, consider the segment \gamma(t),
+ % \gamma:[0,1] -> [\gamma_0,\gamma_1],
+ % t -> \gamma_0 + t(\gamma_1 - \gamma_0)
+ % and
+ % C(\gamma(t)) which is defined on [0,1].
+ %
+ % I'd like to approximate the arc by one or more cubic bezier
+ % splines which interpolate through the last and first provided
+ % points.
+ %
+ % 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.
+ %
+ % The derivatives in our case are
+ % ( C \circ \gamma )'(t) = C'[\gamma(t)] * \gamma'(t)
+ % = ( -a pi/180 sin(\gamma(t)), b pi/180 cos(\gamma(t)) ) * (\gamma_1 - \gamma_0).
+ % The pi/180 comes into play since we are working with degrees.
+ %
+ % Expression (C\circ\gamma)'(0) using P_0 and (C \circ \gamma)'(1)
+ % using P_3 yields the expressions
+ % (C \circ \gamma)'(0) =
+ % pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_0^y - my), b/a (P_0^x - mx) ]
+ % (C \circ \gamma)'(1) =
+ % pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_3^y - my), b/a (P_3^x - mx) ]
+ %
+ % defining
+ % scaleA = a/b * pi / (3*180) * (\gamma_1 - \gamma_0)
+ % and
+ % scaleB = b/a * pi / (3*180) * (\gamma_1 - \gamma_0)
+ % yields the direct expressions for the intermediate bezier
+ % control points
+ %
+ % P_1 = [
+ % P_0^x - scaleA* ( P_0^y -my),
+ % P_0^y + scaleB* ( P_0^x -mx) ]
+ % and
+ % P_2 = [
+ % P_3^x + scaleA* ( P_3^y -my),
+ % P_3^y - scaleB* ( P_3^x -mx) ].
+ %
+ % This works fast, with few operations, if
+ % - a/b and b/a are known in advance
+ % - P_0 and P_3 are known in advance
+ % - \gamma_0 and \gamma_1 are known.
+ %
+ % It is also reliable if (\gamma_1 - \gamma_0) is small
+ %
+ \pgf@process{#1}%
+ \edef\pgfpath@center@x{\the\pgf@x}%
+ \edef\pgfpath@center@y{\the\pgf@y}%
+ \def\pgfpath@completearcend{#4}%
+ % compute scale (#3-#2) * pi/(3*180) = (#3 - #2) * pi/27 * 1/20
+ % splitting pi/(3*180) into two scales has higher TeX accuracy
+ \pgf@xa=#2pt
+ \pgf@xb=#3pt
+ \edef\pgfpath@startangle{#2pt}%
+ \edef\pgfpath@endangle{\pgf@sys@tonumber\pgf@xb}%
+ %
+ \pgf@ya=\pgf@xb
+ \advance\pgf@ya by-\pgf@xa
+ %
+ \ifx\pgfpatharctomaxstepsize\pgfutil@empty
+ \def\pgfpath@N{1}%
+ \pgf@xc=\pgf@ya
+ \else
+ \pgf@xc=\pgf@ya% compute N = floor((gamma_1 - gamma_0) / max) +1
+ \ifdim\pgf@xc<0pt
+ \multiply\pgf@xc by-1
+ \fi
+ \divide\pgf@xc by\pgfpatharctomaxstepsize\relax
+ \afterassignment\pgfutil@gobble@until@relax
+ \c@pgf@counta=\the\pgf@xc\relax
+ \advance\c@pgf@counta by1
+ \edef\pgfpath@N{\the\c@pgf@counta}%
+ %
+ \pgf@xc=\pgf@ya
+ \divide\pgf@xc by\c@pgf@counta
+ \fi
+ %
+ \edef\pgfpath@h{\pgf@sys@tonumber\pgf@xc}%
+ %
+%\message{pgfpathellipse: using N =\pgfpath@N\space spline points y0 = \pgfpath@startangle, y0+i*h, yN=\pgfpath@endangle, i=1,...,(\pgfpath@N-1), with h=\pgfpath@h\space mesh width (total arc angle \pgf@sys@tonumber\pgf@ya).}%
+ %
+ %
+ \pgf@xc=0.116355283466289\pgf@xc % pi/27
+ \divide\pgf@xc by20
+ \pgf@xa=#7\pgf@xc
+ \edef\pgfpath@scale@A{\pgf@sys@tonumber\pgf@xa}%
+ \pgf@xa=#8\pgf@xc
+ \edef\pgfpath@scale@B{\pgf@sys@tonumber\pgf@xa}%
+ %
+ % compute intermediate spline segments for
+ % i = 1,...,N-1
+ % this is a no-op for N=1.
+ \c@pgf@countd=1
+ \pgfutil@loop
+ \ifnum\c@pgf@countd<\pgfpath@N\relax
+ %
+ \pgf@xa=\pgfpath@startangle % compute \pgf@xa = y_0 + i*h
+ \pgf@xb=\pgfpath@h pt
+ \multiply\pgf@xb by\c@pgf@countd
+ \advance\pgf@xa by\pgf@xb
+ \edef\pgfpath@angle@i{\pgf@sys@tonumber\pgf@xa}%
+%\message{angle \the\c@pgf@countd: \pgfpath@angle@i...}%
+ %
+ \pgfpatharcofellipse@{%
+ \pgfpoint
+ {\pgfpath@center@x + #5*cos(\pgfpath@angle@i)}
+ {\pgfpath@center@y + #6*sin(\pgfpath@angle@i)}
+ }%
+ %
+ \advance\c@pgf@countd by1
+ \pgfutil@repeat
+ %
+ % compute final spline segment. It only differs insofar as the
+ % final point is already known explicitly and should be
+ % interpolated without additional math error.
+%\message{angle \pgfpath@N: \pgfpath@endangle...}%
+ \pgfpatharcofellipse@{\pgfpath@completearcend}%
+ \endgroup
+}%
+\def\pgfpatharcofellipse@#1{%
+ \begingroup
+ \pgf@process{#1}%
+ \edef\pgfpath@endpt{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfpathcurveto{
+ \begingroup
+ \global\pgf@x=\pgf@path@lastx
+ \global\pgf@y=\pgf@path@lasty
+ \pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x
+ \pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y
+ \global\advance\pgf@x by-\pgfpath@scale@A\pgf@ya
+ \global\advance\pgf@y by \pgfpath@scale@B\pgf@xa
+ \endgroup
+ }{%
+ \begingroup
+ \pgfpath@endpt
+ \pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x
+ \pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y
+ \global\advance\pgf@x by \pgfpath@scale@A\pgf@ya
+ \global\advance\pgf@y by-\pgfpath@scale@B\pgf@xa
+ \endgroup
+ }{%
+ \pgfpath@endpt
+ }%
+ \endgroup
+}
+
+% bugfix for pgf 2.10, pgfmathfunctions.basic.code.tex :
+%
+\newif\ifpgfmath@divide@period
+\def\pgfmathdivide@#1#2{%
+ \begingroup%
+ \pgfmath@x=#1pt\relax%
+ \pgfmath@y=#2pt\relax%
+ \let\pgfmath@sign=\pgfmath@empty%
+ \ifdim0pt=\pgfmath@y%
+ \pgfmath@error{You've asked me to divide `#1' by `#2', %
+ but I cannot divide any number by `#2'}%
+ \fi%
+ \afterassignment\pgfmath@xa%
+ \c@pgfmath@counta\the\pgfmath@y\relax%
+ \ifdim0pt=\pgfmath@xa%
+ \divide\pgfmath@x by\c@pgfmath@counta%
+ \else%
+ \ifdim0pt>\pgfmath@x%
+ \def\pgfmath@sign{-}%
+ \pgfmath@x=-\pgfmath@x%
+ \fi%
+ \ifdim0pt>\pgfmath@y%
+ \expandafter\def\expandafter\pgfmath@sign\expandafter{\pgfmath@sign-}%
+ \pgfmath@y=-\pgfmath@y%
+ \fi%
+ \ifdim1pt>\pgfmath@y%
+ \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}%
+ \pgfmath@x=\pgfmath@sign\pgfmathresult\pgfmath@x%
+ \else%
+ \def\pgfmathresult{0}%
+ \pgfmath@divide@periodtrue%
+ \c@pgfmath@counta=0\relax%
+ \pgfmathdivide@@%
+ \pgfmath@x=\pgfmath@sign\pgfmathresult pt\relax%
+ \fi%
+ \fi%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+\def\pgfmath@small@number{0.00002}
+\def\pgfmathdivide@@{%
+ \let\pgfmath@next=\relax%
+ \ifdim\pgfmath@small@number pt<\pgfmath@x%
+ \ifdim\pgfmath@small@number pt<\pgfmath@y%
+ \ifdim\pgfmath@y>\pgfmath@x%
+ \ifpgfmath@divide@period%
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult.}%
+ \pgfmath@divide@periodfalse%
+ \fi%
+ \pgfmathdivide@dimenbyten\pgfmath@y%
+ \ifdim\pgfmath@y>\pgfmath@x%
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult0}%
+ \fi%
+ \else%
+ \c@pgfmath@counta=\pgfmath@x%
+ \c@pgfmath@countb=\pgfmath@y%
+ \divide\c@pgfmath@counta by\c@pgfmath@countb%
+ \pgfmath@ya=\c@pgfmath@counta\pgfmath@y%
+ \advance\pgfmath@x by-\pgfmath@ya%
+ \def\pgfmath@next{%
+ \toks0=\expandafter{\pgfmathresult}%
+ \edef\pgfmathresult{\the\toks0 \the\c@pgfmath@counta}%
+ }%
+ \ifpgfmath@divide@period
+ \else
+ % we are behind the period. It may happen that the
+ % result is more than one digit - in that case,
+ % introduce special handling:
+ \ifnum\c@pgfmath@counta>9 %
+ \expandafter\pgfmathdivide@advance@last@digit\pgfmathresult CCCCC\@@
+ \advance\c@pgfmath@counta by-10 %
+ \ifnum\c@pgfmath@counta=0
+ \let\pgfmath@next=\relax
+ \fi
+ \fi
+ \fi
+ \pgfmath@next
+ \fi%
+ \let\pgfmath@next=\pgfmathdivide@@%
+ \fi%
+ \fi%
+ \pgfmath@next%
+}
+
+% advances the last digit found in the number. Any missing digits are
+% supposed to be filled with 'C'.
+\def\pgfmathdivide@advance@last@digit#1.#2#3#4#5#6#7\@@{%
+ \pgfmath@ya=\pgfmathresult pt %
+ \if#2C%
+ \pgfmath@xa=1pt %
+ \else
+ \if#3C%
+ \pgfmath@xa=0.1pt %
+ \else
+ \if#4C%
+ \pgfmath@xa=0.01pt %
+ \else
+ \if#5C%
+ \pgfmath@xa=0.001pt %
+ \else
+ \if#6C%
+ \pgfmath@xa=0.0001pt %
+ \else
+ \pgfmath@xa=0.00001pt %
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \advance\pgfmath@ya by\pgfmath@xa
+ \edef\pgfmathresult{\pgfmath@tonumber@notrailingzero\pgfmath@ya}%
+}%
+
+{
+\catcode`\p=12
+\catcode`\t=12
+\gdef\Pgf@geT@NO@TRAILING@ZERO#1.#2pt{%
+ #1.%
+ \ifnum#2=0 \else #2\fi
+}
+}
+\def\pgfmath@tonumber@notrailingzero#1{\expandafter\Pgf@geT@NO@TRAILING@ZERO\the#1}