%% to be compiled with pdflatex

\documentclass{amsart}

%%%%%%%%

%%%%% Shows an orthogonal projection of Loday's realization of the
%%%%% 3-dimensional associahedron A_3.

%%%%% The realization lies in the hyperplane
%%%%%
%%%%%           H = { x + y + z + t = 10 }
%%%%%
%%%%% in R^4.  On H one takes the inherited Euclidean metric and
%%%%% projects orthogonally to the plane { y = 0 } along (1,-3,1,1).
%%%%% The distance of a vertex from the plane is y times 2/\sqrt{3}
%%%%% (=1.15470).  The plane { y = 1 } contains the pentagon
%%%%%
%%%%%              2134 - 2161 - 4141
%%%%%                 \          /
%%%%%                 3124 -- 4123
%%%%%

%%%%% Orthogonal projections to other faces (up to parallels and the
%%%%% symmetry xyzt<->tyzx) have various collapses and edge overlaps.
%%%%% Presenting understandable drawings is more complicated.
%%%%% Formulas for the essentially 4 cases can be found below.

%%%%% The basic 2-dimensional sub-associahedron A_2 (coordinates NNN4)
%%%%%
%%%%%              3214 - 1414 - 1234
%%%%%                 \          /
%%%%%                 3124 -- 2134
%%%%%
%%%%% and its opposite A_2' (coordinates 4NNN)
%%%%%
%%%%%              4213 -- 4312 - 4321
%%%%%                 \           /
%%%%%                  4123 - 4141
%%%%%
%%%%% are drawn in green.  The arrows indicate the homotopy A_2 ->
%%%%% A_2'.

%%%%% This file is edited from cube-3L.tex, which see for more comments.

%%%%%%%%

\newif\ifLABELS %
%% uncomment to show the coordinates
% \LABELStrue %

\newif\ifNAMES %
%% uncomment to show instead the internal names of the vertices
%%% recommended if you read this file
% \NAMEStrue % no effect with \LABELSfalse
\ifNAMES \LABELStrue \fi

\newif\ifSIMPLE %
%% uncomment to draw the edges only (no colors for faces)
%% useful for the other projections
% \SIMPLEtrue %

%%%%%%%%

\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings}

\begin{document}
\thispagestyle{empty} %

