summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-classes.tex
blob: 53bdb06558c0ed6624831d69516f97a7d4d7eeac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
\newpage
\section{Classes and objects} % (fold)
\label{sec:classes_and_objects}

\subsection{Objects} % (fold)
\label{sub:objects}
The object types currently defined and used are \tkzNameObj{point}, \tkzNameObj{line}, \tkzNameObj{circle}, \tkzNameObj{triangle} and \tkzNameObj{ellipse}. 

They can be created directly using the method \Imeth{obj}{new} and, with the exception of the \Iclass{class}{point} class, by giving points. Objects can also be obtained by applying methods to other objects. For example, |T.ABC : circum_circle ()| creates an object \tkzNameObj{circle}. Some object attributes are also objects, such as |T.ABC.bc| which creates the object \tkzNameObj{line}, a straight line passing through the last two points defining the triangle.

Attributes are accessed using the classic method, so |T.pc| gives the third of the triangle and |C.center| gives the center of the circle, but I've added a |get_points| function that returns the points of an object. This applies to straight lines (pa and pc), triangles (pa, pb and pc) and circles (center and through).

Example: |z.O,z.T = get_points (C)| recovers the center and a point of the circle.
% subsection objects (end)

\subsection{tkz\_elements\_point.lua: complex numbers library} % (fold)
\label{sub:complex_numbers}

Unless you want to create your own functions, you won't need to know and use complex numbers. However, in some cases it may be useful to implement some of their properties.

|za =  point (1,2 )| and \ |zb = point (1,-1)| define two affixes which are |za = 1+2i| and 

 |zb = 1-i|. The notation may come as a surprise, as I used the term "point". The aim here was not to create a complete library on complex numbers, but to be able to use their main properties in relation to points. I didn't want to have two different levels, and since a unique connection can be established between the points of the plane and the complexes, I decided not to mention the complex numbers! But they are there.

The above entries must not be confused with the following ones : 

|z.a = point : new (1,2) | and |z.b = point : new (1,-1) |. 

Here we define two "point" objects that are in the form of an affix in the |z| table.
|z.a = za| only if |scale = 1|  and |z.a| creates a point named |a|. This point is an object and you can use its attributes, as well as methods referring to points.

That said, |z.a| is indeed an affix, and it's possible to use the methods and metamethods associated with complex numbers. 

\bgroup
\catcode`_=12  
\small
\begin{minipage}{\textwidth}
\begin{center}
%\caption{Metamethods and methods about point class.}
\begin{tabular}{ll}   
  \toprule   
  \textbf{Metamethods} & \textbf{Application} \\     
  \midrule      
__add(z1,z2)   & |z.a + z.b| \tkzar affix \\
__sub(z1,z2)   & |z.a - z.b| \tkzar affix\\
__unm(z)   & |- z.a| \tkzar affix\\
__mul(z1,z2)   & |z.a * z.b|  \tkzar  affix\\
__concat(z1,z2)& |z.a .. z.b| \tkzar dot product  = real number \footnote{If $O$ is the origin of the complex plan, then we get the dot product of the vectors $\overrightarrow{Oa}$ and $\overrightarrow{Ob}$} \\
__pow(z1,z2)   & |z.a ^ z.b| \tkzar determinant = real number\\
__div(z1,z2)   & |z.a / z.b|   \tkzar   affix     \\
__tostring(z)  & tex.print(tostring(z)) \tkzar displays the affix   \\
__tonumber(z)  & tonumber(z) \tkzar affix or nil\\
__eq(z1,z2)    &  eq (z.a,z.b) \tkzar boolean\\
\bottomrule
\end{tabular}
\end{center}
\end{minipage}
\egroup

\bgroup
\catcode`_=12  
\small
\begin{center}
%\caption{Metamethods and methods about point class.}
\begin{tabular}{ll}   
  \toprule    
\textbf{Methods} & \textbf{Application}\\     
\midrule     
\Imeth{point}{conj(z)}& |z.a : conj()|  \tkzar affix (conjugate) \\
\Imeth{point}{mod(z)}& |z.a : mod()|   \tkzar real number = modulus  |z.a|\\
\Imeth{point}{abs (z)}& |z.a : abs()|   \tkzar real number = modulus \\
\Imeth{point}{norm (z)} & |z.a : norm()|  \tkzar norm  (real number  ) \\
\Imeth{point}{arg (z)}& |z.a : arg()|   \tkzar real number = argument of z.a (in rad)\\
\Imeth{point}{get(z)}& |z.a : get()|   \tkzar re and im (two real numbers  )  \\
\Imeth{point}{sqrt(z)}& |z.a : sqrt()|  \tkzar affix  \\
\bottomrule
\end{tabular}
\end{center}
\egroup

The class is provided with two specific metamethods.

\begin{itemize}
   \item Since concatenation makes little sense here, the operation associated with |..| is the scalar or dot product. If |z1 = a+ib| and |z2 = c+id| then 
   
   |z1..z2 = (a+ib) .. (c+id) = (a+ib) (c-id) = ac+bd + i(bc-ad) |  
   
   There's also a mathematical function, |dot_product|, which takes three arguments. See example \ref{ssub:dot_or_scalar_product}

   
   \item With the same idea, the operation associated with |^| is the determinant i.e.
   
   |z1 ^ z2 = (a+ib) ^ (c+id) = ad - bc  From  (a-ib) (c+id) = ac+bd + i(ad - bc)| we take the imaginary part.
   
\end{itemize}
% subsection complex_numbers (end)
% section classes_and_objects (end)
\endinput