2

Consider the following code:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{amsmath}

\newcommand{\ptsize}{1.5pt}

\usepackage{xcolor}
\definecolor{MyColor1}{rgb}{0.24, 0.59, 0.32}
\definecolor{MyColor2}{rgb}{0.85, 0.49, 0.19}
\definecolor{MyColor3}{rgb}{0.22, 0.42, 0.69}

\begin{document}
\tdplotsetmaincoords{75}{130}
\begin{tikzpicture}[tdplot_main_coords]

% Define all the nodes necessary for the drawing
\coordinate (alpha1) at (1,-1,0);
\coordinate (alpha2) at (0,1,-1);
\coordinate (alpha3) at (0,0,2);

\coordinate (12) at ($ (alpha1) + (alpha2) $);
\coordinate (23) at ($ (alpha2) + (alpha3) $);
\coordinate (123) at ($ (alpha1) + (alpha2) + (alpha3) $);
\coordinate (223) at ($ (alpha2) + (alpha2) + (alpha3) $);
\coordinate (1223) at ($ (alpha1) + (alpha2) + (alpha2) + (alpha3) $);
\coordinate (11223) at ($ (alpha1) + (alpha1) + (alpha2) + (alpha2) + (alpha3) $);

\coordinate (-alpha1) at (-1,1,0);
\coordinate (-alpha2) at (0,-1,1);
\coordinate (-alpha3) at (0,0,-2);

\coordinate (-12) at ($ (-alpha1) + (-alpha2) $);
\coordinate (-23) at ($ (-alpha2) + (-alpha3) $);
\coordinate (-123) at ($ (-alpha1) + (-alpha2) + (-alpha3) $);
\coordinate (-223) at ($ (-alpha2) + (-alpha2) + (-alpha3) $);
\coordinate (-1223) at ($ (-alpha1) + (-alpha2) + (-alpha2) + (-alpha3) $);
\coordinate (-11223) at ($ (-alpha1) + (-alpha1) + (-alpha2) + (-alpha2) + (-alpha3) $);

% Draw the black polygon
\begin{scope}[opacity=0.5]
    \draw (alpha3) -- (11223) -- (-alpha3) -- (-11223) -- (alpha3);
    \draw (alpha3) -- (223) -- (-alpha3) -- (-223) -- (alpha3);
\end{scope}

% Draw the nodes for the roots in appropriate colors
\begin{scope}[MyColor3]
    \draw[fill] (alpha3)  circle (\ptsize);
    \draw[fill] (-alpha3) circle (\ptsize);
\end{scope}

\begin{scope}[MyColor2]
    \draw[fill] (alpha1)  circle (\ptsize);
    \draw[fill] (223)     circle (\ptsize);
    \draw[fill] (1223)    circle (\ptsize);
    \draw[fill] (11223)   circle (\ptsize);
    \draw[fill] (-alpha1) circle (\ptsize);
    \draw[fill] (-223)    circle (\ptsize);
    \draw[fill] (-1223)   circle (\ptsize);
    \draw[fill] (-11223)  circle (\ptsize);
\end{scope}

\begin{scope}[MyColor1]
    \draw[fill] (alpha2) circle (\ptsize);
    \draw[fill] (12)      circle (\ptsize);
    \draw[fill] (23)      circle (\ptsize);
    \draw[fill] (123)     circle (\ptsize);
    \draw[fill] (-alpha2) circle (\ptsize);
    \draw[fill] (-12)     circle (\ptsize);
    \draw[fill] (-23)     circle (\ptsize);
    \draw[fill] (-123)    circle (\ptsize);
\end{scope}

% Draw the orange rectangle
\draw[MyColor2] (11223) -- (223) -- (-11223) -- (-223) -- (11223);

% Draw the upper green rectangle
\draw[MyColor1] (-alpha2) -- (123) -- (23) -- (-12) -- (-alpha2);

% Draw the upper green rectangle
\draw[MyColor1] (12) -- (-23) -- (-123) -- (alpha2) -- (12);

% Nodes for the names
\node (alpha1-name) at (1.4,-1,0) {$\alpha_1$};
\node (alpha2-name) at (0,1.4,-1) {$\alpha_2$};
\node (alpha3-name) at (0,0,2.3) {$\alpha_3$};

\begin{scope}[shift={(0,0,15)}]
    \draw[dashed] (alpha1) -- (1223) -- (-alpha1) -- (-1223) -- (alpha1);    
\end{scope}

\end{tikzpicture}
\end{document}

which produces the picture

enter image description here

I'm currently trying to shift the dashed rectangle by a certain amount in the z-direction of the graph. Following this my attempt can be found in the above code

\begin{scope}[shift={(0,0,15)}]
    \draw[dashed] (alpha1) -- (1223) -- (-alpha1) -- (-1223) -- (alpha1);    
\end{scope}

but this doesn't produce any changes. So presumably I'm misunderstanding how this shift command is supposed to work... Ideally I'd like to define new coordinates at the edges of the shifted rectangle, but I'm not really sure if this can be done..

1
  • Symbolic coordinates cannot get shifted like this. You could do \begin{scope}[transform canvas={shift={(0,0,2)}}] \draw[dashed] (alpha1) -- (1223) -- (-alpha1) -- (-1223) -- (alpha1); \end{scope} but one has to be careful with transform canvas.
    – user194703
    Commented Feb 20, 2020 at 14:46

