3

I have designed a diagram, with the following code

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

\begin{document}
\begin{figure}
    \centering 
    \setcoords{-25}{10}[1][1.2]
    \setaxis {2}
    \begin{tikzpicture}[scale=1.1,thick=1.5]
    \begin{scope}[xshift=-2cm]
    \draw [->,dashed] (0,0,0) -- (2,0,0)  node [right] {$X$};
    \draw [->,dashed] (0,0,0) -- (0,2,0) node [left] {$Y$};
    \draw [->,dashed] (0,0,0) -- (0,0,2) node [right] {$Z$};  
    \end{scope}
    \begin{scope}
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1.82, -1.56, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1.94,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1.62, -0.29, 1);
    \coordinate (H) at (-1, 0.5, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \end{scope}
    \begin{scope}[xshift=3.25cm]
    \draw [<->] (-0.95,0) -- (0.5,0);
    \node[above] (-0.95,20) {Mapping} ;
    \end{scope}
    \begin{scope}[xshift=5.5cm]
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1, -1, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1, 1, 1);
    \coordinate (H) at (-1, 1, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \draw [->,dotted] (0,0,0) -- (2.2,0,0) node [right] {$\xi$};
    \draw [->,dotted] (0,0,0) -- (0,2.2,0) node [above] {$\eta$};
    \draw [->,dotted] (0,0,0) -- (0,0,2.2) node [above] {$\omega$};
    \end{scope}
    \end{tikzpicture}
\end{figure}

\end{document} 

I wish to have the z-axis pointing upwards, but I am not able to use the tdsetmaincoords or any relevant directives to make the z-axis point up.

Indian
  • 627
  • Your code does not compile on my TeXLive 2018 distribution, ! LaTeX Error: Command \tdplotsinandcos already defined. Do you get the same error? –  Jun 01 '18 at 15:29
  • The easiest way to move the z axis is to rotate the entire image. See also https://tex.stackexchange.com/questions/254820/tikz-pair-of-compasse-rendering-contest/254866?s=1|27.3079#254866. – John Kormylo Jun 01 '18 at 18:23

1 Answers1

3

Loading both stanli and tikz-3dplot is an overkill. You simply forgot to put coords into the options of the tikzpicture. And I think that with local bounding boxes it is easier to achieve what (I assume) you want.

\documentclass{article}
\usepackage{tikz} 
%\usepackage{tikz-3dplot}
\usepackage{stanli} 

\begin{document}
\begin{figure}
    \centering 
    \setcoords{-25}{10}[1][1.2]%[1][0.5]
    \setaxis{2}
    \begin{tikzpicture}[coords,scale=1.1,thick=1.5]
    \begin{scope}[xshift=-2cm]
    \draw [->,dashed] (0,0,0) -- (2,0,0)  node [right] {$X$};
    \draw [->,dashed] (0,0,0) -- (0,2,0) node [left] {$Y$};
    \draw [->,dashed] (0,0,0) -- (0,0,2) node [right] {$Z$};  
    \end{scope}
    \begin{scope}[local bounding box=left]
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1.82, -1.56, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1.94,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1.62, -0.29, 1);
    \coordinate (H) at (-1, 0.5, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \end{scope}
    \begin{scope}[xshift=6cm,yshift=-0.5cm,local bounding box=right]
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1, -1, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1, 1, 1);
    \coordinate (H) at (-1, 1, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \draw [->,dotted] (0,0,0) -- (2.2,0,0) node [right] {$\xi$};
    \draw [->,dotted] (0,0,0) -- (0,2.2,0) node [above] {$\eta$};
    \draw [->,dotted] (0,0,0) -- (0,0,2.2) node [above] {$\omega$};
    \end{scope}
    \draw [<->,shorten >=2pt,shorten <=2pt] (left.east) --
    (left.east-|right.west) node[midway,above,sloped]  {Mapping} ;
    \end{tikzpicture}
\end{figure}

\end{document} 

enter image description here