Debian Codegraph @

texmf-dist/doc/latex/tkz-elements/TKZdoc-elements-classes-angle.tex

raw
1 \newpage
2 \section{Class \tkzClass{angle}}
3 \label{sec:class_angle}
4
5 The \tkzClass{angle} class is an experimental helper object used to represent
6 an angle defined by three points.
7 It is currently self-contained and does not interact with other classes.
8 Its main purpose is to provide a simple and direct interface for obtaining:
9
10 \begin{itemize}
11 \item the oriented angle in radians,
12 \item the normalised oriented angle in $[0, 2\pi]$
13 \item the interior (non-oriented) angle,
14 \item the measure of the interior angle in degrees.
15 \end{itemize}
16
17 An \tkzClass{angle} object is \emph{static}: all values are computed at creation
18 time and never updated.
19
20 \subsection{Creating an object}
21 \label{ssub:method_angle_new}
22
23 \begin{verbatim}
24 local alpha = angle(z.A, z.B, z.C) -- equivalent to angle:new(A,B,C)
25 local beta = angle(z.B, z.C, z.A)
26 local gamma = angle(z.C, z.A, z.B)
27 \end{verbatim}
28
29 The three arguments are:
30 \begin{itemize}
31 \item \tkzVar{ps}: the vertex of the angle,
32 \item \tkzVar{pa}: the first point defining the first ray,
33 \item \tkzVar{pb}: the second point defining the second ray.
34 \end{itemize}
35
36 \subsection{Attributes}
37
38 The following attributes are stored inside every \tkzClass{angle} object:
39
40 \vspace{1em}
41 \bgroup
42 \catcode`_=12
43 \small
44 \captionof{table}{Angle attributes.}\label{angle:attributes}
45 \begin{tabular}{lll}
46 \toprule
47 \textbf{Attribute} & \textbf{Meaning} & \texttt{Reference} \\
48 \midrule
49 \tkzAttr{angle}{ps} & Vertex of the angle & [\ref{par:attr_angle_ps}] \\
50 \tkzAttr{angle}{pa} & First defining point (ray $[ps\,pa]$) & [\ref{par:attr_angle_pa}] \\
51 \tkzAttr{angle}{pb} & Second defining point (ray $[ps\,pb]$) & [\ref{par:attr_angle_pb}] \\
52 \tkzAttr{angle}{raw} & Oriented angle (radians), may be negative & [\ref{par:attr_angle_raw}] \\
53 \tkzAttr{angle}{value} & Non-oriented angle in the range $[0,\pi]$ & [\ref{par:attr_angle_value}] \\
54 \tkzAttr{angle}{deg} & Interior angle in degrees & [\ref{par:attr_angle_deg}] \\
55
56 \bottomrule
57 \end{tabular}
58 \egroup
59
60 \paragraph{\tkzAttr{angle}{ps}}\label{par:attr_angle_ps}
61 The vertex (summit) of the angle.
62
63 \paragraph{\tkzAttr{angle}{pa}}\label{par:attr_angle_pa}
64 A point defining the first ray $[ps\,pa]$.
65
66 \paragraph{\tkzAttr{angle}{pb}}\label{par:attr_angle_pb}
67 A point defining the second ray $[ps\,pb]$.
68
69 \paragraph{\tkzAttr{angle}{raw}}\label{par:attr_angle_raw}
70 The oriented angle in radians as returned by \texttt{get\_angle\_(ps,pa,pb)}; it may be negative.
71
72 \paragraph{\tkzAttr{angle}{norm}}\label{par:attr_angle_norm}
73 The oriented angle normalised to the interval $[0,2\pi)$.
74
75 \paragraph{\tkzAttr{angle}{value}}
76 \label{par:attr_angle_value}
77 Returns the interior (non-oriented) angle in the range $[0,\pi]$:
78
79 \texttt{Example: }
80 \begin{tkzexample}[latex=.45\textwidth]
81 \directlua{%
82 init_elements()
83 z.O = point(0, 1)
84 z.T = point(2, 2)
85 C.OT = circle(z.O, z.T)
86 z.M = C.OT:point(.13)
87 A.OTM = angle(z.O, z.T, z.M)
88 tkzA = A.OTM.value}
89 \begin{center}
90 \begin{tikzpicture}
91 \tkzGetNodes
92 \tkzDrawLines(O,T O,M)
93 \tkzDrawCircle(O,T)
94 \tkzDrawPoints(O,T,M)
95 \tkzLabelPoints(O,T,M)
96 \tkzMarkAngle(T,O,M)
97 \tkzLabelAngle[pos=1.5](T,O,M){%
98 \tkzPN[3]{\tkzUseLua{tkzA}}}
99 \end{tikzpicture}
100 \end{center}
101 \end{tkzexample}
102
103
104 \paragraph{\tkzMeth{angle}{deg}}
105 \label{par:attr_angle_deg}
106 Returns an interior angle in degrees.
107
108 \texttt{Example: }
109
110 \begin{tkzexample}[latex=.35\textwidth]
111 \directlua{
112 init_elements()
113 z.A = point(0,0)
114 z.B = point(3,0)
115 z.C = point(1,2)
116 A.alpha = angle(z.B, z.A, z.C)
117 tex.print("Angle at A = "..A.alpha.deg.." degrees")
118 }
119 \begin{center}
120 \begin{tikzpicture}
121 \tkzGetNodes
122 \tkzDrawPolygon(A,B,C)
123 \tkzDrawPoints(A,B,C)
124 \tkzLabelPoints(A,B)
125 \tkzLabelPoints[above](C)
126 \end{tikzpicture}
127 \end{center}
128 \end{tkzexample}
129
130 Also possible:
131
132 \begin{verbatim}
133 T.ABC = triangle(z.A, z.B, z.C)
134 local val = T.ABC.alpha_.deg
135 \end{verbatim}
136
137 All values are numerical scalars and remain fixed once the object is created.
138
139 \texttt{Example: }
140
141 \begin{tkzexample}[latex=.5\textwidth]
142 \directlua{
143 init_elements()
144 z.A = point(0, 0)
145 z.C = point(3, 0)
146 z.B = point(3, 2)
147 T.ABC = triangle(z.A, z.B, z.C)
148 A.A = T.ABC.alpha_
149 A.B = T.ABC.beta_
150 T.C = T.ABC.gamma_
151 tex.print("A(value) = \\", A.A.value)
152 tex.print('\\\\')
153 tex.print("A(raw) = \\", A.A.raw)
154 tex.print('\\\\')
155 tex.print("A(deg) = \\", A.A.deg)}
156
157 \begin{center}
158 \begin{tikzpicture}
159 \tkzGetNodes
160 \tkzDrawPolygon(A,B,C)
161 \tkzDrawPoints(A,B,C)
162 \tkzLabelPoints(A,C)
163 \tkzLabelPoints[above](B)
164 \end{tikzpicture}
165 \end{center}
166 \end{tkzexample}
167
168
169 \subsection{Methods}
170
171 \vspace{1em}
172 \bgroup
173 \catcode`_=12
174 \small
175 \captionof{table}{angle methods.}\label{angle:methods}
176 \begin{tabular}{ll}
177 \toprule
178 \textbf{Methods} & \texttt{Reference} \\
179 \midrule
180 \textbf{Creation} & \\
181 \midrule
182 \tkzMeth{angle}{angle(ps, pa, pb)} & [\ref{ssub:method_angle_new}] \\
183 \midrule
184 \textbf{Accessors} & \\
185 \midrule
186 \tkzMeth{angle}{get()} & [\ref{ssub:method_angle_get}] \\
187 \midrule
188 \textbf{Tests} & \\
189 \midrule
190 \tkzMeth{angle}{is\_direct()} & [\ref{ssub:method_angle_is_direct}] \\
191
192 \bottomrule
193 \end{tabular}
194 \egroup
195
196
197 \subsubsection{\tkzMeth{angle}{get()}}
198 \label{ssub:method_angle_get}
199 Returns the three defining points:
200 \begin{verbatim}
201 local ps, pa, pb = alpha:get()
202 \end{verbatim}
203
204 \subsubsection{\tkzMeth{angle}{is\_direct()}}
205 \label{ssub:method_angle_is_direct}
206 Returns \verb|true| when the angle is positive (counterclockwise orientation).
207
208
209
210
211 \medskip
212 This class is \emph{experimental} and may evolve in future versions.