summaryrefslogtreecommitdiff
path: root/graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex')
-rw-r--r--graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex52
1 files changed, 29 insertions, 23 deletions
diff --git a/graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex b/graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex
index ace6c5d882..b276178cd8 100644
--- a/graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex
+++ b/graphics/pgf/base/doc/text-en/pgfmanual-en-tutorial-Euclid.tex
@@ -36,6 +36,7 @@ found on his website at Clark University.}
\bigskip
\noindent
\begin{tikzpicture}[thick,help lines/.style={thin,draw=black!50}]
+ \pgfmathsetseed{1}
\def\A{\textcolor{input}{$A$}}
\def\B{\textcolor{input}{$B$}}
\def\C{\textcolor{output}{$C$}}
@@ -226,7 +227,7 @@ it easy to access the $x$- and $y$-coordinates of the coordinates.
Euclid would write the following:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -267,7 +268,7 @@ we can also use a let operation: Instead of writing |\p1 = ...|, we write
``point''). The assignment of a number should be followed by a number in curly
braces.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -288,7 +289,7 @@ have replaced |\n2| in the example by |\n1| and it would still work. Indeed,
the digits following these macros are just normal \TeX\ parameters. We could
also use a longer name, but then we have to use curly braces:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -314,7 +315,7 @@ and outer separations to be set to zero. Then it sets the shape of the node to
parameter given to |circle through|. This radius is computed in essentially the
same way as above.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{through}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -329,8 +330,8 @@ same way as above.
Euclid can now draw the line and the circles. The final problem is to compute
the intersection of the two circles. This computation is a bit involved if you
-want to do it ``by hand''. Fortunately, the intersection library allows us to
-compute the intersection of arbitrary paths.
+want to do it ``by hand''. Fortunately, the |intersections| library allows us
+to compute the intersection of arbitrary paths.
The idea is simple: First, you ``name'' two paths using the |name path| option.
Then, at some later point, you can use the option |name intersections|, which
@@ -339,7 +340,7 @@ intersections of the paths. Euclid assigns the names |D| and |E| to the paths
of the two circles (which happen to be the same names as the nodes themselves,
but nodes and their paths live in different ``namespaces'').
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{intersections,through}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -364,7 +365,7 @@ options for them. This creates more compact code. Although Euclid does not need
it for the current picture, it is just a small step to computing the bisection
of the line $AB$:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{intersections,through}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -389,7 +390,7 @@ Back to Euclid's code. He introduces a few macros to make life simpler, like a
|\A| macro for typesetting a blue $A$. He also uses the |background| layer for
drawing the triangle behind everything at the end.
%
-\begin{codeexample}[]
+\begin{codeexample}[pre={\pgfmathsetseed{1}},preamble={\usetikzlibrary{backgrounds,calc,intersections,through}}]
\begin{tikzpicture}[thick,help lines/.style={thin,draw=black!50}]
\def\A{\textcolor{input}{$A$}} \def\B{\textcolor{input}{$B$}}
\def\C{\textcolor{output}{$C$}} \def\D{$D$}
@@ -434,6 +435,7 @@ The second proposition in the Elements is the following:
\bigskip\noindent
\begin{tikzpicture}[thick,help lines/.style={thin,draw=black!50}]
+ \pgfmathsetseed{1}
\def\A{\textcolor{orange}{$A$}} \def\B{\textcolor{input}{$B$}}
\def\C{\textcolor{input}{$C$}} \def\D{$D$}
\def\E{$E$} \def\F{$F$}
@@ -524,7 +526,7 @@ the |xcolor| syntax for mixing colors.
Here is the computation of the point in the middle of the line $AB$:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -543,7 +545,7 @@ a partway computation can be prefixed by an angle. Then the partway point is
computed normally (as if no angle were given), but the resulting point is
rotated by this angle around the first point.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -558,7 +560,7 @@ rotated by this angle around the first point.
Finally, it is not necessary to explicitly name the point $X$. Rather, again
like in the |xcolor| package, it is possible to chain partway modifiers:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);
@@ -577,7 +579,7 @@ which is easy enough to do using the |circle through| option. Extending the
lines $DA$ and $DB$ can be done using partway calculations, but this time with
a part value outside the range $[0,1]$:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{calc,through}}]
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (0.75,0.25);
@@ -603,9 +605,10 @@ straight line to \meta{q}.
We know that the point $G$ is on the way from $B$ to $F$. The distance is given
by the radius of the circle~$H$. Here is the code for computing $H$:
%
-{\tikzexternaldisable
-\begin{codeexample}[pre={
-\begin{tikzpicture}
+{\ifpgfmanualexternalize\tikzexternaldisable\fi
+\begin{codeexample}[
+ preamble={\usetikzlibrary{calc,through}},
+ pre={\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (0.75,0.25);
\coordinate [label=above:$C$] (C) at (1,1.5);
@@ -613,8 +616,9 @@ by the radius of the circle~$H$. Here is the code for computing $H$:
\coordinate [label=above:$D$] (D) at
($ (A) ! .5 ! (B) ! {sin(60)*2} ! 90:(B) $) {};
\draw (D) -- ($ (D) ! 3.5 ! (B) $) coordinate [label=below:$F$] (F);
- \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E);
-},post={\end{tikzpicture}}]
+ \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E);},
+ post={\end{tikzpicture}},
+]
\node (H) [label=135:$H$,draw,circle through=(C)] at (B) {};
\path let \p1 = ($ (B) - (C) $) in
coordinate [label=left:$G$] (G) at ($ (B) ! veclen(\x1,\y1) ! (F) $);
@@ -625,8 +629,9 @@ However, there is a simpler way: We can simply name the path of the circle and
of the line in question and then use |name intersections| to compute the
intersections.
%
-\begin{codeexample}[pre={
-\begin{tikzpicture}
+\begin{codeexample}[
+ preamble={\usetikzlibrary{calc,intersections,through}},
+ pre={\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (0.75,0.25);
\coordinate [label=above:$C$] (C) at (1,1.5);
@@ -634,8 +639,9 @@ intersections.
\coordinate [label=above:$D$] (D) at
($ (A) ! .5 ! (B) ! {sin(60)*2} ! 90:(B) $) {};
\draw (D) -- ($ (D) ! 3.5 ! (B) $) coordinate [label=below:$F$] (F);
- \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E);
-},post={\end{tikzpicture}}]
+ \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E);},
+ post={\end{tikzpicture}},
+]
\node (H) [name path=H,label=135:$H$,draw,circle through=(C)] at (B) {};
\path [name path=B--F] (B) -- (F);
\path [name intersections={of=H and B--F,by={[label=left:$G$]G}}];
@@ -646,7 +652,7 @@ intersections.
\subsubsection{The Complete Code}
-\begin{codeexample}[]
+\begin{codeexample}[pre={\pgfmathsetseed{1}},preamble={\usetikzlibrary{calc,intersections,through}}]
\begin{tikzpicture}[thick,help lines/.style={thin,draw=black!50}]
\def\A{\textcolor{orange}{$A$}} \def\B{\textcolor{input}{$B$}}
\def\C{\textcolor{input}{$C$}} \def\D{$D$}