1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
%%
%% This is file `tikzlibrarydubins.code.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% sankey.dtx (with options: `tikzlibrarydubins.code.tex')
%%
%% This is a generated file.
%%
%% Copyright (C) 2016, 2021 by Paul Gaborit
%%
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3 of this license or (at
%% your option) any later version. The latest version of this license is
%% in
%%
%% <http://www.latex-project.org/lppl.txt>
%%
%% and version 1.3 or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status “maintained”.
%%
%% The Current Maintainer of this work is Paul Gaborit.
%%
%% This work consists of the files sankey.dtx, sankey.ins and the derived
%% files sankey.sty, tikzlibrarydubins.code.tex, sankey-doc-preamble.sty,
%% sankey-example1.tex, sankey-example2.tex, sankey-example3.tex,
%% sankey-example3-variation.tex, sankey-example4.tex,
%% sankey-example-energy.tex
%%
\def\tikzlibrarydubins@version{v3.0.1}
\def\tikzlibrarydubins@date{2022/02/04}
\usetikzlibrary{calc}
\RequirePackage{etoolbox}
\RequirePackage{xfp}
\newbool{dubinspathreverse}
\def\ifpgfmathcond#1{%
\pgfmathparse{(#1)?1:0}%
\ifnumequal{\pgfmathresult}{1}%
}
\def\dbp@getxy#1#2#3{%
\tikz@scan@one@point\pgfutil@firstofone(#3)\relax%
\edef#1{\the\pgf@x}%
\edef#2{\the\pgf@y}%
}
\def\dbp@anglebetween#1#2#3{%macro, s, t
\dbp@getxy\dbp@ax\dbp@ay{#2}
\dbp@getxy\dbp@bx\dbp@by{#3}
\pgfmathsetmacro#1{atan2(\dbp@by-\dbp@ay,\dbp@bx-\dbp@ax)}
}
\def\dbp@distancebetween#1#2#3{%macro, s, t
\dbp@getxy\dbp@ax\dbp@ay{#2}
\dbp@getxy\dbp@bx\dbp@by{#3}
\edef#1{\fpeval{sqrt(%
(\dbp@bx-\dbp@ax)*(\dbp@bx-\dbp@ax)%
+(\dbp@by-\dbp@ay)*(\dbp@by-\dbp@ay)%
)}}%
}
\newcommand\dbp@rsr{% s, sa, t, ta, as, len, at, r
let
\p{tr}=([shift={(\dbp@angb-90:\dbp@radius pt)}]\dbp@b),
\n1={\dbp@anga+90},
\n2={\dbp@angb+90},
\n3={\n2+\dbp@lastangle}
in
arc(\n1:\n1-\dbp@firstangle:\dbp@rradius pt)
-- ([shift={(\p{tr})}]\n3:\dbp@rradius pt)
arc(\n3:\n2:\dbp@rradius pt)
}
\newcommand\dbp@lsl{% s, sa, t, ta, as, len, at, r
let
\p{tl}=([shift={(\dbp@angb+90:\dbp@radius pt)}]\dbp@b),
\n1={\dbp@anga-90},\n2={\n1+\dbp@firstangle},
\n3={\dbp@angb-90},\n4={\n3-\dbp@lastangle}
in
arc(\n1:\n2:\dbp@lradius pt)
-- ([shift={(\p{tl})}]\n4:\dbp@lradius pt)
arc(\n4:\n3:\dbp@lradius pt)
}
\newcommand\dbp@rsl{% s, sa, t, ta, as, len, at, r
let
\p{tl}=([shift={(\dbp@angb+90:\dbp@radius pt)}]\dbp@b),
\n1={\dbp@anga+90},\n2={\n1-\dbp@firstangle},
\n3={\dbp@angb-90},\n4={\n3-\dbp@lastangle}
in
arc(\n1:\n2:\dbp@rradius pt)
-- ([shift={(\p{tl})}]\n4:\dbp@lradius pt)
arc(\n4:\n3:\dbp@lradius pt)
}
\newcommand\dbp@lsr{% s, sa, t, ta, as, len, at, r
let
\p{tr}=([shift={(\dbp@angb-90:\dbp@radius pt)}]\dbp@b),
\n1={\dbp@anga-90},\n2={\n1+\dbp@firstangle},
\n3={\dbp@angb+90},\n4={\n3+\dbp@lastangle}
in
arc(\n1:\n2:\dbp@lradius pt)
-- ([shift={(\p{tr})}]\n4:\dbp@rradius pt)
arc(\n4:\n3:\dbp@rradius pt)
}
\newcommand\dbp@lrl{% s, sa, t, ta, as, ai, at, r
let
\n1={\dbp@anga-90},\n2={\n1+\dbp@firstangle},
\n3={\dbp@angb-90},\n4={\n3-\dbp@lastangle}
in
arc(\n1:\n2:\dbp@lradius pt)
arc(\n2+180:\n2+180-\dbp@midparam:\dbp@rradius pt)
arc(\n4:\n3:\dbp@lradius pt)
}
\newcommand\dbp@rlr{% s, sa, t, ta, as, ai, at, r
let
\n1={\dbp@anga+90},\n2={\n1-\dbp@firstangle},
\n3={\dbp@angb+90},\n4={\n3+\dbp@lastangle}
in
arc(\n1:\n2:\dbp@rradius pt)
arc(\n2+180:\n2+180+\dbp@midparam:\dbp@lradius pt)
arc(\n4:\n3:\dbp@rradius pt)
}
\newcommand\dbp@rev@lsl{\dbp@rsr}
\newcommand\dbp@rev@rsr{\dbp@lsl}
\newcommand\dbp@rev@lsr{\dbp@lsr}
\newcommand\dbp@rev@rsl{\dbp@rsl}
\newcommand\dbp@rev@lrl{\dbp@rlr}
\newcommand\dbp@rev@rlr{\dbp@lrl}
\newcommand\dubinspath[1]{%
\pgfextra{
\dubinspathset{#1}
\ifbool{dubinspathreverse}{
\edef\dbp@newa{\dbp@b}
\edef\dbp@newb{\dbp@a}
\pgfmathsetmacro\dbp@newanga{180+\dbp@angb}
\pgfmathsetmacro\dbp@newangb{180+\dbp@anga}
\edef\dbp@newfirstangle{\dbp@lastangle}
\edef\dbp@newlastangle{\dbp@firstangle}
\edef\dbp@newmethod{rev@\dbp@method}
\edef\dbp@newlradius{\dbp@rradius}
\edef\dbp@newrradius{\dbp@lradius}
\dubinspathset{
start point=\dbp@newa,
end point=\dbp@newb,
start angle=\dbp@newanga,
end angle=\dbp@newangb,
first angle=\dbp@newfirstangle,
last angle=\dbp@newlastangle,
left and right minimum radii=\dbp@newlradius pt and \dbp@newrradius pt,
method=\dbp@newmethod,
}
}{}
}
\csname dbp@\dbp@method\endcsname%
}
\def\dbp@store#1#2{%
\expandafter\xdef\csname dbp@store@#1@#2\endcsname%
{\csname dbp@#2\endcsname}%
}
\def\dbp@get#1#2{%
\csname dbp@store@#1@#2\endcsname%
}
\def\dbp@setparams#1#2#3#4#5{%
% method, length, fisrt angle, middle param, last angle
\edef\dbp@method{#1}
\edef\dbp@length{#2}
\edef\dbp@firstangle{#3}
\edef\dbp@middleparam{#4}
\edef\dbp@lastangle{#5}
\ifdef{\dbp@storename}{
\foreach \p in {method,length,firstangle,middleparam,lastangle}{
\dbp@store{\dbp@storename}{\p}
}
}{}
}
\def\dbp@updateparams#1#2#3#4#5{
\ifpgfmathcond{#2<\dbp@length}{
\dbp@setparams{#1}{#2}{#3}{#4}{#5}
}{}
}
\tikzset{
dubins path/.is family,
dubins path,
start point/.store in=\dbp@a,
start angle/.store in=\dbp@anga,
end point/.store in=\dbp@b,
end angle/.store in=\dbp@angb,
store/.store in=\dbp@storename,
use store/.style={
method=\dbp@get{#1}{method},
first angle=\dbp@get{#1}{firstangle},
last angle=\dbp@get{#1}{lastangle},
middle param=\dbp@get{#1}{middleparam},
},
minimum radius/.code={
\pgfmathsetmacro\dbp@radius{#1}
\pgfmathsetmacro\dbp@rradius{#1}
\pgfmathsetmacro\dbp@lradius{#1}
},
left and right minimum radii/.code args={#1 and #2}{
\pgfmathsetmacro\dbp@lradius{#1}
\pgfmathsetmacro\dbp@rradius{#2}
\pgfmathsetmacro\dbp@radius{(\dbp@lradius + \dbp@rradius)/2}
},
method/.store in=\dbp@method,
first angle/.store in=\dbp@firstangle,
last angle/.store in=\dbp@lastangle,
middle param/.store in=\dbp@midparam,
reverse/.is if=dubinspathreverse,
}
\newcommand\dubinspathset[1]{\tikzset{dubins path,#1}}
\newcommand\dubinspathcalc[1]{%
\begingroup
\dubinspathset{#1}
\tikzset{
declare function={
angtodist(\dbp@a,\dbp@r)={abs(\dbp@a)*.01745329*\dbp@r};
modangr(\dbp@a,\dbp@b)={
(
Mod(\dbp@a,360)<Mod(\dbp@b,360)
?
Mod(\dbp@a,360)
:
Mod(\dbp@a,360)-360)+\dbp@b-Mod(\dbp@b,360
)
};
modangl(\dbp@a,\dbp@b)={
(
Mod(\dbp@a,360)<Mod(\dbp@b,360)
?
Mod(\dbp@a,360)+360
:
Mod(\dbp@a,360))+(\dbp@b)-Mod(\dbp@b,360)
};
},
}
\pgfmathsetmacro\dbp@radius{\dbp@rradius}
\pgfmathsetmacro\dbp@anga{mod((\dbp@anga)+180,360)-180}
\pgfmathsetmacro\dbp@angb{mod((\dbp@angb)+180,360)-180}
\path
let
\p{a}=(\dbp@a),
\p{b}=(\dbp@b),
\p{ar}=($(\p{a}) + (\dbp@anga-90:\dbp@radius pt)$),
\p{al}=($(\p{a}) + (\dbp@anga+90:\dbp@radius pt)$),
\p{br}=($(\p{b}) + (\dbp@angb-90:\dbp@radius pt)$),
\p{bl}=($(\p{b}) + (\dbp@angb+90:\dbp@radius pt)$)
in \pgfextra{
\pgfinterruptpath
% RSR (ar and br)
\dbp@anglebetween\dbp@rsrarbr{\p{ar}}{\p{br}}
\dbp@distancebetween\dbp@rsrdarbr{\p{ar}}{\p{br}}
\pgfmathsetmacro\dbp@rsrangone{Mod(\dbp@anga-\dbp@rsrarbr,360)}
\pgfmathsetmacro\dbp@rsrangtwo{Mod(\dbp@rsrarbr-\dbp@angb,360)}
\pgfmathsetmacro\dbp@rsrlen{\dbp@rsrdarbr}
\pgfmathsetmacro\dbp@rsrdist{
angtodist(\dbp@rsrangone,\dbp@radius)
+\dbp@rsrlen
+angtodist(\dbp@rsrangtwo,\dbp@radius)
}
\dbp@setparams{rsr}{\dbp@rsrdist}{\dbp@rsrangone}{\dbp@rsrlen}{\dbp@rsrangtwo}
% LSL (al and bl)
\dbp@anglebetween\dbp@lslalbl{\p{al}}{\p{bl}}
\dbp@distancebetween\dbp@lsldalbl{\p{al}}{\p{bl}}
\pgfmathsetmacro{\dbp@lslangone}{mod(\dbp@lslalbl-\dbp@anga+720,360)}
\pgfmathsetmacro{\dbp@lslangtwo}{mod(\dbp@angb-\dbp@lslalbl+720,360)}
\pgfmathsetmacro\dbp@lsllen{\dbp@lsldalbl}
\pgfmathsetmacro\dbp@lsldist{
angtodist(\dbp@lslangone,\dbp@radius)
+\dbp@lsllen
+angtodist(\dbp@lslangtwo,\dbp@radius)
}
\dbp@updateparams%
{lsl}{\dbp@lsldist}{\dbp@lslangone}{\dbp@lsllen}{\dbp@lslangtwo}
% RSL (ar and bl)
\dbp@distancebetween\dbp@rsldarbl{\p{ar}}{\p{bl}}
\pgfmathtruncatemacro\dbp@rslok{(\dbp@rsldarbl>=2*\dbp@radius)?1:0}
\ifnumequal{\dbp@rslok}{1}{
\dbp@anglebetween\dbp@rslarbl{\p{ar}}{\p{bl}}
\pgfmathsetmacro\dbp@rslanglesup{
asin(\dbp@radius/\dbp@rsldarbl*2)}
\pgfmathsetmacro\dbp@rslangone
{Mod(\dbp@anga-\dbp@rslarbl+\dbp@rslanglesup,360)}
\pgfmathsetmacro\dbp@rslangtwo
{Mod(\dbp@angb-\dbp@rslarbl+\dbp@rslanglesup,360)}
\pgfmathsetmacro\dbp@rsllen{veclen(\dbp@rsldarbl,\dbp@radius)}
\pgfmathsetmacro\dbp@rsldist{
angtodist(\dbp@rslangone,\dbp@radius)
+\dbp@rsllen
+angtodist(\dbp@rslangtwo,\dbp@radius)
}
\dbp@updateparams%
{rsl}{\dbp@rsldist}{\dbp@rslangone}{\dbp@rsllen}{\dbp@rslangtwo}
}{}
% LSR (al and br)
\dbp@distancebetween\dbp@lsrdalbr{\p{al}}{\p{br}}
\pgfmathtruncatemacro\dbp@lsrok{(\dbp@lsrdalbr>=2*\dbp@radius)?1:0}
\ifnumequal{\dbp@lsrok}{1}{
\dbp@anglebetween\dbp@lsralbr{\p{al}}{\p{br}}
\pgfmathsetmacro\dbp@lsranglesup{
asin(\dbp@radius/\dbp@lsrdalbr*2)}
\pgfmathsetmacro\dbp@lsrangone
{Mod(\dbp@lsralbr+\dbp@lsranglesup-\dbp@anga,360)}
\pgfmathsetmacro\dbp@lsrangtwo
{Mod(\dbp@lsralbr+\dbp@lsranglesup-\dbp@angb,360)}
\pgfmathsetmacro\dbp@lsrlen{veclen(\dbp@lsrdalbr,\dbp@radius)}
\pgfmathsetmacro\dbp@lsrdist{
angtodist(\dbp@lsrangone,\dbp@radius)
+\dbp@lsrlen
+angtodist(\dbp@lsrangtwo,\dbp@radius)
}
\dbp@updateparams%
{lsr}{\dbp@lsrdist}{\dbp@lsrangone}{\dbp@lsrlen}{\dbp@lsrangtwo}
}{}
% LRL (al and bl)
\dbp@distancebetween\dbp@lrldalbl{\p{al}}{\p{bl}}
\pgfmathtruncatemacro\dbp@lrlok{(\dbp@lrldalbl<=4*\dbp@radius)?1:0}
\ifnumequal{\dbp@lrlok}{1}{
\dbp@anglebetween\dbp@lrlalbl{\p{al}}{\p{bl}}
\pgfmathsetmacro\dbp@lrlangsup{acos(\dbp@lrldalbl/\dbp@radius/4)}
\pgfmathsetmacro\dbp@lrlangone{
modangl(\dbp@lrlalbl+\dbp@lrlangsup,\dbp@anga-90)-(\dbp@anga-90)}
\pgfmathsetmacro\dbp@lrlangtwo{%
(\dbp@angb-90)-modangr(\dbp@lrlalbl+180-\dbp@lrlangsup,\dbp@angb-90)}
\pgfmathsetmacro\dbp@lrlangthree{360-2*(90-\dbp@lrlangsup)}
\pgfmathsetmacro\dbp@lrldist{
angtodist(\dbp@lrlangone,\dbp@radius)
+angtodist(\dbp@lrlangthree,\dbp@radius)
+angtodist(\dbp@lrlangtwo,\dbp@radius)
}
\dbp@updateparams%
{lrl}{\dbp@lrldist}{\dbp@lrlangone}{\dbp@lrlangthree}{\dbp@lrlangtwo}
}{}
% RLR (ar and br)
\dbp@distancebetween\dbp@rlrdarbr{\p{ar}}{\p{br}}
\pgfmathtruncatemacro\dbp@rlrok{(\dbp@rlrdarbr<=4*\dbp@radius)?1:0}
\ifnumequal{\dbp@rlrok}{1}{
\dbp@anglebetween\dbp@rlrarbr{\p{ar}}{\p{br}}
\pgfmathsetmacro\dbp@rlrangsup{acos(\dbp@rlrdarbr/\dbp@radius/4)}
\pgfmathsetmacro\dbp@rlrangone{
(\dbp@anga+90)-modangr(\dbp@rlrarbr-\dbp@rlrangsup,\dbp@anga+90)}
\pgfmathsetmacro\dbp@rlrangtwo{%
modangl(\dbp@rlrarbr+180+\dbp@rlrangsup,\dbp@angb+90)-(\dbp@angb+90)}
\pgfmathsetmacro\dbp@rlrangthree{360-2*(90-\dbp@rlrangsup)}
\pgfmathsetmacro\dbp@rlrdist{
angtodist(\dbp@rlrangone,\dbp@radius)
+angtodist(\dbp@rlrangthree,\dbp@radius)
+angtodist(\dbp@rlrangtwo,\dbp@radius)
}
\dbp@updateparams%
{rlr}{\dbp@rlrdist}{\dbp@rlrangone}{\dbp@rlrangthree}{\dbp@rlrangtwo}
}{}
\endpgfinterruptpath
};
\endgroup
}
\endinput
%%
%% End of file `tikzlibrarydubins.code.tex'.
|