\centerline{%

  \tikzpicture %

  %%%%%%%% Loday coordinates

  \def\LCOORDINATES{%
    A0/1/2/3/4, % ((( 01 )2)3)4
    A1/2/1/3/4, % (( 0(12) )3)4
    X0/1/4/1/4, % ( (01)(23) )4
    A2/3/2/1/4, % ( 0(1(23)) )4
    A3/3/1/2/4, % ( 0((12)3) )4
    Y1/1/2/6/1, %  ((01)2)(34)
    Y2/1/6/2/1, %  (01)(2(34))
    B0/4/3/2/1, %  0(1(2(34)))
    Z1/2/1/6/1, %  (0(12))(34)
    B1/4/1/4/1, %  0((12)(34))
    X2/1/6/1/2, %  (01)((23)4)
    X3/4/3/1/2, %  0(1((23)4))
    B2/4/2/1/3, %  0((1(23))4)
    B3/4/1/2/3% %  0(((12)3)4)
  }

  \def\RTHREE{1.7320508} % \sqrt{3}

  \iftrue %
  % \else %
  %%%% projection to face A1-A3-B3-B1-Z1
  \foreach \NNN/\x/\y/\z/\t in \LCOORDINATES { %

    %%% orthogonal projection with
    %%%%         A3-B3 = (-1,0,0,1)  -> (0,2)
    %%%%     (Z1-B3)/2 = (-1,0,2,-1) -> (2\sqrt{3},0)
    %%%% B3-(X2+2X3)/3 = (1,-3,1,1)  -> (0,0)
    %%% the three vectors are orthogonal with squared length 2,6,12
    %%% their images are orthogonal with squared length 4,12,0
    \coordinate (\NNN) at ($(
                {(-\x+2*\z-\t)/\RTHREE}, %
                {\t-\x} %
                )$) ; }
  \fi %

  \iftrue %
  \else %
  %%%% projection to A_2 (and its parallel), collapsing line A2-B0
  \foreach \NNN/\x/\y/\z/\t in \LCOORDINATES { %

    %%% orthogonal projection with
    %%%%           A3-A1 = (1,0,-1,0)  -> (2\sqrt{3},0)
    %%%% (2X0-(A3+A2))/3 = (-1,2,-1,0) -> (0,6)
    %%%%           B0-A2 = (1,1,1,-3)  -> (0,0)
    %%% the three vectors are orthogonal with squared length 2,6,12
    %%% their images are orthogonal with squared length 12,36,0
    \coordinate (\NNN) at ($(
                {\RTHREE*(\x-\z)}, %
                {-\x+2*\y-\z} %
                )$) ; }
  \fi %

  \iftrue %
  \else %
  %%%% projection to rectangle A2-A3-B3-B2, collapsing the other
  %%%% rectangles to lines
  \foreach \NNN/\x/\y/\z/\t in \LCOORDINATES { %

    %%% orthogonal projection with
    %%%%         A3-A2 = (0,-1,1,0)  -> (2,0)
    %%%%         B2-A2 = (1,0,0,-1)  -> (0,-2)
    %%%% A1-(2A0+Y1)/3 = (1,-1,-1,1) -> (0,0)
    %%% the three vectors are orthogonal with squared length 2,2,4
    %%% their images are orthogonal with squared length 4,4,0
    \coordinate (\NNN) at ($(
                {\z-\y}, %
                {\t-\x} %
                )$) ; }
  \fi %

  \iftrue %
  \else %
  %%%% projection to rectangle A0-Y1-Z1-A1 (and its parallel),
  %%%% collapsing lines X3-A1 and A3-B2 and rectangle A2-A3-B3-B2 to a
  %%%% line
  \foreach \NNN/\x/\y/\z/\t in \LCOORDINATES { %

    %%% orthogonal projection with
    %%%%      (Y1-A0)/3 = (0,0,1,-1)  -> (2,0)
    %%%%          A1-A0 = (1,-1,0,0)  -> (0,-2)
    %%%%      (X3-A1)/2 = (1,1,-1,-1) -> (0,0)
    %%% the three vectors are orthogonal with squared length 2,2,4
    %%% their images are orthogonal with squared length 4,4,0
    \coordinate (\NNN) at ($(
                {\z-\t}, %
                {\y-\x} %
                )$) ; }
  \fi %

  %%%%%%%%

  %%%% make the xy-coordinates of the vectors explicit

  %% \newdimen\cx %
  %% \newdimen\cy %
  %% \foreach \XXX/\UNUSED in \LCOORDINATES { %
  %%   \pgfextractx{\cx}{\pgfpointanchor{\XXX}{center}} %
  %%   \pgfextracty{\cy}{\pgfpointanchor{\XXX}{center}} %
  %%   \typeout{\string\coordinate \space (\XXX) at (\the\cx,\the\cy) ; \csname@percentchar\endcsname} %
  %%   %%
  %% }

  %%%%%%%%

  %% placement in shipout is independent of labels
  \useasboundingbox (A2) (X0) (Y1) (B0) ; %

  %%%%%%%%

  \begin{scope} [blue,semithick]

    %% split "-- cycle" at the sharp corners (acute angles):
    %%% X2-X0-A2 B2-X3-X2
    %%% A0-X0-X2 Y2-Y1-A0
    %%% Y2-B0-B1 Z1-Y1-Y2
    %%% B3-B1-B0 X3-B2-B3
    %%% A1-Z1-B1
    %%% X0-A0-A1 A3-A2-X0

    \ifSIMPLE

    %% simply draw the 1-skeleton

    \draw
    (X0) -- (A2) -- (B2) -- (X3) (X3) -- (X2) -- (X0) % Back Left
    (X0) -- (X2) -- (Y2) -- (Y1) (Y1) -- (A0) -- (X0) % Back Right
    (Y2) -- (X2) -- (X3) -- (B0) -- cycle % Rectangle Back
    (B0) -- (B1) -- (Z1) -- (Y1) (Y1) -- (Y2) -- (B0) % Bottom Right
    (B1) -- (B0) -- (X3) -- (B2) (B2) -- (B3) -- (B1) % South Left
    (Z1) -- (B1) -- (B3) -- (A3) -- (A1) -- (Z1) % Front
    (A0) -- (Y1) -- (Z1) -- (A1) -- cycle % Rectangle Right
    (A2) -- (B2) -- (B3) -- (A3) -- cycle % Rectangle Left
    (A0) -- (A1) -- (A3) -- (A2) (A2) -- (X0) -- (A0) % North Left
    ; %

    \else % \ifSIMPLE

    %% for the first orthogonal projection

    %% edges are drawn twice

    \draw[fill=red!10]
    (X0) -- (A2) -- (B2) -- (X3) (X3) -- (X2) -- (X0) ; % Back Left
    \draw[fill=red!10]
    (X0) -- (X2) -- (Y2) -- (Y1) (Y1) -- (A0) -- (X0) ; % Back Right

    \draw[fill=blue!30]
    (Y2) -- (X2) -- (X3) -- (B0) -- cycle ; % Rectangle Back
    \draw[fill=blue!30]
    (B0) -- (B1) -- (Z1) -- (Y1) (Y1) -- (Y2) -- (B0) ; % Bottom Right

    \draw[fill=green!50,opacity=0.8]
    (B1) -- (B0) -- (X3) -- (B2) (B2) -- (B3) -- (B1) ; % South Left

    \draw[fill=red!20,opacity=0.8]
    (Z1) -- (B1) -- (B3) -- (A3) -- (A1) -- (Z1) ; % Front
    \draw[fill=red!20,opacity=0.8]
    (A0) -- (Y1) -- (Z1) -- (A1) -- cycle ; % Rectangle Right
    \draw[fill=red!20,opacity=0.8]
    (A2) -- (B2) -- (B3) -- (A3) -- cycle ; % Rectangle Left

    \draw[fill=green!50,opacity=0.8]
    (A0) -- (A1) -- (A3) -- (A2) (A2) -- (X0) -- (A0) ; % North Left

    \fi % \ifSIMPLE

  \end{scope}

  %%%%%%%%

  %% arrows

  \tikzset{
    midtip/.style={postaction={decorate,decoration= %
        {markings,mark=at position #1 with %
          {\arrow{stealth}} %
    }}}, %
    midtip/.default=0.4, %
  }

  \def\COLOR{black}

  \foreach \XXX/\YYY in {%
    A0/Y1,A1/Z1,Z1/B1,A2/B2,A3/B3} { %
    \path[midtip,\COLOR] (\XXX) -- (\YYY) ; } %

  \ifSIMPLE\else \def\COLOR{black!50} \fi

  \foreach \XXX/\YYY in {%
    Y1/Y2,Y2/B0,X0/X2,X2/X3} { %
    \path[midtip,\COLOR] (\XXX) -- (\YYY) ; } %

  %%%%%%%%

  % \LABELStrue %
  % \NAMEStrue %
  \ifLABELS

  %%%% from cube-4-84.tex
  \tikzset{
    labelbox/.style={ %
      fill=white,fill opacity=0.6, %
      draw,text opacity=1, %
      inner sep=7/3pt}, %
  }

  \ifNAMES % show the names of the vertices

  \def\Label#1{$\tt\scriptscriptstyle#1$}

  \foreach \XXX/\UNUSED in \LCOORDINATES { %
    \node[labelbox] at (\XXX) {\Label\XXX} ; %
  }

  \else % show the coordinates

  \def\Label#1{$\scriptscriptstyle#1$}

  \foreach \XXX/\x/\y/\z/\t in \LCOORDINATES { %
    \node[labelbox] at (\XXX) {\Label{\x\y\z\t}} ; %
  }

  \fi\fi %

  \endtikzpicture
} % \centerline
\end{document}

