summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex64
1 files changed, 57 insertions, 7 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
index b1be68267d7..fe42eacac4c 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
@@ -26,7 +26,7 @@ Section~\ref{pgfmath-functions-basic}, the following command is
provided:
\begin{command}{\pgfmathreciprocal\marg{x}}
- Defines |\pgfmathresult| as $1\div\meta{x}$. This is provides
+ Defines |\pgfmathresult| as $1\div\meta{x}$. This provides
greatest accuracy when \mvar{x} is small.
\end{command}
@@ -52,12 +52,12 @@ the following commands are provided:
\begin{command}{\pgfmathgeneratepseudorandomnumber}
Defines |\pgfmathresult| as a pseudo-random integer between 1 and
$2^{31}-1$. This uses a linear congruency generator, based on ideas
- due to Erich Janka.
+ of Erich Janka.
\end{command}
-\begin{command}{\pgfmathrandominteger\marg{macro}\marg{maximum}\marg{minimum}}
+\begin{command}{\pgfmathrandominteger\marg{macro}\marg{minimum}\marg{maximum}}
This defines \meta{macro} as a pseudo-randomly generated integer from
- the range \meta{maximum} to \meta{minimum} (inclusive).
+ the range \meta{minimum} to \meta{maximum} (inclusive).
\begin{codeexample}[]
\begin{pgfpicture}
@@ -99,7 +99,7 @@ the following commands are provided:
\end{codeexample}
\begin{command}{\pgfmathsetseed\marg{integer}}
- Explicitly set seed for the pseudo-random number generator. By
+ Explicitly sets the seed for the pseudo-random number generator. By
default it is set to the value of |\time|$\times$|\year|.
\end{command}
@@ -129,6 +129,8 @@ the following commands are provided:
\begin{codeexample}[]
\pgfmathbasetodec\mynumber{107f}{16} \mynumber
\end{codeexample}
+
+ \noindent Note that, as usual in \TeX, the braces around an argument can be omitted if the argument is just a single token (a macro name is a single token).
\begin{codeexample}[]
@@ -187,14 +189,62 @@ the following commands are provided:
\begin{command}{\pgfmathsetbasenumberlength\marg{integer}}
- Set the number of digits in the result of a base conversion to
+ Sets the number of digits in the result of a base conversion to
\meta{integer}. If the result of a conversion has less digits
- than this number it is prefixed with zeros.
+ than this number, it is prefixed with zeros.
\begin{codeexample}[]
\pgfmathsetbasenumberlength{8}
\pgfmathdectobase\mynumber{15}{2} \mynumber
\end{codeexample}
+\end{command}
+
+\begin{command}{\pgfmathtodigitlist\marg{macro}\marg{number}}
+
+ This command converts \meta{number} into a comma-separated
+ list of digits and stores the result in \meta{macro}.
+ The \marg{number} is \emph{not} parsed before processing.
+
+\begin{codeexample}[]
+\pgfmathsetbasenumberlength{8}
+\begin{tikzpicture}[x=0.25cm, y=0.25cm]
+ \foreach \n [count=\y] in {0, 60, 102, 102, 126, 102, 102, 102, 0}{
+ \pgfmathdectobase{\binary}{\n}{2}
+ \pgfmathtodigitlist{\digitlist}{\binary}
+ \foreach \digit [count=\x, evaluate={\c=\digit*50+15;}] in \digitlist
+ \fill [fill=black!\c] (\x, -\y) rectangle ++(1,1);
+ }
+\end{tikzpicture}
+\end{codeexample}
+
+\end{command}
+
+\subsection{Angle Computations}
+
+Unlike the rest of the math engine, which is a ``standalone'' package,
+the following commands only work in conjunction with the core of
+\pgfname.
+
+
+
+\begin{command}{\pgfmathanglebetweenpoints\marg{p}\marg{q}}
+ Returns the angle of a line from \meta{p} to \meta{q} relative to a
+ line going straight right from \meta{p}.
+
+\begin{codeexample}[]
+\pgfmathanglebetweenpoints{\pgfpoint{1cm}{3cm}}{\pgfpoint{2cm}{4cm}}
+\pgfmathresult
+\end{codeexample}
\end{command}
+\begin{command}{\pgfmathanglebetweenlines\marg{$p_1$}\marg{$q_1$}\marg{$p_2$}\marg{$q_2$}}
+ Returns the clockwise angle between a line going through $p_1$ and
+ $q_1$ and a line going through $p_2$ and $q_2$.
+
+\begin{codeexample}[]
+\pgfmathanglebetweenlines{\pgfpoint{1cm}{3cm}}{\pgfpoint{2cm}{4cm}}
+ {\pgfpoint{0cm}{1cm}}{\pgfpoint{1cm}{0cm}}
+\pgfmathresult
+\end{codeexample}
+\end{command}