summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/pst-intersect/pst-intersect.dtx
blob: a02dfd06933aa66431993479d958c6d30b099de4 (plain)
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
% \iffalse meta-comment
%
% Copyright (C) 2014 by Christoph Bersch <usenet@bersch.net>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% 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.3c or later is part of all distributions of LaTeX
% version 2008/05/04 or later.
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{pst-intersect.dtx}
%</driver>
%<stylefile>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<stylefile>\ProvidesPackage{pst-intersect}
%<*stylefile>
    [2014/02/26 v0.2 package wrapper for pst-intersect.tex]
%</stylefile>
%
%<*driver>
\documentclass[a4paper, DIV=9, oneside, toc=index, parskip=half-]{scrreprt}
\usepackage{doc}
\setcounter{IndexColumns}{2}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage{amsmath, marvosym} 
\usepackage{bera}
\providecommand*\mainlang{}
\usepackage[ngerman, english,\mainlang]{babel}
\usepackage{prettyref}
\usepackage[dvipsnames,x11names,svgnames]{xcolor}
\usepackage{ragged2e, calc}
\newlength{\PITcaptionmargin}
\newlength{\PITcaptionheight}
\usepackage[labelfont={color=DOrange}, 
            singlelinecheck=false, 
            justification=raggedright]{caption} 
