summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-12-04 03:01:04 +0000
committerNorbert Preining <norbert@preining.info>2023-12-04 03:01:04 +0000
commitdb0fe20663f1bcb3fcf87c3fb05a727420edd203 (patch)
treee5abdee7535ece54123168f0fa9a21fa0a627464 /macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex
parentde2c50ca7889fda13da11c1ccf6bdbd199ba8c2b (diff)
CTAN sync 202312040301
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex')
-rw-r--r--macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex145
1 files changed, 145 insertions, 0 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex b/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex
new file mode 100644
index 0000000000..8106fbd2e8
--- /dev/null
+++ b/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-transferts.tex
@@ -0,0 +1,145 @@
+
+\newpage
+\section{Transfers} % (fold)
+\label{sec:transfers}
+\subsection{Fom Lua to tkz-euclide or TikZ} % (fold)
+\label{sub:fom_lua_to_tkz_euclide_or_tikz}
+
+In this section, we'll look at how to transfer points, Booleans and numerical values.
+
+\subsubsection{Points transfer} % (fold)
+\label{ssub:points_transfer}
+We use an environment \tkzname{tkzelements} outside an environment \tkzname{tikzpicture} which allows us to carry out all the necessary calculations, then we launch the macro \Imacro{tkzGetNodes} which transforms the affixes of the table \tkzname{z} into \tkzname{Nodes}. It only remains to draw.
+
+Currently the drawing program is either \TIKZ\ or \pkg{tkz-euclide}. You have the possibility to use another package to trace but for that you have to create a macro similar to \tkzcname{tkzGetNodes}. Of course, this package must be able to store the points as does \TIKZ\ or \pkg{tkz-euclide}.
+
+\vspace*{1em}
+
+\begin{mybox}
+\begin{verbatim}
+\def\tkzGetNodes{\directlua{%
+ for K,V in pairs(z) do
+ local n,sd,ft
+ n = string.len(K)
+ if n >1 then
+ _,_,ft, sd = string.find( K , "(.+)(.)" )
+ if sd == "p" then K=ft.."'" end
+ end
+ tex.print("\\coordinate ("..K..") at ("..V.re..","..V.im..") ;\\\\")
+end}
+}\end{verbatim}
+\end{mybox}
+See the section In-depth Study \ref{sec:in_depth_study} for an explanation of the previous code.
+
+The environment \tkzNameEnv{tkzelements} allows to use the underscore |_| and the macro \tkzcname{tkzGetNodes} allows to obtain names of nodes containing \tkzname{prime}. (see the next example)
+
+\begin{minipage}{0.5\textwidth}
+\begin{tkzexample}[latex=0cm,small,code only]
+\begin{tkzelements}
+ scale = 1.2
+ z.o = point: new (0,0)
+ z.a_1 = point: new (2,1)
+ z.a_2 = point: new (1,2)
+ z.ap = z.a_1 + z.a_2
+\end{tkzelements}
+\begin{tikzpicture}
+ \tkzGetNodes
+ \tkzDrawSegments(o,a_1 o,a_2 o,a')
+ \tkzDrawSegments[red](a_1,a' a_2,a')
+ \tkzDrawPoints(a_1,a_2,a',o)
+ \tkzLabelPoints(o,a_1,a_2,a')
+\end{tikzpicture}
+\end{tkzexample}%
+\end{minipage}%
+\begin{minipage}{0.5\textwidth}
+\begin{tkzelements}
+scale = 1.2
+z.o = point: new (0,0)
+z.a_1 = point: new (2,1)
+z.a_2 = point: new (1,2)
+z.ap = z.a_1 + z.a_2
+\end{tkzelements}
+\begin{tikzpicture}
+\tkzGetNodes
+ \tkzDrawSegments(o,a_1 o,a_2 o,a')
+ \tkzDrawSegments[red](a_1,a' a_2,a')
+ \tkzDrawPoints(a_1,a_2,a',o)
+ \tkzLabelPoints(o,a_1,a_2,a')
+\end{tikzpicture}
+\end{minipage}%
+
+\newpage
+% subsection fom_lua_to_tkz_euclide_or_tikz (end)
+\subsubsection{Other transfers} % (fold)
+\label{ssub:other_transfers}
+
+Sometimes it's useful to transfer angle, length measurements or boolean. For this purpose, I have created the macro (see \ref{ssub:transfer_from_lua_to_tex})
+\IEmacro{tkzUseLua(value)}
+
+\begin{verbatim}
+\begin{tkzelements}
+ z.b = point: new (1,1)
+ z.a = point: new (4,2)
+ z.c = point: new (2,2)
+ z.d = point: new (5,2)
+ L.ab = line : new (z.a,z.b)
+ L.cd = line : new (z.c,z.d)
+ det = (z.b-z.a)^(z.d-z.c)
+ if det == 0 then bool = true
+ else bool = false
+ end
+ x = intersection (L.ab,L.cd)
+\end{tkzelements}
+
+The intersection of the two lines lies at
+ a point whose affix is:\tkzUseLua{x}
+
+\begin{tikzpicture}
+ \tkzGetNodes
+ \tkzDrawPoints(a,...,d)
+ \ifthenelse{\equal{\tkzUseLua{bool}}{true}}{
+ \tkzDrawSegments[red](a,b c,d)}{%
+ \tkzDrawSegments[blue](a,b c,d)}
+ \tkzLabelPoints(a,...,d)
+\end{tikzpicture}
+\end{verbatim}
+
+ \begin{tkzelements}
+ z.b = point: new (1,1)
+ z.a = point: new (4,2)
+ z.c = point: new (2,2)
+ z.d = point: new (5,1)
+ L.ab = line : new (z.a,z.b)
+ L.cd = line : new (z.c,z.d)
+ det = (z.b-z.a)^(z.d-z.c)
+ if det == 0 then bool = true
+ else bool = false
+ end
+ x = intersection (L.ab,L.cd)
+ \end{tkzelements}
+
+ The intersection of the two lines lies at
+ a point whose affix is: \tkzUseLua{x}
+
+\vspace{1em}
+\hspace{\fill}
+\begin{tikzpicture}
+ \tkzGetNodes
+ \tkzInit[xmin =-1,ymin=-1,xmax=6,ymax=3]
+ \tkzGrid\tkzAxeX\tkzAxeY
+ \tkzDrawPoints(a,...,d)
+ \ifthenelse{\equal{\tkzUseLua{bool}}{true}}{
+ \tkzDrawSegments[red](a,b c,d)}{%
+ \tkzDrawSegments[blue](a,b c,d)}
+ \tkzLabelPoints(a,...,d)
+ \end{tikzpicture}
+ \hspace{\fill}
+
+
+
+% subsubsection other_transfers (end)
+% subsubsection points_transfer (end)
+
+% section transferts (end)
+
+\endinput \ No newline at end of file