1 Answer 1

1

Symbolic coordinates do not get transformed that way. You can transform them with transform canvas, e.g.

\begin{scope}[transform canvas={shift={(0,0,2)}}]
    \draw[dashed] (alpha1) -- (1223) -- (-alpha1) -- (-1223) -- (alpha1);    
\end{scope}

However, this is a bit dangerous, for instance the bounding box does not get computed correctly. On the other hand, tikz-3dplot loads the calc library, so you might do

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{amsmath}

\newcommand{\ptsize}{1.5pt}

\usepackage{xcolor}
\definecolor{MyColor1}{rgb}{0.24, 0.59, 0.32}
\definecolor{MyColor2}{rgb}{0.85, 0.49, 0.19}
\definecolor{MyColor3}{rgb}{0.22, 0.42, 0.69}

\begin{document}
\tdplotsetmaincoords{75}{130}
\begin{tikzpicture}[tdplot_main_coords]

% Define all the nodes necessary for the drawing
\coordinate (alpha1) at (1,-1,0);
\coordinate (alpha2) at (0,1,-1);
\coordinate (alpha3) at (0,0,2);

\coordinate (12) at ($ (alpha1) + (alpha2) $);
\coordinate (23) at ($ (alpha2) + (alpha3) $);
\coordinate (123) at ($ (alpha1) + (alpha2) + (alpha3) $);
\coordinate (223) at ($ (alpha2) + (alpha2) + (alpha3) $);
\coordinate (1223) at ($ (alpha1) + (alpha2) + (alpha2) + (alpha3) $);
\coordinate (11223) at ($ (alpha1) + (alpha1) + (alpha2) + (alpha2) + (alpha3) $);

\coordinate (-alpha1) at (-1,1,0);
\coordinate (-alpha2) at (0,-1,1);
\coordinate (-alpha3) at (0,0,-2);

\coordinate (-12) at ($ (-alpha1) + (-alpha2) $);
\coordinate (-23) at ($ (-alpha2) + (-alpha3) $);
\coordinate (-123) at ($ (-alpha1) + (-alpha2) + (-alpha3) $);
\coordinate (-223) at ($ (-alpha2) + (-alpha2) + (-alpha3) $);
\coordinate (-1223) at ($ (-alpha1) + (-alpha2) + (-alpha2) + (-alpha3) $);
\coordinate (-11223) at ($ (-alpha1) + (-alpha1) + (-alpha2) + (-alpha2) + (-alpha3) $);

% Draw the black polygon
\begin{scope}[opacity=0.5]
    \draw (alpha3) -- (11223) -- (-alpha3) -- (-11223) -- (alpha3);
    \draw (alpha3) -- (223) -- (-alpha3) -- (-223) -- (alpha3);
\end{scope}

% Draw the nodes for the roots in appropriate colors
\begin{scope}[MyColor3]
    \draw[fill] (alpha3)  circle (\ptsize);
    \draw[fill] (-alpha3) circle (\ptsize);
\end{scope}

\begin{scope}[MyColor2]
    \draw[fill] (alpha1)  circle (\ptsize);
    \draw[fill] (223)     circle (\ptsize);
    \draw[fill] (1223)    circle (\ptsize);
    \draw[fill] (11223)   circle (\ptsize);
    \draw[fill] (-alpha1) circle (\ptsize);
    \draw[fill] (-223)    circle (\ptsize);
    \draw[fill] (-1223)   circle (\ptsize);
    \draw[fill] (-11223)  circle (\ptsize);
\end{scope}

\begin{scope}[MyColor1]
    \draw[fill] (alpha2) circle[radius=\ptsize];
    \draw[fill] (12)      circle[radius=\ptsize];
    \draw[fill] (23)      circle[radius=\ptsize];
    \draw[fill] (123)     circle[radius=\ptsize];
    \draw[fill] (-alpha2) circle[radius=\ptsize];
    \draw[fill] (-12)     circle[radius=\ptsize];
    \draw[fill] (-23)     circle[radius=\ptsize];
    \draw[fill] (-123)    circle[radius=\ptsize];
\end{scope}

% Draw the orange rectangle
\draw[MyColor2] (11223) -- (223) -- (-11223) -- (-223) -- (11223);

% Draw the upper green rectangle
\draw[MyColor1] (-alpha2) -- (123) -- (23) -- (-12) -- (-alpha2);

% Draw the upper green rectangle
\draw[MyColor1] (12) -- (-23) -- (-123) -- (alpha2) -- (12);

% Nodes for the names
\node (alpha1-name) at (1.4,-1,0) {$\alpha_1$};
\node (alpha2-name) at (0,1.4,-1) {$\alpha_2$};
\node (alpha3-name) at (0,0,2.3) {$\alpha_3$};

%\begin{scope}[transform canvas={shift={(0,0,2)}}]
\draw[dashed] ($(alpha1)+(0,0,2)$) -- ($(1223)+(0,0,2)$) 
    -- ($(-alpha1)+(0,0,2)$) --($(-1223)+(0,0,2)$) -- cycle;    
%\end{scope}

\end{tikzpicture}
\end{document}

enter image description here

I shifted by 2 instead of 15 because 15 is really far away, but you can do that, too.

1
  • Thanks for the quick answer.
    – Sito
    Commented Feb 20, 2020 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .