Debian Codegraph @

texmf-dist/doc/latex/lapdf/rcircle.tex

raw
1 \input preamble.tex
2
3 \Defdim(\a,0)
4 \Defdim(\d,0)
5 \Defdim(\x,0)
6 \Defdim(\y,0)
7
8 \def\Ncirc(#1){\Rad(#1,\a)
9 \Cos(\Np\a,\x) \Add(\x,\x)
10 \Sin(\Np\a,\y) \Add(\y,\y)
11 \Circle(64)(\Np\x,\Np\y,2) \Stroke}
12
13 \def\ctitle#1{{\huge\bf{#1}}}
14
15 \title{\Huge \bf{Drawing Circles \\
16 with \\
17 Rational Quadratic Bezier Curves}}
18 \author{Detlef Reimers, [email protected]}
19 \date{\today}
20
21 % ---------------------------------------------------------------------------
22 \begin{document}
23 \maketitle
24
25 \begin{center}
26 \begin{lapdf}(8, 10)(-4,-5)
27 \Whiledim{\d<360}{\Nextcol(0,23) \Ncirc(\Np\d) \Dadd(\d,15)}
28 \end{lapdf}
29
30 \ctitle{Description}
31 \end{center}
32 This document explains, how to calculate the bezier points for
33 complete circles. These can be drawn with the \texttt{Rcurve}
34 commmand from the \texttt{lapdf.sty}. If the weight of the point
35 $P_1$ is $w=\cos(\alpha)$, where $\alpha$ ist the angle between
36 $P_{0}P_{1}$ and $P_{1}P_{2}$, then the conic will be a circular
37 arc, if also both length $P_{0}P_{1}$ and $P_{1}P_{2}$ are equal.
38
39 We have to smothly join several of these arcs together, to get
40 a full circle. Only in the case of two segments, we have have to
41 use one negative weight. In all other cases we only have positive
42 weights. In all of the following calculations and drawings we assume,
43 that the center of the circle lies at the origin.
44
45 \pagebreak
46 \parskip0.3cm
47
48 \begin{center}
49 \ctitle{General calculation scheme}
50
51 \begin{lapdf}(14,13.5)(-7,-6.5)
52 \Dash(1)
53 \Setwidth(0.01)
54 \Polygon(+0.00,-5.00)
55 (+3.63,-5.00)(+4.76,-1.55)
56 (+5.88,+1.91)(+2.94,+4.05)
57 (+0.00,+6.18)(-2.94,+4.05)
58 (-5.88,+1.91)(-4.76,-1.55)
59 (-3.63,-5.00)(+0.00,-5.00) \Stroke
60 \Line(+0.00,+0.00)(+0.00,-5.00) \Stroke
61 \Line(+0.00,+0.00)(+3.63,-5.00) \Stroke
62 \Line(+0.00,+0.00)(+4.76,-1.55) \Stroke
63 \Line(+0.00,+0.00)(+5.88,+1.91) \Stroke
64 \Line(+0.00,+0.00)(+2.94,+4.05) \Stroke
65 \Line(+0.00,+0.00)(+0.00,+6.18) \Stroke
66 \Line(+0.00,+0.00)(-2.94,+4.05) \Stroke
67 \Line(+0.00,+0.00)(-5.88,+1.91) \Stroke
68 \Line(+0.00,+0.00)(-4.76,-1.55) \Stroke
69 \Line(+0.00,+0.00)(-3.63,-5.00) \Stroke
70 \Dash(0)
71 \Setwidth(0.02)
72 \Blue
73 \Circle(96)(0,0,6.18) \Stroke
74 \Red
75 \Circle(96)(0,0,5) \Stroke
76 \Black
77 \Rcurve(64)(+0.00,-1.30,1)(+0.42,-1.30,0.5)(0.76,-1.05,1) \Stroke
78 \Point(1)(+3.63,-5.00)
79 \Point(1)(+4.76,-1.55)
80 \Point(1)(+5.88,+1.91)
81 \Point(1)(+2.94,+4.05)
82 \Point(1)(+0.00,+6.18)
83 \Point(1)(-2.94,+4.05)
84 \Point(1)(-5.88,+1.91)
85 \Point(1)(-4.76,-1.55)
86 \Point(1)(-3.63,-5.00)
87 \Point(1)(+0.00,-5.00)
88 \Text(+3.63,-5.10,tl){$P_1$}
89 \Text(+4.86,-1.55,tl){$P_2$}
90 \Text(+5.98,+2.01,cl){$P_3$}
91 \Text(+3.04,+4.15,bl){$P_4$}
92 \Text(+0.00,+6.38,bc){$P_5$}
93 \Text(-3.04,+4.15,br){$P_6$}
94 \Text(-5.98,+2.01,cr){$P_7$}
95 \Text(-4.86,-1.55,tr){$P_8$}
96 \Text(-3.63,-5.10,tr){$P_9$}
97 \Text(+0.00,-5.10,tc){$P_0=P_{10}$}
98 \Text(0.10,-2.90,cl){$r$}
99 \Text(0.10,+3.10,cl){$R$}
100 \Text(0.25,-0.80,cc){$\alpha$}
101 \end{lapdf}
102 \end{center}
103 We always put $P_0$ at the bottom of the circle and all other points
104 follow counterclockwise.
105 This is the general procedure for circle construction with rational
106 quadratic bezier curves (see picture):
107 \begin{enumerate}
108 \item Set the radius $r$.
109 \item Set the number of bezier segments $n$.
110 \item Calculate $\alpha = \displaystyle {360^\circ \over 2n}$.
111 \item Calculate outer radius $R=\displaystyle {r \over \cos(\alpha)}$.
112 \item Calculate all even bezier points
113 $P_{2i} = \displaystyle {+r \cdot \sin(2i\cdot\alpha)
114 \choose -r \cdot \cos(2i\cdot\alpha)}$ for $i=0 \dots n$.
115 \item Calculate odd bezier points
116 $P_{2i+1} = \displaystyle {+R \cdot \sin((2i+1)\cdot\alpha)
117 \choose -R \cdot \cos((2i+1)\cdot\alpha)}$ for $i=0 \dots n-1$.
118 \end{enumerate}
119 You can control your calculations, if you check your endpoint $P_{2n}$.
120 This point is equal with $P_0$. All curves are drawn with the
121 {\tt Rmoveto()} and {\tt Rcurveto()} combination.
122
123 \pagebreak
124
125 \parskip1cm
126 \begin{center}
127 \ctitle{2 Segments}
128
129 \begin{lapdf}(6,7.5)(-3,-3)
130 \Lingrid(5)(0,1)(-3,3)(-3,5)
131 \Dash(1)
132 \Setwidth(0.01)
133 \Polygon(+2.165,+1.25)
134 (+0.00,+5.0)(-2.165,+1.25) \Stroke
135 \Dash(0)
136 \Red
137 \Setwidth(0.02)
138 \Rmoveto(+2.165,+1.25,1)
139 \Rcurveto(64)(+0.00,+5.0,+0.5)(-2.165,+1.25,1)
140 \Rcurveto(64)(+0.00,+5.0,-0.5)(+2.165,+1.25,1) \Stroke
141 \Black
142 \Point(1)(+2.165,+1.25)
143 \Point(1)(+0.000,+5.00)
144 \Point(1)(-2.165,+1.25)
145 \end{lapdf}
146
147 Circle with $2n+1=5$ points ($w_{2n}=1$ and $w_{2n+1} = \pm \cos(60^\circ) = \pm 0.5$).
148 \end{center}
149 \begin{center}
150 \ctitle{3 Segments}
151
152 \begin{lapdf}(6,7.5)(-3,-3)
153 \Lingrid(5)(0,1)(-5,5)(-3,5)
154 \Dash(1)
155 \Setwidth(0.01)
156 \Polygon(+0.00,-2.50)
157 (+4.333,-2.50)(+2.165,+1.25)
158 (+0.000,+5.00)(-2.165,+1.25)
159 (-4.333,-2.50)(+0.000,-2.50) \Stroke
160 \Dash(0)
161 \Setwidth(0.02)
162 \Red
163 \Rmoveto(+0.000,-2.50,1)
164 \Rcurveto(64)(+4.33,-2.50,0.5)(+2.165,+1.25,1)
165 \Rcurveto(64)(+0.00,+5.00,0.5)(-2.165,+1.25,1)
166 \Rcurveto(64)(-4.33,-2.50,0.5)(+0.000,-2.50,1) \Stroke
167 \Black
168 \Point(1)(+0.000,-2.50)
169 \Point(1)(+4.333,-2.50)
170 \Point(1)(+2.165,+1.25)
171 \Point(1)(+0.000,+5.00)
172 \Point(1)(-2.165,+1.25)
173 \Point(1)(-4.333,-2.50)
174 \end{lapdf}
175
176 Circle with $2n+1=7$ points ($w_{2n}=1$ and $w_{2n+1} = \cos(60^\circ) = 0.5$).
177 \end{center}
178
179 \pagebreak
180
181 \begin{center}
182 \ctitle{4 Segments}
183
184 \begin{lapdf}(6,6)(-3,-3)
185 \Lingrid(5)(0,1)(-3,3)(-3,3)
186 \Dash(1)
187 \Setwidth(0.01)
188 \Polygon(+2.50,+0.00)
189 (+2.50,+2.50)(+0.00,+2.50)
190 (-2.50,+2.50)(-2.50,+0.00)
191 (-2.50,-2.50)(+0.00,-2.50)
192 (+2.50,-2.50)(+2.50,+0.00) \Stroke
193 \Dash(0)
194 \Setwidth(0.02)
195 \Red
196 \Rmoveto(+2.50,+0.00,1)
197 \Rcurveto(64)(+2.50,+2.50,0.707)(+0.00,+2.50,1)
198 \Rcurveto(64)(-2.50,+2.50,0.707)(-2.50,+0.00,1)
199 \Rcurveto(64)(-2.50,-2.50,0.707)(+0.00,-2.50,1)
200 \Rcurveto(64)(+2.50,-2.50,0.707)(+2.50,+0.00,1) \Stroke
201 \Black
202 \Point(1)(+2.50,+0.00)
203 \Point(1)(+2.50,+2.50)
204 \Point(1)(+0.00,+2.50)
205 \Point(1)(-2.50,+2.50)
206 \Point(1)(-2.50,+0.00)
207 \Point(1)(-2.50,-2.50)
208 \Point(1)(+0.00,-2.50)
209 \Point(1)(+2.50,-2.50)
210 \end{lapdf}
211
212 Circle with $2n+1=9$ points ($w_{2n}=1$ and $w_{2n+1} = \cos(45^\circ) = 0.707$).
213 \end{center}
214 \begin{center}
215 \ctitle{5 Segments}
216
217 \begin{lapdf}(6,6)(-3,-3)
218 \Lingrid(5)(0,1)(-3,3)(-3,3)
219 \Dash(1)
220 \Setwidth(0.01)
221 \Polygon(+0.00,-2.50)
222 (+1.815,-2.500)(+2.38,-0.775)
223 (+2.940,+0.905)(+1.47,+2.025)
224 (+0.000,+3.090)(-1.47,+2.025)
225 (-2.940,+0.905)(-2.38,-0.775)
226 (-1.815,-2.500)(+0.00,-2.500) \Stroke
227 \Dash(0)
228 \Setwidth(0.02)
229 \Red
230 \Rmoveto(+0.00,-2.500,1)
231 \Rcurveto(64)(+1.815,-2.500,0.809)(+2.380,-0.775,1)
232 \Rcurveto(64)(+2.940,+0.905,0.809)(+1.470,+2.025,1)
233 \Rcurveto(64)(+0.000,+3.090,0.809)(-1.470,+2.025,1)
234 \Rcurveto(64)(-2.940,+0.905,0.809)(-2.380,-0.775,1)
235 \Rcurveto(64)(-1.815,-2.500,0.809)(+0.000,-2.500,1) \Stroke
236 \Black
237 \Point(1)(+1.815,-2.500)
238 \Point(1)(+2.380,-0.775)
239 \Point(1)(+2.940,+0.905)
240 \Point(1)(+1.470,+2.025)
241 \Point(1)(+0.000,+3.090)
242 \Point(1)(-1.470,+2.025)
243 \Point(1)(-2.940,+0.905)
244 \Point(1)(-2.380,-0.775)
245 \Point(1)(-1.815,-2.500)
246 \Point(1)(+0.000,-2.500)
247 \end{lapdf}
248
249 Circle with $2n+1=11$ points ($w_{2n}=1$ and $w_{2n+1} = \cos(36^\circ) = 0.809$).
250 \end{center}
251
252 \pagebreak
253
254 \begin{center}
255 \ctitle{6 Segments}
256
257 \begin{lapdf}(6,6)(-3,-3)
258 \Lingrid(5)(0,1)(-3,3)(-3,3)
259 \Dash(1)
260 \Setwidth(0.01)
261 \Polygon(+2.50,+0.00)
262 (+2.50,+1.445)(+1.25,+2.165)
263 (+0.00,+2.885)(-1.25,+2.165)
264 (-2.50,+1.445)(-2.50,+0.000)
265 (-2.50,-1.445)(-1.25,-2.165)
266 (+0.00,-2.885)(+1.25,-2.165)
267 (+2.50,-1.445)(+2.50,+0.000) \Stroke
268 \Dash(0)
269 \Setwidth(0.02)
270 \Red
271 \Rmoveto(+2.50,+0.000,1)
272 \Rcurveto(64)(+2.50,+1.445,0.866)(+1.25,+2.165,1)
273 \Rcurveto(64)(+0.00,+2.885,0.866)(-1.25,+2.165,1)
274 \Rcurveto(64)(-2.50,+1.445,0.866)(-2.50,+0.000,1)
275 \Rcurveto(64)(-2.50,-1.445,0.866)(-1.25,-2.165,1)
276 \Rcurveto(64)(+0.00,-2.885,0.866)(+1.25,-2.165,1)
277 \Rcurveto(64)(+2.50,-1.445,0.866)(+2.50,+0.000,1) \Stroke
278 \Black
279 \Point(1)(+2.50,+0.000)
280 \Point(1)(+2.50,+1.445)
281 \Point(1)(+1.25,+2.165)
282 \Point(1)(+0.00,+2.885)
283 \Point(1)(-1.25,+2.165)
284 \Point(1)(-2.50,+1.445)
285 \Point(1)(-2.50,+0.000)
286 \Point(1)(-2.50,-1.445)
287 \Point(1)(-1.25,-2.165)
288 \Point(1)(+0.00,-2.885)
289 \Point(1)(+1.25,-2.165)
290 \Point(1)(+2.50,-1.445)
291 \end{lapdf}
292
293 Circle with $2n+1=13$ points ($w_{2n}=1$ and $w_{2n+1} = \cos(30^\circ) = 0.866$).
294 \end{center}
295
296 \begin{center}
297 \ctitle{7 Segments}
298
299 \begin{lapdf}(6,6)(-3,-3)
300 \Lingrid(5)(0,1)(-3,3)(-3,3)
301 \Dash(1)
302 \Setwidth(0.01)
303 \Polygon(+0.00,-2.50)
304 (+1.205,-2.50)(+1.955,-1.560)
305 (+2.705,-0.62)(+2.440,+0.555)
306 (+2.170,+1.73)(+1.085,+2.255)
307 (+0.000,+2.78)(-1.085,+2.255)
308 (-2.170,+1.73)(-2.440,+0.555)
309 (-2.705,-0.62)(-1.955,-1.560)
310 (-1.205,-2.50)(+0.000,-2.500) \Stroke
311 \Dash(0)
312 \Setwidth(0.02)
313 \Red
314 \Rmoveto(+0.000,-2.500,1)
315 \Rcurveto(64)(+1.205,-2.50,0.901)(+1.905,-1.560,1)
316 \Rcurveto(64)(+2.705,-0.62,0.901)(+2.440,+0.555,1)
317 \Rcurveto(64)(+2.170,+1.73,0.901)(+1.085,+2.255,1)
318 \Rcurveto(64)(+0.000,+2.78,0.901)(-1.085,+2.255,1)
319 \Rcurveto(64)(-2.170,+1.73,0.901)(-2.440,+0.555,1)
320 \Rcurveto(64)(-2.705,-0.62,0.901)(-1.905,-1.560,1)
321 \Rcurveto(64)(-1.205,-2.50,0.901)(+0.000,-2.500,1) \Stroke
322 \Black
323 \Point(1)(+0.000,-2.500)
324 \Point(1)(+1.205,-2.500)
325 \Point(1)(+1.905,-1.560)
326 \Point(1)(+2.705,-0.620)
327 \Point(1)(+2.440,+0.555)
328 \Point(1)(+2.170,+1.730)
329 \Point(1)(+1.085,+2.255)
330 \Point(1)(+0.000,+2.780)
331 \Point(1)(-1.085,+2.255)
332 \Point(1)(-2.170,+1.730)
333 \Point(1)(-2.440,+0.555)
334 \Point(1)(-2.705,-0.620)
335 \Point(1)(-1.905,-1.560)
336 \Point(1)(-1.205,-2.500)
337 \end{lapdf}
338
339 Circle with $2n+1=15$ points ($w_{2n}=1$ and $w_{2n+1} = \cos(25.71^\circ) = 0.901$).
340 \end{center}
341 \end{document}