summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex59
1 files changed, 55 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex
index 02726731357..aa98934e807 100644
--- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex
+++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex
@@ -18,6 +18,23 @@
%
\pgfmathdeclarefunction{pi}{0}{\def\pgfmathresult{3.141592654}}
+\pgfkeys{
+ /pgf/trig format/.is choice,
+ % attention: the luamath library will hook into these code keys.
+ /pgf/trig format/deg/.code={\def\pgfmath@trig@format@choice{0}},
+ /pgf/trig format/rad/.code={\def\pgfmath@trig@format@choice{1}},
+ /pgf/trig format/deg,
+}
+
+% Executes #1 if 'trig format=deg' and #2 otherwise.
+\def\pgfmathiftrigonometricusesdeg#1#2{%
+ \if0\pgfmath@trig@format@choice
+ #1%
+ \else
+ #2%
+ \fi
+}%
+
% \pgfmathradians
% (for comptability with 1.18 beta, will be deprecated)
%
@@ -38,11 +55,15 @@
\pgfmathdeclarefunction{deg}{1}{%
\begingroup%
\expandafter\pgfmath@x#1pt\relax%
- \pgfmath@x57.29577\pgfmath@x\relax% 57.29577 = 360/(2*pi)
+ \pgfmath@scale@rad@to@deg\pgfmath@x
\pgfmath@returnone\pgfmath@x%
\endgroup%
}%
+\def\pgfmath@scale@rad@to@deg#1{%
+ #1=57.29577#1\relax% 57.29577 = 360/(2*pi)
+}%
+
% \pgfmathrad
%
% Convert #1 from degrees to radians.
@@ -50,12 +71,16 @@
\pgfmathdeclarefunction{rad}{1}{%
\begingroup%
\expandafter\pgfmath@x#1pt\relax%
- \pgfmath@x3.14159\pgfmath@x%
- \divide\pgfmath@x180\relax%
+ \pgfmath@scale@deg@to@rad\pgfmath@x
\pgfmath@returnone\pgfmath@x%
\endgroup%
}%
+\def\pgfmath@scale@deg@to@rad#1{%
+ #1=3.14159#1%
+ \divide#1180\relax%
+}%
+
% \pgfmathsin
%
% Calculate the sine of #1 (in degrees).
@@ -66,6 +91,10 @@
%
\begingroup%
\expandafter\pgfmath@x#1pt\relax%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@rad@to@deg\pgfmath@x
+ \fi
\advance\pgfmath@x-90pt\relax%
\afterassignment\pgfmath@gobbletilpgfmath@
\expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@
@@ -108,6 +137,10 @@
%
\begingroup%
\expandafter\pgfmath@x#1pt\relax%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@rad@to@deg\pgfmath@x
+ \fi
\afterassignment\pgfmath@gobbletilpgfmath@%
\expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@%
\divide\c@pgfmath@counta360\relax%
@@ -229,6 +262,10 @@
\ifdim\pgfmath@xa<0pt\relax%
\pgfmath@x-\pgfmath@x%
\fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
\pgfmath@returnone\pgfmath@x%
\endgroup%
}
@@ -281,6 +318,10 @@
\pgfmath@x-\pgfmath@x%
\advance\pgfmath@x by180pt\relax%
\fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
\pgfmath@returnone\pgfmath@x%
\endgroup%
}
@@ -310,6 +351,10 @@
\ifdim\pgfmath@xa<0pt\relax%
\pgfmath@x-\pgfmath@x%
\fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
\pgfmath@returnone\pgfmath@x%
\endgroup%
}
@@ -317,13 +362,15 @@
\pgfmathdeclarefunction{atan2}{2}{%
% Note: first parameter is y (!), second is x (!)
\begingroup%
+ \let\pgfmath@trig@format@choice@@=\pgfmath@trig@format@choice
+ \def\pgfmath@trig@format@choice{0}%
\pgfmath@y=#1pt\relax%
\ifdim\pgfmath@y<0pt\relax%
\pgfmath@y=-\pgfmath@y%
\fi%
\ifdim\pgfmath@y<0.001pt\relax%
\ifdim#2pt<0pt\relax%
- \pgfmath@x=-180pt\relax%
+ \pgfmath@x=+180pt\relax%
\else%
\ifdim#2pt>0pt\relax%
\pgfmath@x=0pt\relax%
@@ -355,6 +402,10 @@
\pgfmath@x=-\pgfmath@x%
\fi%
\fi%
+ \if1\pgfmath@trig@format@choice@@
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
\pgfmath@returnone\pgfmath@x%
\endgroup%
}