%%%%%%%%

%% png creation (normal size, transparent)

%%% pdflatex cube-3LO.tex
%%% pdftocairo -png -singlefile -transp cube-3LO.pdf tmp
%%% magick -define png:exclude-chunk=date,time tmp.png -trim +repage cube-3LO.png
%%% optipng cube-3LO.png

%%%% magick adds white (fallback) background to the transparent image
%%%% and has the convenient option -trim.

%%%% Default resolution of pdftocairo is 150 ppi.  Size of trimmed
%%%% image is 517x357.

%% png creation (large size)

%%% pdflatex cube-3LO.tex
%%% pdftocairo -png -singlefile -r 361.35 -W 1438 -H 1059 -x 817 -y 480 cube-3LO.pdf cube-3LO-large
%%% optipng cube-3LO-large.png

%%%% The resolution 361.35 ppi translates 1pt to 5 pixels.  Hence 1
%%%% pixel in the png corresponds to 0.2pt.  A TeX rule becomes 2
%%%% pixels wide.

%%%% trim parameters (without arrows):
%%% magick tmp.png -format "%@\n" info: %% 1238x859+917+580
%%%% padding is 100 pixels

%% program versions

%%% This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex)
%%% Document Class: amsart 2017/10/31 v2.20.4
%%% Package: tikz 2020/01/08 v3.1.5b (3.1.5b)

%%% pdftocairo version 0.86.1
%%% ImageMagick 7.1.1-43 Q16-HDRI x86_64 22550 https://imagemagick.org
%%% OptiPNG version 0.7.7

%%%%%%%%

%%%% Created:
%%% 2026-03-14

%%%% Latest changes of images:
%%% 2026-03-22 % tiny rendering changes

%%%% Latest code changes:
%%% 2026-03-20 % \iftrue\else\fi wrappers for the other projections
%%% 2026-03-22 % implement \ifSIMPLE

%%%% Latest comment changes:
%%% 2026-03-20 % improve description of the projection

%%%%%%%%
