Debian Codegraph @

texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex

raw
1 % Copyright 2019 by Till Tantau
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 \ProvidesFileRCS{tikzlibrarycalc.code.tex}
11
12 %
13 %
14 % Part I: The let path command
15 %
16 %
17
18
19 %
20 % Syntax: let \p{name1} = (coord), \p{name2} = (coord), ... in ...
21 %
22 % Currently (this may get more fancy in the future), the (coord)s are
23 % evaluated one by one. If the first evaluates to, say, (10pt,20pt),
24 % the macro \p{name1} is set to "10pt,20pt" (without parentheses), the
25 % macro \x{name1} is set to "10pt" and the macro \y{name1} is set to
26 % "20pt".
27 %
28 % If you use a number for {name}, you need no parentheses, so you
29 % could write:
30 %
31 % \draw let
32 % \p1 = (1,1),
33 % \p2 = ($ 2.5*(3,2) $)
34 % in
35 % (\x1,\x2) -- (\y1,\y2);
36
37 \def\tikz@let@command et{%
38 \let\p=\tikz@cc@dop%
39 \let\x=\tikz@cc@dox%
40 \let\y=\tikz@cc@doy%
41 \let\n=\tikz@cc@don%
42 \pgfutil@ifnextchar i{\tikz@cc@stop@let}{\tikz@cc@handle@line}%
43 }%
44 \def\tikz@cc@handle@line{%
45 \pgfutil@ifnextchar\p{%
46 \tikz@cc@handle@coor%
47 }{%
48 \pgfutil@ifnextchar\n{%
49 \tikz@cc@handle@num%
50 }{%
51 \pgfutil@ifnextchar i{%
52 \tikz@cc@stop@let
53 }{%
54 \tikzerror{``\string\p'' or ``\string\n'' expected}%
55 }%
56 }%
57 }%
58 }%
59 \def\tikz@cc@handle@num\n#1#2=#3{%
60 \pgfmathparse{#3}%
61 \expandafter\edef\csname tikz@cc@n@#1\endcsname{\pgfmathresult\ifpgfmathunitsdeclared pt\fi}
62 \pgfutil@ifnextchar,{\tikz@cc@handle@nextline}{\tikz@cc@stop@let}%
63 }%
64 \def\tikz@cc@handle@coor\p#1#2={%
65 \def\tikz@cc@coord@name{#1}%
66 \tikz@scan@one@point\tikz@cc@dolet%
67 }%
68 \def\tikz@cc@dolet#1{%
69 \pgf@process{#1}%
70 \expandafter\edef\csname tikz@cc@p@\tikz@cc@coord@name\endcsname{\the\pgf@x,\the\pgf@y}%
71 \expandafter\edef\csname tikz@cc@x@\tikz@cc@coord@name\endcsname{\the\pgf@x}%
72 \expandafter\edef\csname tikz@cc@y@\tikz@cc@coord@name\endcsname{\the\pgf@y}%
73 \pgfutil@ifnextchar,{\tikz@cc@handle@nextline}{\tikz@cc@stop@let}%
74 }%
75 \def\tikz@cc@handle@nextline,{%
76 \tikz@cc@handle@line%
77 }%
78 \def\tikz@cc@stop@let in{%
79 \tikz@scan@next@command%
80 }%
81
82 \def\tikz@cc@dop#1{\csname tikz@cc@p@#1\endcsname}%
83 \def\tikz@cc@dox#1{\csname tikz@cc@x@#1\endcsname}%
84 \def\tikz@cc@doy#1{\csname tikz@cc@y@#1\endcsname}%
85 \def\tikz@cc@don#1{\csname tikz@cc@n@#1\endcsname}%
86
87
88
89 %
90 %
91 % Part II: The ($...$) parser
92 %
93 %
94
95 \def\tikz@parse@calculator#1(${%$
96 \def\tikz@cc@command{#1}%
97 \begingroup%
98 %
99 % Parse main computation. It's a series of optional factors in front
100 % of coordinates.
101 %
102 \pgf@xa=0pt% We accumulate the result in here.
103 \pgf@ya=0pt%
104 \tikz@cc@parse+%
105 }%
106
107 \def\tikz@cc@parse{%
108 \pgfutil@ifnextchar${%$
109 % Ok, we found the end...
110 \tikz@cc@end%
111 }
112 {\pgfutil@ifnextchar+{%
113 % Ok, we found a coordinate...
114 \tikz@cc@add%
115 }{%
116 \pgfutil@ifnextchar-{%
117 \tikz@cc@sub%
118 }{%
119 \tikzerror{+ or - expected}%
120 \tikz@cc@end$%$
121 }%
122 }%
123 }%
124 }%
125
126 %
127 % The end is reached with $
128 %
129 \def\tikz@cc@end$#1){%$
130 \xdef\tikz@marshal{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
131 \endgroup%
132 \expandafter\tikz@cc@command\expandafter{\tikz@marshal}%
133 }%
134
135
136 %
137 % Another coordinate with +/-, possibly with a factor
138 %
139 \def\tikz@cc@add+{%
140 \def\tikz@cc@factor{1}%
141 \tikz@cc@factororcoordinate%
142 }%
143 \def\tikz@cc@sub-{%
144 \def\tikz@cc@factor{-1}%
145 \tikz@cc@factororcoordinate%
146 }%
147
148 %
149 % Check for a factor: If we see a (, its a coordinate...
150 %
151 \def\tikz@cc@factororcoordinate{%
152 \pgfutil@ifnextchar({%)
153 % Ok, found coordinate
154 \tikz@cc@coordinate%
155 }{%
156 \tikz@cc@parse@factor%
157 }%
158 }%
159
160 %
161 % ... otherwise it's a factor. It ends at ...*(
162 %
163 \def\tikz@cc@parse@factor#1*({%
164 \pgfmathparse{#1*\tikz@cc@factor}%
165 \let\tikz@cc@factor=\pgfmathresult%
166 \tikz@cc@coordinate(%)
167 }%
168
169 \def\tikz@cc@coordinate{%
170 \tikz@scan@absolute\tikz@cc@after@coordinate%
171 }%
172 \def\tikz@cc@after@coordinate#1{%
173 \pgf@process{#1}%
174 \pgf@xb=\pgf@x%
175 \pgf@yb=\pgf@y%
176 \tikz@cc@mid@checks%
177 }%
178
179
180 %
181 % A coordinate can be followed by !...!(...)
182 %
183
184 \def\tikz@cc@mid@checks{%
185 \ifnum\the\catcode`\!=\active\relax
186 \expandafter\tikz@cc@mid@checks@active
187 \else
188 \expandafter\tikz@cc@mid@checks@nonactive
189 \fi
190 }%
191
192 \def\tikz@cc@mid@checks@nonactive{%
193 \pgfutil@ifnextchar!{%
194 \tikz@cc@mid@nonactive%
195 }{%
196 \advance\pgf@xa by\tikz@cc@factor\pgf@xb
197 \advance\pgf@ya by\tikz@cc@factor\pgf@yb
198 \tikz@cc@parse%
199 }%
200 }%
201
202 \def\tikz@cc@mid@nonactive!{%
203 \pgfutil@ifnextchar({%
204 \tikz@scan@one@point\tikz@cc@project%
205 }{%
206 \tikz@cc@mid@num@nonactive%
207 }%
208 }%
209
210 \begingroup
211 \catcode`\!=\active
212 \gdef\tikz@cc@mid@checks@active{%
213 \pgfutil@ifnextchar!{%
214 \tikz@cc@mid@active%
215 }{%
216 \advance\pgf@xa by\tikz@cc@factor\pgf@xb
217 \advance\pgf@ya by\tikz@cc@factor\pgf@yb
218 \tikz@cc@parse%
219 }%
220 }%
221
222 \gdef\tikz@cc@mid@active!{%
223 \pgfutil@ifnextchar({%
224 \tikz@scan@one@point\tikz@cc@project%
225 }{%
226 \tikz@cc@mid@num@active%
227 }%
228 }%
229 \endgroup
230
231 %
232 % Partway case: (coord a)!number!(coord b)
233 %
234 % Returns the position that is at <number> fraction on the way from a
235 % to b. This, (a)!0!(b) is (a), (a)!.5!(b) is the middle and (a)!1!(b)
236 % is (b)
237 %
238
239 \def\tikz@cc@mid@num@nonactive#1!{\tikz@cc@mid@num{#1}}%
240
241 \begingroup
242 \catcode`\!=\active
243 \gdef\tikz@cc@mid@num@active#1!{\tikz@cc@mid@num{#1}}%
244 \endgroup
245
246 \def\tikz@cc@mid@num#1{%
247 \pgfmathparse{#1}%
248 \ifpgfmathunitsdeclared%
249 \let\tikz@cc@mid@unit=\pgfmathresult%
250 \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@unit%
251 \else%
252 \let\tikz@cc@mid@factor=\pgfmathresult%
253 \pgfmathparse{1-\tikz@cc@mid@factor}%
254 \let\tikz@cc@mid@factor@one=\pgfmathresult%
255 \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@num%
256 \fi%
257 }%
258
259 \def\tikz@cc@after@num#1{%
260 \pgf@process{#1}%
261 \pgf@xb=\tikz@cc@mid@factor@one\pgf@xb%
262 \pgf@yb=\tikz@cc@mid@factor@one\pgf@yb%
263 \advance\pgf@xb by\tikz@cc@mid@factor\pgf@x%
264 \advance\pgf@yb by\tikz@cc@mid@factor\pgf@y%
265 \tikz@cc@mid@checks%
266 }%
267
268
269
270 %
271 % Distance case: (coord a)!dimension!(coord b)
272 %
273 % Returns the position that is at <dimension> removed from (coord a)
274 % in the direction of (coord b).
275 %
276
277 \def\tikz@cc@after@unit#1{%
278 \pgf@process{#1}%
279 \advance\pgf@x by-\pgf@xb%
280 \advance\pgf@y by-\pgf@yb%
281 \pgf@process{\pgfpointnormalised{}}%
282 \advance\pgf@xb by\tikz@cc@mid@unit\pgf@x%
283 \advance\pgf@yb by\tikz@cc@mid@unit\pgf@y%
284 \tikz@cc@mid@checks%
285 }%
286
287 %
288 % Projection case: (a)!(p)!(b)
289 %
290 % Projection of p on line from a to b
291 %
292 \def\tikz@cc@project#1{%
293 \pgf@process{#1}%
294 % Save in c
295 \pgf@xc=\pgf@x%
296 \pgf@yc=\pgf@y%
297 \begingroup
298 \ifnum\the\catcode`\!=\active
299 \def\tikz@next{%
300 \endgroup
301 \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project
302 \tikz@cc@scan@ex@active}%
303 \else
304 \def\tikz@next{%
305 \endgroup
306 \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project
307 \tikz@cc@scan@ex@nonactive}%
308 \fi
309 \tikz@next%
310 }%
311
312 \def\tikz@cc@scan@ex@nonactive!{}%
313
314 \begingroup
315 \catcode`\!=\active
316 \gdef\tikz@cc@scan@ex@active!{}%
317 \endgroup
318
319 \def\tikz@cc@after@project#1{%
320 \pgf@process{#1}%
321 % Ok, now we need to project (xc,yc) on the line (xb,xc) to (x,y)
322 \advance\pgf@x by-\pgf@xb%
323 \advance\pgf@y by-\pgf@yb%
324 \advance\pgf@xc by-\pgf@xb%
325 \advance\pgf@yc by-\pgf@yb%
326 \pgf@process{\pgfpointnormalised{}}%
327 % Scalar product
328 \pgf@xc=\pgf@sys@tonumber{\pgf@xc}\pgf@x%
329 \advance\pgf@xc by\pgf@sys@tonumber{\pgf@yc}\pgf@y%
330 % and add
331 \advance\pgf@xb by\pgf@sys@tonumber{\pgf@xc}\pgf@x%
332 \advance\pgf@yb by\pgf@sys@tonumber{\pgf@xc}\pgf@y%
333 \tikz@cc@mid@checks%
334 }%
335
336 %
337 % Rotational scanner: radius:(x)
338 %
339
340 \def\tikz@cc@scan@rot#1{%
341 \pgfutil@ifnextchar({%)
342 \tikz@scan@one@point#1% normal
343 }%
344 {%
345 \def\tikz@cc@scan@rot@cmd{#1}%
346 \ifnum\the\catcode`\:=\active\relax
347 \expandafter\tikz@cc@scan@one@rot@active%
348 \else
349 \expandafter\tikz@cc@scan@one@rot@nonactive%
350 \fi
351 }%
352 }%
353
354 \def\tikz@cc@scan@one@rot@nonactive#1:{%
355 \def\tikz@cc@scan@rot@angle{#1}%
356 \tikz@scan@one@point\tikz@cc@handle@rot%
357 }%
358
359 \begingroup
360 \catcode`\:=\active
361 \gdef\tikz@cc@scan@one@rot@active#1:{%
362 \def\tikz@cc@scan@rot@angle{#1}%
363 \tikz@scan@one@point\tikz@cc@handle@rot%
364 }%
365 \endgroup
366
367 \def\tikz@cc@handle@rot#1{%
368 \pgf@process{#1}%
369 % Ok, now we need to rotate x/y around xb/xb by ...rot@angle
370 {%
371 \pgftransformreset%
372 % Save them...
373 \pgf@xc=\pgf@x%
374 \pgf@yc=\pgf@y%
375 \pgftransformshift{\pgfqpoint{\pgf@xb}{\pgf@yb}}%
376 \pgftransformrotate{\tikz@cc@scan@rot@angle}%
377 \pgftransformshift{\pgfqpoint{-\pgf@xb}{-\pgf@yb}}%
378 \pgfpointtransformed{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
379 \expandafter
380 }%
381 \edef\tikz@marshal{\noexpand\tikz@cc@scan@rot@cmd{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
382 \tikz@marshal%
383 }%
384
385
386
387
388 %
389 %
390 % Part III: Calculation coordinate systems
391 %
392 %
393
394 % Tangent cs: Keys are a node and a point. Depending on the type of
395 % node, the appropriate tangent computation should be done.
396
397 \tikzdeclarecoordinatesystem{tangent}
398 {%
399 \tikzset{cs/.cd,#1}%
400 \expandafter\ifx\csname tikz@tangent@\tikz@cs@type\endcsname\relax%
401 \tikzerror{I do not know how to compute the tangent to
402 a \tikz@cs@type}%
403 \pgfpointorigin%
404 \else%
405 \expandafter\tikz@scan@one@point\expandafter\tikz@lib@do@tangent\tikz@cs@point%
406 \fi%
407 }%
408
409 \tikzset{cs/node/.code=\tikz@cs@unpack{\tikz@cs@node}{\tikz@cs@type}{#1}}%
410 \tikzset{cs/point/.store in=\tikz@cs@point}%
411
412 \def\tikz@lib@do@tangent{\csname tikz@tangent@\tikz@cs@type\endcsname}%
413
414 \def\tikz@tangent@coordinate#1{%
415 \pgfpointanchor{\tikz@cs@node}{center}%
416 }%
417
418 \def\tikz@tangent@circle#1{%
419 {%
420 % Step 1: Compute the transformed position of the input:
421 \pgf@process{\pgfpointtransformed{#1}}%
422 \pgf@xa=\pgf@x%
423 \pgf@ya=\pgf@y%
424 %
425 % Step 2: Compute vector from center of circle to transformed #1
426 %
427 \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikz@cs@node}{center}}}%
428 \advance\pgf@xa by-\pgf@x%
429 \advance\pgf@ya by-\pgf@y%
430 %
431 % Step 2: Reset transformations, they distract...
432 %
433 \pgftransformreset%
434 %
435 % Step 3: Transform to the center of the circle.
436 %
437 \pgftransformshift{\pgfpointanchor{\tikz@cs@node}{center}}%
438 %
439 % Step 4: Compute the radius
440 %
441 \pgf@process{\pgfpointanchor{\tikz@cs@node}{east}}%
442 \pgf@xc=\pgf@x%
443 %
444 % Now, (xa,ya) is a point. Compute the tangent from this point to
445 % a circle around the origin of radius xc.
446 %
447 % acos(radius/veclen(xa,ya)) is the angle of the tangent.
448 \pgfmathparse{veclen(\the\pgf@xa,\the\pgf@ya)}
449 \pgfmathparse{acos(\the\pgf@xc/\pgfmathresult)}
450 \ifnum\pgfkeysvalueof{/tikz/cs/solution}>1\relax%
451 \pgfmathparse{0-\pgfmathresult}%
452 \fi%
453 \let\tikz@lib@temp=\pgfmathresult%
454 %
455 % Now \pgfmathparse contains the desired angle. Use this to
456 % compute the correct position on the circle...
457 %
458 % But, first, rotate to the point.
459 \pgf@process{\pgfpointnormalised{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
460 \pgf@ya=-\pgf@y%
461 \pgftransformcm{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
462 % Finally, rotate...
463 \pgf@process{\pgfpointtransformed{\pgfpointpolar{\tikz@lib@temp}{\the\pgf@xc}}}%
464 %
465 % Ok, undo transformations...
466 }%
467 % \pgf@x, \pgf@y have been smuggled outside by \pgf@process
468 {%
469 \pgftransforminvert%
470 \pgf@process{\pgfpointtransformed{}}%
471 }%
472 }%
473
474
475 % Implementation of intersections
476
477
478 \def\tikz@intersect@circle@and@circle{%
479 {%
480 \pgftransformreset% transformations only confuse us, here...
481 %
482 % Compute origin and radius of first circle
483 %
484 \pgf@process{\pgfpointanchor{\tikz@cs@node@a}{center}}%
485 \pgf@xa=\pgf@x%
486 \pgf@ya=\pgf@y%
487 \pgf@process{\pgfpointanchor{\tikz@cs@node@a}{east}}%
488 \advance\pgf@x by-\pgf@xa%
489 \pgf@xc=\pgf@x% ok, pgf@xc is first radius, (xa,ya) is center
490 %
491 % Compute origin and radius of second circle
492 %
493 \pgf@process{\pgfpointanchor{\tikz@cs@node@b}{center}}%
494 \pgf@xb=\pgf@x%
495 \pgf@yb=\pgf@y%
496 \pgf@process{\pgfpointanchor{\tikz@cs@node@b}{east}}%
497 \advance\pgf@x by-\pgf@xb%
498 \pgf@yc=\pgf@x% \pgf@yc is second radius, (xb,yb) is center
499 %
500 \pgf@process{%
501 \pgfpointintersectionofcircles{\pgfqpoint{\pgf@xa}{\pgf@ya}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}{\pgf@xc}{\pgf@yc}{\pgfkeysvalueof{/tikz/cs/solution}}%
502 }%
503 }%
504 % \pgf@x, \pgf@y have been smuggled outside by \pgf@process,
505 % reinstall transformations...
506 {%
507 \pgftransforminvert%
508 \pgf@process{\pgfpointtransformed{}}%
509 }%
510 }%
511
512
513 \def\tikz@intersect@line@and@circle{%
514 {%
515 %
516 % Step 1: Get line
517 %
518 \expandafter\tikz@scan@one@point\expandafter\tikz@parse@line\tikz@cs@line@a%
519 \pgf@process{\pgfpointtransformed{}}%
520 \pgf@xb=\pgf@x%
521 \pgf@yb=\pgf@y%
522 \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@xc}{\pgf@yc}}}%
523 \pgf@xa=\pgf@x%
524 \pgf@ya=\pgf@y%
525 %
526 % Step 2: Subtract center of circle
527 %
528 \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikz@cs@node@b}{center}}}%
529 \advance\pgf@xa by-\pgf@x%
530 \advance\pgf@ya by-\pgf@y%
531 \advance\pgf@xb by-\pgf@x%
532 \advance\pgf@yb by-\pgf@y%
533 %
534 % Step 3: Reset transformations, they distract...
535 %
536 \pgftransformreset%
537 %
538 % Step 4: Transform to the center of the circle.
539 %
540 \pgftransformshift{\pgfpointanchor{\tikz@cs@node@b}{center}}%
541 %
542 % Step 5: Compute the radius
543 %
544 \pgf@process{\pgfpointanchor{\tikz@cs@node@b}{east}}%
545 \edef\tikz@lib@saved@radius{\pgf@sys@tonumber{\pgf@x}}%
546 %
547 % Step 6: Compute projection of origin on line (xa,ya) -- (xb,yb),
548 % store in (xa,ya)
549 \pgf@x=\pgf@xb%
550 \pgf@y=\pgf@yb%
551 \advance\pgf@x by-\pgf@xa%
552 \advance\pgf@y by-\pgf@ya%
553 \pgf@process{\pgfpointnormalised{}}%
554 % Scalar product
555 \pgf@xc=\pgf@sys@tonumber{\pgf@xa}\pgf@x%
556 \advance\pgf@xc by\pgf@sys@tonumber{\pgf@ya}\pgf@y%
557 \pgf@xc=-\pgf@xc%
558 % and add
559 \advance\pgf@xa by\pgf@sys@tonumber{\pgf@xc}\pgf@x%
560 \advance\pgf@ya by\pgf@sys@tonumber{\pgf@xc}\pgf@y%
561 %
562 % Now, we have a triangle with a right angle at (xa,ya). The
563 % second point of the triangle is the origin. The third point is
564 % sought.
565 % Save x/y
566 \pgf@xc=\pgf@x%
567 \pgf@yc=\pgf@y%
568 % Square radius
569 \pgf@xb=\tikz@lib@saved@radius pt%
570 %
571 % First, make numbers smaller, in case they are too large
572 %
573 \c@pgf@counta=1\relax%
574 \loop%
575 \ifdim\pgf@xb>50pt%
576 \multiply\c@pgf@counta by2\relax%
577 \divide\pgf@xa by2\relax%
578 \divide\pgf@ya by2\relax%
579 \divide\pgf@xb by2\relax%
580 \repeat%
581 \pgf@xb=\pgf@sys@tonumber{\pgf@xb}\pgf@xb%
582 % Subtract xa^2 + ya^2
583 \pgf@yb=\pgf@sys@tonumber{\pgf@xa}\pgf@xa%
584 \advance\pgf@xb by-\pgf@yb%
585 \pgf@yb=\pgf@sys@tonumber{\pgf@ya}\pgf@ya%
586 \advance\pgf@xb by-\pgf@yb%
587 % Square root
588 \ifdim\pgf@xb<0pt%
589 \pgf@xb=0pt%
590 \fi%
591 \pgfmathsqrt@{\pgf@sys@tonumber{\pgf@xb}}%
592 \pgfmathmultiply@{\pgfmathresult}{\the\c@pgf@counta}%
593 \multiply\pgf@xa by\c@pgf@counta\relax%
594 \multiply\pgf@ya by\c@pgf@counta\relax%
595 \ifnum\pgfkeysvalueof{/tikz/cs/solution}>1\relax%
596 \pgfmathsubtract{0}{\pgfmathresult}%
597 \fi%
598 % Ok, now add things...
599 \advance\pgf@xa by \pgfmathresult\pgf@xc%
600 \advance\pgf@ya by \pgfmathresult\pgf@yc%
601 \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
602 % Ok, undo transformations...
603 }%
604 % \pgf@x, \pgf@y have been smuggled outside by \pgf@process
605 {%
606 \pgftransforminvert%
607 \pgf@process{\pgfpointtransformed{}}%
608 }%
609 }%
610
611 \def\tikz@intersect@circle@and@line{%
612 % Swap
613 {%
614 \let\tikz@cs@node@b=\tikz@cs@node@a%
615 \let\tikz@cs@line@a=\tikz@cs@line@b%
616 \tikz@intersect@line@and@circle%
617 }%
618 }%