summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-cox/pst-coxeterp.tex
blob: 32cccc288892e58cc4dd4abd56ae4ec9ea46af22 (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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    pst-coxeter_parameter\pst-coxeterp.tex
%    Authors:      J.-G. Luque and M. Luque
%    Purpose:      Listing of the macros of pst-coxeterp
%    Created:      02/02/2008
%    License:      LGPL
%    Project:      PST-Cox V1.00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright © 2008 Jean-Gabriel Luque, Manuel Luque.
% This work may be distributed and/or modified  under the condition of
% the Lesser GPL.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of PST-Cox V1.00.
%
%    PST-Cox V1.00 is free software: you can redistribute it and/or modify
%    it under the terms of the Lesser GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    PST-Cox V1.00 is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    Lesser GNU General Public License for more details.
%
%    You should have received a copy of the Lesser GNU General Public License
%    along with PST-Cox V1.00.  If not, see <http://www.gnu.org/licenses/>.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\fileversion{0.98 Beta}
\def\filedate{2008/21/01}

\message{`pst-Coxeter-parameter' v\fileversion, \filedate\space
(Jean-Gabriel Luque and Manuel Luque)}

\csname PstCoxeterLoaded\endcsname
\let\PstCoxeter\endinput
% Require PSTricks and pst-xkey
\ifx\PSTnodeLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey.tex\fi
%
% Catcodes changes.
\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax
%
%define the family of parameters pst-coxeter-parameter
%
\pst@addfams{pst-coxeter-parameter}
%
% There is two parameters P and Q which encodes the angle
% between the mirrors. The parameter P is used for the regular polygons
% the polytopes gamma^p_n, beta^p_n, gamma^p_2 and beta^p_2
% Example: \Polygon[P=5]
%
\define@key[psset]{pst-coxeter-parameter}{P}{%
\edef\psk@pstCoxeter@P{#1}}
%
\psset{P=6}
%
% The parameter Q is used for starry regular polygon.
% Example: \Polygon[P=5,Q=2]
%
\define@key[psset]{pst-coxeter-parameter}{Q}{%
\edef\psk@pstCoxeter@Q{#1}}
%
%
\psset{Q=1}
%
% The dimension is used for simplices, polytopes gamma^p_n and beta^p_n
% Example: \Simplex[dimension=4]
%
\define@key[psset]{pst-coxeter-parameter}{dimension}{%
\edef\psk@pstCoxeter@dimension{#1}}
\psset{dimension=3}
%
% Graphical parameters
%
% Colors
% Color of Vertices
% Example: \Polygon[colorVertices=blue,P=5]
\define@key[psset]{pst-coxeter-parameter}{colorVertices}{%
\pst@getcolor{#1}\pscolorVertices}
% by default the color of the vertices is green
\psset{colorVertices=green}
% Color of centers
% Example: \Polygon[colorCenters=blue,P=5]
\define@key[psset]{pst-coxeter-parameter}{colorCenters}{%
\pst@getcolor{#1}\pscolorCenters}
%
% by default the color of the centers is red.
\psset{colorCenters=red}
%
%
% Dot styles
% style of Vertices
% Example: \Polygon[styleVertices=*pentagon,P=5]
\def\psset@styleVertices#1{%
\@ifundefined{psds@#1}%
{\@pstrickserr{styleVertices `#1' not defined}\@eha}%
{\edef\psk@styleVertices{#1}}}
% by default the vertices are represented by a (empty) circle (styleVertices=o)
 \psset@styleVertices{o}
% style of Centers
% Example: \Polygon[styleCenters=*pentagon,P=5]
\def\psset@styleCenters#1{%
\@ifundefined{psds@#1}%
{\@pstrickserr{styleCenters `#1' not defined}\@eha}%
{\edef\psk@styleCenters{#1}}}
% by default the vertices are represented by a disk (styleVertices=*)
 \psset@styleCenters{*}
%
% Dot sizes
% Size of vertices
% Example: \Polygon[sizeVertices=0.1,P=5]
\newdimen\pssizeVertices
\def\psset@sizeVertices#1{\pssetlength\pssizeVertices{#1}}
\psset@sizeVertices{0.05}
% Sizes of centers
% Example: \Polygon[sizeCenters=0.1,P=5]
\newdimen\pssizeCenters
\def\psset@sizeCenters#1{\pssetlength\pssizeCenters{#1}}
\psset@sizeCenters{0.05}
%
% Boolean parameters
%
% The vertices are drawn only if the value of drawvertices is true
% Examples: \Polygon[drawvertices=false,P=5]

\newif\ifPst@drawvertices
\define@key[psset]{pst-coxeter-parameter}{drawvertices}[true]{%
\@nameuse{Pst@drawvertices#1}}
%
% The edges are drawn only if the value of drawedges is true
% Examples: \Polygon[drawedges=false,P=5]
%
\newif\ifPst@drawedges
\define@key[psset]{pst-coxeter-parameter}{drawedges}[true]{%
\@nameuse{Pst@drawedges#1}}
%
%%
% The centers are drawn only if the value of drawcenters is true
%% Examples: \Polygon[drawcenters=false,P=5]
%
\newif\ifPst@drawcenters
\define@key[psset]{pst-coxeter-parameter}{drawcenters}[true]{%
\@nameuse{Pst@drawcenters#1}}
%
% By default the vertices, edges and centers are drawn.
%
%\setkeys{psset}{drawvertices=true,drawedges=true,drawcenters=true}
\psset{drawvertices=true,drawedges=true,drawcenters=true}
%
% All the polytopes are encoded with the same way.
% For each kind of polytope, we have wrote three procedures:
%                           /drawVertices which allows to draw the vertices of the polytope
%                           /drawEdges which allows to draw the edges of the polytope
%                           /drawCenter which allows to draw the centers of the edges of the polytope
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% LIST OF THE POLYTOPES
%%
%                                   Regular real polygons
%
%
% It is a well known family of polytope with two parameters P and Q.
% This is the set of the classical polygons whose symmetric groups are dihedral 2[p]2.
% Use the macro \Polygon[P=p,Q=q] draw the polygon 2{p/q}2 in the notation of Coxeter.
% The non starry real polygons are obtained when Q=1
% The starry polygon are obtained when Q do not divided P
%
% Example:
% \Polygon[P=5] draw a pentagone
% \Polygon[P=5,Q=2] draw a regular star with five vertices.
\def\Polygon{\pst@object{Polygon}}
\def\Polygon@i{\@ifnextchar[{\Polygon@do}{\Polygon@do[]}}
\def\Polygon@do[#1]{{%
\pst@killglue
\setkeys{psset}{#1}%
\begin@ClosedObj
\addto@pscode{%
%%%% macro for the colors of the vertices and the centers
/pscolorVertices {\pst@usecolor\pscolorVertices currentrgbcolor} def
/pscolorCenters {\pst@usecolor\pscolorCenters currentrgbcolor} def
 0 0 translate
%%% some usefull definition
/unit \pst@number\psunit\space def % pts -> cm
/Pi 180 def %%% use Pi instead of 180°
/p \psk@pstCoxeter@P\space def % parameter P
/q \psk@pstCoxeter@Q\space def % parameter Q
/p_1 p 1 sub def % p-1
1 setlinejoin CLW setlinewidth%
%%%%% List of the vertices
%%%%%
 /TableauxPoints [
0 1 p 1 add {%
    /n exch def
    [
             2 n Pi q mul mul mul p div cos    % cos(2nqPi/p)
             unit mul % pts to cm
             2 n Pi q mul mul mul p div sin   % sin(2nPi/p)
             unit mul % pts to cm
    ]
   } for
] def
%
%
%%%% Procedures
%
%  /drawEdges: this procedure draws the edges
%
/drawEdges { 0 1 p  {
        /n exch def
        TableauxPoints n get aload pop
        /YL ED /XL ED
        XL YL moveto % move to the point n of the array
        TableauxPoints n  1 add  get aload pop
        lineto % draw a line from the point n to the point n+1
        stroke
       } for
} def \ifPst@drawedges
    drawEdges
    stroke
\fi
 %%%%%%%%%%%%%%%%%%
 % /drawVertices:this procedure draw the vertices
 %
 %
/DS \pst@number\pssizeVertices\space def
\@nameuse{psds@\psk@styleVertices}%
/drawVertices {%
    /Liste exch def
     0 1 p  {
    /compteur exch def
    pscolorVertices
    Liste compteur get aload pop
    Dot
    } for
} def \ifPst@drawvertices
    TableauxPoints drawVertices
\fi
 %%%%%%%%%%%%%%
% /drawCenters : draw the centers of the edges
%
/DS \pst@number\pssizeCenters\space def
\@nameuse{psds@\psk@styleCenters}%
/drawCenters {
 0 1 p  {
        /n exch def
        TableauxPoints n  get aload pop
        /YL ED /XL ED
        TableauxPoints n 1 add  get aload pop
        /YR ED /XR ED
        /YM YL YR add 2 div def % YM = (YL+YR)/2
        /XM XL XR add 2 div def % XM = (XL+XR)/2
         pscolorCenters
            XM YM
            Dot
        stroke
}for
 } def
\ifPst@drawcenters
    drawCenters
\fi
}%
\end@ClosedObj
}}
%
%%%%%%%%%%%%%%%%%%% The simplices
% Simplices are the real regular polytopes whose
% roots system is A_{n+1}. The reflection groups which generates
% it is the symmetric group (order (n+1)!).
% Simplices are auto-reciprocal polytopes. The first examples are the tetrahedral (for dimension 2),
% the pentatope (in dimension 4), the sextatope in dimension 5 etc.
% In general the number of cells of dimension m ($m<n$) is equal to the binomial $\left(n+1\atop m+1\right)$.
% Each cell is a simplex of dimension $m$.
% For example, the tetrahedral has $4$ vertices, $6$ edges and $4$ faces; the pentatope has $5$ vertices, $10$ edges,
% $10$ faces and $5$ cells of dimension $3$.
%
% Use the macro \Simplex to draw the projection of a simplex.
% Use the parameter dimension to choose the dimension of the simplex.
%
% Example: \Simplex[dimension=5]
%
\def\Simplex{\pst@object{Simplex}}
\def\Simplex@i{\@ifnextchar[{\Simplex@do}{\Simplex@do[]}}
\def\Simplex@do[#1]{{%
\pst@killglue
\setkeys{psset}{#1}%
\begin@ClosedObj
\addto@pscode{%
% Some usefull definitions
/pscolorVertices {\pst@usecolor\pscolorVertices currentrgbcolor} def
/pscolorCenters {\pst@usecolor\pscolorCenters currentrgbcolor} def 0
0 translate
/unit \pst@number\psunit\space def % pts -> cm
/Pi 180 def
/p \psk@pstCoxeter@dimension\space 1 add def % dimension of the space plus 1
/p_1 p 1 sub def % dimension of the space
1 setlinejoin CLW setlinewidth%
%%%% Computation if the array of the Vertices
 /TableauxPoints [
0 1 p 1 add {% for n from 0 to p+1
    /n exch def
    1 1 p 1 sub{ % for m from 1 to p+1
       /m exch def
    [
             2 n Pi mul mul p div cos    % cos(2nPi/p)
             unit mul % pts to cm
             2 n Pi mul mul p div sin   % sin(2nPi/p)
             unit mul % pts to cm
    ]
    [
             2 n m add Pi mul mul p div cos    % cos(2nPi/p)
             unit mul % pts to cm
             2 n m add Pi mul mul p div sin   % sin(2nPi/p)
             unit mul % pts to cm
    ]
    }for
   } for
] def
%
%%%%%% Procedure
%  /drawEdges : draw the edges of the simplex
%  One use the array TableauxPoints
/drawEdges { 0 1 p p mul  { % for n from 0 to p^2
        /n exch def
        TableauxPoints n 2 mul get aload pop % the point 2n of the array
        /YL ED /XL ED
        XL YL moveto
        TableauxPoints n  2 mul 1 add  get aload pop % the point 2n+1 of the array
        lineto
        stroke
       } for
} def \ifPst@drawedges
    drawEdges
    stroke
\fi
%
% /drawVertices : draw the vertices of the simplex
%
/DS \pst@number\pssizeVertices\space def% define  the size of the dots
\@nameuse{psds@\psk@styleVertices}% style of the dots
/drawVertices {%
    /Liste exch def
     0 1 p p mul { % for compteur from 0 to p^2
    /compteur exch def
    pscolorVertices % color of the parameters colorVertices
        Liste compteur get aload pop
    Dot % draw a dot
    } for
} def \ifPst@drawvertices
    TableauxPoints drawVertices % apply drawVertices to TableauxPoints
\fi
%
% /drawCenters : draw the centers of the simplex
%
/DS \pst@number\pssizeCenters\space def % define  the size of the dots
\@nameuse{psds@\psk@styleCenters}% style of the dots
/drawCenters {
 0 1 p p mul { % from n from 0 to p^2
        /n exch def
        TableauxPoints n 2 mul get aload pop % point $2n$ of TableauxPoints
        /YL ED /XL ED
        TableauxPoints n 2 mul 1 add  get aload pop % point $2n+1$ of TableauxPoints
        /YR ED /XR ED
        /YM YL YR add 2 div def % YM:=(YL+YZ)/2
        /XM XL XR add 2 div def % XM:=(XY+XZ)/2
        pscolorCenters
            XM YM
         Dot
        stroke
}for
 } def
\ifPst@drawcenters
    drawCenters
\fi
}
\end@ClosedObj
}}
%
%%%%%%%%%%%%%%%%%% The polytopes $\gamma^p_n$
% These polytopes are complex polytopes $p\{4\}2\{3\}2\dots 2\{3\}2$ in the notation of Coxeter.
% This means that their symmetric group is a $n!p$ order group generated by $n$ reflections
% with relations $R_1^p=R_2^2=\dots R_n^2=Id$
% $R_1R_2R_1R_2=R_2R_1R_2R_1$, $R_iR_{i+1}R_i=R_{i+1}R_i$ if i>1, $R_iR_j=R_jR_i$ if $|i-j|>1$.
% Such a complex polytope has $\left(n\atop m\right)p^n$ cells of dimension $m$ ($m<n$) which are
% complex polytopes $\gamma^p_m$.
% When $p=2$, the polytope $\gamma^2_n$ is an hypercube.
% When $p>2$, the polytope is not a real polytope since $R_1^2\neq Id$.
% In this case, the edges are regular polygons with $p$ vertices.
% When $n=2$, the projection is not convenient since the projection of some vertices are the same.
% For an other projection, use the macro \gammaptwo described below.
%
% The two parameters are the dimension and $p$.
%
% Use the macro \gammapn[dimension=...,P=...] to draw the projection of a polytope $\gamma^p_n$.
%
% Example : \gammapn[dimension=5,P=4]
%
\def\gammapn{\pst@object{gammapn}}
\def\gammapn@i{\@ifnextchar[{\gammapn@do}{\gammapn@do[]}}
\def\gammapn@do[#1]{{%
\pst@killglue
\setkeys{psset}{#1}%
\begin@ClosedObj
\addto@pscode{%
%%% Some usefull definitions
/pscolorVertices {\pst@usecolor\pscolorVertices currentrgbcolor} def
 /pscolorCenters {\pst@usecolor\pscolorCenters currentrgbcolor} def
0 0 translate
/unit \pst@number\psunit\space def % pts -> cm
/Pi 180 def
/p \psk@pstCoxeter@P\space def % parameter p
%/p 3 def
/n \psk@pstCoxeter@dimension\space def% dimension
/n_1 n 1 sub def % n-1
/p_1 p 1 sub def % p-1
1 setlinejoin CLW setlinewidth%
%
%
%    The procedures
%
% /drawEdges : draw the edges of the polytopes
/drawEdges { /pow2 1 def
 1 1 n_1 {/pop %for from 1 to n-1
   /pow2 pow2 p  mul def%
    } for % compute p^{n-1}
%
    1 1 n  {% for i from 1 to n
    /i exch def
     0 1 pow2  1 sub { % for j from  0 to p^{n-1}-1
            /j exch def
            /num j def % num := j
            /s1 0 def  % s1 := 0
            /s2 0 def  % s2 := 0
            1 1 i 1 sub {% for k from  1 to i-1
               /k exch def
               /c unit k n num mul add 2 Pi mul mul p div n div  cos  mul def% c := cos( (p*num+k)*2*Pi/p/n)*unit
               /s unit k n num mul add 2 Pi mul mul p div n div  sin  mul def% s := sin( (p*num+k)*2*Pi/p/n)*unit
               /s1 s1 c add def %s1 := s1+c
               /s2 s2 s add def %s2 := s2+s
               /num num p idiv def % num := num/p
            } for
           i 1 add 1 n {% for k from  i+1 to  n
               /k exch def
               /c unit k n num mul add 2 Pi mul mul p div n div  cos  mul def% c := cos( (p*num+k)*2*Pi/p/n)*unit
               /s unit k n num mul add 2 Pi mul mul p div n div  sin  mul def% s := sin( (p*num+k)*2*Pi/p/n)*unit
               /s1 s1 c add def %s1 := s1+c
               /s2 s2 s add def %s2 := s2+s
               /num num p idiv def % num := num/p
            } for
      /x unit i 2 Pi mul mul p  div n div cos mul s1 add def %x := s1+unit*cos(2*i*Pi/p/n)
      /y unit i 2 Pi mul mul p  div n div sin mul s2 add def %y := s2+unit*sin(2*i*Pi/n)
       x y moveto %
       0 1 p  { % from jj from 0 to p
       /jj exch def
       /x unit i jj n mul add 2 Pi mul mul n div p div cos mul s1 add def %x := s1+unit*cos((i+jj*n)*Pi*2/p/n)
       /y unit i jj n mul add 2 Pi mul mul n div p div sin mul s2 add def %y := s2+unit*sin((i+jj*n)*Pi*2/p/n)
       x y lineto
       } for
        stroke
}for
   } for
   stroke
} def \ifPst@drawedges
    drawEdges
    stroke
\fi
%
% \drawVertices : draw the vertices of the polytopes
%
% Almost the same procedure than \drawEdges
/DS \pst@number\pssizeVertices\space def
\@nameuse{psds@\psk@styleVertices}%
/drawVertices   {%
 /pow2 1 def
 1 1 n_1 {/pop
   /pow2 pow2 p  mul def%
    } for
%
    1 1 n  {%
    /i exch def
     0 1 pow2  1 sub { % for j from 0 to p^{n-1}-1
            /j exch def
            /num j def
            /s1 0 def
            /s2 0 def
            1 1 i 1 sub {% for k from  1 to i-1
               /k exch def
               /c unit k n num mul add 2 Pi mul mul p div n div  cos  mul def% cos( (p*num+k)*2*Pi/p/n)*unit
               /s unit k n num mul add 2 Pi mul mul p div n div  sin  mul def% sin( (p*num+k)*2*Pi/p/n)*unit
               /s1 s1 c add def %s1=s1+c
               /s2 s2 s add def %s2=s2+s
               /num num p idiv def % num:=num/p
            } for
           i 1 add 1 n {% for k from i+1 to n
               /k exch def
               /c unit k n num mul add 2 Pi mul mul p div n div  cos  mul def% cos( (p*num+k)*2*Pi/p/n)*unit
               /s unit k n num mul add 2 Pi mul mul p div n div  sin  mul def% sin( (p*num+k)*2*Pi/p/n)*unit
               /s1 s1 c add def %s1=s1+c
               /s2 s2 s add def %s2=s2+s
               /num num p idiv def % num:=num/p
            } for
      /x unit i 2 Pi mul mul p  div n div cos mul s1 add def %x:=s1+unit*cos(2*i*Pi/p/n)
      /y unit i 2 Pi mul mul p  div n div sin mul s2 add def
       pscolorVertices
       x y
       Dot
       0 1 p { % for jj from 0 to p
       /jj exch def
       /x unit i jj n mul add 2 Pi mul mul n div p div cos mul s1 add def%x:=s1+unit*cos((i+jj*n)*Pi*2/p/n)
       /y unit i jj n mul add 2 Pi mul mul n div p div sin mul s2 add def
        pscolorVertices
       x y
        Dot
       } for
        stroke
}for
   } for
   stroke
} def \ifPst@drawvertices
    %Tableaaux
     drawVertices
\fi
%
% \drawCenters : draw the centers of the  edges of the polytopes
%
% Almost the same procedure than \drawEdges
/DS \pst@number\pssizeCenters\space def
\@nameuse{psds@\psk@styleCenters}%
/drawCenters {
 /pow2 1 def
 1 1 n_1 {/pop
   /pow2 pow2 p  mul def%
    } for
%
    1 1 n  {%
    /i exch def
     0 1 pow2  1 sub { % for j from 0 to p^{n-1}-1
            /j exch def
            /num j def
            /s1 0 def
            /s2 0 def
            1 1 i 1 sub {% for k from 1 to i-1
               /k exch def
               /c unit k n num mul add 2 Pi mul mul p div n div  cos  mul def% cos( (p*num+k)*2*Pi/p/n)*unit
               /s unit k n num mul add 2 Pi mul mul p div n div  sin  mul def% sin( (p*num+k)*2*Pi/p/n)*unit
               /s1 s1 c add def %s1=s1+c
               /s2 s2 s add def %s2=s2+s
               /num num p idiv def % num:=num/p
            } for
           i 1 add 1 n {% for k from i+1 à n
               /k exch def
               /c unit k n num mul add 2 Pi mul mul p div n div  cos  mul def% cos( (p*num+k)*2*Pi/p/n)*unit
               /s unit k n num mul add 2 Pi mul mul p div n div  sin  mul def% sin( (p*num+k)*2*Pi/p/n)*unit
               /s1 s1 c add def %s1=s1+c
               /s2 s2 s add def %s2=s2+s
               /num num p idiv def % num:=num/p
            } for
       /x unit i 2 Pi mul mul p  div n div cos mul s1 add def %x:=s1+unit*cos(2*i*Pi/p/n)
       /y unit i 2 Pi mul mul p  div n div sin mul s2 add def
       1 1 p 1 sub { % for jj from 1 to p-1
       /jj exch def
       /x unit i jj n mul add 2 Pi mul mul n div p div cos mul s1 add x add def%x:=s1+unit*cos((i+jj*n)*Pi*2/p/n)
       /y unit i jj n mul add 2 Pi mul mul n div p div sin mul s2 add y add def
       } for
       /x x p 0 add div def
       /y y p 0 add div def
        pscolorCenters
       x y
       Dot
        stroke
}for
   } for
   stroke
 } def
\ifPst@drawcenters
    drawCenters
\fi }
\end@ClosedObj
}}
%
%%%%%%%%%%%%%%%%%% The polytopes $\beta^p_n$
% These polytopes are complex polytopes $2\{3\}2\{3\}2\dots 2\{4\}p$ in the notation of Coxeter.
% They are the reciprocal polytopes of $\gamma^p_n$
% When $p=2$, the polytope $\beta^2_n$ is an hyperoctaedre.
% When $n=2$, the projection is not convenient since the projection of some vertices are the same.
% For an other projection, use the macro \betaptwo described below.
%
% The two parameters are the dimension and $p$.
%
% Use the macro \betapn[dimension=...,P=...] to draw the projection of a polytope $\beta^p_n$.
%
% Example : \betapn[dimension=5,P=4]
%%
%
%
\def\betapn{\pst@object{betapn}}
\def\betapn@i{\@ifnextchar[{\betapn@do}{\betapn@do[]}}
\def\betapn@do[#1]{{%
\pst@killglue
\setkeys{psset}{#1}%
\begin@ClosedObj
\addto@pscode{%
% Some useful definitions
/pscolorVertices {\pst@usecolor\pscolorVertices currentrgbcolor} def
 /pscolorCenters {\pst@usecolor\pscolorCenters currentrgbcolor} def
0 0 translate
/unit \pst@number\psunit\space def % pts -> cm
/Pi 180 def
/p \psk@pstCoxeter@P\space def % parameter
%/p 3 def
/n \psk@pstCoxeter@dimension\space def% dimension
/n_1 n 1 sub def % n-1
/p_1 p 1 sub def % p-1
1 setlinejoin CLW setlinewidth%
 /TableauxPoints [
] def
%
%%%%% The procedures
% % /drawEdges : draw the edges of the polytopes
 /drawEdges {
  0 1 n { % for k from 0 to n
      /k exch def
      k 1 add 1 n{ % for l from k+1 to n
             /l exch def
             0 1 p  { % for i from 0 to p
                    /i exch def
                    0  1 p  { % for j from 0 to p
                            /j exch def
                            /s1 unit n i mul  k add 2 Pi mul mul n div p div cos mul def % s1 := unit*cos(2*Pi*(n*i)+k)/n/p)
                            /s2 unit n i mul  k add 2 Pi mul mul n div p div sin mul  def % s2 := unit*sin(2*Pi*(n*i)+k)/n/p)
                            /s3 unit n j mul  1 k add add 2 Pi mul mul n div p div cos mul  def % s3 := unit*cos(2*Pi*(n*j)+k)/n/p)
                            /s4 unit n j mul  1 k add add 2 Pi mul mul n div p div sin mul  def % s4 := unit*sin(2*Pi*(n*j)+k)/n/p)
                            s1 s2 moveto
                            s3 s4 lineto
                            stroke
                    }for
             }for
      } for
  }for
 } def \ifPst@drawedges
    drawEdges
    stroke
\fi
%
% \drawVertices : draw the vertices of the polytopes
%
% Almost the same procedure than \drawEdges
/DS \pst@number\pssizeVertices\space def
\@nameuse{psds@\psk@styleVertices}%
/drawVertices   {%
 0 1 n {
      /k exch def
      k 1 add 1 n{
             /l exch def
             0 1 p 0 sub {
                    /i exch def
                    0  1 p 0 sub {
                            /j exch def
                            /s1 unit n i mul  k add 2 Pi mul mul n div p div cos mul  def
                            /s2 unit n i mul  k add 2 Pi mul mul n div p div sin mul  def
                            /s3 unit n j mul  1 k add add 2 Pi mul mul n div p div cos mul  def
                            /s4 unit n j mul  1 k add add 2 Pi mul mul n div p div sin mul  def
                            pscolorVertices
                            s1 s2 %radiusVertices  0 360 arc
                            Dot
                            %0 1 0 setrgbcolor % green
                            %pscolorVertices
                           % fill
                            s3 s4 %radiusVertices  0 360 arc
                            Dot
                            %0 1 0 setrgbcolor % green
                            %pscolorVertices
                            %fill
                            stroke
                    }for
             }for
      } for
  }for
} def \ifPst@drawvertices
     drawVertices
\fi
%
% \drawCenters : draw the vertices of the polytopes
%
% Almost the same procedure than \drawCenters
/DS \pst@number\pssizeCenters\space def
\@nameuse{psds@\psk@styleCenters}%
/drawCenters {
 0 1 n {
      /k exch def
      k 1 add 1 n{
             /l exch def
             0 1 p 0 sub {
                    /i exch def
                    0  1 p 0 sub {
                            /j exch def
                            /s1 unit n i mul  k add 2 Pi mul mul n div p div cos mul  def
                            /s2 unit n i mul  k add 2 Pi mul mul n div p div sin mul  def
                            /s3 unit n j mul  1 k add add 2 Pi mul mul n div p div cos mul  def
                            /s4 unit n j mul  1 k add add 2 Pi mul mul n div p div sin mul  def
                            pscolorCenters
                            %newpath
                            s1 s3 add 2 div s2 s4 add 2 div %1.5 0 360 arc
                            %closepath
                            Dot
                           %1 0 0 setrgbcolor % red
                            stroke
                    }for
             }for
      } for
  }for
  } def \ifPst@drawcenters
    drawCenters
\fi
}%
\end@ClosedObj
}}
%
% %%%%% Polygon $\gamma^p_2$
% A special projection for polytopes $\gamma^p_2$.
%
\def\gammaptwo{\pst@object{gammaptwo}}
\def\gammaptwo@i{\@ifnextchar[{\gammaptwo@do}{\gammaptwo@do[]}}
\def\gammaptwo@do[#1]{{%
\pst@killglue
\setkeys{psset}{#1}%
\begin@ClosedObj
\addto@pscode{%
/pscolorVertices {\pst@usecolor\pscolorVertices currentrgbcolor} def
 /pscolorCenters {\pst@usecolor\pscolorCenters currentrgbcolor} def
0 0 translate
/unit \pst@number\psunit\space def % pts -> cm
/Pi 180 def
/p \psk@pstCoxeter@P\space def % parameter
/p_1 p 1 add def % p+1
1 setlinejoin CLW setlinewidth
% list of the vertices
/TableauxPointsL [
0 1 p_1 {% for n from 0 to p-1
    /n exch def
0 1 p { % for n from 0 to p
    /i exch def
    [
             2 n Pi mul mul p div cos 7.5 sin mul     % cos(2nPi/p)sin(Pi/24)
             2 n Pi mul mul p div sin 7.5 cos mul add % +sin(2nPi/p)cos(Pi/24)
             2 i Pi mul mul p div cos 7.5 sin mul sub % -cos(2iPi/p)sin(Pi/24)
             2 i Pi mul mul p div sin 7.5 cos mul sub % -sin(2iPi/p)cos(Pi/24)
             %
             unit mul % pts to cm
             2 n Pi mul mul p div cos 7.5 cos mul     % cos(2nPi/p)cos(Pi/24)
             2 n Pi mul mul p div sin 7.5 sin mul sub % -sin(2nPi/p)sin(Pi/24)
             2 i Pi mul mul p div cos 7.5 cos mul add % +cos(2iPi/p)cos(Pi/24)
             2 i Pi mul mul p div sin 7.5 sin mul sub % -sin(2iPi/p)sin(Pi/24)
             unit mul % pts to cm
    ]
    } for
    } for
] def
%
/TableauxPointsR [
0 1 p_1 {%for n from 0 to p-1
    /n exch def
0 1 p {% for i from 0 to p
    /i exch def
    [
             2 i Pi mul mul p div cos 7.5 sin mul     % cos(2iPi/p)sin(Pi/24)
             2 i Pi mul mul p div sin 7.5 cos mul add % +sin(2iPi/p)cos(Pi/24)
             2 n Pi mul mul p div cos 7.5 sin mul sub % -cos(2nPi/p)sin(Pi/24)
             2 n Pi mul mul p div sin 7.5 cos mul sub % -sin(2nPi/p)cos(Pi/24)
             unit mul % pts to cm
             %
             2 i Pi mul mul p div cos 7.5 cos mul     % cos(2iPi/p)cos(Pi/24)
             2 i Pi mul mul p div sin 7.5 sin mul sub % -sin(2iPi/p)sin(Pi/24)
             2 n Pi mul mul p div cos 7.5 cos mul add % +cos(2nPi/p)cos(Pi/24)
             2 n Pi mul mul p div sin 7.5 sin mul sub % -sin(2nPi/p)sin(Pi/24)
             unit mul % pts to cm
    ]
    } for
    } for
] def
 %%%% The procedures
 %
 % / drawEdges draw the edges of the polygon
/drawEdges {
  /Liste exch def
newpath
 Liste 0 get aload pop moveto
 0 1 p_1 p mul {
    /compteur exch def
    Liste compteur get aload pop
        lineto } for
closepath stroke } def \ifPst@drawedges
    TableauxPointsL drawEdges
    TableauxPointsR drawEdges
\fi
%
 % / drawVertices draw the vertices of the polygon
/DS \pst@number\pssizeVertices\space def
\@nameuse{psds@\psk@styleVertices}%
/drawVertices {%
    /Liste exch def
     0 1 p_1 p mul {
    /compteur exch def
        pscolorVertices
        Liste compteur get aload pop
        Dot
 pscolorVertices
    fill
    } for
} def \ifPst@drawvertices
    TableauxPointsL drawVertices
    TableauxPointsR drawVertices
\fi
 %% List of the centers
/TableauMilieuxL[
0 1 p 1 sub {% for n from 0 to p-1
    /n exch def
    [
             2 n Pi mul mul p div cos 7.5 sin mul     % cos(2nPi/p)sin(Pi/24)
             2 n Pi mul mul p div sin 7.5 cos mul add % +sin(2nPi/p)cos(Pi/24)
             unit mul % pts to cm
             2 n Pi mul mul p div cos 7.5 cos mul     %  cos(2nPi/p)cos(Pi/24)
             2 n Pi mul mul p div sin 7.5 sin mul sub % -sin(2nPi/p)sin(Pi/24)
             unit mul % pts to cm
    ]
    } for
] def
%
/TableauMilieuxR[
0 1 p 1 sub {% for n from 0 to p-1
    /n exch def
    [
             2 n Pi mul mul p div cos 7.5 sin mul neg % -cos(2nPi/p)sin(Pi/24)
             2 n Pi mul mul p div sin 7.5 cos mul sub % -sin(2nPi/p)cos(Pi/24)
             unit mul % pts to cm
             2 n Pi mul mul p div cos 7.5 cos mul     %  cos(2nPi/p)cos(Pi/24)
             2 n Pi mul mul p div sin 7.5 sin mul sub % -sin(2nPi/p)sin(Pi/24)
             unit mul % pts to cm
    ]
    } for
] def
%
 % / drawEdges draw the edges of the polygon
/DS \pst@number\pssizeCenters\space def
\@nameuse{psds@\psk@styleCenters}%
/drawCenters {%
  /Liste exch def
  0 1 p 1 sub {%
        /compteur exch def
        pscolorCenters
        Liste compteur get aload pop
        Dot
        stroke
        } for
} def \ifPst@drawcenters
    TableauMilieuxL drawCenters
    TableauMilieuxR drawCenters
\fi
}%
\end@ClosedObj
}}
%
%
% %%%%% Polygon $\gamma^p_2$
% A special projection for polytopes $\gamma^p_2$.
%
%
\def\betaptwo{\pst@object{betaptwo}}
\def\betaptwo@i{\@ifnextchar[{\betaptwo@do}{\betaptwo@do[]}}
\def\betaptwo@do[#1]{{%
\pst@killglue
\setkeys{psset}{#1}%
\begin@ClosedObj
\addto@pscode{%
/pscolorVertices {\pst@usecolor\pscolorVertices currentrgbcolor} def
 /pscolorCenters {\pst@usecolor\pscolorCenters currentrgbcolor} def
0 0 translate
/unit \pst@number\psunit\space def % pts -> cm
/Pi 180 def
/p \psk@pstCoxeter@P\space def % parameter
/p_1 p 1 sub def % p-1
1 setlinejoin CLW setlinewidth
% List of the vertices
 /TableauxPointsL24p [
0 1 p_1 {% for n from 0 to p-1
    /n exch def
    [
             2 n Pi mul mul p div cos 7.5 sin mul     % cos(2nPi/p)sin(Pi/24)
             2 n Pi mul mul p div sin 7.5 cos mul add % +sin(2nPi/p)cos(Pi/24)
             unit mul % pts to cm
             2 n Pi mul mul p div cos 7.5 cos mul     % cos(2nPi/p)cos(Pi/24)
             2 n Pi mul mul p div sin 7.5 sin mul sub % -sin(2nPi/p)cos(Pi/24)
             unit mul % pts to cm
    ]
    } for
] def
%
/TableauxPointsR24p [
0 1 p_1 {% for m from 0 to p-1
    /m exch def
    [
             2 m Pi mul mul p div cos 7.5 sin mul neg %  cos(2mPi/p)sin(Pi/24)
             2 m Pi mul mul p div sin 7.5 cos mul sub % -sin(2mPi/p)cos(Pi/24)
             unit mul % pts to cm
             2 m Pi mul mul p div cos 7.5 cos mul     %  cos(2mPi/p)cos(Pi/24)
             2 m Pi mul mul p div sin 7.5 sin mul sub % -sin(2mPi/p)sin(Pi/24)
             unit mul % pts to cm
    ]
    } for
] def
%%%% The procedures
 %
 % / drawEdges draw the edges of the polygon
/drawEdges { 0 1 p_1 { %
        /n exch def
        TableauxPointsL24p n get aload pop
        /YL ED /XL ED
0 1 p_1 {
        /m ED
        XL YL moveto
        TableauxPointsR24p m get aload pop
        lineto
%        0 0 1 setrgbcolor
        stroke
       } for } for
} def
 \ifPst@drawedges
    drawEdges
    stroke
\fi
 % / drawVertices draw the vertices of the polygon
 /DS \pst@number\pssizeVertices\space def
\@nameuse{psds@\psk@styleVertices}%
/drawVertices {%
    /Liste exch def
     0 1 p_1 {
    /compteur exch def
 %   newpath
    pscolorVertices
        Liste compteur get aload pop
       Dot% radiusVertices  0 360 arc
    %closepath
%0 1 0 setrgbcolor % green
%pscolorVertices
%    fill
    } for
} def
%
\ifPst@drawvertices
    TableauxPointsL24p drawVertices
    TableauxPointsR24p drawVertices
\fi
 % / drawCenters draw the centers of the edges of the polygon
/DS \pst@number\pssizeCenters\space def
\@nameuse{psds@\psk@styleCenters}%
/drawCenters {
 0 1 p_1 {
        /n exch def
        TableauxPointsL24p n get aload pop
        /YL ED /XL ED
0 1 p_1 {
        /m ED
        TableauxPointsR24p m get aload pop
        /YR ED /XR ED
            /YM YL YR add 2 div def
            /XM XL XR add 2 div def
        pscolorCenters
        %newpath
            XM YM %1.5 0 360 arc
            Dot
        %closepath
        %1 0 0 setrgbcolor % red
        stroke
       } for } for
 } def
\ifPst@drawcenters
    drawCenters
\fi }
\end@ClosedObj
}}
%
%
%\catcode`\@=\PstAtCode\relax
\endinput
%
%%
%% END: pst-coxeter.tex