summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-3dplot/pst-3dplot.tex
blob: e8812bd5102e3e063c520635010783a0e51a910a (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
%%
%% This is file `pst-3dplot.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-3dplot.tex'
%%
%% Herbert Voss <voss _at_ perce.de>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-3dplot' is a PSTricks package to draw 3d curves,
%%       data and different graphical objects
%%
\csname PSTThreeDplotLoaded\endcsname
\let\PSTThreeDplotLoaded\endinput
% Requires PSTricks, pst-node, pst-plot, multido packages
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-3d.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex\fi
\ifx\PSTplotLoaded\endinput\else\input pst-plot.tex\fi% plotpoints
%\ifx\PSTVueTroisDLoaded\endinput\else\input pst-vue3d.tex\fi
\ifx\PSTMultidoLoaded\endinput\else\input multido.tex\fi
%
\def\fileversion{1.72}
\def\filedate{2006/02/07}
\message{`PST-3dplot' v\fileversion, \filedate\space (HV)}
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
\pst@addfams{pst-3dplot}
\SpecialCoor
%
%%%%%%%%%%%%%%%%%% Macrolist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \def\pstThreeDPut
% \def\pstThreeDLine
% \def\pstThreeDDot
% \def\pstThreeDNode
% \def\pstUThreeDPut
% \def\pstThreeDSquare
% \def\pstThreeDBox
% \def\pstThreeDSphere
% \def\pstThreeDEllipse
% \def\pstThreeDPlotFunc
% \def\psplotThreeD
% \def\parametricplotThreeD
% \def\psThreeDPlot
% \def\pstThreeDCoor
% \def\fileplotThreeD
% \def\dataplotThreeD
% \def\listplotThreeD
%
%
\newdimen\pst@dimf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ---------------- the if's -----------------
%
\newif\ifPst@drawing%			draw the coordinates?
\define@key[psset]{pst-3dplot}{drawing}[true]{\@nameuse{Pst@drawing#1}}
\newif\ifPst@drawCoor%		draw the coordinates of a dot?
\define@key[psset]{pst-3dplot}{drawCoor}[true]{\@nameuse{Pst@drawCoor#1}}
\newif\ifPst@hiddenLine%	emulate hidden line surface?
\define@key[psset]{pst-3dplot}{hiddenLine}[true]{\@nameuse{Pst@hiddenLine#1}}
\newif\ifPst@SphericalCoor% 	(r,phi,theta)
\define@key[psset]{pst-3dplot}{SphericalCoor}[true]{\@nameuse{Pst@SphericalCoor#1}}
\psset[pst-3dplot]{SphericalCoor=false}
\newif\ifPst@leftHanded%			left-Handed coor?
\define@key[psset]{pst-3dplot}{leftHanded}[true]{\@nameuse{Pst@leftHanded#1}}
\psset[pst-3dplot]{leftHanded=false}
%
% ------- the global definitions for the pspicture frame ------
%
\define@key[psset]{pst-3dplot}{xMin}{\def\psk@ThreeDplot@xMin{#1}}
\define@key[psset]{pst-3dplot}{xMax}{\def\psk@ThreeDplot@xMax{#1}}
\define@key[psset]{pst-3dplot}{yMin}{\def\psk@ThreeDplot@yMin{#1}}
\define@key[psset]{pst-3dplot}{yMax}{\def\psk@ThreeDplot@yMax{#1}}
\define@key[psset]{pst-3dplot}{zMin}{\def\psk@ThreeDplot@zMin{#1}}
\define@key[psset]{pst-3dplot}{zMax}{\def\psk@ThreeDplot@zMax{#1}}
\define@key[psset]{pst-3dplot}{xThreeDunit}{\def\psk@ThreeDplot@xThreeDunit{#1}}
\define@key[psset]{pst-3dplot}{yThreeDunit}{\def\psk@ThreeDplot@yThreeDunit{#1}}
\define@key[psset]{pst-3dplot}{zThreeDunit}{\def\psk@ThreeDplot@zThreeDunit{#1}}
\define@key[psset]{pst-3dplot}{deltax}{\def\psk@ThreeDplot@deltax{#1}}
\define@key[psset]{pst-3dplot}{deltay}{\def\psk@ThreeDplot@deltay{#1}}
\define@key[psset]{pst-3dplot}{deltaz}{\def\psk@ThreeDplot@deltaz{#1}}
\define@key[psset]{pst-3dplot}{Deltax}{\def\psk@ThreeDplot@Deltax{#1}}
\define@key[psset]{pst-3dplot}{Deltay}{\def\psk@ThreeDplot@Deltay{#1}}
\define@key[psset]{pst-3dplot}{Deltaz}{\def\psk@ThreeDplot@Deltaz{#1}}
%
% -------------- the angles and the plotpoints -------------
%
\define@key[psset]{pst-3dplot}{Alpha}{\def\psk@ThreeDplot@Alpha{#1}} %	Horizontal turn
\define@key[psset]{pst-3dplot}{Beta}{\def\psk@ThreeDplot@Beta{#1}}%	Vertical turn
\define@key[psset]{pst-3dplot}{RotX}{\def\psk@ThreeD@RotX{#1}}% x rotation 
\define@key[psset]{pst-3dplot}{RotY}{\def\psk@ThreeD@RotY{#1}}% y rotation
\define@key[psset]{pst-3dplot}{RotZ}{\def\psk@ThreeD@RotZ{#1}}% z 
\define@key[psset]{pst-3dplot}{RotSequence}{\def\psk@ThreeD@RotS{#1}}%
\define@key[psset]{pst-3dplot}{zCoor}{\def\psk@ThreeDplot@zCoor{#1}} 
\psset[pst-3dplot]{zCoor=0}
%
\def\drawStyle@xLines{xLines}% 0
\def\drawStyle@yLines{yLines}% 1
\def\drawStyle@xyLines{xyLines}% 2
\def\drawStyle@yxLines{yxLines}% 3
\define@key[psset]{pst-3dplot}{drawStyle}{%			how to draw 3D functions
  \def\pst@tempa{#1}%
  \ifx\pst@tempa\drawStyle@xLines\let\psk@ThreeDplot@drawStyle\z@\else%
    \ifx\pst@tempa\drawStyle@yLines\let\psk@ThreeDplot@drawStyle\@ne\else%
      \ifx\pst@tempa\drawStyle@xyLines\let\psk@ThreeDplot@drawStyle\tw@\else%
         \ifx\pst@tempa\drawStyle@yxLines\let\psk@ThreeDplot@drawStyle\thr@@\else%
            \@pstrickserr{Bad draw style: `\pst@tempa'}\@ehpa%
  \fi\fi\fi\fi%
%  \typeout{drawStyle: \the\psk@ThreeDplot@drawStyle}
  }
\psset[pst-3dplot]{drawStyle=xLines}
%
\define@key[psset]{pst-3dplot}{xPlotpoints}{\def\psk@ThreeDplot@xPlotpoints{#1}}
\define@key[psset]{pst-3dplot}{yPlotpoints}{\def\psk@ThreeDplot@yPlotpoints{#1}}
\define@key[psset]{pst-3dplot}{beginAngle}{%		for ellipse/circle arc
  \def\psk@ThreeDplot@beginAngle{#1}}
\define@key[psset]{pst-3dplot}{endAngle}{%			for ellipse/circle arc
  \def\psk@ThreeDplot@endAngle{#1}}
\define@key[psset]{pst-3dplot}{linejoin}{%		how lines come together 0,1,2
  \def\psk@ThreeDplot@linejoin{#1}}
\define@key[psset]{pst-3dplot}{plane}{%			xy,xz,yz
  \def\psk@ThreeDplot@plane{#1}}
\define@key[psset]{pst-3dplot}{pOrigin}{%			combination of (lr)(tBb)
  \def\psk@ThreeDplot@pOrigin{#1}}
\def\ThreeDplot@planeXY{xy}
\def\ThreeDplot@planeXZ{xz}
\def\ThreeDplot@planeYZ{yz}
%
% -------------- the length and node definitions -------------
%
\define@key[psset]{pst-3dplot}{XO}{%			the X-offset
  \def\psk@ThreeDplot@XO{#1}}
\define@key[psset]{pst-3dplot}{YO}{%			the y-offset
  \def\psk@ThreeDplot@YO{#1}}
\define@key[psset]{pst-3dplot}{angleStep}{%		for circles
  \def\psk@ThreeDplot@angleStep{#1}}
\define@key[psset]{pst-3dplot}{posStart}{%		where the arrows start
  \def\psk@ThreeDplot@posStart{#1}}
\define@key[psset]{pst-3dplot}{length}{%		the length of the before|outlines
  \def\psk@ThreeDplot@length{#1}}
\define@key[psset]{pst-3dplot}{arrowOffset}{%	offset for \arrowLine
  \def\psk@ThreeDplot@arrowOffset{#1}}
\define@key[psset]{pst-3dplot}{visibleLineStyle}{%	offset for \arrowLine
  \def\psk@ThreeDplot@visibleLineStyle{#1}}
\define@key[psset]{pst-3dplot}{invisibleLineStyle}{%	offset for \arrowLine
  \def\psk@ThreeDplot@invisibleLineStyle{#1}}
%
\newif\if@IIIDticks%          draw the ticks?
\define@key[psset]{pst-3dplot}{IIIDticks}[true]{\@nameuse{@IIIDticks#1}}
\define@key[psset]{pst-3dplot}{Dz}{\def\psk@Dz{#1}}
\define@key[psset]{pst-3dplot}{IIIDxTicksPlane}{\def\psk@IIIDxTicksPlane{#1}}
\define@key[psset]{pst-3dplot}{IIIDyTicksPlane}{\def\psk@IIIDyTicksPlane{#1}}
\define@key[psset]{pst-3dplot}{IIIDzTicksPlane}{\def\psk@IIIDzTicksPlane{#1}}
\define@key[psset]{pst-3dplot}{IIIDticksize}{\def\psk@IIIDticksize{#1}}
\define@key[psset]{pst-3dplot}{IIIDxticksep}{\def\psk@IIIDxticksep{#1}}
\define@key[psset]{pst-3dplot}{IIIDyticksep}{\def\psk@IIIDyticksep{#1}}
\define@key[psset]{pst-3dplot}{IIIDzticksep}{\def\psk@IIIDzticksep{#1}}
\define@key[psset]{pst-3dplot}{nameX}{%		start of the object arrow
	\def\psk@ThreeDplot@nameX{#1}}
\define@key[psset]{pst-3dplot}{spotX}{%		where to draw the label
	\def\psk@ThreeDplot@spotX{#1}}
\define@key[psset]{pst-3dplot}{nameY}{\def\psk@ThreeDplot@nameY{#1}}
\define@key[psset]{pst-3dplot}{spotY}{\def\psk@ThreeDplot@spotY{#1}}
\define@key[psset]{pst-3dplot}{nameZ}{\def\psk@ThreeDplot@nameZ{#1}}
\define@key[psset]{pst-3dplot}{spotZ}{\def\psk@ThreeDplot@spotZ{#1}}
%
% ###   begin Torsten Suhling
\define@key[psset]{pst-3dplot}{planecorr}{%			make plane tags readable 
	\def\psk@ThreeDplot@planecorr{#1}} 
\def\ThreeDplot@planecorrOff{off}	% default
\def\ThreeDplot@planecorrNormal{normal}	% make planes readable 
\def\ThreeDplot@planecorrXYrot{xyrot}	% and put tag for xy-plane 
% 					% parallel to the y-axis 
% ###   end Torsten Suhling
%
\def\psds@none{\pst@gdot{}}% define none for the dotstyle
%
\newpsstyle{hiddenStyle}{fillstyle=solid,fillcolor=white}
\newcount\pst@cntx\newcount\pst@cnty\newcount\pst@cntz
\newdimen\pst@dimx\newdimen\pst@dimy\newdimen\pst@dimz
%
\define@key[psset]{pst-3dplot}{planeGrid}{\def\psk@planeGrid{#1}}
\define@key[psset]{pst-3dplot}{planeGridOffset}{\def\psk@planeGridOffset{#1}}
\define@key[psset]{pst-3dplot}{subticks}{\def\psk@xsubticks{#1}\def\psk@ysubticks{#1}}
\define@key[psset]{pst-3dplot}{xsubticks}{\def\psk@xsubticks{#1}}
\define@key[psset]{pst-3dplot}{ysubticks}{\def\psk@ysubticks{#1}}
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                              %
%                        B A S I C S	                       %
%                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\pstheader{pst-3dplot.pro}
% ---- only shortcuts -------
\def\pst@3ddict{tx@3DPlotDict begin }
\def\tx@saveCoor{\pst@3ddict saveCoor end }
\def\tx@X{\pst@3ddict x end }
\def\tx@Y{\pst@3ddict y end }
\def\tx@Z{\pst@3ddict z end }
\def\tx@xIID{\pst@3ddict x2D end }
\def\tx@yIID{\pst@3ddict y2D end }
\def\tx@ConvertToIID{\pst@3ddict ConvertTo2D end }
\def\tx@SphericalCoor{\pst@3ddict SphericalCoor end }
\def\tx@ConvertToCartesian{\pst@3ddict ConvertToCartesian end }
%
\def\setDefaults{%
  \psset[pst-3dplot]{%
  drawing=true,hiddenLine=false,xMin=-1,xMax=4,yMin=-1,yMax=4,zMin=-1,zMax=4,%
  xThreeDunit=1.0,yThreeDunit=1.0,zThreeDunit=1.0,Alpha=45,Beta=30,%
  deltax=1,deltay=1,deltaz=1,Deltax=1,Deltay=1,Deltaz=1,%
  RotX=0,RotY=0,RotZ=0,RotSequence=xyz,%
  drawStyle=xLines,xPlotpoints=25,yPlotpoints=25,beginAngle=0,endAngle=360,%
  linejoin=1,XO=0,YO=0,angleStep=1,posStart=0,length=2,arrowOffset=0,%
  visibleLineStyle=solid,invisibleLineStyle=dashed,nameX=$x$,spotX=180,%
  nameY=$y$,spotY=0,nameZ=$z$,spotZ=90,plane=xy,pOrigin=c,SphericalCoor=false,%
  Dz=1,IIIDticks=false,IIIDxTicksPlane=xy,IIIDyTicksPlane=yz,IIIDzTicksPlane=yz,%
  IIIDticksize=0.1,IIIDxticksep=-0.4,IIIDyticksep=-0.2,IIIDzticksep=0.2,
  planecorr=off,%
  planeGrid=xy,planeGridOffset=0,subticks=10,
  leftHanded=false%
  }%
  \def\pst@linetype{2}%  to prevent an unknown linetyp with dash
}
\setDefaults
%
\def\variablesIIID{
%  0 0 translate
  /RotX \psk@ThreeD@RotX\space def
  /RotY \psk@ThreeD@RotY\space def
  /RotZ \psk@ThreeD@RotZ\space def
  /dxUnit \psk@ThreeDplot@xThreeDunit\space def
  /dyUnit \psk@ThreeDplot@yThreeDunit\space def
  /dzUnit \psk@ThreeDplot@zThreeDunit\space def
  /RotSequence (\psk@ThreeD@RotS) def
  /Alpha \psk@ThreeDplot@Alpha\space def
  /Beta \psk@ThreeDplot@Beta\space def
  /Sin1 Beta sin def
  /Sin2 Alpha sin def
  /Cos1 Beta cos def
  /Cos2 Alpha cos def
  /Cos1Sin2 Cos1 Sin2 mul def
  /Sin1Sin2 Sin1 Sin2 mul def
  /Cos1Cos2 Cos1 Cos2 mul def
  /Sin1Cos2 Sin1 Cos2 mul def
  /M11 RotZ cos RotY cos mul def
  /M12 RotZ cos RotY sin mul RotX sin mul RotZ sin RotX cos mul sub def
  /M13 RotZ cos RotY sin mul RotX cos mul RotZ sin RotX sin mul add def
  /M21 RotZ sin RotY cos mul def
  /M22 RotZ sin RotY sin RotX sin mul mul RotZ cos RotX cos mul add def
  /M23 RotZ sin RotY sin mul RotX cos mul RotZ cos RotX sin mul sub def
  /M31 RotY sin neg def
  /M32 RotX sin RotY cos mul def
  /M33 RotX cos RotY cos mul def
  /leftHanded \ifPst@leftHanded true \else false \fi def
}%
%
% (#1) -> #1 #2 #3
\def\getThreeDCoor#1#2{\pst@getThreeDcoor(#1)\let#2\pst@coorIIID}
\def\pst@getThreeDcoor(#1,#2,#3){%
  \edef\pst@coorIIID{#1\space #2\space #3\space}%
}
\def\pst@addThreeDVec(#1)(#2)#3#4#5{%
  \pst@calcThreeDVec(#1)(#2)%
  \let#3\pst@getValueX%
  \let#4\pst@getValueY%
  \let#5\pst@getValueZ%
}
\def\pst@subThreeDVec(#1)(#2,#3,#4)#5#6#7{%
  \pst@calcThreeDVec(#1)(-#2,-#3,-#4)%
  \let#5\pst@getValueX%
  \let#6\pst@getValueY%
  \let#7\pst@getValueZ%
}
\def\pst@calcThreeDVec(#1,#2,#3)(#4,#5,#6){{%
    \pst@dima=#1 pt%
    \pst@dimb=#2 pt%
    \pst@dimc=#3 pt%
    \pst@dimf=#4 pt%
    \pst@dimg=#5 pt%
    \pst@dimh=#6 pt%
    \advance\pst@dima by \pst@dimf%
    \advance\pst@dimb by \pst@dimg%
    \advance\pst@dimc by \pst@dimh%
    \xdef\pst@getValueX{\pst@number\pst@dima}%
    \xdef\pst@getValueY{\pst@number\pst@dimb}%
    \xdef\pst@getValueZ{\pst@number\pst@dimc}%
}}%
%
% the ThreeD coordinate system
%
\def\psxyzlabel#1{\bgroup\footnotesize\textsf{#1}\egroup}
%
\def\pstThreeDCoor{\pst@object{pstThreeDCoor}}
\def\pstThreeDCoor@i{%
  \pst@killglue%
  \begingroup%
  \addbefore@par{linewidth=0.5pt,linecolor=red,arrows=->,dotstyle=|}%
  \use@par%
  \pstThreeDNode(\psk@ThreeDplot@xMin,0,0){xMin}%
  \pstThreeDNode(\psk@ThreeDplot@xMax,0,0){xMax}%
  \pstThreeDNode(0,\psk@ThreeDplot@yMin,0){yMin}%
  \pstThreeDNode(0,\psk@ThreeDplot@yMax,0){yMax}%
  \pstThreeDNode(0,0,\psk@ThreeDplot@zMin){zMin}%
  \pstThreeDNode(0,0,\psk@ThreeDplot@zMax){zMax}%
  \ifPst@drawing% ThreeDplot axes
    \psline(xMin)(xMax)%
    \psline(yMin)(yMax)%
    \psline(zMin)(zMax)%
    \uput[\psk@ThreeDplot@spotX](xMax){\psk@ThreeDplot@nameX}%
    \uput[\psk@ThreeDplot@spotY](yMax){\psk@ThreeDplot@nameY}%
    \uput[\psk@ThreeDplot@spotZ](zMax){\psk@ThreeDplot@nameZ}%
  \if@IIIDticks%
%    \ifnum\psk@ThreeDplot@Alpha=90\else
    \pst@dimx=\psk@ThreeDplot@xMax\p@%
    \pst@dima=\psk@ThreeDplot@xThreeDunit\p@%
    \pst@dima=\psk@ThreeDplot@deltax\pst@dima
    \pst@dima=\pst@dima
    \divide\pst@dimx by \pst@dima 
    \pst@cntx=\number\pst@dimx\advance\pst@cntx by -1%
    \multido{%
%      \rA=\psk@ThreeDplot@Deltax+\psk@ThreeDplot@Deltax,% the label increment
      \rA=\psk@Dx+\psk@Dx,%
      \rB=\psk@ThreeDplot@deltax+\psk@ThreeDplot@deltax}{\pst@cntx}{% the coor increment
%      \rB=\psk@ThreeDplot@xThreeDunit+\psk@ThreeDplot@xThreeDunit}{\pst@cntx}{%
      \pstThreeDLine[arrows=-](\rB,-\psk@IIIDticksize,0)(\rB,\psk@IIIDticksize,0)%
      \pstPlanePut[plane=\psk@IIIDxTicksPlane]%
         (\rB,\psk@IIIDxticksep,0){\psxyzlabel{\rA}}%
    }%
    \pst@dimx=\psk@ThreeDplot@xMin\p@%
    \pst@dima=\psk@ThreeDplot@xThreeDunit\p@%
    \divide\pst@dimx by \pst@dima%
    \ifnum\psk@ThreeDplot@xMin<\z@\pst@cntx=-\number\pst@dimx%
    \else\pst@cntx=\number\pst@dimx%
    \fi%
    \multido{\rA=-\psk@Dx+-\psk@Dx,%
       \rB=-\psk@ThreeDplot@xThreeDunit+-\psk@ThreeDplot@xThreeDunit}{\pst@cntx}{%
      \pstThreeDLine[arrows=-](\rB,-\psk@IIIDticksize,0)(\rB,\psk@IIIDticksize,0)%
      \pstPlanePut[plane=\psk@IIIDxTicksPlane](\rB,\psk@IIIDxticksep,0){\psxyzlabel{\rA}}%
    }%
%    \fi%
%    \ifnum\psk@ThreeDplot@Alpha=0\else
    \pst@dimy=\psk@ThreeDplot@yMax\p@%
    \pst@dima=\psk@ThreeDplot@yThreeDunit\p@%
    \divide\pst@dimy by \pst@dima%
    \pst@cnty=\number\pst@dimy\advance\pst@cnty by -1%
    \mmultido{\rA=0.0+\psk@Dy,\rB=0.0+\psk@ThreeDplot@yThreeDunit}{\pst@cnty}{%
      \pstThreeDLine[arrows=-](-\psk@IIIDticksize,\rB,0)(\psk@IIIDticksize,\rB,0)%
      \pstPlanePut[plane=\psk@IIIDyTicksPlane](\psk@IIIDyticksep,\rB,0){\psxyzlabel{\rA}}%
    }%
    \pst@dimy=\psk@ThreeDplot@yMin\p@%
    \pst@dima=\psk@ThreeDplot@yThreeDunit\p@%
    \divide\pst@dimy by \pst@dima%
    \ifnum\psk@ThreeDplot@yMin<\z@\pst@cnty=-\number\pst@dimy%
    \else\pst@cnty=\number\pst@dimy%
    \fi%
    \multido{\rA=-\psk@Dy+-\psk@Dy,%
        \rB=-\psk@ThreeDplot@yThreeDunit+-\psk@ThreeDplot@yThreeDunit}{\pst@cnty}{%
      \pstThreeDLine[arrows=-](-\psk@IIIDticksize,\rB,0)(\psk@IIIDticksize,\rB,0)%
      \pstPlanePut[plane=\psk@IIIDyTicksPlane](\psk@IIIDyticksep,\rB,0){\psxyzlabel{\rA}}%
    }%
%    \fi%
    \pst@dimz=\psk@ThreeDplot@zMax\p@%
    \pst@dima=\psk@ThreeDplot@zThreeDunit\p@%
    \divide\pst@dimz by \pst@dima%
    \pst@cntz=\number\pst@dimz\advance\pst@cntz by -1%
    \mmultido{\rA=0.0+\psk@Dz,\rB=0.0+\psk@ThreeDplot@zThreeDunit}{\pst@cntz}{%
      \pstThreeDLine[arrows=-](0,-\psk@IIIDticksize,\rB)(0,\psk@IIIDticksize,\rB)%
      \pstPlanePut[plane=\psk@IIIDzTicksPlane](0,\psk@IIIDzticksep,\rB){\psxyzlabel{\rA}}%
    }%
    \pst@dimz=\psk@ThreeDplot@zMin\p@%
    \pst@dima=\psk@ThreeDplot@zThreeDunit\p@%
    \divide\pst@dimz by \pst@dima%
    \ifnum\psk@ThreeDplot@zMin<\z@\pst@cntz=-\number\pst@dimz%
    \else\pst@cntz=\number\pst@dimz%
    \fi%
    \multido{\rA=-\psk@Dz+-\psk@Dz,%
       \rB=-\psk@ThreeDplot@zThreeDunit+-\psk@ThreeDplot@zThreeDunit}{\pst@cntz}{%
      \pstThreeDLine[arrows=-](0,-\psk@IIIDticksize,\rB)(0,\psk@IIIDticksize,\rB)%
      \pstPlanePut[plane=\psk@IIIDzTicksPlane](0,\psk@IIIDzticksep,\rB){\psxyzlabel{\rA}}%
    }%
  \fi\fi%
  \endgroup%
  \ignorespaces%
}
%
% planeGrids
%
\newdimen\pst@dx\newdimen\pst@dy
\def\pstThreeDPlaneGrid{\pst@object{pstThreeDPlaneGrid}}
\def\pstThreeDPlaneGrid@i(#1,#2)(#3,#4){{%
  \pst@killglue
  \use@par
  \pssetxlength\pst@dima{#1}
  \pssetxlength\pst@dimb{#3}
  \advance\pst@dimb by -\pst@dima
  \divide\pst@dimb by \psk@xsubticks
  \pst@dx=\pst@dimb
%  
  \pssetylength\pst@dima{#2}
  \pssetylength\pst@dimb{#4}
  \advance\pst@dimb by -\pst@dima
  \divide\pst@dimb by \psk@ysubticks
  \pst@dy=\pst@dimb
%  
  \pssetylength\pst@dimx{#2}
  \pssetylength\pst@dimy{#4}
  \pssetylength\pst@dimz{#1}
  \pssetylength\pst@dimf{#3}
  \pst@getlength\psk@planeGridOffset\pst@dima
  \pst@cntx=\psk@xsubticks\advance\pst@cntx by \@ne
  \pst@cnty=\psk@ysubticks\advance\pst@cnty by \@ne
  \psset{unit=1pt,planeGridOffset=\pst@dima}% we need everything in pt
  \ifx\psk@planeGrid\ThreeDplot@planeXY
    \multido{\rA=\strip@pt\pst@dimz+\strip@pt\pst@dx}{\pst@cntx}{%
      \pstThreeDLine(\rA,\strip@pt\pst@dimx,\psk@planeGridOffset)%
                    (\rA,\strip@pt\pst@dimy,\psk@planeGridOffset)}
    \multido{\rA=\strip@pt\pst@dimx+\strip@pt\pst@dy}{\pst@cnty}{%
      \pstThreeDLine(\strip@pt\pst@dimz,\rA,\psk@planeGridOffset)%
                    (\strip@pt\pst@dimf,\rA,\psk@planeGridOffset)}
  \else
    \ifx\psk@planeGrid\ThreeDplot@planeXZ
      \multido{\rA=\strip@pt\pst@dimz+\strip@pt\pst@dx}{\pst@cntx}{%
        \pstThreeDLine(\rA,\psk@planeGridOffset,\strip@pt\pst@dimx)%
	              (\rA,\psk@planeGridOffset,\strip@pt\pst@dimy)}
      \multido{\rA=\strip@pt\pst@dimx+\strip@pt\pst@dy}{\pst@cnty}{%
        \pstThreeDLine(\strip@pt\pst@dimz,\psk@planeGridOffset,\rA)%
	              (\strip@pt\pst@dimf,\psk@planeGridOffset,\rA)}
    \else
      \multido{\rA=\strip@pt\pst@dimz+\strip@pt\pst@dx}{\pst@cntx}{%
        \pstThreeDLine(\psk@planeGridOffset,\rA,\strip@pt\pst@dimx)%
	              (\psk@planeGridOffset,\rA,\strip@pt\pst@dimy)}
      \multido{\rA=\strip@pt\pst@dimx+\strip@pt\pst@dy}{\pst@cnty}{%
        \pstThreeDLine(\psk@planeGridOffset,\strip@pt\pst@dimz,\rA)%
	              (\psk@planeGridOffset,\strip@pt\pst@dimf,\rA)}
    \fi 
  \fi%
}\ignorespaces}
%
% put anything at (#2,#3,#4)
%
\def\pstThreeDPut{\@ifnextchar[{\pst@ThreeDPut}{\pst@ThreeDPut[]}}
\def\pst@ThreeDPut[#1](#2,#3,#4)#5{{%
  \pst@killglue%
  \psset{#1}%
  \pstThreeDNode(#2,#3,#4){temp@pstNode}%
%	\def\@tempa{c}
%	\ifx\pst@ThreeDplot@pOrigin\@tempa%
%	    \rput(temp@pstNode){#5}%
%	\else%
  \rput[\psk@ThreeDplot@pOrigin](temp@pstNode){#5}%
%	\fi%
}\ignorespaces}
%
% draws a 3d line
%
\def\cartesianIIID@coor#1,#2,#3,#4\@nil{\edef\pst@coor{#1 #2 #3 }}
\def\NormalIIIDCoor{%
  \def\pst@@getcoor##1{\pst@expandafter\cartesianIIID@coor{##1}, ,\@nil}%
  \def\pst@@getangle##1{%
    \pst@checknum{##1}\pst@angle%
    \edef\pst@angle{\pst@angle \pst@angleunit}%
  }%
  \def\psput@##1{\pst@@getcoor{##1}\leavevmode\psput@cartesian}%
}%

\def\pstThreeDLine{\NormalIIIDCoor\pst@object{lineIIID}}
\def\lineIIID@i{%
  \pst@killglue%
  \pst@getarrows{%
    \begin@OpenObj%
      \pst@getcoors[\lineIIID@ii%
  }%
}
\def\lineIIID@ii{%
  \addto@pscode{%
    \pst@3ddict
      \variablesIIID
      /dxUnit \psk@ThreeDplot@xThreeDunit\space def
      /dyUnit \psk@ThreeDplot@yThreeDunit\space def
      /dzUnit \psk@ThreeDplot@zThreeDunit\space def 
      \ifPst@SphericalCoor /SphericalCoor true def 
      \else /SphericalCoor false def
      \fi %
      /xUnit { \pst@number\psxunit\space mul } def
      /yUnit { \pst@number\psyunit\space mul } def
      convertStackTo2D
    end
    \pst@cp\space \psline@iii\space \tx@Line
  }%
  \end@OpenObj%
  \SpecialCoor%
  \ignorespaces
}
%
% set a 3d dot
%
\def\pstThreeDDot{\pst@object{pst@ThreeDDot}}
\def\pst@ThreeDDot@i(#1,#2,#3){%
  \addbefore@par{linestyle=dashed,linewidth=0.5pt}% default
%  \typeout{\pst@par}
  \begin@SpecialObj
  \pstThreeDNode(#1,#2,#3){A}% we need the parameters
  \ifx\psk@dotstyle\@none\else\psdots(A)\fi%
  \ifPst@drawCoor%  
    \addto@pscode{
       \pst@3ddict
       \variablesIIID
       \ifPst@SphericalCoor
          #1\space #2\space #3\space
          ConvertToCartesian
       \else
         /x #1\space\psk@ThreeDplot@xThreeDunit\space mul def
         /y #2\space\psk@ThreeDplot@yThreeDunit\space mul def 
         /z #3\space\psk@ThreeDplot@zThreeDunit\space mul def
       \fi
       ConvertTo2D 
       x2D \pst@number\psxunit\space mul 
       y2D \pst@number\psyunit\space mul 
       moveto /RotX 0 def /RotY 0 def /RotZ 0 def
       /z 0 def 
       ConvertTo2D /x2DOld x2D def /y2DOld y2D def 
       x2D \pst@number\psxunit\space mul 
       y2D \pst@number\psyunit\space mul 
       lineto
       /y@i y def /y 0 def
       ConvertTo2D 
       x2D \pst@number\psxunit\space mul 
       y2D \pst@number\psyunit\space mul 
       lineto 
       x2DOld \pst@number\psxunit\space mul 
       y2DOld \pst@number\psyunit\space mul 
       moveto 
       /y y@i def /x 0 def
       ConvertTo2D 
       x2D \pst@number\psxunit\space mul 
       y2D \pst@number\psyunit\space mul 
       lineto 
       \ifx\pslinestyle\@none\else
         gsave
         \pst@number\pslinewidth SLW
         \pst@usecolor\pslinecolor
         \@nameuse{psls@\pslinestyle}
         grestore
       \fi
     end
   }%
  \fi%
  \end@SpecialObj%
  \ignorespaces}
%
% transform the 3d coordinates of the node (#1,#2,#3)
% into a 2d node with the name #4
%
\def\pstThreeDNode{\@ifnextchar[{\pst@ThreeDNode}{\pst@ThreeDNode[]}}
\def\pst@ThreeDNode[#1](#2,#3,#4)#5{{%
  \psset{#1}%
  \pnode(!%
    \pst@3ddict
    \variablesIIID
    \ifPst@SphericalCoor
      #2\space #3\space #4\space
      ConvertToCartesian
    \else
      /x #2\space\psk@ThreeDplot@xThreeDunit\space mul def 
      /y #3\space\psk@ThreeDplot@yThreeDunit\space mul def 
      /z #4\space\psk@ThreeDplot@zThreeDunit\space mul def
    \fi
    ConvertTo2D x2D y2D end ){#5}%
}\ignorespaces}
%
% a 3d uput[](){}
%
\def\pstUThreeDPut{\@ifnextchar[{\pst@UThreeDPut}{\pst@UThreeDPut[]}}
\def\pst@UThreeDPut[#1](#2,#3,#4)#5{{%
  \uput[#1](!%
    \pst@3ddict
      \variablesIIID
      \ifPst@SphericalCoor
        #2\space #3\space #4\space
        ConvertToCartesian
      \else
        /x #2\space\psk@ThreeDplot@xThreeDunit\space mul def 
        /y #3\space\psk@ThreeDplot@yThreeDunit\space mul def 
        /z #4\space\psk@ThreeDplot@zThreeDunit\space mul def
      \fi
      ConvertTo2D x2D y2D 
    end ){#5}%
}\ignorespaces}
%
% Trangle [options](Point1)(Point2)(Point3)
%
\def\pstThreeDTriangle{\@ifnextchar[{\do@ThreeDTriangle}{\do@ThreeDTriangle[]}}
\def\do@ThreeDTriangle[#1](#2)(#3)(#4){{%
  \ifx#1\empty\else\psset{#1}\fi%
  \ifPst@drawCoor%
    \pstThreeDDot[drawCoor=true](#2)%
    \pstThreeDDot[drawCoor=true](#3)%
    \pstThreeDDot[drawCoor=true](#4)%
  \fi%
  \pstThreeDNode(#2){A}%
  \pstThreeDNode(#3){B}%
  \pstThreeDNode(#4){C}%
  \ifx\psk@fillstyle\@none%
  \else%
    \pscustom{%
      \code{\psk@ThreeDplot@linejoin\space setlinejoin}%
  \fi%
  \psline[#1](A)(B)(C)(A)(B)%
  \ifx\psk@fillstyle\@none\else}\fi%
}\ignorespaces}
%
% draws a threeD square as a polygon
%
% [#1] options
% (#2) starting vector ax,ay,az
% (#3) first direction vector ux,uy,uz
% (#4) second direction vector wx,wy,wz
%
\def\pstThreeDSquare{\pst@object{squareIIID}}
\def\squareIIID@i{\squareIIID@ii}
\def\squareIIID@ii(#1)(#2)(#3){%
  \ifPst@drawCoor%
    {%
    \psset{linestyle=dashed,linewidth=0.5pt}%
    \pstThreeDDot(#1)%
    \pst@addThreeDVec(#1)(#2)\pst@tempa\pst@tempb\pst@tempc%
    \pstThreeDDot(\pst@tempa,\pst@tempb,\pst@tempc)%
    \pst@addThreeDVec(#1)(#3)\pst@tempa\pst@tempb\pst@tempc
    \pstThreeDDot(\pst@tempa,\pst@tempb,\pst@tempc)%
    \pst@addThreeDVec(\pst@tempa,\pst@tempb,\pst@tempc)%
      (#2)\pst@tempa\pst@tempb\pst@tempc%
    \pstThreeDDot(\pst@tempa,\pst@tempb,\pst@tempc)%
    }%
  \fi%
  \getThreeDCoor{#1}\pst@tempA%
  \getThreeDCoor{#2}\pst@tempB%
  \getThreeDCoor{#3}\pst@tempC%
  \begin@OpenObj
    \addto@pscode{%
      \pst@3ddict
        \variablesIIID
        /P1 { \pst@tempA\space } def % x y z or Radius longitude lattitude
        /P2 { \pst@tempB\space } def %
        /P3 { \pst@tempC\space } def %
        /SphericalCoor \ifPst@SphericalCoor true \else false \fi def %
        /xUnit { \pst@number\psxunit\space mul } def
        /yUnit { \pst@number\psyunit\space mul } def
        P1 saveCoor
	SphericalCoor { ConvertToCartesian } if
        ConvertTo2D
        /x0 x2D xUnit def /y0 y2D yUnit def
        P2 saveCoor
        SphericalCoor { ConvertToCartesian } if
        ConvertTo2D
        /x1 x2D xUnit x0 add def /y1 y2D yUnit y0 add def
        P3 saveCoor
        SphericalCoor { ConvertToCartesian } if
        ConvertTo2D
        /x2 x2D xUnit x1 add def /y2 y2D yUnit y1 add def
        P2 saveCoor
        SphericalCoor { ConvertToCartesian } if
        ConvertTo2D
        /x3 x2D xUnit neg x2 add def /y3 y2D yUnit neg y2 add def
        [ x0 y0 x1 y1 x2 y2 x3 y3 x0 y0
        \pst@cp\space \psline@iii\space \tx@Line\space
      end
    }%
  \end@OpenObj%
}

%
% draws a threeD Box
% [#1] options
% (#2) first direction vector ux,uy,uz
% (#3) second direction vector vx,vy,vz
% (#4) third direction vector wx,wy,wz
%
\def\pstThreeDBox{\@ifnextchar[{\pstThreeDBox@i}{\pstThreeDBox@i[]}}
\def\pstThreeDBox@i[#1](#2)(#3)(#4)(#5){%
  \pst@killglue%
  \begingroup%
  \psset{linestyle=\psk@ThreeDplot@invisibleLineStyle}%
  \psset{#1}%
  \pstVerb{ 
    \pst@3ddict
      \variablesIIID
    end
  }%
  \pstThreeDSquare[#1](#2)(#4)(#5) % 	lower square
  \pstThreeDSquare(#2)(#3)(#4)% 	back square
%
  \psset{linestyle=\psk@ThreeDplot@visibleLineStyle}%
  \pst@addThreeDVec(#2)(#4)\pst@tempa\pst@tempb\pst@tempc
  \pstThreeDSquare[#1](\pst@tempa,\pst@tempb,\pst@tempc)(#3)(#5)% left square
  \pst@addThreeDVec(#2)(#3)\pst@tempa\pst@tempb\pst@tempc
  \pstThreeDSquare[#1](\pst@tempa,\pst@tempb,\pst@tempc)(#4)(#5)% top square
  \pst@addThreeDVec(#2)(#5)\pst@tempa\pst@tempb\pst@tempc
  \pstThreeDSquare[#1](\pst@tempa,\pst@tempb,\pst@tempc)(#3)(#4)% front square
  \endgroup%
  \ignorespaces%
}
%
% set a 3d ellipse/circle
%
% #1 options
% #2 center cx,cy,cz
% #3 radius ax,ay,az
% #4 radius bx,by,bz
%
\def\pstThreeDEllipse{\pst@object{pstThreeDEllipse}}
\def\pstThreeDEllipse@i(#1)(#2)(#3){%
  \addbefore@par{plotstyle=curve}%
  \@nameuse{beginplot@\psplotstyle}%
  \getThreeDCoor{#1}\pst@tempC%  center
  \getThreeDCoor{#2}\pst@tempA%  a
  \getThreeDCoor{#3}\pst@tempB%  b
  \addto@pscode{%
    \pst@3ddict \variablesIIID end
    \ifPst@SphericalCoor 
      \pst@tempC\space \tx@ConvertToCartesian 
        /zM \tx@Z def /yM \tx@Y def /xM \tx@X def % center
      \pst@tempA\space \tx@ConvertToCartesian  
        /zA \tx@Z def /yA \tx@Y def /xA \tx@X def % a
      \pst@tempB\space \tx@ConvertToCartesian 
        /zB \tx@Z def /yB \tx@Y def /xB \tx@X def % b 
    \else
      \pst@tempC\space /zM exch def /yM exch def /xM exch def % center
      \pst@tempA\space /zA exch def /yA exch def /xA exch def % a
      \pst@tempB\space /zB exch def /yB exch def /xB exch def % b
    \fi
    /aStart \psk@ThreeDplot@beginAngle\space def
%    /aEnd \psk@ThreeDplot@endAngle\space dup aStart lt { 360 add } if def
%    /da aEnd aStart sub \psk@plotpoints\space div abs def
    /aEnd \psk@ThreeDplot@endAngle\space def
    /da aEnd aStart sub \psk@plotpoints\space div def
    /xyz {
      xM xA angle cos mul add xB angle sin mul add 
      yM yA angle cos mul add yB angle sin mul add 
      zM zA angle cos mul add zB angle sin mul add 
      \pst@3ddict saveCoor ConvertTo2D 
      x2D \pst@number\psxunit mul y2D \pst@number\psyunit mul end
    } def
    /angle aStart def
  }%
  \gdef\psplot@init{}%
  \@pstfalse%
  \@nameuse{testqp@\psplotstyle}%
  \if@pst\pstThreeDEllipse@ii\else\pstThreeDEllipse@iii\fi%
  \ignorespaces}
%
\def\pstThreeDEllipse@ii{%
    \addto@pscode{%
      xyz \@nameuse{beginqp@\psplotstyle}
      \psk@plotpoints 1 sub {
        /angle angle da add def
        xyz \@nameuse{doqp@\psplotstyle}
      } repeat
      /angle aEnd def
      xyz \@nameuse{doqp@\psplotstyle}}%
  \@nameuse{endqp@\psplotstyle}}
    
\def\pstThreeDEllipse@iii{%
  \addto@pscode{%
      mark
      /n 2 def
      \psk@plotpoints {
        xyz
        n 2 roll
        /n n 2 add def
        /angle angle da add def
      } repeat
      /angle aEnd def
      xyz
      n 2 roll}%
  \@nameuse{endplot@\psplotstyle}}
%
\def\pstThreeDCircle{\pstThreeDEllipse}
\def\pstThreeDPlotFunc{\psplotThreeD}%	only for compatibility
%
%
% cone[options](center){radius}{height}
%
\def\pstThreeDCone{\pst@object{pstThreeDCone}}
\def\pstThreeDCone@i(#1)(#2)(#3)#4{{%
  \pst@usepar
  \pstThreeDEllipse(#1)(#2)(#3)%
  \begin@OpenObj%
  \getThreeDCoor{#1}\pst@tempA%
  \getThreeDCoor{#2}\pst@tempB%
  \getThreeDCoor{#3}\pst@tempC%
  \addto@pscode{
    \pst@3ddict
    \variablesIIID
    /xUnit { \pst@number\psxunit\space mul } def
    /yUnit { \pst@number\psyunit\space mul } def
    /SphericalCoor \ifPst@SphericalCoor true \else false \fi def %
    /Center [ \pst@tempA\space SphericalCoor { ConvertToCartesian } if ] def % x y z or Radius longitude lattitude
    Center aload pop saveCoor ConvertTo2D /xC x2D def /yC y2D def
    /rA [ \pst@tempB \space SphericalCoor { ConvertToCartesian } if ] def
    /rB [ \pst@tempC \space SphericalCoor { ConvertToCartesian } if ] def
    rA rB AxB UnitVec #4 AmulC Center AaddB aload pop saveCoor ConvertTo2D /x2 x2D xUnit def /y2 y2D yUnit def
    [ xC rA VecNorm add 90 Beta sub sin sub xUnit yC Beta sin add yUnit 
      x2 y2
      xC rA VecNorm sub xUnit yC yUnit
      \pst@cp\space \psline@iii\space \tx@Line\space }%
  \end@OpenObj%
}\ignorespaces}
%
\def\pstRotNodeIIID{\pst@object{RotNodeIIID}}
\def\RotNodeIIID@i(#1,#2,#3)(#4,#5,#6)#7{%
  \pst@killglue
  \begingroup%
  \use@par%
  \def\pst@ThreeDplot@ThetaX{#4}%    rotating angle
  \def\pst@ThreeDplot@ThetaY{#5}%    rotating angle
  \def\pst@ThreeDplot@ThetaZ{#6}%    rotating angle
  \pnode(!%
    \pst@3ddict
      \variablesIIID
      \ifPst@SphericalCoor
        #1\space #2\space #3\space
        ConvertToCartesian
      \else
        /x #1\space\psk@ThreeDplot@xThreeDunit\space mul def 
        /y #2\space\psk@ThreeDplot@yThreeDunit\space mul def 
        /z #3\space\psk@ThreeDplot@zThreeDunit\space mul def
      \fi
      ConvertTo2D x2D y2D 
    end ){#7}%
  \endgroup%
  \ignorespaces}
%
% Paraboloid (Idea is from Manuel ... )
\newif\ifPstThreeDplot@showInside
\define@key[psset]{pst-3dplot}{showInside}[true]{\@nameuse{PstThreeDplot@showInside@#1}}
\define@key[psset]{pst-3dplot}{SegmentColor}{\pst@getcolor{#1}\psk@ThreeDplot@SegmentColor}
\define@key[psset]{pst-3dplot}{increment}{\pst@getint{#1}\psk@ThreeDplot@increment}
%\define@key[psset]{pst-3dplot}{CMYK}{\def\psk@ThreeDplot@CMYK{#1}} 
\define@key[psset]{pst-3dplot}{xyzLight}{\def\psk@ThreeDplot@xyzLight{#1}} 
\psset[pst-3dplot]{xyzLight=1 1 2,showInside=true,SegmentColor={[cmyk]{0.2,0.6,1,0}},increment=10}
%
\def\pstParaboloid{\pst@object{pstParaboloid}}
\def\pstParaboloid@i#1#2{% #1:height  #2:radius 
\addto@par{viewpoint=0 0 0}%
\begin@SpecialObj%
\addto@pscode{%
  /height #1 def
  /radius #2 #1 sqrt div def
  /increment \psk@ThreeDplot@increment\space def
  /cmyk {} def
  /viewpoint {
    \psk@viewpoint
    \psk@ThreeDplot@Beta\space sin add 3 1 roll
    \psk@ThreeDplot@Alpha\space cos add \psk@ThreeDplot@Beta\space cos mul 3 1 roll
    \psk@ThreeDplot@Alpha\space sin add \psk@ThreeDplot@Beta\space cos mul 3 1 roll
  } def
  0 viewpoint 0 \tx@SetMatrixThreeD
  viewpoint /vZ ED /vY ED /vX ED
  1 setlinejoin
  % les rayons de lumière
  /xLight 1 def
  /yLight 0.1 def
  /zLight 0.2 def
  % précision du tracé
  /pas 0.5 def
  /pas10 {pas 10 div} bind def
%
  /NormeLight {xLight dup mul yLight dup mul zLight dup mul add add sqrt} bind def
% l'ellipse du plan de coupe : le contour
  /calculate2DPoint { % four values on stack; x2D y2D are returned
    /V0 ED /Z0 ED /U20 ED /U10 ED
    U10 cos V0 mul radius mul \pst@number\psunit mul
    U20 sin V0 mul radius mul \pst@number\psunit mul
    Z0 \pst@number\psunit mul \tx@ProjThreeD
  } def
  /PlanCoupe {
    /Z height store
    /V {Z sqrt} bind def
    /TableauxPoints [
      0 1 359 { 
        /U exch def [ U U Z V caclculate2DPoint ] % on décrit le cercle
      } for
    ] def
    newpath
    TableauxPoints 0 get aload pop moveto
    0 1 359 {
      /compteur exch def
      TableauxPoints compteur get aload pop
      lineto } for
    closepath
  } def
%
  /facette {
    newpath
    U U Z V calculate2DPoint moveto
    U 1 U increment add  {%
      /U1 exch def
      U1 U1 Z V calculate2DPoint lineto
    } for
    Z pas10 Z pas add pas10 add{
      /Z1 exch def
      /V {Z1 sqrt} bind def
      U1 U1 Z1 V calculate2DPoint lineto
    } for
    U increment add -1 U {%
      /U2 exch def
      U2 U2 Z pas add V calculate2DPoint lineto
    } for
    Z pas add pas10 sub pas10 neg Z pas10 sub{
      /Z2 exch def
      /V {Z2 abs sqrt} bind def
      U U Z2 V calculate2DPoint lineto
    } for
    closepath
  } def % facette
%
  /MaillageParaboloid {
    0 pas height pas sub{%
      /Z ED
      /V {Z sqrt} bind def
      0 increment 360 increment sub {%
        /U exch def
% Centre de la facette
        /Ucentre {U increment 2 div add} bind def
        /Vcentre {Z pas 2 div add sqrt} bind def
% normale à la facette
        /nXfacette {2 Vcentre dup mul mul Ucentre cos mul radius mul} bind def
        /nYfacette {2 Vcentre dup mul mul Ucentre sin mul radius mul} bind def
        /nZfacette {Vcentre neg radius dup mul mul} bind def
        /NormeN {
          nXfacette dup mul
          nYfacette dup mul
          nZfacette dup mul
          add add sqrt} bind def
        NormeN 0 eq {/NormeN 1e-10 def} if
% test de visibilité
       /PSfacette vX nXfacette mul
                  vY nYfacette mul add
                  vZ nZfacette mul add def
       condition {
         facette
         /cosV {1 xLight nXfacette mul
           yLight nYfacette mul
           zLight nZfacette mul
           add add
           NormeLight
           NormeN mul div sub} bind def
         \psk@ThreeDplot@SegmentColor\space 
         cosV mul 4 1 roll cosV mul 4 1 roll cosV dup mul mul 4 1 roll cosV dup mul mul 4 1 roll
         setcmykcolor fill
         0 setgray
         facette
         stroke
       } if
     } for
    } for
  } def
  /conditionGE { PSfacette 0 ge } def
  /conditionLE { PSfacette 0 le } def
  \ifPstThreeDplot@showInside
    /condition { conditionGE } def
    MaillageParaboloid
    vZ 0 ge {
      PlanCoupe 1 0.5 0.5 setrgbcolor fill
      PlanCoupe 0 setgray stroke } if
  \else 
    /condition { conditionLE } def
    MaillageParaboloid
    /condition { conditionGE } def
    MaillageParaboloid
  \fi
}%
% fin du code ps
  \showpointsfalse%
  \end@SpecialObj%
\ignorespaces}
%
% Sphere
% the new one
\def\pstThreeDSphere{\pst@object{pstSphereIIID}}
\def\pstSphereIIID@i(#1,#2,#3)#4{% #1:origin (x,y,z)  #2:radius 
\addto@par{viewpoint=0 0 0}% to make it compatible with pst-3dplot
\begin@SpecialObj%
\addto@pscode{%
  /viewpoint {% to make it compatible with parallel projection
    \psk@viewpoint
    \psk@ThreeDplot@Beta\space sin add 3 1 roll
    \psk@ThreeDplot@Alpha\space cos add \psk@ThreeDplot@Beta\space cos mul 3 1 roll
    \psk@ThreeDplot@Alpha\space sin add \psk@ThreeDplot@Beta\space cos mul 3 1 roll
  } def
  0 viewpoint 0 \tx@SetMatrixThreeD
  viewpoint /vZ ED /vY ED /vX ED
% on stack must be
% x y z Radius increment C M Y K x y zLight
  #1 \pst@number\psunit mul #2 \pst@number\psunit mul #3 \pst@number\psunit mul  
  #4 \pst@number\psunit mul
  \psk@ThreeDplot@increment\space
  /cmyk {} def   % we need only the values
  \psk@ThreeDplot@SegmentColor\space 
%  \psk@ThreeDplot@CMYK\space  % CMYK
  \psk@ThreeDplot@xyzLight\space          % xLight yLight zLight
  tx@3DPlotDict begin MaillageSphere end
}% fin du code ps
  \showpointsfalse%
  \end@SpecialObj%
\ignorespaces}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\psplotinit#1{\xdef\psplot@init{#1 }}
\def\psplot@init{}
%
%\def\psplotThreeD{\@ifnextchar[{\ps@plotThreeD}{\ps@plotThreeD[]}}
\def\psplotThreeD{\def\pst@par{}\pst@object{psplotThreeD}}
\def\psplotThreeD@i(#1,#2)(#3,#4)#5{{%
  \pst@killglue
  \use@par%
  \ifcase\psk@ThreeDplot@drawStyle%
    \psplotThreeD@xLines(#1,#2)(#3,#4){#5}\or%
    \psplotThreeD@yLines(#1,#2)(#3,#4){#5}\or    
    \psplotThreeD@xLines(#1,#2)(#3,#4){#5}%
    \psplotThreeD@yLines(#1,#2)(#3,#4){#5}\or%
    \psplotThreeD@yLines(#1,#2)(#3,#4){#5}%
    \psplotThreeD@xLines(#1,#2)(#3,#4){#5}%
  \fi%
}\ignorespaces}
%
%\def\doPlotThreeD@xLines{\pst@object{psplotThreeD@xLines}}
%\def\doPlotThreeD@yLines{\pst@object{psplotThreeD@yLines}}
%
\def\psplotThreeD@xLines(#1,#2)(#3,#4)#5{%
  \pst@killglue%
  \begingroup%
%    \use@par%
    \@pstfalse%
    \@nameuse{beginplot@\psplotstyle}%
    \gdef\psplot@init{}%
    \@nameuse{testqp@\psplotstyle}%
    \if@pst%	lines and dots
      \addto@pscode{
        \variablesIIID
        /xMin #1 def
        /x xMin def
        /x1 #2 def
        /y #3 def
        /y1 #4 def
        /dx x1 x sub \psk@ThreeDplot@xPlotpoints\space dup 0 gt {div}{pop} ifelse def
        /dy y1 y sub \psk@ThreeDplot@yPlotpoints\space dup 0 gt {div}{pop} ifelse def
        /func {#5} def
        /xyz {
          x neg Alpha cos mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha sin mul add \pst@number\psxunit mul
          x Alpha sin mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha cos mul add neg Beta sin mul
          \psk@ThreeDplot@zCoor\space 0 gt { \psk@ThreeDplot@zCoor }{ func } ifelse 
	    Beta cos mul add \pst@number\psyunit mul} def
        }%
        \psplotThreeD@xLines@ii
    \else%	curves
  \endgroup%
  \multido{\n@Y=0+1}{\psk@ThreeDplot@yPlotpoints}{%
    \ifPst@hiddenLine\pscustom[style=hiddenStyle]{\fi%
    \@nameuse{beginplot@\psplotstyle}%
    \addto@pscode{
      \variablesIIID
      /xMin #1 def
      /x xMin def
      /x1 #2 def
      /dx x1 x sub \psk@ThreeDplot@xPlotpoints\space dup 0 gt {div}{pop} ifelse def
      /dy #4\space #3\space sub \psk@ThreeDplot@yPlotpoints\space dup 0 gt {div}{pop} ifelse def
      /y #3\space \n@Y\space dy mul add def
      /func {#5} def
      /xyz {
          x neg Alpha cos mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha sin mul add \pst@number\psxunit mul
          x Alpha sin mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha cos mul add neg Beta sin mul
          \psk@ThreeDplot@zCoor\space 0 gt { \psk@ThreeDplot@zCoor }{ func } ifelse 
	    Beta cos mul add \pst@number\psyunit mul} def
%        x neg Alpha cos mul y Alpha sin mul add \pst@number\psxunit mul
%        x Alpha sin mul y Alpha cos mul add neg Beta sin mul
%        func Beta cos mul add \pst@number\psyunit mul} def
    }%
    \psplotThreeD@xLines@iii%
    \ifPst@hiddenLine }\fi%
  }%
  \fi%
  \endgroup%
  \ignorespaces%
}
%
\def\psplotThreeD@xLines@ii{%
  \addto@pscode{%
    xyz \@nameuse{beginqp@\psplotstyle}
   \psk@ThreeDplot@yPlotpoints\space 1 add {
     /x xMin def
     xyz moveto
     \psk@ThreeDplot@xPlotpoints\space 1 add {
       xyz \@nameuse{doqp@\psplotstyle}
       /x x dx add def
     } repeat
     /y y dy add def
   } repeat
   /x x1 def
   /y y1 def
   xyz \@nameuse{doqp@\psplotstyle}
  }%
  \@nameuse{endqp@\psplotstyle}%
}
\def\psplotThreeD@xLines@iii{%    curves
  \addto@pscode{%
    /x xMin def
    mark
    /n 2 def
    \psk@ThreeDplot@xPlotpoints {
      xyz
      n 2 roll
      /n n 2 add def
      /x x dx add def
    } repeat
    /x x1 def
    xyz
    n 2 roll
  }%
  \@nameuse{endplot@\psplotstyle}%
}
%
\def\psplotThreeD@yLines(#1,#2)(#3,#4)#5{%
  \pst@killglue
  \begingroup
%  \use@par%
  \@pstfalse
  \@nameuse{beginplot@\psplotstyle}%
  \gdef\psplot@init{}%
  \@nameuse{testqp@\psplotstyle}%
  \if@pst%	lines and dots
    \addto@pscode{%
      \variablesIIID
      /x #1 def
      /x1 #2 def
      /yMin #3 def
      /y yMin def
      /y1 #4 def
      /dx x1 x sub \psk@ThreeDplot@xPlotpoints\space dup 0 gt {div}{pop} ifelse def
      /dy y1 y sub \psk@ThreeDplot@yPlotpoints\space dup 0 gt {div}{pop} ifelse def
      /func {#5} def
      /xyz {
          x neg Alpha cos mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha sin mul add \pst@number\psxunit mul
          x Alpha sin mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha cos mul add neg Beta sin mul
          \psk@ThreeDplot@zCoor\space 0 gt { \psk@ThreeDplot@zCoor }{ func } ifelse 
	    Beta cos mul add \pst@number\psyunit mul} def
%        x neg Alpha cos mul y Alpha sin mul add \pst@number\psxunit mul
%        x Alpha sin mul y Alpha cos mul add neg Beta sin mul
%        func Beta cos mul add \pst@number\psyunit mul} def
    }%
    \psplotThreeD@yLines@ii
  \else%	curves
    \endgroup
    \multido{\n@X=0+1}{\psk@ThreeDplot@xPlotpoints}{%
      \ifPst@hiddenLine\pscustom[style=hiddenStyle]{\fi
      \@nameuse{beginplot@\psplotstyle}%
      \addto@pscode{%
        \variablesIIID
        /yMin #3 def
        /y yMin def
        /y1 #4 def
        /dy y1 y sub \psk@ThreeDplot@yPlotpoints\space dup 0 gt {div}{pop} ifelse def
        /dx #2\space #1\space sub \psk@ThreeDplot@xPlotpoints\space dup 0 gt {div}{pop} ifelse def
        /x #1\space \n@X\space dx mul add def
        /func {#5} def
        /xyz {
          x neg Alpha cos mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha sin mul add \pst@number\psxunit mul
          x Alpha sin mul 
	    \psk@ThreeDplot@zCoor\space 0 gt { func }{ y } ifelse Alpha cos mul add neg Beta sin mul
          \psk@ThreeDplot@zCoor\space 0 gt { \psk@ThreeDplot@zCoor }{ func } ifelse 
	    Beta cos mul add \pst@number\psyunit mul} def
%        x neg Alpha cos mul y Alpha sin mul add \pst@number\psxunit mul
%        x Alpha sin mul y Alpha cos mul add neg Beta sin mul
%        func Beta cos mul add \pst@number\psyunit mul} def
      }%
      \psplotThreeD@yLines@iii%
      \ifPst@hiddenLine }\fi%
    }%
  \fi
  \endgroup
  \ignorespaces%
}
\def\psplotThreeD@yLines@ii{%
  \addto@pscode{%
    xyz \@nameuse{beginqp@\psplotstyle}
    \psk@ThreeDplot@xPlotpoints\space 1 add {
      /y yMin def
      xyz moveto
      \psk@ThreeDplot@yPlotpoints\space 1 add {
        xyz \@nameuse{doqp@\psplotstyle}
        /y y dy add def
      } repeat
      /x x dx add def
    } repeat
    /x x1 def
    /y y1 def
    xyz \@nameuse{doqp@\psplotstyle}
  }%
  \@nameuse{endqp@\psplotstyle}%
}
\def\psplotThreeD@yLines@iii{%    curves
  \addto@pscode{%
    /y yMin def
    mark
    /n 2 def
    \psk@ThreeDplot@yPlotpoints {
      xyz
      n 2 roll
      /n n 2 add def
      /y y dy add def
    } repeat
    /y y1 def
    xyz
    n 2 roll
  }%
    \@nameuse{endplot@\psplotstyle}%
}
%
% parametricplot ----------------------------------------------------------------
%
\def\parametricplotThreeD{\def\pst@par{}\pst@object{parametricPlotThreeD}}
\def\parametricPlotThreeD@i(#1){%
  \@ifnextchar({\parametricPlotThreeD@ii(#1)}{\parametricPlotThreeD@ii(#1)(0,0)}%
}
\def\parametricPlotThreeD@ii(#1,#2)(#3,#4)#5{{%
  \pst@killglue%
  \use@par%
  \@pstfalse%
  \@nameuse{beginplot@\psplotstyle}%
  \@nameuse{testqp@\psplotstyle}% quick plot or something special
  \pstVerb{%
      /3D2DConv {
        3 -1 roll               % y z x
        \psk@ThreeDplot@xThreeDunit\space mul
        dup                     % y z x x
        neg Alpha cos mul       % y z x (x)
        4 -1 roll               % z x (x) y
       \psk@ThreeDplot@yThreeDunit\space mul
       dup                     % z x (x) y y
       5 1 roll                % y z x (x) y
       Alpha sin mul add \pst@number\psxunit mul       % y z x (x2)
       4 1 roll                % (x2) y z x
       Alpha sin mul           % (x2) y z (x)
       3 -1 roll               % (x2) z (x) y
       Alpha cos mul add neg Beta sin mul % (x2) z (x)
       exch                    % (x2) (x) z
       \psk@ThreeDplot@zThreeDunit\space mul
       Beta cos mul add \pst@number\psyunit mul        % (x2) (y2)
      } def
  }%
  \if@pst%
    \def\pslinetype{0}%
    \addto@pscode{%
      \variablesIIID
      /tMin #1 def
      /t tMin def
      /t1 #2 def
      /u #3 def
      /u1 #4 def
      /dt t1 t sub \psk@ThreeDplot@xPlotpoints\space dup 1 gt %
        { 1 sub div }{ pop pop 0 } ifelse def % step for t
      /du u1 u sub \psk@ThreeDplot@yPlotpoints\space dup 1 gt %
        { 1 sub div }{ pop pop 0 } ifelse def % step for u
      /xyz { #5 3D2DConv } def
   }%
   \parametricPlotThreeD@iii%
  \else%
    \def\pslinetype{-3}%
    \endgroup%
    \pst@dima=#3pt\pst@dimb=#4pt
    \ifdim\pst@dima=\pst@dimb\psset{yPlotpoints=1}\fi% #3=#4 ??
    \multido{\n@Y=0+1}{\psk@ThreeDplot@yPlotpoints}{%
      \@nameuse{beginplot@\psplotstyle}%
      \addto@pscode{%
        \variablesIIID
        /tMin #1 def
        /t tMin def
        /t1 #2 def
	/u1 #2 def
        /dt t1 t sub \psk@ThreeDplot@xPlotpoints\space dup 1 gt %
          { 1 sub div }{ pop pop 0 } ifelse def % step for t
        /du #4\space #3\space sub \psk@ThreeDplot@yPlotpoints\space dup 1 gt %
          { 1 sub div }{ pop pop 0 } ifelse def % step for t
        /u #3\space \n@Y\space du mul add def
        /xyz { #5 3D2DConv } def
     }%
     \parametricPlotThreeD@iv%
    }%
  \fi%
}\ignorespaces}
\def\parametricPlotThreeD@iii{%   without arrows (quickplot)
  \addto@pscode{%
    \psk@ThreeDplot@yPlotpoints\space {
      /t tMin def
      xyz \@nameuse{beginqp@\psplotstyle}
      \psk@ThreeDplot@xPlotpoints {
        xyz \@nameuse{doqp@\psplotstyle}
        /t t dt add def
      } repeat
      /u u du add def
    } repeat
  }%
  \@nameuse{endqp@\psplotstyle}%
}
\def\parametricPlotThreeD@iv{%    with arrows or curve
  \addto@pscode{%
%	    /t tMin def
    mark
    /n 0 def
    \psk@ThreeDplot@xPlotpoints\space {
      xyz
      /n n 2 add def
      n 2 roll
      /t t dt add def
    } repeat
%    /t t1 def
%    /u u1 def
%    xyz
%    n 2 roll
  }%
  \@nameuse{endplot@\psplotstyle}%
}
%
% Plot 3D data
%
\def\fileplotThreeD{\def\pst@par{}\pst@object{fileplotThreeD}}
\def\fileplotThreeD@i#1{%
    \pst@killglue%
    \begingroup%
	\use@par%
	\@pstfalse%
	\@nameuse{testqp@\psplotstyle}%%
	\if@pst
	    \dataplotThreeD@ii{\pst@readfile{#1}}%
	\else
	    \listplotThreeD@ii{\pst@altreadfile{#1}}%
	\fi
    \endgroup%
    \ignorespaces%
}
%
% dataplot
%
\def\dataplotThreeD{\def\pst@par{}\pst@object{dataplotThreeD}}
\def\dataplotThreeD@i#1{%
  \pst@killglue
  \begingroup
    \use@par
    \@pstfalse
    \@nameuse{testqp@\psplotstyle}%
    \if@pst
      \dataplotThreeD@ii{\addto@pscode{#1}}%
    \else
      \listplot@ii{\addto@pscode{#1}}%
    \fi
  \endgroup
  \ignorespaces%
}
\def\dataplotThreeD@ii#1{%
  \@nameuse{beginplot@\psplotstyle}%
    \addto@pscode{%
      \variablesIIID
      /Dx { /D { Dy } def } def
      /Dy { /D { Dz } def } def
      /Dz { 			% now we have x y z
	3 -1 roll		% y z x
        \psk@ThreeDplot@xThreeDunit\space div
	dup			% y z x x
	neg Alpha cos mul	% y z x (x)
	4 -1 roll		% z x (x) y
	\psk@ThreeDplot@yThreeDunit\space div
	dup			% z x (x) y y
	5 1 roll		% y z x (x) y
	Alpha sin mul add \pst@number\psxunit mul % y z x (x2)
	4 1 roll		% (x2) y z x
	Alpha sin mul		% (x2) y z (x)
	3 -1 roll		% (x2) z (x) y
	Alpha cos mul add neg Beta sin mul % (x2) z (x)
	exch			% (x2) (x) z
	\psk@ThreeDplot@zThreeDunit\space div
	Beta cos mul add \pst@number\psyunit mul % (x2) (y2)
	Do /D { Dx } def } def
      /D { /D { Dx } def } def
      /Do {
        \@nameuse{beginqp@\psplotstyle}%
        /Do { \@nameuse{doqp@\psplotstyle}} def
      } def}%
    #1%
    \addto@pscode{D}%
  \@nameuse{endqp@\psplotstyle}%
}
%
%
\pst@def{ScalePointsThreeD}<%
	counttomark dup dup cvi eq not { exch pop } if
	/m exch def /n m 3 div cvi def
	n { 				% now we have x y z
		3 -1 roll		% y z x
		\psk@ThreeDplot@xThreeDunit\space div
		dup			% y z x x
		neg Alpha cos mul	% y z x (x)
		4 -1 roll		% z x (x) y
		\psk@ThreeDplot@yThreeDunit\space div
		dup			% z x (x) y y
		5 1 roll		% y z x (x) y
		Alpha sin mul add \pst@number\psxunit mul	% y z x (x2)
		4 1 roll		% (x2) y z x
		Alpha sin mul		% (x2) y z (x)
		3 -1 roll		% (x2) z (x) y
		Alpha cos mul add neg Beta sin mul % (x2) z (x)
		exch			% (x2) (x) z
		\psk@ThreeDplot@zThreeDunit\space div
		Beta cos mul add \pst@number\psyunit mul 	% (x2) (y2)
		m 1 sub 1 roll m 1 sub 1 roll /m m 3 sub def } repeat>
%
% listplotThreeD
%
\def\listplotThreeD{\def\pst@par{}\pst@object{listplotThreeD}}
\def\listplotThreeD@i#1{\listplotThreeD@ii{\addto@pscode{#1}}}
\def\listplotThreeD@ii#1{%
  \@nameuse{beginplot@\psplotstyle}%
  \addto@pscode{%
    \variablesIIID
    /D {} def mark %
  }%
  #1%
  \addto@pscode{\tx@ScalePointsThreeD}%
  \@nameuse{endplot@\psplotstyle}%
}
%
% adopted from pst-3d
%
\pst@def{TMSave}<%
  tx@Dict /TMatrix known not { /TMatrix { } def /RAngle { 0 } def } if
  /TMatrix [ TMatrix CM ] cvx def>
%
\pst@def{TMRestore}<%
  CP /TMatrix [ TMatrix setmatrix ] cvx def moveto>
%
\pst@def{TMChange}<%
  \tx@TMSave
  /cp [ currentpoint ] cvx def
  CM
  CP T \tx@STV
  CM matrix invertmatrix 
  matrix concatmatrix
  exch exec
  concat cp moveto>
%
\def\pstPlanePut{\@ifnextchar[{\pst@PlanePut}{\pst@PlanePut[]}}
\def\pst@PlanePut[#1](#2)#3{{%
  \pst@killglue%
  \psset{pOrigin=lB}%
  \psset{#1}%
  \pstThreeDPut[#1](#2){\ps@Plane{#3}}%
}}
%
\def\ps@Plane{\pst@makebox{\psPlane@}}
\def\psPlane@{%
  \begingroup
  \leavevmode%
  \hbox{%
%	    \kern\wd\pst@hbox%
    \pst@Verb{%
      { [ 1 0
        \variablesIIID
%
% ###  begin Torsten Suhling
% ------------------------------------------------------------------------
% ===================================================================
% How should 'Alpha' be for planes, if real Alpha and Beta are:
% Alpha	Beta	xy 	    xy (par. y-axis)  yz	  xz
% -------------------------------------------------------------------
% 75	> 0[1]	180 + Alpha 	90 +  Alpha  Alpha	  Alpha + 180 		
% 165	> 0	Alpha 		90 +  Alpha  Alpha	  Alpha 
% 255	> 0	Alpha		270 + Alpha  Alpha + 180  Alpha
% 345	> 0	180 + Alpha 	270 + Alpha  Alpha + 180  Alpha + 180 
% -------------------------------------------------------------------
% 75	< 0	180 - Alpha 	270 - Alpha  Alpha  	  Alpha + 180  
% 165	< 0	-Alpha 		270 - Alpha  Alpha  	  Alpha
%
% 255	< 0	-Alpha 		90 -  Alpha  Alpha + 180  Alpha
%
% 345	< 0	180 -Alpha 	90 -  Alpha  Alpha + 180  Alpha + 180 
% ------------------------------------------------------------------
% How should 'Beta' be for planes, if real Alpha and Beta are:
% Alpha	Beta	xy 	      xy (par. y-axis)	yz		xz
% -------------------------------------------------------------------
% 75 	> 0 	Beta 		Beta 		Beta[2] 	Beta 
% 165	> 0 	Beta 		Beta 		Beta 		Beta 
% 255	> 0 	Beta 		Beta 		Beta 		Beta 
% 345	> 0 	Beta 		Beta 		Beta 		Beta 
% ...................................................................
% 75 	< 0 	-Beta 		-Beta 		Beta 		Beta 
% 165	< 0 	-Beta 		-Beta 		Beta 		Beta 
% 255	< 0 	-Beta 		-Beta 		Beta 		Beta 
% 345	< 0 	-Beta 		-Beta 		Beta 		Beta 
% ================================================================
        \ifx\psk@ThreeDplot@planecorr\ThreeDplot@planecorrOff
		/SignFlag 	1 def
		/AlphaOffset 	0 def
	\else%
          \ifx\psk@ThreeDplot@plane\ThreeDplot@planeXY 			% XY-layer's tag
            \ifx\psk@ThreeDplot@planecorr\ThreeDplot@planecorrXYrot 	% Tag written parallel y-axis
	        Beta  sin 0 lt {/SignFlag  -1}{/SignFlag    1}ifelse def
                Alpha sin 0 gt {/AlphaOffset 180 -90 SignFlag mul add}
		               {/AlphaOffset 180  90 SignFlag mul add} ifelse def 
	    \else% 							% Normal (par. x-axis)
	        Beta  sin 0 gt {/SignFlag      1}{/SignFlag     -1}ifelse def
	        Alpha cos 0 gt {/AlphaOffset 180}{/AlphaOffset   0}ifelse def
	    \fi%
	  \else 							% Vertical layers 
            \ifx\psk@ThreeDplot@plane\ThreeDplot@planeYZ 		% YZ-layer's tag 
		/SignFlag 1 def 
	        Alpha sin 0 gt {/AlphaOffset   0}{/AlphaOffset 180}ifelse def
	    \else% 							% XZ-layer's tag 
		/SignFlag 1 def 
	        Alpha cos 0 gt {/AlphaOffset 180}{/AlphaOffset   0}ifelse def
	    \fi% which vert. layer's tag 
	  \fi% vert. or xy-layer's tag 
	\fi% planecorr or not 
% ------------------------------------------------------------------ Ende
% ------------------------------------------------------------------------
% ###   Aenderung --> es werden die Operatoren SignFlag und AlphaOffset
%	eingefuegt
% ------------------------------------------------------------------------
%       /Delta Beta sin Alpha sin mul Alpha cos atan neg 90 add def 
%       /Gamma Beta sin Alpha cos mul neg Alpha sin atan def 
% ------------------------------------------------------------------------
        /Delta Beta SignFlag mul sin Alpha SignFlag mul AlphaOffset add sin mul Alpha SignFlag mul AlphaOffset add cos atan neg 90 add def 
        /Gamma Beta SignFlag mul sin Alpha SignFlag mul AlphaOffset add cos mul neg Alpha SignFlag mul AlphaOffset add sin atan def 
% ------------------------------------------------------------------- Ende
        \ifx\psk@ThreeDplot@plane\ThreeDplot@planeXY
          270 Delta sub rotate
          /Rho 90 Gamma add Delta add def
        \else%
          \ifx\psk@ThreeDplot@plane\ThreeDplot@planeXZ
            270 Delta sub rotate
            /Rho 180 Delta add def
          \else%
            Gamma rotate
            /Rho 90 Gamma sub def
          \fi%
        \fi%
        Rho cos Rho sin 0 0 ] concat} \tx@TMChange%
    }%
    \box\pst@hbox%
    \pst@Verb{\tx@TMRestore}%
%	    \kern\ht\pst@hbox%
  }%
  \endgroup%
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Utility stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% posStart=Starting point
% length=  Arrow length.
\def\Arrows{\@ifnextchar[{\pst@Arrows}{\pst@Arrows[]}}
\def\pst@Arrows[#1](#2)(#3){{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempa
	\pst@getcoor{#3}\pst@tempb
	\pnode(!%
		/StartArrow \psk@ThreeDplot@posStart\space def
		/LengthArrow \psk@ThreeDplot@length\space def
		\pst@tempa /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempb /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/XD StartArrow angleDirectionAB cos mul XA add def
		/YD StartArrow angleDirectionAB sin mul YA add def
		/XF XD LengthArrow angleDirectionAB cos mul add def
		/YF YD LengthArrow angleDirectionAB sin mul add def
		XD YD ){ArrowStart}
	\pnode(! XF YF){ArrowEnd}
	\psset{arrows=->}%
	\psline[#1](ArrowStart)(ArrowEnd)%
}\ignorespaces}
%
% draw a line (===) outside: #2-----#3=======#4
%
\def\psOutLine{\@ifnextchar[{\pst@ToDrawOut}{\pst@ToDrawOut[]}}
\def\pst@ToDrawOut[#1](#2)(#3)#4{{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempa
	\pst@getcoor{#3}\pst@tempb
	\pnode(!%
		/LengthArrow \psk@ThreeDplot@length\space def
		\pst@tempa /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempb /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/Xend XB LengthArrow angleDirectionAB cos mul add def
		/Yend YB LengthArrow angleDirectionAB sin mul add def
		Xend Yend){#4}
	\psline[#1](#3)(#4)
}\ignorespaces}
%
% draw a line (===) before: #4========#2-----#3
%
\def\psBeforeLine{\@ifnextchar[{\pst@BeforeLine}{\pst@BeforeLine[]}}
\def\pst@BeforeLine[#1](#2)(#3)#4{{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempa
	\pst@getcoor{#3}\pst@tempb
	\pnode(!%
		/LengthArrow \psk@ThreeDplot@length\space def
		\pst@tempa /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempb /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/Xstart XA LengthArrow angleDirectionAB cos mul sub def
		/Ystart YA LengthArrow angleDirectionAB sin mul sub def
		Xstart Ystart){#4}
	\psline[#1](#4)(#2)%
}\ignorespaces}
%
% intersection de deux droites
% 2 juillet 2001/ rewritten 2003-01-27 Herbert
%
\def\ABinterCD(#1)(#2)(#3)(#4)#5{%
    \pst@getcoor{#1}\pst@tempa
    \pst@getcoor{#2}\pst@tempb
    \pst@getcoor{#3}\pst@tempc
    \pst@getcoor{#4}\pst@tempd
\pnode(!%
    /YA \pst@tempa exch pop \pst@number\psyunit div def
    /XA \pst@tempa pop \pst@number\psxunit div def
    /YB \pst@tempb exch pop \pst@number\psyunit div def
    /XB \pst@tempb pop \pst@number\psxunit div def
    /YC \pst@tempc exch pop \pst@number\psyunit div def
    /XC \pst@tempc pop \pst@number\psxunit div def
    /YD \pst@tempd exch pop \pst@number\psyunit div def
    /XD \pst@tempd pop \pst@number\psxunit div def
    /dY1 YB YA sub def
    /dX1 XB XA sub def
    /dY2 YD YC sub def
    /dX2 XD XC sub def
    dX1 abs 0.01 lt {
	/m2 dY2 dX2 div def
	XA dup XC sub m2 mul YC add 
    }{
	dX2 abs 0.01 lt {
	    /m1 dY1 dX1 div def
	    XC dup XA sub m1 mul YA add 
	}{%
	    /m1 dY1 dX1 div def
	    /m2 dY2 dX2 div def
	    m1 XA mul m2 XC mul sub YA sub YC add m1 m2 sub div dup
	    XA sub m1 mul YA add 
	} ifelse
    } ifelse ){#5}
}
%
% draw a parallel line
%     #2---------#3
%         #4----------#5(new)  
\def\Parallel{\@ifnextchar[{\pst@Parallel}{\pst@Parallel[]}}
\def\pst@Parallel[#1](#2)(#3)(#4)#5{{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempa
	\pst@getcoor{#3}\pst@tempb
	\pst@getcoor{#4}\pst@tempc
	\pnode(!%
		/LengthArrow \psk@ThreeDplot@length\space def
		\pst@tempa /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempb /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		\pst@tempc /YC exch \pst@number\psyunit div def
		/XC exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/XstartParallel XC LengthArrow angleDirectionAB cos mul add def
		/YstartParallel YC LengthArrow angleDirectionAB sin mul add def
		XstartParallel YstartParallel){#5}
	\psline[#1](#4)(#5)
}\ignorespaces}
%
% arrowLine[options](A)(B){n}
% #2---->---->---->---->----#3  #4-arrows inside
\def\arrowLine{\@ifnextchar[{\pst@arrowLine}{\pst@arrowLine[]}}
\def\pst@arrowLine[#1](#2)(#3)#4{{%
  \psset{arrowsize=4pt,arrows=->}% the defaults
  \psset{#1}%
  \def\pst@ThreeDplot@n{#4}%
  \pst@getcoor{#2}\pst@tempa
  \pst@getcoor{#3}\pst@tempb
  \pnode(!%
    /YA \pst@tempa exch pop \pst@number\psyunit div def
    /XA \pst@tempa pop \pst@number\psxunit div def
    /YB \pst@tempb exch pop \pst@number\psyunit div def
    /XB \pst@tempb pop \pst@number\psxunit div def
    /dY YB YA sub \pst@ThreeDplot@n\space 1 add div def
    /dX XB XA sub \pst@ThreeDplot@n\space 1 add div def
    /Alpha dY dX atan def
    /dYOffset \psk@ThreeDplot@arrowOffset\space Alpha sin mul def
    /dXOffset \psk@ThreeDplot@arrowOffset\space Alpha cos mul def
    XA YA ){tempArrowC}
  \multido{\i=1+1}{#4}{%
    \pnode(!%
      XA dX \i\space mul add dXOffset add
      YA dY \i\space mul add dYOffset add ){tempArrowB}
    \psline(tempArrowC)(tempArrowB)
    \pnode(tempArrowB){tempArrowC}
  }
  \psline[arrows=-](tempArrowB)(#3)
}\ignorespaces}
%
%   #1------#3------#2
\def\nodeBetween(#1)(#2)#3{%    Herbert 2003/01/05
  \pst@getcoor{#1}\pst@tempa
  \pst@getcoor{#2}\pst@tempb
  \pnode(!%
    /XA \pst@tempa pop \pst@number\psxunit div def
    /YA \pst@tempa exch pop \pst@number\psyunit div def
    /XB \pst@tempb pop \pst@number\psxunit div def
    /YB \pst@tempb exch pop \pst@number\psyunit div def
    XB XA add 2 div YB YA add 2 div){#3}
}
%
% rotateNode(A)
% (A) the node
% #2  the angle
% Herbert Voss <voss@perce.de> 2003-01-26
\def\rotateNode{\pst@rotateNode}
\def\pst@rotateNode(#1)#2{{%
    \pst@getcoor{#1}\pst@tempa%
    \def\pst@ThreeDplot@angle{#2}%        the rotating angle
    \pnode(!%
    	/YA \pst@tempa exch pop \pst@number\psyunit div def
	/XA \pst@tempa pop \pst@number\psxunit div def
	YA 0 eq XA 0 eq and {0 0}{
	    /r XA dup mul YA dup mul add sqrt def
	    /AlphaOld YA XA atan def
	    /AlphaNew AlphaOld \pst@ThreeDplot@angle\space add def
	    r AlphaNew cos mul r AlphaNew sin mul
	} ifelse ){temp}%
    \pnode(temp){#1}%
}\ignorespaces}
%
\def\rotateTriangle{\pst@rotateTriangle}
\def\pst@rotateTriangle(#1)(#2)(#3)#4{{%
    \rotateNode(#1){#4}%
    \rotateNode(#2){#4}%
    \rotateNode(#3){#4}%
}\ignorespaces}
%
\def\rotateFrame{\pst@rotateFrame}
\def\pst@rotateFrame(#1)(#2)(#3)(#4)#5{{%
    \rotateNode(#1){#5}%
    \rotateNode(#2){#5}%
    \rotateNode(#3){#5}%
    \rotateNode(#4){#5}%
}\ignorespaces}
%
% An add macro for integer values
% \pstAdd{34}{6}\value ==> \value is 30
%
\def\pstAdd#1#2#3{%
  \begingroup%
  \pst@dima=#1pt
  \advance\pst@dima by #2pt
  \edef\pst@value{\endgroup\def\noexpand#3{\pst@number\pst@dima}}\pst@value%
}
\def\pstSub#1#2#3{%
  \begingroup%
  \pst@dima=#1pt\relax
  \pst@dimb=#2pt\relax
  \advance\pst@dima by -\pst@dimb
  \edef\pst@value{\endgroup%
  \def\noexpand#3{\pst@number\pst@dima}}\pst@value%
}
% An mul macro for real values
% \pstmul{2.5}{1,5}\value ==> \value is 6.25
%
\def\pstMul#1#2#3{%
  \begingroup%
  \pst@dima=#1pt\relax
  \pst@dimb=#2\pst@dima\relax
  \edef\pst@value{\endgroup
  \def\noexpand#3{\pst@number\pst@dimb}}\pst@value%
}
%
\let\pstDiv\pst@divide
%
\chardef\nin@ty=90% stolen from the trig.sty package by David Carlisle
\chardef\@clxx=180
\chardef\@lxxi=71
\mathchardef\@mmmmlxviii=4068
\chardef\@coeffz=72
\chardef\@coefb=42
\mathchardef\@coefc=840
\mathchardef\@coefd=5040
{\catcode`t=12\catcode`p=12\gdef\noPT#1pt{#1}}
\def\TG@rem@pt#1{\expandafter\noPT\the#1\space}
\def\TG@term#1{%
 \dimen@\@tempb\dimen@
 \advance\dimen@ #1\p@}
\def\TG@series{%
  \dimen@\@lxxi\dimen@
  \divide \dimen@ \@mmmmlxviii
  \edef\@tempa{\TG@rem@pt\dimen@}%
  \dimen@\@tempa\dimen@
  \edef\@tempb{\TG@rem@pt\dimen@}%
  \divide\dimen@\@coeffz
  \advance\dimen@\m@ne\p@
  \TG@term\@coefb
  \TG@term{-\@coefc}%
  \TG@term\@coefd
  \dimen@\@tempa\dimen@
  \divide\dimen@ \@coefd}
\def\CalculateSin#1{{%
  \expandafter\ifx\csname sin(\number#1)\endcsname\relax
    \dimen@=#1\p@\TG@@sin
    \expandafter\xdef\csname sin(\number#1)\endcsname
                                    {\TG@rem@pt\dimen@}%
  \fi}}
\def\CalculateCos#1{{%
  \expandafter\ifx\csname cos(\number#1)\endcsname\relax
    \dimen@=\nin@ty\p@
    \advance\dimen@-#1\p@
    \TG@@sin
    \expandafter\xdef\csname cos(\number#1)\endcsname
                                     {\TG@rem@pt\dimen@}%
  \fi}}
\def\TG@reduce#1#2{%
\dimen@#1#2\nin@ty\p@
  \advance\dimen@#2-\@clxx\p@
  \dimen@-\dimen@
  \TG@@sin}
\def\TG@@sin{%
  \ifdim\TG@reduce>+%
  \else\ifdim\TG@reduce<-%
  \else\TG@series\fi\fi}%
\def\UseSin#1{\csname sin(\number#1)\endcsname}
\def\UseCos#1{\csname cos(\number#1)\endcsname}
\chardef\z@num\z@
\expandafter\let\csname sin(0)\endcsname\z@num
\expandafter\let\csname cos(0)\endcsname\@ne
\expandafter\let\csname sin(90)\endcsname\@ne
\expandafter\let\csname cos(90)\endcsname\z@num
\expandafter\let\csname sin(-90)\endcsname\m@ne
\expandafter\let\csname cos(-90)\endcsname\z@num
\expandafter\let\csname sin(180)\endcsname\z@num
\expandafter\let\csname cos(180)\endcsname\m@ne

% A macro for sin cos values
% \pstSinCos{30}\SinVal\CosVal ==> \SinVal 0.5 \CosVal 0.86
 %
\def\pstSinCos#1#2#3{%
%\begingroup%
%  \pst@getsinandcos{#1}
%  \edef\pst@values{\endgroup%
%    \def\noexpand#2{\ifcase\pst@quadrant\or\or-\or-\fi\pst@sin}%
%    \def\noexpand#3{\ifcase\pst@quadrant\or-\or-\or\fi\pst@cos}}\pst@values%
  \CalculateSin#1
  \CalculateCos#1
  \edef#2{\UseSin#1}%
  \edef#3{\UseCos#1}%
}
%
\def\pstRotPointIIID{\pst@object{RotPointIIID}}% A real TeX solution
\def\RotPointIIID@i(#1,#2,#3)#4#5#6{%
  \pst@killglue%
  \begingroup%
  \use@par%
% x- axis
  \pstSinCos{\psk@ThreeD@RotX}\pst@sinTheta\pst@cosTheta
  \def\pst@xVala{#1}
  \pstMul{#2}{\pst@cosTheta}\pst@tempA
  \pstMul{#3}{\pst@sinTheta}\pst@tempB
  \pstSub{\pst@tempA}{\pst@tempB}\pst@yVala
  \pstMul{#2}{\pst@sinTheta}\pst@tempA
  \pstMul{#3}{\pst@cosTheta}\pst@tempB
  \pstAdd{\pst@tempA}{\pst@tempB}\pst@zVala
% y- axis
  \pstSinCos{\psk@ThreeD@RotY}\pst@sinTheta\pst@cosTheta
  \pstMul{\pst@xVala}{\pst@cosTheta}\pst@tempA
  \pstMul{\pst@zVala}{\pst@sinTheta}\pst@tempB
  \pstAdd{\pst@tempA}{\pst@tempB}\pst@xValb
  \let\pst@yValb\pst@yVala
  \pstMul{\pst@xVala}{\pst@sinTheta}\pst@tempA
  \pstMul{\pst@zVala}{\pst@cosTheta}\pst@tempB
  \pstSub{\pst@tempB}{\pst@tempA}\pst@zValb
% z- axis
  \pstSinCos{\psk@ThreeD@RotZ}\pst@sinTheta\pst@cosTheta
  \pstMul{\pst@xValb}{\pst@cosTheta}\pst@tempA
  \pstMul{\pst@yValb}{\pst@sinTheta}\pst@tempB
  \pstSub{\pst@tempA}{\pst@tempB}\pst@xValc
  \pstMul{\pst@xValb}{\pst@sinTheta}\pst@tempA
  \pstMul{\pst@yValb}{\pst@cosTheta}\pst@tempB
  \pstAdd{\pst@tempA}{\pst@tempB}\pst@yValc
  \let\pst@zValc\pst@zValb
  %  
  \edef\pst@values{\endgroup%
    \def\noexpand#4{\pst@xValc}%
    \def\noexpand#5{\pst@yValc}%
    \def\noexpand#6{\pst@zValc}}\pst@values%
  \ignorespaces%
}
%
\catcode`\@=\PstAtCode\relax
%
%% END: pst-3dplot.tex
\endinput