summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex')
-rw-r--r--macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex230
1 files changed, 155 insertions, 75 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex b/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex
index d837d4a826..900bdef5e6 100644
--- a/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex
+++ b/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-presentation.tex
@@ -1,44 +1,84 @@
+\newpage
\section{Presentation}
-I created \pkg{tkz-euclide} to give math teachers and students a tool to draw Euclidean geometry figures. This package was created as an interface based on \pkg{TikZ}, itself based on \TEX{}. The only problem encountered with this method is, in complicated cases, the lack of precision of the calculations made by \TEX{}.
-
-To remedy this lack of precision, I first introduced the package \pkg{fp}, then the package \pkg{xfp}. Lately, with the arrival of lua\LATEX{}, I have been able to add a \tkzname{Lua} option whose goal was to perform some calculations with \tkzname{Lua}. It is much easier to program mathematics with \tkzname{Lua} than with \TEX{} so having prepared \pkg{tkz-euclide}, by separating the first parts of definitions and calculations from the drawing part, the idea of carrying out the first parts with only \tkzname{Lua} was necessary.
-
-I had received some examples of programming with \tkzname{Lua} from Nicolas Kisselhoff and I took many of his ideas.
-
-The essential principles of figure construction with \tkzname{tkz-euclide} are kept: definition, calculations, tracings, labels as well as the step-by-step programmation, corresponding to a construction with a ruler and a compass.
-
-Then, I read an article by Roberto Giacomelli on object programming based on the \tkzname{Lua} and \TIKZ\ tools. This was my second source of inspiration. Not only could the programming be done step-by-step, but the introduction of objects allowed the link between the code and the geometry. The code becomes more readable, the code is more explicit and better structured but it is less concise. Finally, as the problem of precision disappeared, I came to appreciate more and more what I was getting with object programming. So I've tried to develop this programming as much as possible.
-
-In order to organize and maintain all the functions and methods, I chose to use classes of objects whose main ones are \tkzname{point}, \tkzname{line}, \tkzname{triangle}, \tkzname{circle} and \tkzname{ellipse}.
-
\subsection{With Lua} % (fold)
\label{sub:with_lua}
The purpose of tkz-elements is simply to calculate dimensions and define points. This is done in Lua. You can think of tkz-elements as a kernel that will be used either by tkz-euclide or by TikZ, see MetaPost.
Definitions and calculations are done inside the environment \tkzNameEnv{tkzelements}, this environment is based on \tkzNameEnv{luacode}.
-To improve precision, if it's necessary to modify the scale of your figure, it's best to change the "scale" variable at the start of the code placed in environment \tkzNameEnv{tkzelements}.
-Then we need to be able to transfer the coordinates of the points to a package that can use them, in this case tkz-euclide or TikZ.
+
+\begin{minipage}[t]{.52\textwidth}\vspace{0pt}%
+ The key points are:
+ \begin{itemize}
+ \item the source file must be \tkzEHand\ {\color{red}\uline{ \color{black}utf8}} encoded;
+ \item compilation is done with \tkzEHand\ {\color{red}\uline{ \color{black}Lua\LATEX{}}};
+ \item you need to load \tkzimp{\TIKZ}{} ou \tkzimp{tkz-euclide} and \tkzimp{tkz-elements};
+ \item definitions and calculations are performed in an orthonormal sytem of reference, using Lua, and are carried out in an environment of \tkzimp{tkzelements}.
+ \end{itemize}
+
+ To the right, see the minimum template.
+
+The code is divided into two parts, which are two environments \tkzNameEnv{tkzelements} and \tkzNameEnv{tikzpicture}. In the first environment, you place your Lua code, and in the second, tkz-euclide commands.
+
+\vspace*{4.1 cm}%
+\end{minipage}\hspace*{\fill}
+\begin{minipage}[t]{.45\textwidth}\vspace{0pt}%
+\begin{mybox}
+\begin{verbatim}
+% !TEX TS-program = lualatex
+% Created by Alain Matthes
+\documentclass{standalone}
+\usepackage{tkz-euclide}
+% or simply TikZ
+\usepackage{tkz-elements}
+begin{document}
+
+\begin{tkzelements}
+ scale = 1
+% definition of some points
+z.A = point : new ( , )
+z.B = point : new ( , )
+
+ ...code...
+\end{tkzelements}
+
+\begin{tikzpicture}
+% point transfer to Nodes
+\tkzGetNodes
+
+\end{tikzpicture}
+\end{document}
+\end{verbatim}
+\end{mybox}
+\end{minipage}
% subsection with_lua (end)
-\subsection{The main process : from tkz-elements (lua) to tkz-euclide (TikZ) with Lua\LaTeX.} % (fold)
+\subsection{The main process} % (fold)
\label{sub:the_main_process}
+\tikzset{concept/.append style={fill={none}}}
+\tikzset{root concept/.style= {minimum size=3cm,text width=2.8cm}}%
+\tikzset{level 1 concept/.append style={minimum size=4cm, font=\large, text width=3cm}}%
+\begin{tikzpicture}
+ \path[mindmap,concept color=orange,text=black]
+ node[concept] {Transfers\\\textcolor{orange}{ \textbackslash{tkzGetNodes}}}
+ child[concept color=red,grow=right] {
+ node[concept] {Drawings\\\textcolor{red}{tkz-euclide}\\\textcolor{red}{\TIKZ}} }
+ child[concept color=purple,grow=left] {
+ node[concept] {Definitions\\Calculations\\\textcolor{purple}{tkz-elements}} };
+\end{tikzpicture}
When all the points necessary for the drawing are obtained, they must be transformed into \tkzname{nodes} so that \pkg{TikZ} or \pkg{tkz-euclide} can draw the figure. This is done through the macro \tkzcname{tkzGetNodes}. This macro browse all the elements of the table |z| using the key (in fact the name of the point) and retrieves the values associated with it, i.e. the coordinates of the point (node).
-
-A point $A$ is defined and stored in tkz-elements as follows:
-|z.A| is an element of a table |z| which contains the coordinates of $A$ in the form of a complex number (very useful for calculations). Then a macro, \tkzcname{tkzGetNodes}, transforms all elements of table |z| into nodes usable by tkz-euclide or TikZ. For another package, you'll need to adapt \tkzcname{tkzGetNodes}.
-
% subsection the_main_process (end)
\newpage
\subsection{Complete example: Pappus circle} % (fold)
\label{sub:the_figure_pappus_circle}
-The figure:
+\subsubsection{The figure}
\begin{tkzelements}
+ scale = 1.2
z.A = point: new (0 , 0)
z.B = point: new (10 , 0)
L.AB = line: new ( z.A, z.B)
@@ -61,8 +101,7 @@ The figure:
z.P_0 = intersection (C.PC,C.AB)
z.P_1 = intersection (C.PC,C.AC)
_,z.P_2 = intersection (C.QA,C.CB)
- T = triangle: new ( z.P_0, z.P_1, z.P_2)
- z.O_3 = T.circumcenter
+ z.O_3 = triangle: new ( z.P_0, z.P_1, z.P_2).circumcenter
\end{tkzelements}
\hspace*{\fill}
\begin{tikzpicture}
@@ -90,30 +129,26 @@ The figure:
\begin{document}
\begin{tkzelements}
- z.A = point: new (0 , 0)
- z.B = point: new (10 , 0)
- L.AB = line: new ( z.A, z.B)
- z.C = L.AB: gold_ratio ()
- L.AC = line: new ( z.A, z.C)
- L.CB = line: new ( z.C, z.B)
- L.AB = line: new ( z.A, z.B)
- z.O_0 = L.AB.mid
- z.O_1 = L.AC.mid
- z.O_2 = L.CB.mid
- C.AB = circle: new ( z.O_0, z.B)
- C.AC = circle: new ( z.O_1, z.C)
- C.CB = circle: new ( z.O_2, z.B)
- z.P = C.CB.north
- z.Q = C.AC.north
- z.O = C.AB.south
- z.c = z.C : north (2)
- C.PC = circle: new ( z.P, z.C)
- C.QA = circle: new ( z.Q, z.A)
- z.P_0 = intersection (C.PC,C.AB)
- z.P_1 = intersection (C.PC,C.AC)
- _,z.P_2 = intersection (C.QA,C.CB)
- T = triangle: new ( z.P_0, z.P_1, z.P_2)
- z.O_3 = T.circumcenter
+z.A = point: new (0 , 0)
+z.B = point: new (10 , 0) creation of two fixed points $A$ and $B$
+L.AB = line: new ( z.A, z.B)
+z.C = L.AB: gold_ratio () use of a method linked to "line"
+z.O_0 = line: new ( z.A, z.B).mid midpoint of segment with an attribute of "line"
+z.O_1 = line: new ( z.A, z.C).mid objects are not stored and cannot be reused.
+z.O_2 = line: new ( z.C, z.B).mid
+C.AB = circle: new ( z.O_0, z.B) new object "circle" stored and reused
+C.AC = circle: new ( z.O_1, z.C)
+C.CB = circle: new ( z.O_2, z.B)
+z.P = C.CB.north "north" atrributes of a circle
+z.Q = C.AC.north
+z.O = C.AB.south
+z.c = z.C : north (2) "north" method of a point (needs a parameter)
+C.PC = circle: new ( z.P, z.C)
+C.QA = circle: new ( z.Q, z.A)
+z.P_0 = intersection (C.PC,C.AB) search for intersections of two circles.
+z.P_1 = intersection (C.PC,C.AC) idem
+_,z.P_2 = intersection (C.QA,C.CB) idem
+z.O_3 = triangle: new ( z.P_0, z.P_1, z.P_2).circumcenter attribute of "triangle"
\end{tkzelements}
\begin{tikzpicture}
@@ -131,37 +166,82 @@ The figure:
\end{tkzexample}
% subsubsection the_code (end)
-\subsubsection{Some explanations} % (fold)
-\label{ssub:some_explanations}
-
-Half of the code concerns the direct creation of objects (|point: new |, |circle: new | etc.)
-
-Then points are obtained using object attributes like |L.AB.mid| which determines the middle of the segment $[AB]$ or |C.AB.south| which allows to obtain the south pole of the circle with center $A$ passing through $B$.
-
-About the naming of objects, see the section \ref{sec:writing_convention}
-
-\begin{itemize}
- \item Lines 8 and 9 create two fixed points $A$ and $B$.
-
- \item Line 10 these two points are used to create the line.
-
- \item Line 11 the gold method creates a point $C$ which divides the segment $[AB]$ according to the golden ratio.
-
- \item Lines 12, 13 and 14 creation of 3 new lines.
-
-\item Lines 15, 16 and 17 creation of 3 points: the midpoints of the previous segments. These points are predefined and it is enough to use the attributes of the lines. Another possibility is to use the triangle T.ABC with the method : |medial_tr|
-
-\item Lines 18, 19 et 20 creation of three circles.
-
-\item Line 21 creation of the south pole $P$ of the circle of center C passing through B. It is also a predefined point and we still use an attribute.
+\subsection{Another example with comments: South Pole} % (fold)
+\label{sub:south_pole}
-\item Lines 22 and 23 we create two new poles: north and south for two other circles.
+Here's another example with comments
-\item Lines 24 and 25 creation of two circles.
+\begin{verbatim}
+% !TEX TS-program = lualatex
+\documentclass{standalone}
+\usepackage{tkz-euclide,tkz-elements}
+\begin{document}
+\begin{tkzelements} we create environment tkzelements
+ z.A = point: new (2 , 4) three fixed points are used
+ z.B = point: new (0 , 0)
+ z.C = point: new (8 , 0)
+ T.ABC = triangle: new (z.A,z.B,z.C) we create a new triangle object
+ C.ins = T.ABC: in_circle () we get the incircle of this triangle
+ z.I = C.ins.center center is an attribute of the circle
+ z.T = C.ins.through through is also an attribute
+ -- z.I,z.T = get_points (C.ins) get_points is a shortcut
+ C.cir = T.ABC : circum_circle () we get the circumscribed circle
+ z.W = C.cir.center we get the center of this circle
+ z.O = C.cir.south now we get the south pole of this circle
+ L.AO = line: new (z.A,z.O) we create an object "line"
+ L.BC = T.ABC.bc we get the line (BC)
+ z.I_A = intersection (L.AO,L.BC) we search the intersection of the last lines
+\end{tkzelements}
+\end{verbatim}
+\begin{tkzelements}
+ scale = 1.2
+ z.A = point: new (2 , 4)
+ z.B = point: new (0 , 0)
+ z.C = point: new (8 , 0)
+ T.ABC = triangle: new (z.A,z.B,z.C)
+ C.ins = T.ABC: in_circle ()
+ z.I = C.ins.center
+ z.T = C.ins.through
+-- z.I,z.T = get_points (C.ins)
+ C.cir = T.ABC : circum_circle ()
+ z.W = C.cir.center
+ z.O = C.cir.south
+ L.AO = line: new (z.A,z.O)
+ L.BC = T.ABC.bc
+ z.I_A = intersection (L.AO,L.BC)
+\end{tkzelements}
-\item Lines 26 and 27 search for intersections of two circles.
+\hspace*{\fill}
+\begin{tikzpicture}
+\tkzGetNodes
+\tkzDrawCircles(W,A I,T)
+\tkzDrawArc(O,C)(B)
+\tkzDrawPolygon(A,B,C)
+\tkzDrawSegments[new](A,O B,O C,O)
+\tkzDrawLine(B,I)
+\tkzDrawPoints(A,B,C,I,I_A,W,O)
+\tkzFillAngles[green!20,opacity=.3](A,O,B A,C,B)
+\tkzFillAngles[teal!20,opacity=.3](O,B,C B,C,O B,A,O O,A,C)
+\tkzLabelPoints(I,I_A,W,B,C,O)
+\tkzLabelPoints[above](A)
+\end{tikzpicture}
+\hspace*{\fill}
-\item Lines 28 and 29 we use a triangle to search for its circum center.
-\end{itemize}
-% subsubsection some_explanations (end)
+Here's the tikzpicture environment to obtain the drawing:
+\begin{verbatim}
+\begin{tikzpicture}
+\tkzGetNodes
+\tkzDrawCircles(W,A I,T)
+\tkzDrawArc(O,C)(B)
+\tkzDrawPolygon(A,B,C)
+\tkzDrawSegments[new](A,O B,O C,O)
+\tkzDrawLine(B,I)
+\tkzDrawPoints(A,B,C,I,I_A,W,O)
+\tkzFillAngles[green!20,opacity=.3](A,O,B A,C,B)
+\tkzFillAngles[teal!20,opacity=.3](O,B,C B,C,O B,A,O O,A,C)
+\tkzLabelPoints(I,I_A,W,B,C,O)
+\tkzLabelPoints[above](A)
+\end{tikzpicture}
+\end{verbatim}
+% subsection south_pole (end)
\endinput \ No newline at end of file