%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    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