Debian Codegraph @

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

raw
1 \newpage
2 \section{Class \tkzClass{regular polygon}}
3
4 The variable \tkzVar{regular\_polygon}{RP} holds a table used to store regular polygons. It is optional, and you are free to choose the variable name. However, using \code{RP} is a recommended convention for clarity and consistency. If you use a custom variable (e.g., REP), you must initialize it manually. The \tkzFct{tkz-elements}{init\_elements()} function reinitializes the \code{RP} table if used.
5
6
7 \subsection{Creating a regular polygon}
8
9 The \tkzClass{regular\_polygon} class builds a regular polygon from its center, a first vertex, and the number of sides.
10
11 \medskip
12 The result is usually stored in \tkzVar{regular\_polygon}{P}, a variable used to group polygonal objects.
13
14 \begin{mybox}
15 \begin{verbatim}
16 P.hex = regular_polygon:new(z.O, z.A, 6)
17 \end{verbatim}
18 \end{mybox}
19
20 \textbf{Short form.}
21
22 Use the short form for brevity:
23
24 \begin{mybox}
25 \begin{verbatim}
26 P.hex = regular_polygon(z.O, z.A, 6)
27 \end{verbatim}
28 \end{mybox}
29
30 \subsection{Regular\_polygon attributes}
31 \label{sub:regular_polygon_attributes}
32
33 \begin{mybox}
34 Creation | RP.IA = regular_polygon(z.I,z.A,6)|
35 \end{mybox}
36
37
38 \bgroup
39 \catcode`_=12
40 \small
41 \captionof{table}{Regular\_polygon attributes.}\label{regular:attributes}
42 \begin{tabular}{ll}
43 \toprule
44 \texttt{Attributes} & \textbf{Application} \\
45 \midrule
46 \tkzAttr{regular}{center} & |z.I = RP.IA.center| \\
47 \tkzAttr{regular}{vertices} & array containing all vertex affixes \\
48 \tkzAttr{regular}{through} & first vertex \\
49 \tkzAttr{regular}{circle} & defines the circle with center I passing through A \\
50 \tkzAttr{regular}{type} & |RP.IA.type= 'regular\_polygon'| \\
51 \tkzAttr{regular}{side} & |s = RP.IA.side| ; s = length of side\\
52 \tkzAttr{regular}{circumradius}& |S.AB.circumradius| ; radius of the circumscribed circle \\
53 \tkzAttr{regular}{inradius}& |S.AB.inxradius| ; radius of the inscribed circle \\
54 \tkzAttr{regular}{apothem} & |RP.IA.apothem| ; projection of the center on one side \\
55 \tkzAttr{regular}{angle} & |RP.IA.angle| ; angle formed by the center and 2 consecutive vertices \\
56 \bottomrule %
57 \end{tabular}
58 \egroup
59
60
61
62
63 \subsubsection{Pentagon}
64 \label{ssub:pentagon}
65 \begin{minipage}{.5\textwidth}
66 \begin{verbatim}
67 \directlua{
68 init_elements()
69 z.O = point(0, 0)
70 z.I = point(1, 3)
71 z.A = point(2, 0)
72 RP.five = regular_polygon(z.I, z.A, 5)
73 RP.five:name("P_")
74 C.ins = circle:radius(z.I,
75 RP.five.inradius)
76 z.H = RP.five.apothem
77 }
78 \begin{tikzpicture}[scale = .75]
79 \def\nb{\tkzUseLua{RP.five.nb}}
80 \tkzGetNodes
81 \tkzDrawCircles(I,A I,H)
82 \tkzDrawPolygon(P_1,P_...,P_\nb)
83 \tkzDrawPoints[red](P_1,P_...,P_\nb,H,I)
84 \tkzLabelPoints[red](I,A,H)
85 \end{tikzpicture}
86 \end{verbatim}
87 \end{minipage}
88 \begin{minipage}{.5\textwidth}
89 \directlua{
90 init_elements()
91 z.O = point(0, 0)
92 z.I = point(1, 3)
93 z.A = point(2, 0)
94 RP.five = regular_polygon(z.I, z.A, 5)
95 RP.five:name("P_")
96 C.ins = circle:radius(z.I, RP.five.inradius )
97 z.H = RP.five.apothem_foot
98 }
99
100 \begin{center}
101 \begin{tikzpicture}[scale = .75]
102 \def\nb{\tkzUseLua{RP.five.nb}}
103 \tkzGetNodes
104 \tkzDrawCircles(I,A I,H)
105 \tkzDrawPolygon(P_1,P_...,P_\nb)
106 \tkzDrawPoints[red](P_1,P_...,P_\nb,H,I)
107 \tkzLabelPoints[red](I,A,H)
108 \end{tikzpicture}
109 \end{center}
110
111
112 \end{minipage}
113
114 \subsection{Regular\_polygon methods}
115 \label{sub:regular_polygon_methods}
116
117
118 \bgroup
119 \catcode`_=12
120 \small
121 \captionof{table}{regular\_polygon methods.}\label{regular:methods}
122 \begin{tabular}{ll}
123 \toprule
124 \texttt{Constructor}&\\ \\
125 \midrule
126 \tkzFct{regular\_polygon}{new(O,A,n)} & [\ref{ssub:function_regular_new}] \\
127 \midrule
128 \texttt{Methods Returning a Circle}&\\
129 \midrule
130 \tkzMeth{regular\_polygon}{incircle ()} & [\ref{ssub:method_regular_incirle}]\\
131 \midrule
132 \texttt{Methods Returning a Point}&\\
133 \midrule
134 \tkzMeth{regular\_polygon}{name (string)} & [\ref{ssub:method_regular_name}] \\
135 \bottomrule %
136 \end{tabular}
137 \egroup
138
139
140 \subsubsection{Method \tkzMeth{regular}{new(pt, pt, n)}}
141 \label{ssub:function_regular_new}
142
143 \begin{tkzexample}[latex=.5\textwidth]
144 \directlua{
145 z.A = point(0, -4)
146 z.O = point(0, 0)
147 RP.six = regular_polygon(z.O, z.A, 6)
148 RP.six:name("A_")
149 z.i, z.p = RP.six:incircle():get()}
150
151 \begin{tikzpicture}[gridded,scale=.75]
152 \tkzGetNodes
153 \tkzDrawCircles[red](O,A)
154 \tkzDrawCircles[teal](i,p)
155 \tkzDrawPolygon(A_1,A_...,A_6)
156 \tkzDrawPoints[red](A_1,A_...,A_6)
157 \tkzLabelPoints[red](A_1,A_...,A_6)
158 \end{tikzpicture}
159 \end{tkzexample}
160
161 \subsubsection{Method \tkzMeth{regular}{incirle()}}
162 \label{ssub:method_regular_incirle}
163
164 See previous example [\ref{ssub:function_regular_new}]
165
166 \subsubsection{Method \tkzMeth{regular}{name(s)}}
167 \label{ssub:method_regular_name}
168
169 See [\ref{ssub:function_regular_new}]
170 \endinput