Debian Codegraph @

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

raw
1 \newpage
2 \section{Class \tkzClass{square}}
3 The variable \tkzVar{square}{S} holds a table used to store squares. It is optional, and you are free to choose the variable name. However, using \code{S} is a recommended convention for clarity and consistency. If you use a custom variable (e.g., Squares), you must initialize it manually. The \code{init\_elements()} function reinitializes the \code{S} table if used.
4
5
6 \subsection{Creating a square}
7 \label{sub:creating_a_square}
8
9 The \tkzClass{square} class constructs a square from two adjacent vertices. The order of the points defines the orientation.
10
11
12 \medskip
13 The result is stored in \tkzVar{square}{S}.
14
15 \begin{mybox}
16 \begin{verbatim}
17 S.ABCD = square:new(z.A, z.B)
18 \end{verbatim}
19 \end{mybox}
20
21 \textbf{Short form.}
22
23 The short form \code{square(z.A, z.B)} is equivalent:
24
25 \begin{mybox}
26 \begin{verbatim}
27 S.ABCD = square(z.A, z.B)
28 \end{verbatim}
29 \end{mybox}
30
31 \subsection{Square attributes}
32 \label{sub:square_attributes}
33 Points are created in the direct direction. A test is performed to check whether the points form a square. Otherwise, compilation is blocked."
34 \begin{mybox}
35 Creation | S.AB = square(z.A,z.B,z.C,z.D)|
36 \end{mybox}
37
38
39 \bgroup
40 \catcode`_=12
41 \small
42 \captionof{table}{Square attributes.}\label{square:attributes}
43 \begin{tabular}{lll}
44 \toprule
45 \textbf{Attributes} & \textbf{Application} & \\
46 \midrule
47 \tkzAttr{square}{pa} & |z.A = S.AB.pa| & \\
48 \tkzAttr{square}{pb} & |z.B = S.AB.pb| & \\
49 \tkzAttr{square}{pc} & |z.C = S.AB.pc| & \\
50 \tkzAttr{square}{pd} & |z.D = S.AB.pd| & \\
51 \tkzAttr{square}{type} & |S.AB.type= 'square'| & \\
52 \tkzAttr{square}{side} & |s = S.AB.center| & s = length of side \\
53 \tkzAttr{square}{center} & |z.I = S.AB.center| & center of the square \\
54 \tkzAttr{square}{circumradius} & |S.AB.circumradius| & radius of the circumscribed circle \\
55 \tkzAttr{square}{inradius} & |S.AB.inxradius| & radius of the inscribed circle (apothem) \\
56 \tkzAttr{square}{apothem\_foot} & |S.AB.proj| & projection of the center on one side \\
57 \tkzAttr{square}{ab} & |S.AB.ab| & line passing through two vertices \\
58 \tkzAttr{square}{ac} & |S.AB.ca| & idem. \\
59 \tkzAttr{square}{ad} & |S.AB.ad| & idem. \\
60 \tkzAttr{square}{bc} & |S.AB.bc| & idem. \\
61 \tkzAttr{square}{bd} & |S.AB.bd| & idem. \\
62 \tkzAttr{square}{cd} & |S.AB.cd| & idem. \\
63 \bottomrule %
64 \end{tabular}
65 \egroup
66
67
68
69
70
71 \subsubsection{Example: square attributes }
72 \label{ssub:example_square_attributes}
73
74 \begin{minipage}{.5\textwidth}
75 \begin{verbatim}
76 \directlua{
77 init_elements()
78 z.A = point(0, 0)
79 z.B = point(4, 0)
80 z.C = point(4, 4)
81 z.D = point(0, 4)
82 S.new = square(z.A, z.B, z.C, z.D)
83 z.I = S.new.center
84 z.H = S.new.proj}
85 \begin{tikzpicture}
86 \tkzGetNodes
87 \tkzDrawCircles[orange](I,A I,H)
88 \tkzDrawPolygon(A,B,C,D)
89 \tkzDrawPoints(A,B,C,D,H,I)
90 \tkzLabelPoints(A,B,H,I)
91 \tkzLabelPoints[above](C,D)
92 \tkzDrawSegments(I,B I,H)
93 \tkzLabelSegment[sloped](I,B){%
94 \pmpn{\tkzUseLua{S.new.circumradius}}}
95 \tkzLabelSegment[sloped](I,H){%
96 \pmpn{\tkzUseLua{S.new.inradius}}}
97 \tkzLabelSegment[sloped](D,C){%
98 \pmpn{\tkzUseLua{S.new.side}}}
99 \end{tikzpicture}
100 \end{verbatim}
101 \end{minipage}
102 \begin{minipage}{.5\textwidth}
103 \directlua{
104 init_elements()
105 z.A = point(0, 0)
106 z.B = point(4, 0)
107 z.C = point(4, 4)
108 z.D = point(0, 4)
109 S.new = square(z.A, z.B, z.C, z.D)
110 z.I = S.new.center
111 z.H = S.new.proj}
112
113 \begin{center}
114 \begin{tikzpicture}
115 \tkzGetNodes
116 \tkzDrawCircles[orange](I,A I,H)
117 \tkzDrawPolygon(A,B,C,D)
118 \tkzDrawPoints(A,B,C,D,H,I)
119 \tkzLabelPoints(A,B,H,I)
120 \tkzLabelPoints[above](C,D)
121 \tkzDrawSegments(I,B I,H)
122 \tkzLabelSegment[sloped](I,B){\pmpn{\tkzUseLua{S.new.circumradius}}}
123 \tkzLabelSegment[sloped](I,H){\pmpn{\tkzUseLua{S.new.inradius}}}
124 \tkzLabelSegment[sloped](D,C){\pmpn{\tkzUseLua{S.new.side}}}
125 \end{tikzpicture}
126 \end{center}
127 \end{minipage}
128
129
130 \newpage
131
132
133 \subsection{Square Methods and Functions}
134 \label{sub:square_methods}
135
136
137 \bgroup
138 \catcode`_=12
139 \small
140 \captionof{table}{Square methods}\label{square:methods}
141 \begin{tabular}{lll}
142 \toprule
143 \textbf{Methods} & \texttt{Reference}& \\
144 \midrule
145
146 \tkzMeth{square}{new(za,zb,zc,zd)} &[\ref{ssub:method_square_rotation}]\\
147
148 \tkzFct{square}{square.by\_rotation (zi,za)} &[\ref{ssub:method_square_rotation}]\\
149
150 \tkzFct{square}{square.from\_side(za,zb,"swap")} & \ref{ssub:square_with_side_method} \\
151 \bottomrule %
152 \end{tabular}
153 \egroup
154
155
156
157
158 \subsubsection{Function \tkzFct{square}{square.by\_rotation(pt,pt)}}
159 \label{ssub:method_square_rotation}
160 $I$ square center; $A$ first vertex
161
162 \vspace{1em}
163 \begin{tkzexample}[latex=.5\textwidth]
164 \directlua{
165 z.A = point(0, 0)
166 z.I = point(2, -1)
167 S = square.by_rotation(z.I, z.A)
168 z.B = S.pb
169 z.C = S.pc
170 z.D = S.pd
171 z.I = S.center}
172 \begin{tikzpicture}
173 \tkzGetNodes
174 \tkzDrawPolygon(A,B,C,D)
175 \tkzDrawPoints(A,B,C,D)
176 \tkzLabelPoints(B)
177 \tkzLabelPoints[above](A)
178 \tkzLabelPoints[right](C,D)
179 \tkzDrawPoints[red](I)
180 \end{tikzpicture}
181 \end{tkzexample}
182
183 \subsubsection{Method \tkzFct{square}{square.from\_side(za,zb)}}
184 \label{ssub:square_with_side_method}
185 With the option \code{"swap"} then the square is defined in counterclockwise. The result can also be obtained from a line [\ref{ssub:method_line_square}].
186
187 \begin{minipage}{.5\textwidth}
188 \begin{verbatim}
189 \directlua{
190 init_elements()
191 z.A = point(0, 0)
192 z.B = point(2, 1)
193 S.side = square.from_side(z.A, z.B)
194 z.B = S.side.pb
195 z.C = S.side.pc
196 z.D = S.side.pd
197 z.I = S.side.center}
198 \begin{tikzpicture}[scale = 2]
199 \tkzGetNodes
200 \tkzDrawPolygon(A,B,C,D)
201 \tkzDrawPoints(A,B,C,D)
202 \tkzLabelPoints(A,B)
203 \tkzLabelPoints[above](C,D)
204 \tkzDrawPoints[red](I)
205 \end{tikzpicture}
206 \end{verbatim}
207 \end{minipage}
208 \begin{minipage}{.5\textwidth}
209 \directlua{
210 init_elements()
211 z.A = point(0, 0)
212 z.B = point(2, 1)
213 S.side = square.from_side(z.A, z.B)
214 z.B = S.side.pb
215 z.C = S.side.pc
216 z.D = S.side.pd
217 z.I = S.side.center}
218 \begin{center}
219 \begin{tikzpicture}[scale = 2]
220 \tkzGetNodes
221 \tkzDrawPolygon(A,B,C,D)
222 \tkzDrawPoints(A,B,C,D)
223 \tkzLabelPoints(A,B)
224 \tkzLabelPoints[above](C,D)
225 \tkzDrawPoints[red](I)
226 \end{tikzpicture}
227 \end{center}
228
229 \end{minipage}
230 \endinput