\DeclareCaptionFormat{pitnocaption}{%
  \setlength{\PITcaptionmargin}{\widthof{#1}+7pt}%
  \setlength{\PITcaptionheight}{\heightof{#1}+3pt}%
  \hspace*{-\PITcaptionmargin}#1\par\vspace*{-\PITcaptionheight}%
}%
\DeclareCaptionFormat{pitcaption}{%
  \setlength{\PITcaptionmargin}{\widthof{#1}+7pt}%
  \hspace*{-\PITcaptionmargin}#1#2#3\par
}%
\captionsetup[lstlisting]{format=pitnocaption}
\usepackage{multido}
\usepackage{pst-intersect}
\usepackage{hypdoc}
\hypersetup{%
  colorlinks=true, 
  urlcolor=DOrange, 
  linkcolor=pdflinkcolor, 
  breaklinks,
  linktocpage=true} 
\usepackage{breakurl}
\definecolor{DOrange}{rgb}{1,.4,.2}%
\definecolor{DDOrange}{rgb}{0.7, 0.23, 0.07}%
\colorlet{pdflinkcolor}{DOrange}
\usepackage{showexpl}
\makeatletter\renewcommand*\SX@Info{}\makeatother
\usepackage{etoolbox}
\undef{\cs}\undef{\cmd}
\usepackage{ltxdockit}
\definecolor{colKeys}{rgb}{0,0,0}
\definecolor{colIdentifier}{rgb}{0,0,0}
\colorlet{colComments}{green!60!black}
\definecolor{colString}{rgb}{0,0.5,0}
\newlength{\codeoverhang}
\setlength{\codeoverhang}{0.5\marginparwidth+\marginparsep}
\lstset{%
  language=[LaTeX]TeX, identifierstyle=\color{colIdentifier},
  keywordstyle=\color{colKeys},
  keywordstyle = [21]\color{DOrange},
  keywordstyle = [22]\color{DOrange},
  stringstyle=\color{colString},
  commentstyle=\color{colComments},
  alsoletter={12},
  float=hbp,
  basicstyle=\ttfamily\small,
  columns=flexible,
  tabsize=4,
  showspaces=false,
  showstringspaces=false,
  breaklines=true,
  breakautoindent=true,
  breakatwhitespace=true,
  captionpos=t,
  belowcaptionskip=0pt,
  abovecaptionskip=0pt,
  xleftmargin=1em,
  prebreak = {\raisebox{-0.5ex}[\ht\strutbox]{\kern0.5ex\large\Righttorque}},
  rulecolor=\color{black!20}, 
  texcsstyle = [20]\color{DDOrange},
  moretexcs = [20]{pssavebezier, pssavepath, pstracecurve, psintersect},
  explpreset={%
    pos=l, width=-99pt, hsep=5mm, overhang=\codeoverhang, varwidth,
    vsep=\bigskipamount, rframe={}}, extendedchars=true
}%
\lstdefinestyle{example}{explpreset={%
    escapechar=*, pos=l, width=-99pt, hsep=5mm, overhang=\codeoverhang,
    varwidth, vsep=\bigskipamount, rframe={}}}
\makeatletter
\providecommand\ON{%
  \gdef\lst@alloverstyle##1{\textcolor{black!50}{\strut##1}%
}}
\providecommand\OFF{\xdef\lst@alloverstyle##1{##1}}
\makeatother
\colorlet{sectioncolor}{DOrange}
\addtokomafont{sectioning}{\color{sectioncolor}}
\usepackage[automark,nouppercase]{scrpage2}
\pagestyle{scrheadings}
\clearscrheadings
\clearscrplain
\ohead{\pagemark}
\ihead{\headmark}
\ofoot[\pagemark]{}
\automark[subsection]{section}
\setheadsepline{.4pt}[\color{DOrange}]
\setheadwidth[0pt]{text}
\setfootwidth[0pt]{text}
\makeatletter
\patchcmd{\l@chapter}{1.5em}{2em}{}{}
\renewcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{3.0em}}
\renewcommand*\l@subsection{\bprot@dottedtocline{2}{3.8em}{4.0em}}
\newrobustcmd*{\fnurl}[1][]{\hyper@normalise\ltd@fnurl{#1}}
\def\ltd@fnurl#1#2{\footnote{#1\hyper@linkurl{\Hurl{#2}}{#2}}}
\newrobustcmd*{\arxivurl}[1]{\href{http://arxiv.org/abs/#1}{arXiv:#1}}
\newrobustcmd*{\doiurl}[1]{\href{http://dx.doi.org/#1}{DOI:#1}}
\makeatother
\usepackage{csquotes}
\MakeAutoQuote{«}{»}
%^^A spot is used in ltxdockit.sty
\colorlet{spot}{sectioncolor}
%^^A Fonts definitions used in ltxdockit.sty
\renewcommand*{\verbatimfont}{\ttfamily}
\renewcommand*{\displayverbfont}{\ttfamily}
\renewcommand*{\marglistfont}{\spotcolor\sffamily\small}
\renewcommand*{\margnotefont}{\sffamily\small}
\renewcommand*{\optionlistfont}{\spotcolor\sffamily\displayverbfont}
\renewcommand*{\ltxsyntaxfont}{\ttfamily}
\renewcommand*{\ltxsyntaxlabelfont}{\spotcolor\displayverbfont}
\renewcommand*{\changelogfont}{\normalfont}
\renewcommand*{\changeloglabelfont}{\spotcolor\sffamily\bfseries}

\makeatletter
\renewenvironment*{ltxsyntax}
  {\list{}{%
     \setlength{\labelwidth}{\marglistwidth}%
     \setlength{\labelsep}{0pt}%
     \setlength{\leftmargin}{0pt}%
     \renewcommand*{\makelabel}[1]{%
       \hss\ltxsyntaxfont\ltxsyntaxlabelfont##1}}%
   \let\cmditem\PIT@cmditem}
  {\endlist}

\def\ltd@optionlist{%
  \let\optitem\PIT@optitem
  \let\valitem\PIT@valitem
  \let\choitem\PIT@choitem
  \let\boolitem\PIT@boolitem
  \let\intitem\PIT@intitem
  \let\numitem\PIT@numitem
  \let\psnumitem\PIT@psnumitem
  \let\pititem\ltd@item
  \let\typeitem\PIT@typeitem}

\def\PIT@typeitem#1#2{%
  \item[{#1}]%
  \label{prm:#1}%
  \begingroup\raggedright
  #2%
  \settowidth\@tempdimb{\prm{psstyle}}%
  \settowidth\@tempdimc{#1}%
  \@tempdimc=\dimexpr\@tempdimc+\labelsep-\labelwidth\relax
  \ifdim\@tempdimc>0pt%
    \@tempdima=\dimexpr\linewidth-\@tempdimb-\@tempdimc-1em\relax
  \else
    \@tempdima=\dimexpr\linewidth-\@tempdimb-1em\relax
  \fi
  \par\endgroup}

\def\PIT@option#1#2#3{%
  \item[#1]%
  \begingroup\raggedright
  \ltd@textverb{=}%
  \settowidth\@tempdimb{\ltd@textverb{=}}%
  \settowidth\@tempdimc{#1}%
  \@tempdimc=\dimexpr\labelwidth-\@tempdimc\relax
  \ifdim\@tempdimc<0pt
    \@tempdima=\dimexpr\linewidth-\@tempdimb+\@tempdimc-2em\relax
  \else
    \@tempdima=\dimexpr\linewidth-\@tempdimb-2em\relax
  \fi
  \ifblank{#3}
    {}
    {\settowidth\@tempdimb{default: #3}%
     \@tempdima=\dimexpr\@tempdima-\@tempdimb-2em\relax}%
  \parbox[t]{\@tempdima}{\raggedright #2}%
  \ifblank{#3}
    {}
    {\hfill default:~#3}%
  \par\endgroup
  \nobreak\vspace{\itemsep}}

\def\PIT@optitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@optitem@i}
    {\booltrue{@tempswa}\PIT@optitem@i}}
\newcommand*{\PIT@optitem@i}[3][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{#3}{}}
    {\PIT@option{#2}{#3}{\ltd@textverb{#1}}}}%

\def\PIT@valitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@valitem@i}
    {\booltrue{@tempswa}\PIT@valitem@i}}
\newcommand*{\PIT@valitem@i}[3][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{\prm{#3}}{}}
    {\PIT@option{#2}{\prm{#3}}{\ltd@textverb{#1}}}}%

\def\PIT@choitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@choitem@i}
    {\booltrue{@tempswa}\PIT@choitem@i}}
\newcommand*{\PIT@choitem@i}[3][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{\ltd@verblist{#3}}{}}
    {\PIT@option{#2}{\ltd@verblist{#3}}{\ltd@textverb{#1}}}}%

\def\PIT@boolitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@boolitem@i}
    {\booltrue{@tempswa}\PIT@boolitem@i}}
\newcommand*{\PIT@boolitem@i}[2][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{\ltd@verblist{true,false}}{}}
    {\PIT@option{#2}{\ltd@verblist{true,false}}{\ltd@textverb{#1}}}}%

\def\PIT@intitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@intitem@i}
    {\booltrue{@tempswa}\PIT@intitem@i}}
\newcommand*{\PIT@intitem@i}[2][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{\prm{int}}{}}
    {\PIT@option{#2}{\prm{int}}{\ltd@textverb{#1}}}}%

\def\PIT@numitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@numitem@i}
    {\booltrue{@tempswa}\PIT@numitem@i}}
\newcommand*{\PIT@numitem@i}[2][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{\prm{num}}{}}
    {\PIT@option{#2}{\prm{num}}{\ltd@textverb{#1}}}}%

\def\PIT@psnumitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@psnumitem@i}
    {\booltrue{@tempswa}\PIT@psnumitem@i}}
\newcommand*{\PIT@psnumitem@i}[2][]{%
  \ifbool{@tempswa}%
    {\label{prm:#2}\xdefLkeyword{#2}}%
    {\xLkeyword{#2}}%
  \ifblank{#1}
    {\PIT@option{#2}{\prm{psnum}}{}}
    {\PIT@option{#2}{\prm{psnum}}{\ltd@textverb{#1}}}}%

\def\ltd@csitem{%
  \@ifstar
    {\boolfalse{@tempswa}\ltd@csitem@i}
    {\booltrue{@tempswa}\ltd@csitem@i}}
\def\ltd@csitem@i#1{%
  \ifbool{@tempswa}
    {\ltd@item@ii{\textbackslash#1\hspace\marglistsep}{#1}}
    {\ltd@item@ii{\textbackslash#1\hspace\marglistsep}{}}}

\def\PIT@cmditem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@cmditem@i}
    {\booltrue{@tempswa}\PIT@cmditem@i}}
\def\PIT@cmditem@i#1{%
  \ifbool{@tempswa}
    {\PIT@cmditem@ii{\textbackslash#1}{cs:#1}}
    {\PIT@cmditem@ii{\textbackslash#1}{}}}
\def\PIT@compitem{%
  \@ifstar
    {\boolfalse{@tempswa}\PIT@compitem@i}
    {\booltrue{@tempswa}\PIT@compitem@i}}
\def\PIT@compitem@i#1{%
  \ifbool{@tempswa}
    {\PIT@cmditem@ii{\textbackslash#1}{comp:#1}}
    {\PIT@cmditem@ii{\textbackslash#1}{}}}
\def\PIT@cmditem@ii#1#2{%
  \ltd@itemsave
  \ifhmode
    \itemsep-\topsep
  \else
    \ltd@itembreak
  \fi
  \item[#1]%
  \ltd@itemrest
  \ifblank{#2}{}{\label{#2}}%
  \begingroup
  \ltd@syntaxsetup
  \ltxsyntaxfont
  \let\@tempa\@empty
  \ltd@parseargs}

\def\ltd@csitem@ii#1#2{%
  \ltd@itemsave
  \ifhmode
    \itemsep-\topsep
  \else
    \ltd@itembreak
  \fi
  \item[#1]%
  \ltd@itemrest
  \ifblank{#2}{}{\label{cs:#2}}%
  \begingroup
  \ltd@syntaxsetup
  \ltxsyntaxfont
  \let\@tempa\@empty
  \ltd@parseargs}


\let\plainllap\llap
\newrobustcmd\macro@llap[1]{{\global\let\llap\plainllap
 \setbox0=\hbox\bgroup \macro@font\small\saved@macroname\egroup
 \ifdim\wd0>30mm
    \hbox to\z@ \bgroup\hss \hbox to30mm{\unhcopy0\hss}\egroup
    \edef\@tempa{\hskip\dimexpr\the\wd0-30mm}\global\everypar\expandafter{\the\expandafter\everypar
                                                                           \@tempa \global\everypar{}}%
 \else \llap{\unhbox0}\fi}}
 \AtBeginEnvironment{macro}{\let\llap\macro@llap}
\makeatother

\newcommand*{\PSstring}[1]{{\normalfont\small\ttfamily(#1)}}
\newcommand*{\PSarray}[1]{{\normalfont\small\ttfamily[#1]}}
\newcommand*{\PSname}[1]{{\normalfont\small\ttfamily/#1}}
\newcommand*{\PSproc}[1]{{\normalfont\small\ttfamily\textbraceleft #1\textbraceright}}
\newcommand*{\PSvar}[1]{{\normalfont\small\ttfamily #1}}
\newcommand*{\PSop}[1]{{\normalfont\small\ttfamily\color{DOrange}\hskip 3pt #1\hskip 3pt}}

\newcommand*{\compref}[1]{\ref{comp:#1}}
\newcommand*{\hyperpagedef}[1]{\textbf{\hyperpage{#1}}}
\newcommand*{\nodename}[1]{\emph{#1}}
\newcommand*{\param}[1]{\normalfont\texttt{#1}}
\newcommand*{\paramvalue}[1]{\texttt{#1}}
\newcommand*{\styleshape}[1]{\texttt{#1}}
\newcommand{\docindex}[1]{\sindex[doc]{#1|hyperpage}}
\newcommand{\docindexdef}[1]{\sindex[doc]{#1|hyperpagedef}}
\makeatletter
\def\Lcs{\@ifstar{\Lcs@nobm}{\Lcs@bm}}
\def\Lcs@nobm#1{\nxLcs{#1}\xLcs{#1}}
\def\Lcs@bm#1{\hyperref[cs:#1]{\Lcs@nobm{#1}}}
\def\xLcs#1{}
\def\nxLcs#1{\texttt{\textbackslash#1}}

\def\Lcomp{\@ifstar{\Lcomp@nobm}{\Lcomp@bm}}
\def\Lcomp@nobm#1{\nxLcomp{#1}\xLcomp{#1}}
\def\Lcomp@bm#1{\hyperref[comp:#1]{\Lcomp@nobm{#1}}}
\def\xLcomp#1{}
\def\nxLcomp#1{\texttt{\textbackslash#1}}

\def\LPack#1{\nxLPack{#1}}
\def\nxLPack#1{\texttt{#1}}

\def\Lenv{\@ifstar{\Lenv@nobm}{\Lenv@bm}}
\def\Lenv@nobm#1{\nxLenv{#1}\xLenv{#1}}
\def\Lenv@bm#1{\hyperref[env:#1]{\Lenv@nobm{#1}}}
\def\xLenv#1{}
\def\nxLenv#1{\texttt{#1}}
\let\orig@ltd@envitem\ltd@envitem
\def\ltd@envitem#1{\orig@ltd@envitem{#1}\label{env:#1}\xLenv{#1}}

\def\Lkeyword{\@ifstar{\Lkeyword@nobm}{\Lkeyword@bm}}
\def\Lkeyword@nobm#1{\nxLkeyword{#1}\xLkeyword{#1}}
\def\Lkeyword@bm#1{\hyperref[prm:#1]{\Lkeyword@nobm{#1}}}
\def\xLkeyword#1{}
\def\xdefLkeyword#1{}
\def\nxLkeyword#1{\texttt{#1}}

\def\xLoption#1{}
\def\Loption#1{\texttt{#1}\xLoption{#1}}
\def\nxLoption#1{\texttt{#1}}

\def\Lstyle{\@ifstar{\Lstyle@nobm}{\Lstyle@bm}}
\def\Lstyle@nobm#1{\nxLstyle{#1}\xLstyle{#1}}
\def\Lstyle@bm#1{\hyperref[sty:#1]{\Lstyle@nobm{#1}}}
\def\xLstyle#1{}
\def\xdefLstyle#1{}
\def\nxLstyle#1{\texttt{#1}}

\makeatother

\newcommand{\dipoledesc}[1]{%
  \xLdipole{#1}%
  \compitem{#1}[options](in)(out){label}%
}
\newcommand{\tripoledesc}[1]{%
  \xLtripole{#1}%
  \compitem{#1}[options](in)(center)(out){label}%
}

\newcommand{\fiberdipoledesc}[1]{%
  \xLfdipole{#1}%
  \compitem{#1}[options](in)(out){label}%
}

\newenvironment*{pssyntax}
  {\list{}{\small
     \setlength{\labelsep}{0pt}%
     \setlength{\leftmargin}{10pt}%
     \item[]}}
  {\endlist}

\newcommand{\psarglistfont}{\small}
\newenvironment*{psarglist}
  {\list{}{%
     \setlength{\labelwidth}{10pt}%
     \setlength{\labelsep}{0pt}%
     \setlength{\leftmargin}{0pt}%
     \setlength{\itemsep}{\parsep}%
     \setlength{\parsep}{0pt}%
     \renewcommand*{\makelabel}[1]{\hss\psarglistfont##1}}}
  {\endlist}

\makeatletter
\renewenvironment{theglossary}{\GlossaryParms \let\item\@idxitem \ignorespaces}{}
\makeatother
\def\psargitem#1{\item[#1]\hfill\par\nobreak}

\addtopsstyle{Fiber}{linecolor=DOrange,linewidth=1.5\pslinewidth}
\addtopsstyle{Beam}{linewidth=1.5\pslinewidth}
\EnableCrossrefs
\CodelineIndex
\OnlyDescription
\begin{document}
  \DocInput{pst-intersect.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \GetFileInfo{pst-intersect.dtx}
%
% \newif\ifGERMAN  \GERMANfalse
% \newif\ifENGLISH \ENGLISHfalse
% \iflanguage{ngerman}{\GERMANtrue}{%
%   \iflanguage{german}{\GERMANtrue}{\GERMANfalse}}
% \iflanguage{english}{\ENGLISHtrue}{\ENGLISHfalse}
%
% \ifGERMAN
%   \newrefformat{chap}{Kap.~\ref{#1}}
%   \newrefformat{sec}{Kap.~\ref{#1}}
%   \newrefformat{l}{Zeile~\ref{#1}}
%   \newrefformat{ex}{Bsp.~\ref{#1}}
%   \newrefformat{tab}{Tab.~\ref{#1}}
%   \newrefformat{fig}{Abb.~\ref{#1}}
%   \newcommand{\PITindexMacro}{Makros}
%   \newcommand{\PITindexKeyword}{Parameter}
%   \newcommand{\PITindexEnv}{Umgebungen}
%   \newcommand{\PITindexPack}{Pakete}
%   \renewcommand*\lstlistingname{Bsp.}
% \fi
% \ifENGLISH
%   \newrefformat{chap}{Sec.~\ref{#1}}
%   \newrefformat{sec}{Sec.~\ref{#1}} 
%   \newrefformat{l}{Line~\ref{#1}}
%   \newrefformat{ex}{Ex.~\ref{#1}}
%   \newrefformat{tab}{Tab.~\ref{#1}}
%   \newrefformat{fig}{Fig.~\ref{#1}}
%   \newcommand{\PITindexMacro}{macros}
%   \newcommand{\PITindexKeyword}{parameters}
%   \newcommand{\PITindexEnv}{environments}
%   \newcommand{\PITindexPack}{packages}
%   \renewcommand*\lstlistingname{Ex.}
% \fi
%
% \makeatletter
% \renewcommand\maketitle{^^A
% \thispagestyle{empty}^^A
% \begin{titlepage}
% \begin{pspicture}(1.6in,0.685in)(10,21.7)
%   \psframe[fillstyle=solid,linecolor=lightgray,fillcolor=lightgray,linestyle=solid](0,-5.75)(21.5,10)
%   \psframe[fillstyle=solid,linecolor=Orange!85!Red,fillcolor=Orange!85!Red,linestyle=solid](0,10)(21.5,10.5)
%   \psframe[fillstyle=solid,linecolor=Orange!85!Red,fillcolor=Orange!85!Red,linestyle=solid](0,21.1)(21.5,21.2)
%   \rput[lb](3,22){\Huge\sffamily\color{Orange!65!Red}\psscalebox{2}{\textbf{PSTricks}}}
%   \rput[lb](3,14.1){\parbox{15cm}{\sffamily\RaggedRight\bfseries\huge\@title}}
%   \rput[lb](3,7.6){\parbox{13cm}{\sffamily\@date}}
%   \rput[lb](3,-2.6){\parbox[b]{17cm}{\sffamily\RaggedRight 
%     ~\hfill\makebox[7cm][l]{\ifGERMAN Paketautor:\fi\ifENGLISH Package author:\fi}\\
%     ~\hfill\makebox[7cm][l]{^^A
%       \bfseries\tabular[t]{@{}l@{}}\@author\endtabular}}}
%  \rput[C](11,4){\bgImage}
%  \end{pspicture}^^A
% \end{titlepage}}
% \makeatother
% 
% \ifGERMAN
%   \title{\texttt{pst-intersect}\\ Berechnen der Schnittpunkte beliebiger Kurven\\[0.5ex] \small \fileversion}
%   \hypersetup{pdftitle={Berechnen der Schnittpunkte beliebiger Kurven}}
% \fi
% \ifENGLISH
%   \title{\texttt{pst-intersect}\\ Intersecting arbitrary curves\\[0.5ex] \small \fileversion}
%   \hypersetup{pdftitle={Intersecting arbitrary curves}}
% \fi
% \author{Christoph Bersch}
% \date{\filedate}
% \def\bgImage{}
%
% \maketitle
% 
% \clearpage
% \tableofcontents
% \clearpage
% 
% \ifGERMAN
%   \chapter{Einführung}
% \fi
% \ifENGLISH
%   \chapter{Introduction}
% \fi
% 
% \ifGERMAN
%   \section{Über das Paket}
%
%   \LPack{pst-intersect} ist ein PSTricks-Paket zur
%   Berechnung der Schnittpunkte von Bézier-Kurven und beliebigen
%   Postscript-Pfaden.
%
%   Beachten Sie, dass die Paket-Versionen 0.x sich in einem
%   experimentellen Status befinden, und sich grundlegende Änderungen
%   ergeben können, die zur Vorgängerversion inkompatibel sind.
% \fi 
% \ifENGLISH
%   \section{About the package}
%   \LPack{pst-intersect} is a PSTricks package to calculate
%   the intersections of Bezier curves and arbitrary Postscript paths.
%
%   Please note, that package versions 0.x are experimental, and may be
%   subject to fundamental changes, which aren't backward compatible.
% \fi
%
% \ifGERMAN
%   \section{Anforderungen}
%   \LPack{pst-intersect} benötigt aktuelle Versionen der
%   Pakete \LPack{pstricks}, \LPack{pst-node} und \LPack{pst-func}.
%
%   Alle PSTricks-Pakete machen regen Gebrauch von der Postscript-Sprache, so
%   dass der typische Arbeitsfluss \opt{latex}, \opt{dvips} und
%   ggf. \opt{ps2pdf} umfasst. Es gibt viele alternative Methoden um die
%   Dokumente zu
%   kompilieren.\fnurl{http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput}
% \fi
% \ifENGLISH
%   \section{Requirements}
%   \LPack{pst-intersect} requires recent versions of
%   \LPack{pstricks}, \LPack{pst-node}, and \LPack{pst-func}.
%
%   All PSTricks package rely heavily on the Postscript language so that the
%   typical workflow involves \opt{latex}, \opt{dvips}, and \opt{ps2pdf}. Of
%   course there are several alternative ways to compile your
%   documents.\fnurl{http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput} 
% \fi
%
% \ifGERMAN
%   \section{Verbreitung und Installation}
%   Dieses Paket ist auf
%   CTAN\fnurl{http://mirror.ctan.org/help/Catalogue/entries/pst-intersect.html}
%   erhältlich.
% 
%   Das \LPack{pst-intersect}-Paket umfasst die zwei Hauptdateien
%   \texttt{pst-intersect.ins} und \texttt{pst-intersect.dtx}. Durch Aufrufen
%   von \texttt{tex pst-intersect.ins} werden die drei folgenden
%   Dateien erzeugt:
%   \begin{itemize}
%   \item \texttt{pst-intersect.pro}: die Postscript Prologdatei
%   \item \texttt{pst-intersect.sty}: die \LaTeX-Stildatei
%   \item \texttt{pst-intersect.tex}: die \TeX-Datei
%   \end{itemize}
%   Speichern Sie diese Dateien in einem Verzeichnis der Teil Ihres
%   lokalen \TeX-Baums ist.
% 
%   Vergessen Sie nicht \texttt{texhash} aufzurufen um den Baum zu
%   aktualisieren. MiK\TeX{}-Benutzer müssen die Dateinamen-Datenbank
%   (FNDB) aktualisieren.
% 
%   Detailliertere Information finden Sie in der Dokumentation Ihrer
%   \LaTeX-Distribution über die Installation in den lokalen
%   \TeX{}-Baum.
% \fi
% \ifENGLISH
%   \section{Distribution and installation}
%   This package is available on
%   CTAN\fnurl{http://mirror.ctan.org/help/Catalogue/entries/pst-intersect.html}.
% 
%   The \LPack{pst-intersect} package consists of the two main files
%   \texttt{pst-intersect.ins} and \texttt{pst-intersect.dtx}. By running \texttt{tex
%   pst-intersect.ins} the following derived files are generated:
%   \begin{itemize}
%   \item \texttt{pst-intersect.pro}: the Postscript prolog file
%   \item \texttt{pst-intersect.sty}: the \LaTeX{} style file
%   \item \texttt{pst-intersect.tex}: the \TeX{} file
%   \end{itemize}
%   Save the files in a directory which is part of your local \TeX{} tree.
% 
%   Do not forget to run \texttt{texhash} to update this tree. For MiK\TeX{}
%   users, do not forget to update the file name database (FNDB).
% 
%   For more detailed information see the documentation of your personal
%   \LaTeX{} distribution on installing packages to your local \TeX{}
%   system.
% \fi
%
% \ifGERMAN\section{Lizenz}\fi
% \ifENGLISH\section{License}\fi
% \ifGERMAN
% Es wird die Erlaubnis gewährt, dieses Dokument zu kopieren, zu verteilen
% und\slash oder zu modifizieren, unter den Bestimmungen der \LaTeX{} Project
% Public License, Version
% 1.3c.\fnurl{http://www.latex-project.org/lppl.txt}. Dieses
% Paket wird vom Autor betreut (author-maintained).
% \fi
% \ifENGLISH
% Permission is granted
% to copy, distribute and\slash or modify this software under the terms of the
% \LaTeX{} Project Public License, version
% 1.3c.\fnurl{http://www.latex-project.org/lppl.txt} This
% package is author-maintained.
% \fi
%
% \ifGERMAN
%   \section{Danksagung}
% \fi
% \ifENGLISH
%   \section{Acknowledgements}
% \fi
% \ifGERMAN
% Ich danke Marco Cecchetti, dessen
% \opt{lib2geom}-Bibliothek\fnurl{http://lib2geom.sourceforge.net/}
% mir als Vorlage für einen Großteil des Postscript-Kodes für den
% Bézier-Clipping-Algorithmus diente. Außerdem gilt mein Dank William
% A. Casselman, für seine Erlaubnis, den Quicksort-Kode und den Kode zur
% Berechung der konvexen Hüllen aus seinem Buch «Mathematical
% Illustration» verwenden zu
% dürfen\fnurl{http://www.math.ubc.ca/~cass/graphics/text/www/}. Der
% Dokumentationsstil ist eine Mischung aus der \opt{pst-doc} Klasse
% (Herbert Voß) und dem \opt{ltxdockit} Paket für die \opt{biblatex}
% Dokumentation (Philipp Lehmann).
% \fi
% \ifENGLISH
% I thank Marco Cecchetti, for his
% \opt{lib2geom}-library\fnurl{http://lib2geom.sourceforge.net/} from
% which I derived great parts of the Postscript code for the Bézier
% clipping algorithm. Also I want to thank William A. Casselman for the
% Postscript code of the quicksort procedure and the procedure for
% calculating the convex hull from his book «Mathematical
% Illustration»\fnurl{http://www.math.ubc.ca/~cass/graphics/text/www/},
% and the permission to use it. The documentation style is a mixture of
% the \opt{pst-doc} class (Herbert Voß) and the \opt{ltxdockit} package
% for the \opt{biblatex} documentation (Philipp Lehman).
% \fi
%
%
% \ifGERMAN
% \chapter{Benutzung}
% \fi
% \ifENGLISH
% \chapter{Usage}
% \fi
%
% \ifGERMAN
% Das \LPack{pst-intersect}-Paket kann Schnittpunkte von beliebigen
% Postscript-Pfaden berechnen. Diese setzen sich nur aus drei primitiven
% Operation zusammen: Linien (\opt{lineto}), Bézier-Kurven dritter
% Ordnung (\opt{curveto}) und Sprüngen (\opt{moveto}). Speziellere
% Konstruktionen, wie z.B. Kreise werden intern zu
% \opt{curveto}-Anweisungen umgewandelt. Über diese Kommandos hinaus
% kann \LPack{pst-intersect} auch Bézier-Kurven bis neunter Ordnung
% verwenden. Das diese keine primitiven Postscript-Pfadelemente
% darstellen, müssen sie gesondert behandelt werden.
%
% Der allgemeine Arbeitsablauf besteht darin eine oder mehrere Kurven
% oder Pfade zu speichern, und danach die Schnittpunkte zu
% berechnen. Anschließend können die Schnittpunkte als normale
% PSTricks-Knoten verwendet werden, oder Abschnitte der Kurven und Pfade
% nachgezogen werden (z.B. zwischen zwei Schnittpunkten). 
% \fi
% \ifENGLISH
% The \LPack{pst-intersect} package can compute the intersections of
% arbitrary Postscript paths. These are composed of three primitive
% operations: lines (\opt{lineto}), third order Bézier curves
% (\opt{curveto}) and jumps (\opt{moveto}). More specialized
% constructions, like circles, are converted internally to \opt{curveto}
% operations. Besides these three path operations, the
% \LPack{pst-intersect} supports Bézier curves up to nineth order. As
% these aren't primitive Postscript path elements, they require separate
% handling.
%
% The general workflow consists in defining and saving paths and curves,
% and then compute the intersections between them. Following, those
% intersection points can be used as normal PSTricks nodes, or portions
% of the curves and paths can be retraced (e.g. between two
% intersections).
% \fi
%
% \ifGERMAN
% \section{Speichern von Pfaden und Kurven}
% \fi
% \ifENGLISH
% \section{Saving paths and curves}
% \fi
%
% \ifGERMAN
% 
% \fi
%
% \begin{ltxsyntax}
%   \cmditem{pssavepath}[options]{curvename}{commands} 
%   
%   \ifGERMAN
%   Speichert den gesamten Pfad, der durch \prm{commands} erstellt wird,
%   unter Verwendung des Namens \prm{curvename}. Das Makro funktioniert
%   genauso wie \cs{pscustom}, und kann daher auch nur die darin
%   erlaubten Kommandos verarbeiten.
%
%   In den Standardeinstellungen wird der entsprechende Pfad auch gleich
%   gezeichnet, was mit \prm{options} beeinflusst werden kann. Mit
%   \opt{linestyle=none} wird das unterbunden.
%   \fi
%   \ifENGLISH
%   Saves the complete path, which is generated by \prm{commands}, under
%   the name \prm{curvename}. The macro is a modification of
%   \cs{pscustom}, and does, therefore, supports only the same commands.
%
%   By default, the path is also drawn, which can be changed over the
%   \prm{options}, e.g. with \opt{linestyle=none}.
%   \fi
% \end{ltxsyntax}
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(3,2)
  \pssavepath[linecolor=DOrange]{MyPath}{%
    \pscurve(0,2)(0,0.5)(3,1)
  }%
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \begin{ltxsyntax}
%   \cmditem{pssavebezier}[options]{curvename}($X_0$)\ldots(\prm{$X_n$})
%
%   \ifGERMAN 
%   Die Postscript-Sprache unterstützt nur Bézier-Kurven dritter
%   Ordnung. Mit dem Makro \Lcs{pssavebezier} können Bézier-Kurven
%   bis neunter Ordnung definiert werden. Die angegebenen Knoten sind die
%   Kontrollpunkte der Kurve, für eine Kurve $n$-ter Ordnung werden
%   $(n+1)$ Kontrollpunkte benötigt. Die Darstellung der Kurve erfolgt
%   mit dem Makro \cs{psBezier} aus dem \LPack{pst-func}-Paket.
%   \fi
%   \ifENGLISH
%   The Postscript language supports only third-order Bézier
%   curves. With the macro \Lcs{pssavebezier} you can define Bézier
%   curves up to nineth order. The specified nodes are the control
%   points of the curve, for an $n$-th order curve $n+1$ control points
%   are required. The drawing of the curve is done with the
%   \cs{psBezier} macro from the \LPack{pst-func} package.
%   \fi
% \end{ltxsyntax}
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(3,2)
  \pssavebezier[showpoints]{MyBez}(0,0)(0,1)(1,2)(3,2)(1,0)(3,0)
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \ifGERMAN
% \section{Schnittpunkte berechnen}
% \fi
% \ifENGLISH
% \section{Calculating intersections}
% \fi
%
% \begin{ltxsyntax}
%   \cmditem{psintersect}{curveA}{curveB}
% 
%   \ifGERMAN
%   Nachdem Sie nun Pfade oder Kurven gespeichert haben, können Sie
%   deren Schnittpunkte berechnen. Das geschieht mit dem Makro
%   \Lcs{psintersect}. Dieses benötigt als Argumente zwei Namen von
%   Pfaden oder Kurven (Das Argument \prm{curvename} der beiden
%   \cs{pssave*} Makros).
%   \fi
%   \ifENGLISH
%   After having saved some paths and curves, you can now calculate the
%   intersections. That is done with the \Lcs{psintersect} macro. This
%   needs as arguments two names of paths or curves (the \prm{curvename}
%   argument of the two \cs{pssave*} macros).
%   \fi
% \end{ltxsyntax}
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(3,2)
  \pssavepath[linecolor=DOrange]{MyPath}{\pscurve(0,2)(0,0.5)(3,1)}
  \pssavebezier{MyBez}(0,0)(0,1)(1,2)(3,2)(1,0)(3,0)
  \psintersect[showpoints]{MyPath}{MyBez}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \ifGERMAN
% Der PSTricks-Parameter \opt{showpoints} steuert dabei, ob die
% Schnittpunkte angezeigt werden.
% \fi
% \ifENGLISH
% The \opt{showpoints} PSTricks parameter determines, if the
% intersections are drawn directly. 
% \fi
%
% \begin{optionlist}
% \valitem[@tmp]{name}{string}
% \ifGERMAN
% Die berechneten Schnittpunkte können unter einem hier angegebenen
% Namen gespeichert und zu einem späteren Zeitpunkt verwendet werden
% (siehe \prettyref{sec:pstracecurve-int}). 
% \fi
% \ifENGLISH
% The calculated intersections can be saved for later use under this
% name (see \prettyref{sec:pstracecurve-int}).
% \fi
%
% \boolitem[true]{saveintersections}
% \ifGERMAN
% Ist dieser Schalter gesetzt, dann werden die Schnittpunkte als
% PSTricks-Knoten unter den Namen \prm{name}1, \prm{name}2 \ldots
% gespeichert. Die Nummerierung erfolgt aufsteigend nach dem Wert der
% $x$-Koordinate.
% \fi
% \ifENGLISH
% If this option is set, the intersections are saved as PSTricks nodes
% with the names \prm{name}1, \prm{name}2 \ldots. The numbering is
% ascending according to the value of their $x$-coordinate.
% \fi
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}[caption={caption}, label={ex:saveintersections}]
\begin{pspicture}(5,5)
  \pssavebezier[linecolor=DOrange]{A}%
             (0,0)(0,5)(5,5)(5,1)(1,1.5)
  \pssavebezier{B}(0,5)(0,0)(5,0)(5,5)(0,2)
  \psintersect[name=C, showpoints]{A}{B}
  \uput[150](C1){1}
  \uput[85](C2){2}
  \uput[90](C3){3}
  \uput[-20](C4){4}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
% \end{optionlist}
%
% \ifGERMAN
% \section{Darstellung gespeicherter Pfade}
% \fi
% \ifENGLISH
% \section{Visualization of saved paths}
% \fi
%
% \begin{ltxsyntax}
%   \cmditem{pstracecurve}[options]{curvename}
%
% \ifGERMAN
% Gespeicherte Pfade und Kurven können mit diesem Makro nachträglich
% gezeichnet werden.
% \fi
% \ifENGLISH
% Saved paths and curves can be drawn again with this macro.
% \fi
% \end{ltxsyntax}
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(2,2)
  \pssavepath{Circle}{\pscircle(1,1){1}}
  \pstracecurve[linestyle=dashed, linecolor=green]{Circle}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \begin{optionlist}
% \numitem{tstart}
% \numitem{tstop}
%
% \ifGERMAN Unter Verwendung dieser beiden Parameter können auch
% Abschnitte von Pfaden und Kurven gezeichnet werden. Bei Bézier-Kurven
% ist der Parameterbereich $[0, 1]$, wobei $0$ dem Anfang der Kurve,
% also dem ersten bei \Lcs{pssavebezier} angegebenen Knoten entspricht.
% \fi
% \ifENGLISH
% With these parameters also parts of paths and curves can be drawn. For
% Bézier curves the allowed range is $[0, 1]$, where $0$ corresponds to
% the start of the curve, which is given by the first node given to
% \Lcs{pssavebezier}.
% \fi
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(5,5)
  \psset{showpoints}
  \pssavebezier{B}(0,5)(0,0)(5,0)(5,5)(0,2)
  \pstracecurve[linestyle=dashed, linecolor=blue!50,
               tstart=0, tstop=0.5]{B}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \medskip
% \ifGERMAN 
% Pfaden können aus mehr als einem Abschnitt bestehen, der Bereich ist
% also $[0, n]$, wobei $n$ die Anzahl der Pfadabschnitte ist. Dabei ist
% zu beachten, dass z.B. \cs{pscurve}-Pfade oder auch Kreise und
% Kreisbögen aus mehreren Abschnitten bestehen.
% \fi
% \ifENGLISH
% Paths can be composed of more than one segmet, and the range is $[0,
% n]$, where $n$ is the number of path segments. For this you must keep
% in mind, that also e.g \cs{pscurve} paths, circles or arcs consist of
% several segments.
% \fi
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(2,2)
  \pssavepath[linestyle=none]{Circle}{\pscircle(1,1){1}}
  \pstracecurve[tstart=0, tstop=1, linecolor=green]{Circle}
  \pstracecurve[tstart=2, tstop=3, linecolor=red]{Circle}
  \pstracecurve[tstart=1.25, tstop=1.75, linecolor=blue]{Circle}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \end{optionlist}
%
% \ifGERMAN
% Beachten Sie, dass die Reihenfolge von \Lkeyword{tstart} und
% \Lkeyword{tstop} eine Rolle spielt. Ist \Lkeyword{tstart}
% \textgreater{} \Lkeyword{tstop} dann wird die Pfadrichtung umgekehrt.
% \fi
% \ifENGLISH
% Please note, that the order of \Lkeyword{tstart} and \Lkeyword{tstop}
% plays a role. For \Lkeyword{tstart} \textgreater{} \Lkeyword{tstop}
% the path direction is reversed.
% \fi
%
% \iffalse
%<*ignore>
% \fi
\begin{LTXexample}
\begin{pspicture}(2,2)
  \psset{arrows=->, arrowscale=1.5}
  \pssavepath[linestyle=dashed, linewidth=0.5\pslinewidth]{A}{\psline(0,0)(1,2)(2,0)}
  \pstracecurve[tstart=0.1, tstop=0.9]{A}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\begin{pspicture}(2,2)
  \psset{arrows=->, arrowscale=1.5}
  \pssavepath[linestyle=dashed, linewidth=0.5\pslinewidth]{A}{\psline(0,0)(1,2)(2,0)}
  \pstracecurve[tstart=0.9, tstop=0.1]{A}
\end{pspicture}
\end{LTXexample}
% \iffalse
%</ignore>
% \fi
%
% \ifGERMAN
% \section{Darstellung gespeicherter Schnitte}
% \fi
% \ifENGLISH
% \section{Visualization of saved intersections}
% \fi
% \label{sec:pstracecurve-int}
%
% \begin{ltxsyntax}
% \cmditem*{pstracecurve}[options]{intersection}{curvename}
% \end{ltxsyntax}
% 
% \begin{optionlist}
% \numitem{istart}
% \numitem{istop}
%
% \ifGERMAN 
% Dieser beiden Parameter können auch verwendet werden um Abschnitte von
% Pfaden und Kurven zwischen Schnittpunkten zu zeichnen. Die
% Schnittpunkte werden dabei angefangen bei $1$ in aufsteigender
% Reihenfolge entlang der Kurve durchnummeriert.
% \fi
% \ifENGLISH
% These two parameters can be used to draw path or curve segments
% between intersections. The intersections are numbered starting at $1$
% in ascending order along the curve.
% \fi
% \end{optionlist}
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(5.2,5.2)
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{A}(0,0)(0,5)(5,2)(5,5)
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{B}(0,2.5)(2.5,2.5)(4.5, 3)(2,4)
\psintersect[linecolor=green!70!black, name=C]{A}{B}
\pstracecurve[linecolor=red, istart=1, istop=2]{C}{A}
\pstracecurve[linecolor=blue, istart=1, istop=2]{C}{B}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \ifGERMAN 
% Wird nur ein Wert angegeben, beispielsweise \Lkeyword{istop}, dann
% wird die Kurve vom Anfang bis zum entsprechenden Schnittpunkt
% gezeichnet. Wird nur \Lkeyword{istart} angegeben, dann endet die Kurve
% am Ende. Die Parameter \Lkeyword{istart} bzw. \Lkeyword{istop} können
% mit \Lkeyword{tstart} bzw. \Lkeyword{tstop} kombiniert werden.
% \fi
% \ifENGLISH
% If only one value is specified, e.g. \Lkeyword{istop}, the curve is
% drawn from the start to the respective intersection. If only
% \Lkeyword{istart} is given, the curve is drawn from this intersection
% to the curve end. The parameters \Lkeyword{istart} and
% \Lkeyword{istop} can be combined with \Lkeyword{tstart} and
% \Lkeyword{tstop}.
% \fi
%
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(5.2,5.2)
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{A}(0,0)(0,5)(5,2)(5,5)
\pssavebezier[linewidth=0.5\pslinewidth, linestyle=dashed, arrows=->]{B}(0,2.5)(2.5,2.5)(4.5, 3)(2,4)
\psintersect[linecolor=green!70!black, name=C]{A}{B}
\pstracecurve[linecolor=red, istop=2]{C}{A}
\pstracecurve[linecolor=blue, istart=1]{C}{B}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
%
% \begin{ltxsyntax}
%   \cmditem{psGetIsectCenter}{intersection}{curvename}{n}
%
%   \ifGERMAN 
%   Lädt die Koordinaten des $n$-ten Schnittpunkts des Pfades
%   \prm{curvename} in der Schnittmenge \prm{intersection}. Dabei
%   startet die Nummer der Schnittpunkte bei \prm{n}$=1$ und wird in
%   Pfadrichtung durchnummeriert.
% 
%   Die Schnittpunkte können mit \Lkeyword{saveintersections}\opt{=true}
%   natürlich auch über \cs{psGetNodeCenter} geladen werden. Diese
%   werden dann nach aufsteigender $x$-Koordinate nummeriert, siehe
%   \prettyref{ex:saveintersections}.
%   \fi
%   \ifENGLISH
%   Loads the coordinates of the $n$-th intersection point of the path
%   \prm{curvename} in the intersection set \prm{intersection}. The
%   numbering of the intersections starts at \prm{n}$=1$ and the number
%   increases along the path in its original direction.
%
%   The intersection points can also be loaded with \cs{psGetNodeCenter}
%   if \Lkeyword{saveintersections}\opt{=true} is set. In that case, the
%   numbering of the intersection increases according to their $x$
%   coordinate, see \prettyref{ex:saveintersections}.
% \fi
% \end{ltxsyntax}
%
% \iffalse
%<*ignore>
%\fi
\begin{LTXexample}
\begin{pspicture}(5,5)
  \pssavebezier[linecolor=DOrange, arrows=->]{A}%
             (0,0)(0,5)(5,5)(5,1)(1,1.5)
  \pssavebezier[arrows=->]{B}(0,5)(0,0)(5,0)(5,5)(0,2)
  \psintersect[name=C, showpoints]{A}{B}
  \color{DOrange}
  \uput[150](!\psGetIsectCenter{C}{A}{1} A1.x A1.y){1}
  \uput[85](!\psGetIsectCenter{C}{A}{2} A2.x A2.y){2}
  \uput[-20](!\psGetIsectCenter{C}{A}{3} A3.x A3.y){3}
  \uput[90](!\psGetIsectCenter{C}{A}{4} A4.x A4.y){4}
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi
% \ifGERMAN
% \chapter{Beispiele}
% \fi
% \ifENGLISH
% \chapter{Examples}
% \fi
%\iffalse
%<*ignore>
%\fi
\begin{LTXexample}[caption={caption}]
\begin{pspicture}(5,5)
  \pssavebezier{A}(0,0)(0,5)(5,5)(5,1)(1,1.5)
  \multido{\i=100+-20,\r=1+-0.2}{5}{%
    \pstracecurve[linecolor=red!\i, tstop=\r, arrows=-|, showpoints]{A}
  }%
\end{pspicture}
\end{LTXexample}
%\iffalse
%</ignore>
%\fi 
%
%\iffalse
%<*ignore>
%\fi
\begingroup
\captionsetup[lstlisting]{format=pitcaption}
\begin{LTXexample}[pos=t, caption={%
\ifGERMAN Mit diesem Paket können auch die Schnittpunkte von
 Funktionen berechnet werden, die mit \cs{psplot} gezeichnet
 werden. Dabei ist zu beachten, dass beide einzelnen Kurven aus
 \opt{plotpoints} Abschnitten bestehen, von denen jeder mit jedem
 geschnitten wird, was zu langen Berechnungen führen kann.
 \fi
 \ifENGLISH
 The package can also calculate the intersections of functions which are
 drawn with \cs{psplot}. Here you must keep in mind, that such curves
 consists of \opt{plotpoints} segments, which must all be considered for
 intersections, what can result in long calculations.
 \fi}]
\begin{pspicture}(10,4.4)
  \pssavepath{A}{\psplot[plotpoints=200]{0}{10}{x 180 mul sin 1 add 2 mul}}
  \pssavepath{B}{\psplot[plotpoints=50]{0}{10}{2 x neg 0.5 mul exp 4 mul}}
  \psintersect[name=C, showpoints]{A}{B}
  \multido{\i=1+1}{5}{\uput[210](C\i){\i}}
  \multido{\i=6+2,\ii=7+2}{3}{\uput[225](C\i){\i}\uput[-45](C\ii){\ii}}
\end{pspicture}
\end{LTXexample}
\endgroup
%\iffalse
%</ignore>
%\fi 
%
% \appendix
%
% \ifGERMAN
% \chapter{Versionsgeschichte}
%
% Diese Versionsgeschichte ist eine Liste von Änderungen, die für den Nutzer des
% Pakets von Bedeutung sind. Änderungen, die eher technischer Natur sind und für
% den Nutzer des Pakets nicht relevant sind und das Verhalten des Pakets nicht
% ändern, werden nicht aufgeführt. Wenn ein Eintrag der Versionsgeschichte ein
% Feature als \emph{improved} oder \emph{extended} bekannt gibt, so bedeutet
% dies, dass eine Modifikation die Syntax und das Verhalten des Pakets nicht
% beeinflusst, oder das es für ältere Versionen kompatibel ist. Einträge, die
% als \emph{deprecated}, \emph{modified}, \emph{renamed}, oder \emph{removed}
% deklariert sind, verlangen besondere Aufmerksamkeit. Diese bedeuten, dass eine
% Modifikation Änderungen in existierenden Dokumenten mit sich ziehen kann. 
% \fi
% \ifENGLISH
% \chapter{Revision history}
%
% This revision history is a list of changes relevant to users of this
% package. Changes of a more technical nature which do not affect the
% user interface or the behavior of the package are not included in the
% list. If an entry in the revision history states that a feature has
% been \emph{improved} or \emph{extended}, this indicates a modification
% which either does not affect the syntax and behavior of the package or
% is syntactically backwards compatible (such as the addition of an
% optional argument to an existing command). Entries stating that a
% feature has been \emph{deprecated}, \emph{modified}, \emph{fixed},
% \emph{renamed}, or \emph{removed} demand attention. They indicate a
% modification which may require changes to existing documents.
% \fi
%
% \begin{changelog}
%\patchcmd{\release}{\setlength{\itemsep}{0pt}}{\setlength{\itemsep}{0pt}\setlength{\parsep}{0pt}}{}{}
%   \begin{release}{0.2}{2014-02-26}
%   \item Added support for \opt{arrows} parameter to \cs{pstracecurve}.
%   \item Modified parameters \opt{tstart}, \opt{tstop}, \opt{istart}
%     and \opt{istop} to respect different directions.
%   \item Added macro \cs{psGetIsectCenter}
%   \item Fixed a bug in the termination of the iteration procedure.
%   \item Fixed a bug in the point order of Bézier curves, which was
%     related to a now fixed bug in \opt{pst-func}.
%   \item Several other improvements.
%   \end{release}
%   \begin{release}{0.1}{2014-02-19}
%   \item First CTAN version
%   \end{release}
% \end{changelog}
%
% \StopEventually{}
%
%   \begin{otherlanguage}{english}
%    \printindex[idx]
%  \end{otherlanguage}
%
% \chapter{The \LaTeX\ wrapper}
%<*stylefile>
%    \begin{macrocode}
\RequirePackage{pstricks}
\RequirePackage{pst-xkey}
\RequirePackage{pst-node}
\RequirePackage{pst-func}
\input{pst-intersect.tex}
\IfFileExists{pst-intersect.pro}{%
    \ProvidesFile{pst-intersect.pro}
      [2014/02/26 PostScript prologue file]
      \@addtofilelist{pst-intersect.pro}}{}%
%    \end{macrocode}
%</stylefile>
%
% \chapter{The \TeX\ implementation}
%
%<*texfile>
%    \begin{macrocode}
\csname PSTintersectLoaded\endcsname
\let\PSTintersectLoaded\endinput

\ifx\PSTricksLoaded\endinput\else\input pstricks.tex \fi
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex \fi
\ifx\PSTfuncLoaded\endinput\else \input pst-func.tex \fi

\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax

\pst@addfams{intersect}
\pstheader{pst-intersect.pro}

\def\pst@intersectdict{tx@IntersectDict begin }
\def\PIT@dict#1{\pst@intersectdict #1 end}
\def\PIT@Verb#1{\pst@Verb{\PIT@dict{#1} }}%

\def\pssavebezier{\pst@object{pssavebezier}}
\def\pssavebezier@i#1{%
  \begin@OpenObj
    \PIT@checkname{#1}%
    \addto@pscode{ /\PIT@name{#1} }%
    \pst@getcoors[\pssavebezier@ii%]
}%
\def\pssavebezier@ii{%
  \addto@pscode{%
%    \end{macrocode}
% only 10 points allowed, remove the rest
%    \begin{macrocode}
    counttomark 20 gt { counttomark 20 sub { pop } repeat } if
    counttomark 2 idiv 1 sub
    \psk@plotpoints\space exch
    \txFunc@BezierCurve
    \ifshowpoints \txFunc@BezierShowPoints \else pop \fi
    tx@FuncDict begin Points aload pop end
  }%
  \let\use@pscode\PIT@use@pscode
  \end@OpenObj
  \PIT@Verb{%
    [ count 1 sub 1 roll ] ArrayToPointArray def 
  }%
\ignorespaces}%
\def\psGetIsectCenter#1#2#3{%
  \pst@intersectdict
  \PIT@name{#1} /\PIT@name{#2@t} get #3 1 sub get 
  \PIT@name{#1} /\PIT@name{#2} get
  dup IsPath {
    PreparePath exch dup 3 1 roll cvi get
  } if
  PointArrayToArray
  tx@FuncDict begin 2 dict begin
    dup length 2 idiv 1 sub /BezierType exch def /Points exch def GetBezierCoor
  end end
  end
  \tx@UserCoor /#2#3.y exch def /#2#3.x exch def
}%
\define@key[psset]{intersect}{tstart}{%
  \pst@checknum{#1}\PIT@key@tstart
}
\define@key[psset]{intersect}{tstop}{%
  \pst@checknum{#1}\PIT@key@tstop
}
\define@key[psset]{intersect}{istart}{%
  \pst@checknum{#1}\PIT@key@istart
}
\define@key[psset]{intersect}{istop}{%
  \pst@checknum{#1}\PIT@key@istop
}
\define@key[psset]{intersect}{name}{%
  \def\PIT@key@name{#1}%
}%
\newif\PIT@saveintersections
\define@boolkey[psset]{intersect}[PIT@]{saveintersections}[true]{}
\psset[intersect]{%
  tstart=-1,
  tstop=-1,
  istart=-1,
  istop=-1,
  name={},
  saveintersections
}%
\def\PIT@use@pscode{%
  \pstverb{%
    \pst@dict
    \tx@STP
    \pst@newpath
    \psk@origin
    \psk@swapaxes
    \pst@code
    end
    count /ocount exch def
  }%
  \gdef\pst@code{}%
}%
\let\PIT@pst@stroke@orig\pst@stroke
\def\PIT@save@path{%
  \PIT@pst@stroke@orig
  \addto@pscode{%
    clear mark
    \pst@intersectdict GetFullPath end
    counttomark 1 add -1 roll pop count }%
}%
\def\PIT@name@default{@tmp}%
\def\PIT@name#1{PIT@#1}%
\def\PIT@checkname#1{%
  \ifx\@empty#1\@empty
    \@pstrickserr{Unexpected empty argument!}\@ehpb
  \fi
}%
\def\pssavepath{\pst@object{pssavepath}}%
\long\def\pssavepath@i#1#2{%
  \begin@SpecialObj
    \PIT@checkname{#1}%
    \let\pst@stroke\PIT@save@path
    \let\use@pscode\PIT@use@pscode
    \pscustom{#2}%
    \PIT@Verb{%
      /\PIT@name{#1}
      [ 3 -1 roll 2 add 2 roll ] def }%
  \end@SpecialObj
}%
\def\pstracecurve{\pst@object{pstracecurve}}%
\def\pstracecurve@i#1{%
  \addbefore@par{plotpoints=200}%
  \begin@OpenObj
   \@ifnextchar\bgroup
     {\PIT@traceintersection{#1}}%
     {\PIT@tracecurve{#1}}%
}%
\def\PIT@tracecurve#1{%
  \PIT@checkname{#1}%
  \addto@pscode{%
    \pst@intersectdict
    \PIT@key@tstop\space dup 0 lt { pop \PIT@name{#1} GetSegmentCount } if
    \PIT@key@tstart\space dup 0 lt { pop 0 } if exch
    \PIT@name{#1} GetSegmentCount
    2 copy exch dup 3 1 roll
    lt exch 0 lt or { exch } if pop
    \PIT@name{#1} dup IsPath {
      3 1 roll 2 copy gt {
%    \end{macrocode}
% reverse the path, draw everything and resave the path
%    \begin{macrocode}
        exch 3 -1 roll dup 4 1 roll GetSegmentCount
        dup 4 1 roll exch sub 3 1 roll sub exch
        gsave newpath
          [ 4 -1 roll aload pop InitTracing
          { counttomark 0 eq { exit } if
            load exec
          } loop
          reversepath
          GetFullPath ] 3 1 roll        
        grestore
      } if
      ShowPathPortion
    }{
      [ exch dup 5 -2 roll
      2 copy gt {
        exch
        2 copy gt { exch } if
        [ 5 -2 roll pop PointArrayToArray aload pop
        counttomark -2 4 { 2 roll } for ] ArrayToPointArray dup
        4 2 roll
      } if
      ToUnitInterval Portion
      { aload pop } forall
      % reverse the point order
      counttomark -2 4 { 2 roll } for
      counttomark 2 sub 2 idiv
      \psk@plotpoints
      exch
      \txFunc@BezierCurve
      \ifshowpoints \txFunc@BezierShowPoints \else pop \fi
    } ifelse
    end
  }%
  \end@OpenObj
}%
\def\PIT@traceintersection#1#2{%
  \PIT@checkname{#2}%
  \addto@pscode{%
    \pst@intersectdict
    \ifx\\#1\\%
    /\PIT@name{\PIT@name@default}
    \else
    /\PIT@name{#1}
    \fi 
    dup currentdict exch known not {
      \ifx\\#1\\%
      (You haven't defined an intersection!) ==
      \else
      (You haven't defined the intersection '#1') ==
      \fi
    } if 
    load
    dup dup type /dicttype eq exch /\PIT@name{#2} known and not {
      (You haven't defined the intersection '#2') ==
    } if
    dup /\PIT@name{#2} get
    exch /\PIT@name{#2}@t get
    dup length \PIT@key@istart\space ge 0 \PIT@key@istart\space lt and {
      dup \PIT@key@istart\space cvi 1 sub get
    } {
      \PIT@key@tstart
    } ifelse
    dup 0 lt { pop 0 } if
    exch % [curve] t_istart|tstart [ts]
    % 
    dup length \PIT@key@istop\space ge 0 \PIT@key@istop\space lt and {
      \PIT@key@istop\space cvi 1 sub get
    } {
      pop \PIT@key@tstop
    } ifelse
    3 -1 roll dup 4 1 roll GetSegmentCount 
    2 copy exch dup 3 1 roll % [curve] tstart tstop cnt tstop cnt tstop 
    lt exch 0 lt or { exch } if pop % (tstop < 0 | cnt < tstop)
    3 -1 roll dup
    IsPath {
      3 1 roll
      2 copy gt {
        exch 3 -1 roll dup 4 1 roll GetSegmentCount
        dup 4 1 roll exch sub 3 1 roll sub exch
%    \end{macrocode}
% reverse the path, draw everything and resave the path
%    \begin{macrocode}
        gsave newpath
          [ 4 -1 roll aload pop InitTracing
          { counttomark 0 eq { exit } if
            load exec
          } loop
          reversepath
          GetFullPath ] 3 1 roll        
        grestore
      } if
      ShowPathPortion
    }{
      [ exch dup 5 -2 roll
      exch dup 0 lt { pop 0 } if exch
      dup 0 lt { pop 1 } if
      2 copy gt {
        exch
        [ 5 -2 roll pop PointArrayToArray aload pop
        counttomark -2 4 { 2 roll } for ] ArrayToPointArray dup
        4 2 roll
      } if
      ToUnitInterval Portion 
      { aload pop } forall
      counttomark 2 sub 2 idiv
      \psk@plotpoints
      exch
      \txFunc@BezierCurve
      \ifshowpoints \txFunc@BezierShowPoints \else pop \fi
    } ifelse
    end
  }%
  \end@OpenObj
}%
%
% \begin{macro}{\psintersect}
%    \begin{macrocode}
\def\psintersect{\pst@object{psintersect}}
\def\psintersect@i#1#2{%
  \PIT@checkname{#1}%
  \PIT@checkname{#2}%
  \begin@SpecialObj
  \def\PIT@@name{%
    \ifx\PIT@key@name\@empty
      \PIT@name{\PIT@name@default}
    \else
      \PIT@name{\PIT@key@name} 
    \fi}%
  \PIT@Verb{%
    currentdict /\PIT@name{#1} known not {
      (You haven't defined the curve or path '#1') ==
    } if
    currentdict /\PIT@name{#2} known not {
      (You haven't defined the curve or path '#2') ==
    } if
    \PIT@name{#1} \PIT@name{#2}
    \PIT@name{#1} IsPath {
      \PIT@name{#2} IsPath {
        IntersectPaths
      }{
        IntersectPathCurve
      } ifelse
    }{
      \PIT@name{#2} IsPath {
        IntersectCurvePath
      }{
        IntersectBeziers
        4 copy LoadIntersectionPoints 5 1 roll
      } ifelse
    } ifelse
    /\PIT@@name\space /\PIT@name{#1} /\PIT@name{#2} 8 3 roll 
    SaveIntersection
  }%
  \ifPIT@saveintersections
    \pst@Verb{%
      \pst@intersectdict 
        \PIT@@name\space /Points get 
        ArrayToPointArray
      end
      tx@NodeDict begin 
        dup length 1 1 3 -1 roll {
          2 copy 1 sub get cvx
          false 3 -1 roll (N@\PIT@key@name) exch 20 string cvs 
          \pst@intersectdict strcat end cvn
          10 {InitPnode} /NodeScale {} def NewNode
        } for
      end
      pop
    }%
  \fi
  \ifshowpoints
    \addto@pscode{%
      \pst@intersectdict
        [ \PIT@@name\space /Points get aload pop 
      end 
    }%
    \psdots@ii
  \else
    \end@SpecialObj
  \fi
}%
%    \end{macrocode}
% \end{macro}
% 
%    \begin{macrocode}
\catcode`\@=\PstAtCode\relax
%    \end{macrocode}
%</texfile> 
%
% \chapter{The Postscript header file}
% \makeatletter
%^^A Copied this definition from doc.sty and changed it not to add a
%^^A backslash to the Postscript procedure name in the index.
% \def\SpecialIndex@#1#2{%
%    \@SpecialIndexHelper@#1\@nil
%    \def\@tempb{ }%
%    \ifcat \@tempb\@gtempa
%       \special@index{\quotechar\space\actualchar
%                      \string\verb\quotechar*\verbatimchar
%                      \quotechar\space\verbatimchar#2}%
%    \else
%      \def\@tempb##1##2\relax{\ifx\relax##2\relax
%           \def\@tempc{\special@index{\quotechar##1\actualchar
%                       \string\verb\quotechar*\verbatimchar
%                       \quotechar##1\verbatimchar#2}}%
%         \else
%           \def\@tempc{\special@index{##1##2\actualchar
%                        \string\verb\quotechar*\verbatimchar##1##2\verbatimchar#2}}%
%         \fi}%
%      \expandafter\@tempb\@gtempa\relax
%      \@tempc
%    \fi}
% \makeatother
%
%<*prolog>
%    \begin{macrocode}
/tx@IntersectDict 200 dict def
tx@IntersectDict begin
%    \end{macrocode}
% These are some helper procedures for vector operations.
%
% \begin{macro}{VecAdd}
% Addition of two vectors.
% \begin{pssyntax}
%   \PSvar{Xa Ya Xb Yb} \PSop{VecAdd} \PSvar{Xa+Xb Ya+Yb}
% \end{pssyntax}
%    \begin{macrocode}
/VecAdd {
    3 -1 roll add 3 1 roll add exch
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{VecSub}
% Subtraction of two vectors.
% \begin{pssyntax}
%   \PSvar{Xa Ya Xb Yb} \PSop{VecSub} \PSvar{Xa-Xb Ya-Yb}
% \end{pssyntax}
%    \begin{macrocode}
/VecSub {
    neg 3 -1 roll add 3 1 roll neg add exch
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{VecScale}
% Scale a vector by a factor \PSvar{fac}.
% \begin{pssyntax}
%   \PSvar{Xa Ya fac} \PSop{VecScale} \PSvar{fac}$\cdot$\PSvar{Xa} \PSvar{fac}$\cdot$\PSvar{Ya}
% \end{pssyntax}
%    \begin{macrocode}
/VecScale {
  dup 4 -1 roll mul 3 1 roll mul
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{ToVec}
%   Convert two numbers to a procedure holding the two values. This
%   representation is used to save coordinate values of nodes and vectors.
%   \begin{pssyntax}
%     \PSvar{X Y} \PSop{ToVec} \PSarray{X Y}
%   \end{pssyntax}
%    \begin{macrocode}
/ToVec {
    [ 3 1 roll ]
} bind def
%    \end{macrocode}
% \end{macro}
%
% \PSvar{MaxPrecision} gives the precision of the curve parameter t for the
% intersection. This shouldn't be lower than $10^{-6}$, because
% PostScript uses single precision.
%    \begin{macrocode}
/MaxPrecision 1e-6 def
%    \end{macrocode}
%
% \PSvar{Epsilon} gives the allowed relative error of the intersection point. 
%    \begin{macrocode}
/Epsilon 1e-4 def
%    \end{macrocode}
% 
% The threshold for curve subdivision, see below.
%    \begin{macrocode}
/MinClippedSizeThreshold 0.8 def
%    \end{macrocode}
%
% The predefined intervals for the subdivision of the curves.
%    \begin{macrocode}
/H1Interval [0 0.5] def
/H2Interval [0.5 MaxPrecision add 1] def
%    \end{macrocode}
% 
% \begin{macro}{IntersectBeziers}
%   The main procedure, which computes the intersection of two bezier
%   curves of arbitrary order.  This, and most of the following
%   procedures operate on curves, which are stored as arrays of points,
%   the points are also arrays with two elements -- \PSvar{X} and
%   \PSvar{Y}. A Bezier curve of $n$-th order is then givesn by
%   \PSarray{\PSarray{X0 Y0} \PSarray{X1 Y1} \ldots \PSarray{XN YN}}.
%
% \begin{pssyntax}
%   \PSarray{curveA} \PSarray{curveB} \PSop{IntersectBeziers} 
%   \PSarray{curveA} \PSarray{tA} \PSarray{curveB} \PSarray{tB}
% \end{pssyntax}
%    \begin{macrocode}
/IntersectBeziers {
  2 copy length 2 eq exch length 2 eq and {
    IntersectLines
  }{ 
    2 copy [0 1] [0 1] IterateIntersection
  } ifelse
  3 -1 roll exch
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{IntersectLines}
% 
%   \begin{pssyntax}
%     \PSarray{lineA} \PSarray{lineB} \PSop{IntersectLines}
%     \PSarray{lineA} \PSarray{tA} \PSarray{lineB} \PSarray{tB}
%   \end{pssyntax}
%    \begin{macrocode}
/IntersectLines {
  (IntersectLines) DebugBegin
  2 copy
  exch { aload pop } forall 5 -1 roll { aload pop } forall
  8 -2 roll 2 copy 10 4 roll 4 2 roll 2 copy 6 2 roll 10 2 roll
  VecSub
  6 2 roll 4 2 roll VecSub
  8 4 roll 4 2 roll VecSub % X3-X4 Y3-Y4 X2-X1 Y2-Y1 X3-X1 Y3-Y1 % b1 b2 a1 a2 c1 c2
  6 copy 12 -4 roll 
  neg 4 -1 roll mul 3 1 roll mul add
  dup 0 eq {
    % no intersections
    9 { pop } repeat [] []
  } {
    dup 10 1 roll 5 1 roll
     4 -1 roll mul 3 1 roll mul sub exch div
     6 1 roll 4 -1 roll mul 3 1 roll mul sub exch div
     2 copy 2 copy 0 ge exch 0 ge and 3 1 roll 1 le exch 1 le and and {
       [ exch ] exch [ exch ]
     } {
       pop pop [] []
     } ifelse
  } ifelse
  DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% \begin{macro}{IntersectPaths}
%   \begin{pssyntax}
%     \PSarray{pathA} \PSarray{pathB} \PSop{IntersectPaths}
%     \PSarray{intersections} \PSarray{pathA} \PSarray{tA} \PSarray{pathB} \PSarray{tB}
%   \end{pssyntax}
%    \begin{macrocode}
/IntersectPaths {
  (IntersectPaths) DebugBegin
  6 dict begin 
    2 copy exch PreparePath dup length /nA exch def 
    exch PreparePath dup length /nB exch def
    /isect [] def
    /tA [] def /tB [] def
    { % [pathA] [Bi]
      /nB nB 1 sub def
      exch dup 3 1 roll % [pathA] [Bi] [pathA]
      {
        /nA nA 1 sub def
        exch dup 3 1 roll % [pathA] [Bi] [Aj] [Bi]
        IntersectBeziers % [curveA] [tA] [curveB] [tB]
        4 copy LoadIntersectionPoints
        [ exch isect aload pop ] /isect exch def
        exch pop 3 -1 roll pop
        [ tB aload length 2 add -1 roll TArray { nB add } forall ] /tB exch def
        [ tA aload length 2 add -1 roll TArray { nA add } forall ] /tA exch def
      } forall
      pop % remove [Bi]
      dup length /nA exch def
    } forall
    pop % remove [pathA]
    [ isect { aload pop } forall ] 3 1 roll tA exch tB
    % [intersections] [pathA] [tA] [pathB] [tB]
  end
  DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{IntersectCurvePath}
%   \begin{pssyntax}
%     \PSarray{curveA} \PSarray{pathB} \PSop{IntersectCurvePath}
%     \PSarray{intersections} \PSarray{curveA} \PSarray{tA} \PSarray{pathB} \PSarray{tB}
%   \end{pssyntax}
%    \begin{macrocode}
/IntersectCurvePath {
  (IntersectCurvePath) DebugBegin
  6 dict begin 
    2 copy PreparePath dup length /n exch def
    /isect [] def
    /tA [] def /tB [] def
    { % [curveA] [Bi]
      /n n 1 sub def
      exch dup 3 -1 roll % [curveA] [curveA] [Bi] 
      IntersectBeziers 
      4 copy LoadIntersectionPoints % [curveA] [tA] [curveB] [tB]
      [ exch isect aload pop ] /isect exch def
      pop 3 -1 roll pop
      [ tB aload length 2 add -1 roll TArray { n add } forall ] /tB exch def
      [ tA aload length 2 add -1 roll TArray aload pop ] /tA exch def
    } forall
    pop % remove [curveA]
    [ isect { aload pop } forall ] 3 1 roll tA exch tB
    % [intersections] [curveA] [tA] [pathB] [tB]
  end
  DebugEnd
} bind def
/IntersectPathCurve {
  exch IntersectCurvePath 4 2 roll
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{SaveIntersection}
%   \begin{pssyntax}
%     \PSname{isectname} \PSname{nameA} \PSname{nameB} 
%     \PSarray{intersectionpoints} \PSarray{A} \PSarray{tA} \PSarray{B} \PSarray{tB} 
%     \PSop{SaveIntersection}
%   \end{pssyntax}
%    \begin{macrocode}
/SaveIntersection {
  (SaveIntersection) DebugBegin
  4 dict dup 10 -1 roll exch def
  begin %
    /Points 6 -1 roll def
    5 -1 roll dup 4 -1 roll def % /curveA [curveA] [tA] [tB] /curveB /curveB [curveB] def
    nametostr (@t) strcat cvn exch TArray def % /curveA [curveA] [tA] /curveB@t [tB] def
    3 -1 roll dup 4 -1 roll def
    nametostr (@t) strcat cvn exch TArray def
  end
  DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{TArray}
%   The curve parameters \PSvar{t} as determined by
%   \PSvar{IntersectBeziers} are given in a special array
%   construct. \PSvar{TArray} creates a simple array with the
%   \PSvar{t}-values given in ascending order.
%
% \begin{pssyntax}
% \PSarray{\PSarray{t0a t0b} \ldots \PSvar{null}\ldots \PSvar{integer}}
% \PSop{TArray} \PSarray{t0 t1 \ldots tN}
% \end{pssyntax}
%    \begin{macrocode}
/TArray {
  (TArray) DebugBegin
  dup length 0 gt {
    dup 0 get type /arraytype eq {
      [ exch
      { %dup type /nulltype eq { pop exit } if
  	aload pop add 0.5 mul
      } forall ]
    } if
    dup /lt exch quicksort
  } if
  DebugEnd %1 debug
} bind def
%    \end{macrocode}
% \end{macro} 
% 
% We can save arbitrary paths using \PSvar{pathforall}. The saved path
% contains the commands \PSname{movetype}, \PSname{linetype} and
% \PSname{curvetype}. By default, these are defined as the respective
% original procedures.
%    \begin{macrocode}
/InitTracing {
  /movetype /moveto load def
  /linetype /lineto load def
  /curvetype /curveto load def
} bind def
InitTracing
/GetFullPath {
  { /movetype counttomark 3 roll }
  { /linetype counttomark 3 roll }
  { /curvetype counttomark 7 roll }{} pathforall 
} bind def
%    \end{macrocode}
%
% \begin{macro}{PreparePath}
% [ ... /movetype ... /linetype .../curvetype ]
%    \begin{macrocode}
/PreparePath {
  [ exch aload pop
  {
    dup type /nametype eq not { exit } if
    dup /movetype eq {
      pop ToVec /@mycp exch def
    } {
      dup /linetype eq {
        pop [ @mycp 4 2 roll 2 copy ToVec /@mycp exch def ToVec ]
      } {
        pop [ @mycp 8 2 roll 2 copy ToVec /@mycp exch def
        ToVec 5 1 roll ToVec 4 1 roll ToVec 3 1 roll ]
      } ifelse
      counttomark 1 roll	
    } ifelse
  } loop ]
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{GetSegmentCount}
% \PSarray{CurveOrPath} \PSop{GetSegmentCount} -> number of /linetype and /curvetypes
%    \begin{macrocode}
/GetSegmentCount {
  dup IsPath {
    [ exch aload pop 0
    {
      counttomark 1 eq { exit } if
      exch 
      dup /movetype eq {
        pop 3 1 roll pop pop
      }{
        dup /linetype eq {
          pop 1 add 3 1 roll pop pop
        }{
          pop 1 add 7 1 roll 6 { pop } repeat
        } ifelse
      } ifelse
    } loop
    exch pop
  } {
    % a Bezier curve is a single segment
    pop 1
  } ifelse
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{LoadLineIntersectionPoints}
% Prepare \PSarray{Curve} for use with tx@Func
% \begin{pssyntax}
% \PSarray{curve} \PSarray{t} \PSop{LoadLineIntersectionPoints}
% \PSarray{I0.x I0.y \ldots IN.x YN.x}
% \end{pssyntax}
%    \begin{macrocode}
/LoadLineIntersectionPoints {
  (LoadLineIntersectionPoints) DebugBegin
  exch [ exch { aload pop } forall ]
  tx@Dict begin tx@FuncDict begin 2 dict begin
    dup length 2 idiv 1 sub /BezierType exch def /Points exch def
    [ exch { GetBezierCoor } forall ]
  end end end
  DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{LoadCurveIntersectionPoints}
%   Load the intersection points. This loads the same intersection point
%   from both curves, and chooses the one with the lowest error.
% \begin{pssyntax}
% \PSarray{curveA} \PSarray{tA} \PSArray{curveB} \PSarray{tB} 
%  \PSop{LoadCurveIntersectionPoints}
% \PSarray{I0.x I0.y \ldots IN.x YN.x}
% \end{pssyntax}
%    \begin{macrocode}
/LoadCurveIntersectionPoints {
  (LoadCurveIntersectionPoints) DebugBegin
  2 {
    4 2 roll
    [ exch { aload pop } forall ]
    exch [ exch { aload pop } forall ]
  } repeat
  % [A0.x A0.y ... AM.x AM.y] [tA0a tA0b ... tAMa tAMb] [tB0a tB0b ... tBNa tBNb] [B0.x B0.y ... BN.x BN.y]
  tx@Dict begin tx@FuncDict begin 2 dict begin
    dup length 2 idiv 1 sub /BezierType exch def /Points exch def
      [ exch { GetBezierCoor } forall ]
    3 1 roll 
    dup length 2 idiv 1 sub /BezierType exch def /Points exch def
      [ exch { GetBezierCoor } forall ]
    end
    %2 debug
    % [IB0.xa IB0.ya IB0.xb IB0.yb ... IBM.yb] [IA0.xa IA0.ya IA0.xb IA0.yb ... IAM.yb]
    2 {
      [ exch aload length 4 idiv {
        [ 5 1 roll ] counttomark 1 roll
      } repeat ]
      exch 
    } repeat
    % [[IB0.xa ...] ... [... IBM.yb]] [[IA0.xa IA0.ya IA0.xb IA0.yb] ...[IAM.xa ... IAM.yb]]
    2 {
      dup hulldict /comp get exch quicksort exch
    } repeat
    2 dict begin
      /B exch def /A exch def
      [ 0 1 A length 1 sub {
        dup A exch get exch B exch get % [IAi] [IBi]
        2 copy aload pop VecSub Pyth exch 
        aload pop VecSub Pyth lt { exch } if pop
        aload pop VecAdd 0.5 VecScale
      } for 
      % merge near intersection points
      %counttomark 2 idiv 1 1 3 -1 roll {
      %  pop
      %  counttomark 4 lt { exit } if
      %  4 copy 4 2 roll ToVec 3 1 roll ToVec AreNear {

      %  }
      %} for
      ]
    end
  end end
  DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{LoadIntersectionPoints}
%    \begin{macrocode}
/LoadIntersectionPoints {
  (LoadIntersectionPoints) DebugBegin
  4 copy pop exch pop length 2 eq exch length 2 eq and {
    pop pop LoadLineIntersectionPoints
  }{
    LoadCurveIntersectionPoints
  } ifelse
  DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{IterateIntersection}
% Iteration procedure to compute all intersections of CurveA and CurveB.
% This contains the
% 
% \begin{pssyntax}
% \PSarray{CurveA} \PSarray{CurveB} \PSarray{intervalA} \PSarray{intervalB}
% \PSop{IterateIntersection} \PSarray{domsA} \PSarray{domsB}
% \end{pssyntax}
%    \begin{macrocode}
/IterateIntersection {
    (IterateIntersection) DebugBegin
    12 dict begin
	/precision MaxPrecision def
        4 2 roll 2 copy 6 2 roll
        dup IsPath not { PointArrayToArray } if
        0 exch { dup type /nametype eq { pop }{ abs max} ifelse } forall
        exch dup IsPath not { PointArrayToArray } if
        { dup type /nametype eq { pop }{ abs max} ifelse } forall
        Epsilon mul /epsilon exch def
%    \end{macrocode}
% in order to limit recursion
%    \begin{macrocode}
        /counter 0 def
	/depth 0 def
	/domsA [] def
	/domsB [] def
	/domsA /domsB 6 2 roll _IterateIntersection
	domsB domsA
    end
    dup length 0 gt {
      TArraysRemoveDup
    } if
    DebugEnd
} bind def
/TArraysRemoveDup {
  4 dict begin
    /tB exch def
    /tA exch def
    /j 0 def
    [ tA 0 get tB 0 get
    1 1 tA length 1 sub {
      /i exch def
      tA j get aload pop tA i get aload pop tx@Dict begin Pyth2 end MaxPrecision gt
      tB j get aload pop tB i get aload pop tx@Dict begin Pyth2 end MaxPrecision gt and {
        % keep the current parameter point
        /j i def
        tB i get tA i get
        counttomark 2 idiv 1 add 1 roll 
      } if
    } for
    counttomark 2 idiv 1 add [ exch 1 roll ] % [ ... [tB]
    counttomark 1 add 1 roll ] exch % [tA] [tB]
  end 
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{_IterateIntersection}
% This is the iteration part which is called recursively.
%
% \begin{pssyntax}
%   \PSname{domsA} \PSname{domsB} \PSarray{CurveA} \PSarray{CurveB}
%   \PSarray{domA} \PSarray{domB} \PSop{_IterateIntersection}
% \end{pssyntax}
%    \begin{macrocode}
/_IterateIntersection {
    (_IterateIntersection) DebugBegin
    CloneVec /domB exch def
    CloneVec /domA exch def
    CloneCurve /CurveB exch def
    CloneCurve /CurveA exch def
    /iter 0 def
    /depth depth 1 add def
    /dom null def
    /counter counter 1 add def

    CheckIT {
	(>> curve subdivision performed: dom(A) = ) domA CurveToString strcat
	(, dom(B) = ) strcat domB CurveToString strcat ( <<) strcat ==
    } if
    CurveA IsConstant CurveB IsConstant and {
	CurveA MiddlePoint ToVec
	CurveB MiddlePoint ToVec AreNear {
	    domA domB 4 -1 roll exch PutInterval PutInterval
	} {
	    pop pop
	} ifelse
    }{
	counter 100 lt {
%    \end{macrocode}
% Use a loop to simulate some kind of return to exit at different positions.
%    \begin{macrocode}
	    {
		/iter iter 1 add def
		iter 100 lt
		domA Extent precision ge
		domB Extent precision ge or and not {
		    iter 100 ge {
			false 
		    } {
			CurveA MiddlePoint ToVec
			CurveB MiddlePoint ToVec AreNear {
			    domA domB true
			}{
			    false
			} ifelse
		    } ifelse
		    exit
		} if
%    \end{macrocode}
% iter < 100 && (dompA.extent() >= precision || dompB.extent() >= precision)
%    \begin{macrocode}
		CheckIT {
		    (counter: ) counter 20 string cvs strcat
		    (, iter: ) iter 20 string cvs strcat strcat
		    (, depth: ) depth 20 string cvs strcat strcat ==
		} if
	
		CurveA CurveB ClipCurve /dom exch def
	
		CheckIT {(dom : ) dom CurveToString strcat == } if		
		dom IsEmptyInterval {
		    CheckIT { (empty interval, exit) == } if
		    false exit
		} if
%    \end{macrocode}
% dom[0] > dom[1], invalid.
%    \begin{macrocode}
		dom aload pop 2 copy min 3 1 roll max gt {
		    CheckIT {
			(dom[0] > dom[1], invalid!) ==
		    } if
		    false exit
		} if

		domB dom MapTo /domB exch def
		CurveB dom Portion

		CurveB IsConstant CurveA IsConstant and {
		    CheckIT {
          		(both curves are constant: ) ==	
			(C1: [ ) CurveA { CurveToString ( ) strcat strcat } forall (]) strcat ==
			(C2: [ ) CurveB { CurveToString ( ) strcat strcat } forall (]) strcat ==
		    } if
		    CurveA MiddlePoint ToVec
		    CurveB MiddlePoint ToVec AreNear {
			domA domB true
		    } {
			false
		    } ifelse
		    exit
		} if
%    \end{macrocode}
% If we have clipped less than 20%, we need to subdivide the
% curve with the largest domain into two sub-curves.
%    \begin{macrocode} 
		dom Extent MinClippedSizeThreshold gt {
		    CheckIT {
			(clipped less than 20% : ) ==
			(angle(A) = ) CurveA dup length 1 sub get aload pop
				      CurveA 0 get aload pop VecSub
   				      exch 2 copy 0 eq exch 0 eq and {
					  pop pop (NaN)
				      } {
					  atan 20 string cvs
				      } ifelse strcat ==
		        (angle(B) = ) CurveB dup length 1 sub get aload pop
		                      CurveB 0 get aload pop VecSub
				      exch 2 copy 0 eq exch 0 eq and {
					  pop pop (NaN)
				      } {
					  atan 20 string cvs
				      } ifelse strcat ==
		        (dom : ) == dom == (domB :) == domB ==
		    } if
%    \end{macrocode}
% Leave those five values on the stack to revert to the current state after the recursive calls.
%    \begin{macrocode}
		    CurveA CurveB domA domB iter
     		    7 -2 roll 2 copy 9 2 roll 2 copy 
%    \end{macrocode}
% On the stack: /domsA /domsB CurveA CurveB domA domB iter /domsA /domsB /domsA /domsB
%    \begin{macrocode}
		    domA Extent domB Extent gt {
			CurveA CloneCurve dup H1Interval Portion % pC1
			CurveA CloneCurve dup H2Interval Portion % pC2
			domA H1Interval MapTo                    % dompC1
			domA H2Interval MapTo                    % dompC2
%    \end{macrocode}
% Need on the stack: /domsA /domsB pC2 CurveB dompC2 domB   /domsA /domsB pC1 CurveB dompC1 domB
%    \begin{macrocode}
			3 -1 roll exch % /domsA /domsB /domsA /domsB pC1 dompC1 pC2 dompC2
			CurveB exch domB 8 4 roll % /domsA /domsB pC2 CurveB dompC2 domB /domsA /domsB pC1 dompC1
			CurveB exch domB % /domsA /domsB pC2 CurveB dompC2 domB /domsA /domsB pC1 CurveB dompC1 domB
		    } {
			CurveB CloneCurve dup H1Interval Portion % pC1
			CurveB CloneCurve dup H2Interval Portion % pC2
			domB H1Interval MapTo                    % dompC1
			domB H2Interval MapTo                    % dompC2
%    \end{macrocode}
% Need on the stack: /domsB /domsA pC2 CurveA dompC2 domA   /domsB /domsA pC1 CurveA dompC1 domA
%    \begin{macrocode}
			8 -2 roll exch 8 2 roll 6 -2 roll exch 6 2 roll % /domsB /domsA /domsB /domsA pC1 pC2 dompC1 dompC2
			3 -1 roll exch % /domsB /domsA /domsB /domsA pC1 dompC1 pC2 dompC2
			CurveA exch domA 8 4 roll % /domsB /domsA pC2 CurveA dompC2 domA /domsB /domsA pC1 dompC1
			CurveA exch domA          % /domsB /domsA pC2 CurveA dompC2 domA /domsB /domsA pC1 CurveA dompC1 domA
		    } ifelse

		    _IterateIntersection
		    _IterateIntersection
%    \end{macrocode}		    
% Restore the state before the recursive calls.
%    \begin{macrocode}
		    /iter exch def
		    /domB exch def
		    /domA exch def
		    /CurveB exch def
		    /CurveA exch def
		    false exit
		} if
		CurveA CurveB /CurveA exch def /CurveB exch def
		domA domB /domA exch def /domB exch def
%    \end{macrocode}
% exchange /domsA and /domsB on the stack!
%    \begin{macrocode}
		exch
	    } loop	
%    \end{macrocode}
% boolean on stack
%    \begin{macrocode}
	    {
		4 -1 roll exch PutInterval PutInterval
		CheckIT {
		    (found an intersection ============================) ==
		} if
	    } { pop pop } ifelse
	} {
	    pop pop
	} ifelse
    } ifelse
    /depth depth 1 sub def
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{PutInterval}
%   Add a new interval \PSarray{newinterval} to the array stored in
%   \PSname{/Intervals}. The new interval is "cloned" before storing it.
% \begin{pssyntax}
% \PSname{Intervals} \PSarray{newinterval} \PSop{PutInterval}
% \end{pssyntax}
%    \begin{macrocode}
/PutInterval {
    CloneVec [ exch 3 -1 roll dup 4 1 roll load aload pop ] def
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{IsEmptyInterval}
% Check if an interval is empty, which is represented by a [1 0] interval.
% \begin{pssyntx}
% \PSarray{interval} \PSop{IsEmptyInterval} \PSvar{boolean}
%    \begin{macrocode}
/IsEmptyInterval {
    aload pop 0 eq exch 1 eq and
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{ToUnitInterval}
% Limit an interval \PSvar{a b} to the unit interval \PSarray{0 1}.
% \begin{pssyntax}
% \PSvar{a b} \PSop{ToUnitInterval} \PSarray{a|0 b|1}
% \end{pssyntax}
%    \begin{macrocode}
/ToUnitInterval {
    ToUnitRange exch ToUnitRange 2 copy gt {
	exch
    } if
    ToVec
} bind def
%    \end{macrocode}
% \end{macro}
% \begin{macro}{ToUnitRange}
% Limit a number to the range \PSarray{0 1}.
%    \begin{macrocode}
/ToUnitRange {
    dup 0 lt {
	pop 0
    }{
	dup 1 gt {
	    pop 1
	} if
    } ifelse
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{CloneCurve}
% Does a deep copy of the array \PSarray{Curve}. This also involved deep copies of the contained point arrays.
% \begin{pssyntax}
% \PSarray{Curve} \PSop{CloneCurve} \PSarray{newCurve}
%    \begin{macrocode}
/CloneCurve {
    [ exch {
	CloneVec
    } forall ]
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{CloneVec}
% Does a deep copy of the vector \PSarray{X Y}
% \begin{pssyntax}
% \PSarray{X Y} \PSop{CloneVec} \PSarray{Xnew Ynew}
% \end{pssyntax}
%    \begin{macrocode}
/CloneVec {
    aload pop ToVec
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{MapTo}
% Map the sub-interval \PSarray{I} in \PSarray{0 1} into the interval \PSarray{J}. Returns a new array.
% \begin{pssyntax}
% \PSarray{J} \PSarray{I} \PSop{MapTo} \PSarray{Jnew}
% \end{pssyntax}
%    \begin{macrocode}
/MapTo {
    (MapTo) DebugBegin
    exch aload 0 get 3 1 roll exch sub 2 copy % [I] J0 Jextent J0 Jextent
    5 -1 roll aload aload pop % J0 Jextent J0 Jextent I0 I1 I0 I1
    min 4 -1 roll mul % J0 Jextent J0 I0 I1 min(I0,I1)*Jextent
    4 -1 roll add [ exch % J0 Jextent I0 I1 [ J0new
    6 2 roll max mul add ]
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{Portion}
% Compute the portion of the Bezier curve \PSarray{CurveB} wrt the interval \PSarray{I}.
% \begin{pssyntax}
% \PSarray{CurveB} \PSarray{I} \PSop{Portion} \PSarray{CurvePartB}
% \end{pssyntax}
%    \begin{macrocode}
/Portion {
    (Portion) DebugBegin
    dup Min 0 eq { % [CurveB] [I]
	% I.min() == 0
	Max dup 1 eq {% [CurveB] I.max()
	    % I.max() == 1
	    pop pop	    
	} { % [CurveB] I.max()
	    LeftPortion
	} ifelse
    } { % [CurveB] [I]
	2 copy Min % [CurveB] [I] [CurveB] I.min()
	RightPortion
	dup Max 1 eq {
	    % I.max() == 1
	    pop pop
	} {% [CurveB] [I]
	    dup aload pop exch sub 1 3 -1 roll Min sub div % [CurveB] (I1-I0)/(1-I.min())
	    LeftPortion
	} ifelse
    } ifelse
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{LeftPortion}
%   Compute the portion of the Bezier curve \PSarray{CurveB} wrt the
%   interval \PSarray{0 t}.
% \begin{pssyntax}
% \PSarray{CurveB} \PSvar{t} \PSop{LeftPortion} \PSarray{CurvePartB}
% \end{pssyntax}
%    \begin{macrocode}
/LeftPortion {
    (LeftPortion) DebugBegin
    exch dup length 1 sub dup 4 1 roll % L-1 t [CurveB] L-1
    1 1 3 -1 roll { % L-1 t [CurveB] i
	4 -1 roll dup 5 1 roll % L-1 t [CurveB] i L-1
	-1 3 -1 roll % L-1 t [CurveB] L-1 -1 i
	{ % L-1 t [CurveB] j
	    2 copy 5 copy % L-1 t [CurveB] j [CurveB] j t [CurveB] j [CurveB] j 
	    1 sub get 3 1 roll get % L-1 t [CurveB] j [CurveB] j t B[j-1] B[j]
	    Lerp put pop % L-1 t [CurveB]
	} for
    } for
    pop pop pop
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{RightPortion}
%   Compute the portion of the Bezier curve \PSarray{CurveB} wrt the
%   interval \PSarray{t 1}.
% \begin{pssyntax}
% \PSarray{CurveB} \PSvar{t} \PSop{RightPortion} \PSarray{CurvePartB}
% \end{pssyntax}
%    \begin{macrocode}
/RightPortion {
    (RightPortion) DebugBegin
    exch dup length 1 sub dup 4 1 roll % L-1 t [CurveB] L-1
    1 1 3 -1 roll {% L-1 t [CurveB] i
	4 -1 roll dup 5 1 roll % L-1 t [CurveB] i L-1
	exch sub 0 1 3 -1 roll  % L-1 t [CurveB] 0 1 L-i-1
	{% L-1 t [CurveB] j
	    2 copy 5 copy
	    get 3 1 roll 1 add get Lerp put pop
	} for
    } for
    pop pop pop
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{Lerp}
% Given two points and a parameter \PSvar{t} $\in$ \PSarray{0 1}, return a point
% proportionally from \PSarray{A} to \PSarray{B} by \PSvar{t}. Akin to 1 degree Bezier.
% \begin{pssyntax}
% \PSvar{t} \PSarray{A} \PSarray{B} \PSop{Lerp} \PSarray{newpoint}
% \end{pssyntax}
%    \begin{macrocode}
/Lerp {
    (Lerp) DebugBegin
    3 -1 roll dup 1 exch sub 3 1 roll % [A] (1-t) [B] t
    exch aload pop 3 -1 roll VecScale % [A] (1-t) B.x*t B.y*t
    4 2 roll
    exch aload pop 3 -1 roll VecScale VecAdd ToVec % [A.x*(1-t)+B.x*t A.y*(1-t)+B.y*t]
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{IsConstant}
% Test if all points of a curve are near to each other. This is used as termination criterium for the intersection procedure.
% \begin{pssyntax}
% \PSarray{Curve} \PSop{IsConstant} \PSvar{boolean}
% \end{pssyntax}
%    \begin{macrocode}
/IsConstant {
    aload length [ exch 1 roll ] true 3 1 roll
    {
	exch dup 4 1 roll
	AreNear and exch
    } forall
    pop
} bind def
%    \end{macrocode}
% \end{macro}
% \begin{macro}{AreNear}
% Test if two points are near to each other.
% \begin{pssyntax}
% \PSarray{P1} \PSarray{P2} \PSop{AreNear} \PSvar{boolean}
% \end{pssyntax}
%    \begin{macrocode}
/AreNear {
    (AreNear) DebugBegin
    aload pop 3 -1 roll aload pop
    VecSub abs epsilon lt exch abs epsilon lt and
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{Min}
% Get the minimum value of the vector \PSarray{P}.
% \begin{pssyntax}
% \PSarray{P} \PSop{Min} \PSvar{minimum}
% \end{pssyntax}
%    \begin{macrocode}
/Min {
    aload pop min
} bind def
%    \end{macrocode}
% \end{macro}
% \begin{macro}{Min}
% Get the maximum value of the vector \PSarray{P}.
% \begin{pssyntax}
% \PSarray{P} \PSop{Max} \PSvar{maximum}
% \end{pssyntax}
%    \begin{macrocode}
/Max {
    aload pop max
} bind def
%    \end{macrocode}
% \end{macro}
% \begin{macro}{Min}
% Get the extent of the interval \PSarray{I}.
% \begin{pssyntax}
% \PSarray{I} \PSop{Extent} \PSvar{I1-I0}
% \end{pssyntax}
%    \begin{macrocode}
/Extent {
    aload pop exch sub
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{MiddlePoint}
% Compute the middle point of the first and last point of \PSarray{Curve}.
% \begin{pssyntax}
% \PSarray{Curve} \PSop{MiddlePoint} \PSvar{X Y}
% \end{pssyntax}
%    \begin{macrocode}
/MiddlePoint {
    dup dup length 1 sub get aload pop
    3 -1 roll 0 get aload pop
    VecAdd 0.5 VecScale
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{OrthogonalOrientationLine}
% \begin{pssyntax}
% \PSvar{MiddlePointA} \PSarray{CurveB} \PSop{OrthogonalOrientationLine} \PSvar{A B C}
% \end{pssyntax}
%    \begin{macrocode}
/OrthogonalOrientationLine {
    (OrthogonalOrientationLine) DebugBegin
    dup dup length 1 sub get aload pop 3 -1 roll 0 get aload pop VecSub
%    \end{macrocode}
% rotate by +90 degrees
%    \begin{macrocode}
    neg exch
    4 2 roll 2 copy 6 2 roll VecAdd
    ImplicitLine
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{PickOrientationLine}
%   Pick an orientation line for a Bezier curve. This uses the first
%   point and the lastmost point, which is not near to it.
% \begin{pssyntax}
% \PSarray{Curve} \PSop{PickOrientationLine} \PSvar{A B C}
% \end{pssyntax}
%    \begin{macrocode}
/PickOrientationLine {
    (PickOrientationLine) DebugBegin
    dup dup length 1 sub exch 0 get% [Curve] L-1 P0
    exch -1 1 {% [Curve] P0 i
	3 -1 roll dup 4 1 roll exch get % [Curve] P0 Pi
	2 copy AreNear {
	    pop
	} {
	    exit
	} ifelse
    } for
    3 -1 roll pop
    exch aload pop 3 -1 roll aload pop ImplicitLine
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{ImplicitLine}
% Compute the coefficients \PSvar{A}, \PSvar{B}, \PSvar{C} of the normalized implicit equation
% of the line which goes through the points \PSarray{Xi Yi} and \PSarray{Xj Yj}.
%
% \begin{pssyntax}
% \PSvar{Xi Yi Xj Yj} \PSop{ImplicitLine} \PSvar{A B C}
% \end{pssyntax}
%    \begin{macrocode}
/ImplicitLine {
    4 copy % Xi Yi Xj Yj Xi Yi Xj Yj
    3 -1 roll sub 7 1 roll sub 5 1 roll % Yj-Yi Xi-Xj Xi Yi Xj Yj
    % Yi*Xj - Xi*Yj
    4 -1 roll mul neg % Yj-Yi Xi-Xj Yi Xj -Yj*Xi
    3 1 roll mul add % Yj-Yi Xi-Xj Yi*Xj-Yj*Xi | l0 l1 l2
    3 1 roll 2 copy tx@Dict begin Pyth end dup dup % l2 l0 l1 L L L
    5 -1 roll exch % l2 l1 L L l0 L
    div 5 1 roll % l0/L l2 l1 L L
    3 1 roll div % l0/L l2 L l1/L
    3 1 roll div % l0/L l1/L l2/L
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{distance}
% Compute the distance of point \PSarray{X Y} from the implicit line given
% by $Ax + By + C = 0,\quad (A^2+B^2 = 1)$.
% \begin{pssyntax}
% \PSvar{X Y A B C} \PSop{distance} \PSvar{d}
% \end{pssyntax}
%    \begin{macrocode}
/distance {
    5 1 roll 3 -1 roll mul 3 1 roll mul add add
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{ArrayToPointArray}
% \begin{pssyntax}
% \PSarray{A.x A.y ... N.x N.y} \PSop{ArrayToPointArray} \PSarray{\PSarray{A.x A.y} \ldots \PSarray{N.x N.y}}
% \end{pssyntax}
%    \begin{macrocode}
/ArrayToPointArray {
    aload length dup 2 idiv {
	3 1 roll [ 3 1 roll ] exch
	dup 1 sub 3 1 roll 1 roll
    } repeat 1 add [ exch 1 roll ]
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{PointArrayToArray}
% \begin{pssyntax}
% \PSarray{\PSarray{A.x A.y} \ldots \PSarray{N.x N.y}} \PSop{PointArrayToArray} \PSarray{A.x A.y ... N.x N.y}
% \end{pssyntax}
%    \begin{macrocode}
/PointArrayToArray {
    aload length dup {
	1 add dup 3 -1 roll aload pop 4 -1 roll 1 add 2 roll
    } repeat 1 add [ exch 1 roll ]
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{ClipCurve}
% Clip the Bezier curve B with respect to the Bezier curve A for
% individuating intersection points. The new parameter interval for the
% clipped curve is pushed on the stack.
% \begin{pssyntax}
% \PSarray{CurveA} \PSarray{CurveB} \PSop{ClipCurve} \PSarray{newinterval}
% \end{pssyntax}
%    \begin{macrocode}
/ClipCurve {
    (ClipCurve) DebugBegin
    4 dict begin 
    /CurveB exch def /CurveA exch def
    CurveA IsConstant {
    	CurveA MiddlePoint CurveB OrthogonalOrientationLine
    } {
	CurveA PickOrientationLine
    } ifelse
    CheckIT {
	3 copy exch 3 -1 roll (OrientationLine : )
	3 { exch 20 string cvs ( ) strcat strcat } repeat ==
    } if
    CurveA FatLineBounds
    CheckIT { dup (FatLineBounds : ) exch aload pop exch 20 string cvs (, ) strcat exch 20 string cvs strcat strcat == } if
    CurveB ClipCurveInterval
    end
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{FatLineBounds}
% Compute the boundary of the fat line given by \PSvar{A B C}
% \begin{pssyntax}
% \PSvar{A B C} \PSarray{Curve} \PSop{FatLineBounds} \PSvar{A B C} \PSarray{dmin dmax}
% \end{pssyntax}
%    \begin{macrocode}
/FatLineBounds {
    (FatLineBounds) DebugBegin
    /dmin 0 def /dmax 0 def
    { 
	4 copy aload pop 5 2 roll distance
	dup dmin lt { dup /dmin exch def } if
	dup dmax gt { dup /dmax exch def } if
	pop pop
    } forall
    [dmin dmax]
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{ClipCurveInterval}
%   Clip the Bezier curve wrt the fat line defined by the orientation
%   line (given by \PSvar{A B C}) and the interval range
%   \PSarray{bound}. The new parameter interval \PSarray{newinterval}
%   for the clipped curve is pushed on the stack.
% \begin{pssyntax}
% \PSvar{A B C} \PSarray{bound} \PSarray{curve} \PSop{ClipCurveInterval} \PSarray{newinterval}
% \end{pssyntax}
%    \begin{macrocode}
/ClipCurveInterval {
    (ClipCurveInterval) DebugBegin
    15 dict begin
    /curve exch def
    aload pop 2 copy min /boundMin exch def max /boundMax exch def
    [ 4 1 roll ] cvx /fatline exch def
    % number of sub-intervals
    /n curve length 1 sub def
    % distance curve control points
    /D n 1 add array def
    0 1 n { % i
	dup curve exch get aload pop % i Pi.x Pi.y
	fatline distance % distance d of Point i from the orientation line, on stack; i d
	exch dup n div % d i i/n
	[ exch 4 -1 roll ] % i [ i/n d ]
	D 3 1 roll put 
    } for
    D ConvexHull /D exch def
%    \end{macrocode}
% get the x-coordinate of the i-th point, i getX -> D[i][X]
%    \begin{macrocode}
    /getX { D exch get 0 get } def
%    \end{macrocode}
% get the y-coordinate of the i-th point, i getY -> D[i][Y]
%    \begin{macrocode}
    /getY { D exch get 1 get } def
    /tmin 1 def /tmax 0 def
    0 getY dup
    boundMin lt /plower exch def
    boundMax gt /phigher exch def
    plower phigher or not {
%    \end{macrocode}
% inside the fat line
%    \begin{macrocode}
	tmin 0 getX gt { /tmin 0 getX def } if
	tmax 0 getX lt { /tmax 0 getX def } if	
    } if
    1 1 D length 1 sub {
	/i exch def
	/clower i getY boundMin lt def
	/chigher i getY boundMax gt def
	clower chigher or not {
%    \end{macrocode}
% inside the fat line
%    \begin{macrocode}
	    tmin i getX gt { /tmin i getX def } if
	    tmax i getX lt { /tmax i getX def } if
	} if
	clower plower eq not {
%    \end{macrocode}
% cross the lower bound
%    \begin{macrocode}
	    boundMin i 1 sub i D Intersect % t on stack
	    dup tmin lt { dup /tmin exch def } if
	    dup tmax gt { dup /tmax exch def } if
	    pop 
	    /plower clower def
	} if
	chigher phigher eq not {
%    \end{macrocode}
% cross the upper bound
%    \begin{macrocode}
	    boundMax i 1 sub i D Intersect
	    dup tmin lt { dup /tmin exch def } if
	    dup tmax gt { dup /tmax exch def } if
	    pop 
	    /phigher chigher def
	} if
    } for
%    \end{macrocode}
% we have to test the closing segment for intersection
%    \begin{macrocode}
    /i D length 1 sub def
    /clower 0 getY boundMin lt def
    /chigher 0 getY boundMax gt def
    clower plower eq not {
%    \end{macrocode}
% cross the lower bound
%    \begin{macrocode}
	boundMin i 0 D Intersect
	dup tmin lt { dup /tmin exch def } if
	dup tmax gt { dup /tmax exch def } if
	pop
    } if
    chigher phigher eq not {
%    \end{macrocode}
% cross the lower bound
%    \begin{macrocode}
	boundMax i 0 D Intersect
	dup tmin lt { dup /tmin exch def } if
	dup tmax gt { dup /tmax exch def } if
	pop
    } if
    [tmin tmax]
    end
    DebugEnd
} bind def
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{Intersect}
%   Get the x component of the intersection point between the line
%   passing through $i$-th and $j$-th points of \PSarray{Curve} and the
%   horizonal line through \PSvar{y}.
% \begin{pssyntax}
% \PSvar{y i j} \PSarray{Curve} \PSop{Intersect} \PSvar{Xisect}
% \end{pssyntax}
%    \begin{macrocode}
/Intersect {
    dup 4 -1 roll get aload pop
    4 2 roll exch get aload pop
%    \end{macrocode}
% On the stack: \PSvar{y Xi Yi Xj Yj}, Compute (Xj - Xi) * (y - Yi)/(Yj - Yi) + Xi
%
% We are sure, that Yi != Yj, because this procedure is called only
% when the lower or upper bound is crossed.
%    \begin{macrocode}
    4 2 roll 2 copy 6 2 roll VecSub
    5 2 roll
    neg 3 -1 roll add
    3 -1 roll div
    3 -1 roll mul add
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{IsPath}
%   Check if an array is a path. A path is represented as array, which
%   contains other arrays which represent native Postscript
%   operations. Those can be \PSarray{X Y /@m}, \PSarray{X Y /@l}, or
%   \PSarray{X1 Y1 X2 Y2 X3 Y3 /@c}.
%
%   \begin{pssyntax}
%     \PSarray{array} \PSop{IsPath} \PSvar{boolean}
%   \end{pssyntax}
%    \begin{macrocode}
/IsPath {
  dup length 1 sub get type /nametype eq { true } { false } ifelse
} bind def
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{ShowPathPortion}
%   \begin{pssyntax}
%     \PSarray{path} \PSvar{tstart tstop} \PSop{ShowPathPortion}
%   \end{pssyntax}
%    \begin{macrocode}
/ShowPathPortion {
  6 dict begin
  /tstop exch def
  /tstart exch def
  InitTracing
  /n 0 def
  mark exch aload pop
  {
    counttomark 0 eq n tstop ge or { pop exit } if
    dup /movetype eq not { /n n 1 add def } if
    
    dup /movetype eq {
      load exec
    } {
      tstart n gt {
%    \end{macrocode}      
% current path section is before tstop
%    \begin{macrocode}
        /curvetype eq { 6 2 roll 4 { pop } repeat } if
        movetype
      } {
        tstart n 1 sub gt tstop n lt or {
%    \end{macrocode}
% draw a truncated segment
%    \begin{macrocode}
          tstart n sub 1 add tstop n sub 1 add
          ToUnitInterval exch
          /linetype eq {
            3 1 roll ToVec currentpoint ToVec exch ToVec
            dup 3 -1 roll Portion
            aload pop exch 
            tstart n 1 sub gt { 
%    \end{macrocode}
% This is the start segment, move to the starting point, as it lies in the middle of the segment.
%    \begin{macrocode}
              exch aload pop 3 -1 roll aload pop ArrowA 
              tstop n le { 
%    \end{macrocode}
% only a single segment, draw also the ending arrow 
%    \begin{macrocode}
                currentpoint 4 2 roll ArrowB lineto pop pop
              } {
%    \end{macrocode}
% other segments to follow
%    \begin{macrocode}
                lineto
              } ifelse
            } { 
%    \end{macrocode}
% this is the last segment
%    \begin{macrocode}
              pop aload pop currentpoint 4 2 roll ArrowB lineto pop pop
            } ifelse
          } {
            7 1 roll [ currentpoint 9 3 roll ] ArrayToPointArray
            dup 3 -1 roll Portion 
            { aload pop } forall
            8 -2 roll
            tstart n 1 sub gt { moveto } { pop pop } ifelse
            6 -2 roll currentpoint ArrowA 6 2 roll
            tstop n le {
%    \end{macrocode}              
% only a single segment
%    \begin{macrocode}
              ArrowB
            } if
            curveto
          } ifelse
        }{
%    \end{macrocode}
% full segment
%    \begin{macrocode}
          tstart n 1 sub eq {
%    \end{macrocode}
% the first segment
%    \begin{macrocode}
            /linetype eq {
              currentpoint ArrowA
              tstop n eq {
%    \end{macrocode}
% a single, full segment
%    \begin{macrocode}
                currentpoint 4 2 roll ArrowB lineto pop pop
              } {
%    \end{macrocode}
% not the last segment
%    \begin{macrocode}
                lineto
              } ifelse
            } {
              6 -2 roll currentpoint ArrowA 6 2 roll
              tstop n eq {
%    \end{macrocode}
% single, full curve segment
%   \begin{macrocode}
                ArrowB
              } if
              curveto
            } ifelse
          } {
%    \end{macrocode}
% not the first segment
%    \begin{macrocode}
            /linetype eq {
              tstop n eq {
%    \end{macrocode}
% last segment but not a single one
%    \begin{macrocode}
                currentpoint 4 2 roll ArrowB lineto pop pop
              }{
%    \end{macrocode}
% full middle segment
%    \begin{macrocode}
                lineto
              } ifelse
            } {
              tstop n eq {
%    \end{macrocode}
% last curveto segment, not a single one
%    \begin{macrocode}
                ArrowB
              } if
              curveto
            } ifelse
          } ifelse
        } ifelse
      } ifelse
    } ifelse
  } loop
  end
} bind def
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
 % Graham Scal algorithm to compute the convex hull of a set of
 % points. Code written by Bill Casselman,
 %  http://www.math.ubc.ca/~cass/graphics/text/www/
 %
 % [[X1 Y1] [X2 Y2] ... [Xn Yn]] hull -> [[...] ... [...]]
 %
/hulldict 32 dict def
hulldict begin

 % u - v 
/vsub { 2 dict begin
/v exch def
/u exch def
[ 
  u 0 get v 0 get sub
  u 1 get v 1 get sub
]
end } def

 % u - v rotated 90 degrees
/vperp { 2 dict begin
/v exch def
/u exch def
[ 
  v 1 get u 1 get sub
  u 0 get v 0 get sub
]
end } def

/dot { 2 dict begin
/v exch def
/u exch def
  v 0 get u 0 get mul
  v 1 get u 1 get mul
  add
end } def 

 % P Q
 % tests whether P < Q in lexicographic order
 % i.e xP < xQ, or yP < yQ if xP = yP
/comp { 2 dict begin
/Q exch def
/P exch def
P 0 get Q 0 get lt 
  P 0 get Q 0 get eq
  P 1 get Q 1 get lt 
  and 
or 
end } def

end

 % args: an array of points C
 % effect: returns the array of points on the boundary of
 %     the convex hull of C, in clockwise order 

/ConvexHull {
(ConvexHull) DebugBegin
hulldict begin
/C exch def
/comp C quicksort
/n C length def
 % Q might circle around to the start
/Q n 1 add array def
Q 0 C 0 get put
Q 1 C 1 get put
/i 2 def
/k 2 def
 % i is next point in C to be looked at
 % k is next point in Q to be added
 % [ Q[0] Q[1] ... ]
 % scan the points to make the top hull
n 2 sub {
  % P is the current point at right
  /P C i get def
  /i i 1 add def
  {
    % if k = 1 then just add P 
    k 2 lt { exit } if
    % now k is 2 or more
    % look at Q[k-2] Q[k-1] P: a left turn (or in a line)?
    % yes if (P - Q[k-1])*(Q[k-1] - Q[k-2])^perp >= 0
    P Q k 1 sub get vsub 
    Q k 1 sub get Q k 2 sub get vperp 
    dot 0 lt {
      % not a left turn
      exit
    } if
    /k k 1 sub def
  } loop
  Q k P put
  /k k 1 add def
} repeat

 % done with top half
 % K is where the right hand point is
/K k 1 sub def

/i n 2 sub def
Q k C i get put
/i i 1 sub def
/k k 1 add def
n 2 sub {
  % P is the current point at right
  /P C i get def
  /i i 1 sub def
  {
    % in this pass k is always 2 or more
    k K 2 add lt { exit } if
    % look at Q[k-2] Q[k-1] P: a left turn (or in a line)?
    % yes if (P - Q[k-1])*(Q[k-1] - Q[k-2])^perp >= 0
    P Q k 1 sub get vsub 
    Q k 1 sub get Q k 2 sub get vperp 
    dot 0 lt {
      % not a left turn
      exit
    } if
    /k k 1 sub def
  } loop
  Q k P put
  /k k 1 add def
} repeat

 % strip Q down to [ Q[0] Q[1] ... Q[k-2] ]
 % excluding the doubled initial point
[ 0 1 k 2 sub {
  Q exch get
} for ] 
end
DebugEnd
} def

/qsortdict 8 dict def

qsortdict begin

 % args: /comp a L R x
 % effect: effects a partition into two pieces [L j] [i R]
 %     leaves i j on stack

/partition { 8 dict begin
/x exch def
/j exch def
/i exch def
/a exch def
dup type /nametype eq { load } if /comp exch def
{
  {
    a i get x comp exec not {
      exit
    } if
    /i i 1 add def
  } loop
  {
    x a j get comp exec not {
      exit
    } if
    /j j 1 sub def
  } loop
  
  i j le {
    % swap a[i] a[j]
    a j a i get
    a i a j get 
    put put
    /i i 1 add def
    /j j 1 sub def
  } if
  i j gt {
    exit
  } if
} loop
i j
end } def

 % args: /comp a L R
 % effect: sorts a[L .. R] according to comp
/subsort {
 % /c a L R
[ 3 1 roll ] 3 copy
 % /c a [L R] /c a [L R]
aload aload pop 
 % /c a [L R] /c a L R L R
add 2 idiv
 % /c a [L R] /c a L R (L+R)/2
3 index exch get
 % /c a [L R] /c a L R x
partition
 % /c a [L R] i j
 % if j > L subsort(a, L, j)
dup 
 % /c a [L R] i j j
3 index 0 get gt {
  % /c a [L R] i j
  5 copy 
  % /c a [L R] i j /c a [L R] i j
  exch pop
  % /c a [L R] i j /c a [L R] j
  exch 0 get exch
  % ... /c a L j 
  subsort
} if
 % /c a [L R] i j
pop dup
 % /c a [L R] i i
 % if i < R subsort(a, i, R)
2 index 1 get lt {
  % /c a [L R] i
  exch 1 get 
  % /c a i R
  subsort
}{
  4 { pop } repeat
} ifelse
} def

end % qsortdict

 % args: /comp a
 % effect: sorts the array a 
 % comp returns truth of x < y for entries in a

/quicksort { qsortdict begin
dup length 1 gt {
 % /comp a
dup 
 % /comp a a 
length 1 sub 
 % /comp a n-1
0 exch subsort
} {
pop pop
} ifelse
end } def
%    \end{macrocode}
% 
% Debugging stuff
%    \begin{macrocode}
/debug {
    dup 1 add copy {==} repeat pop
} bind def
/DebugIT false def
/CheckIT false def
/DebugDepth 0 def
/DebugBegin {
  DebugIT {
    /DebugProcName exch def
    DebugDepth 2 mul string
    0 1 DebugDepth 2 mul 1 sub {
      dup 2 mod 0 eq { (|) }{( )} ifelse
      3 -1 roll dup 4 2 roll
      putinterval
    } for
    DebugProcName strcat ==
    /DebugDepth DebugDepth 1 add def
  }{
    pop
  } ifelse
} bind def
/DebugEnd {
  DebugIT {
    /DebugDepth DebugDepth 1 sub def
    DebugDepth 2 mul 2 add string
    0 1 DebugDepth 2 mul 1 sub {
      dup 2 mod 0 eq { (|) }{ ( ) } ifelse
      3 -1 roll dup 4 2 roll
      putinterval
    } for
    dup DebugDepth 2 mul (+-) putinterval
    ( done) strcat ==
  } if
} bind def
/strcat {
    exch 2 copy
    length exch length add
    string dup dup 5 2 roll
    copy length exch
    putinterval
} bind def
/nametostr {
    dup length string cvs
} bind def
/ShowCurve {
    { aload pop } forall
    8 -2 roll moveto curveto
} bind def
/CurveToString {
    (CurveToString) DebugBegin
    aload pop ([) 3 -1 roll 20 string cvs strcat (, ) strcat exch 20 string cvs strcat (]) strcat
    DebugEnd
} bind def
end % tx@IntersectDict
%    \end{macrocode}
%</prolog> 
% \Finale
% \endinput