tikz add tag
Anonymous 1123
I am trying to draw this picture
![ScreenHunter 1010.png](/image?hash=0911f0cf0d055c28d2cfdfe121354a3ffe3e281e2830e883172d710201e1447a)
I tried

```
  \documentclass[border=2mm,tikz]{standalone} 
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools,intersections,calc}
\makeatletter 
\tikzset{
	reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\tikzset{even odd clip/.code={\pgfseteorule},
	protect/.code={
		\clip[overlay,even odd clip,reuse path=#1]
		(-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt);
}}
\makeatother
\begin{document} 
      \tdplotsetmaincoords{70}{120} 
    \begin{tikzpicture}[scale=1,tdplot_main_coords,line join = round, line cap = round, declare function={a = 3;b = 4;}]
    \path
    (0,0,2*a+2) coordinate (M)
    (0,-a,-a) coordinate (N)
    (0,a,2*a+2) coordinate (M')
    (0,a-5,-a-4) coordinate (N')
    ;

    \begin{scope} [canvas is xy plane at z=0] 
      \draw[thick,save path=\rectA] (-a,-a) rectangle (a,a); 
    \end{scope}

    \begin{scope} [canvas is xy plane at z=a] 
    \draw[thick,save path=\rectB] (-a,-a) rectangle (a,a); 
    \end{scope}


\begin{scope} [canvas is xy plane at z=2*a] 
	\draw[thick,save path=\rectC] (-a,-a) rectangle (a,a); 
\end{scope}
 
\path[3d/plane with normal={(0,0,1) through (0,0,0) named p1},
3d/plane with normal={(0,0,1) through (0,0,a) named p2},
3d/plane with normal={(0,0,1) through (0,0,2*a) named p3}
];
\path[3d/line through={(M) and (N) named lMN}];
 \path[overlay][3d/intersection of={lMN with p1}] coordinate (B);
 \path[overlay][3d/intersection of={lMN with p2}] coordinate (A);
 \path[overlay][3d/intersection of={lMN with p3}] coordinate (C);
 \path[3d/line through={(M') and (N') named lM'N'}];
 \path[overlay][3d/intersection of={lM'N' with p1}] coordinate (B');
 \path[overlay][3d/intersection of={lM'N' with p2}] coordinate (A');
 \path[overlay][3d/intersection of={lM'N' with p3}] coordinate (C');
\begin{scope}
	\clip[reuse path=\rectC];
	\draw[blue,dashed] (M) -- (C);
\end{scope}
\draw[blue]  (C) -- (A);
\begin{scope}
	\tikzset{protect=\rectC}
	\draw[blue] (M) -- (A);
\end{scope}

\begin{scope}
	\clip[reuse path=\rectB];
	\draw[blue,dashed] (A) -- (B);
\end{scope}
\draw[blue]  (B) -- (N);
\begin{scope}
	\tikzset{protect=\rectB}
	\draw[blue] (C) -- (N);
\end{scope}
\foreach \p in {A,B,C,A',B',C'}
    \draw[fill=black] (\p) circle (1pt);
    \foreach \p/\g in {B/0,A/0,C/0,A'/0,B'/0,C'/0,M/0}
    \path (\p)+(\g:3mm) node{$\p$};

    %\draw[thick] (M) -- (N) ;
    \end{tikzpicture} 
\end{document}

```
![ScreenHunter 1011.png](/image?hash=d475d830c52e837a76510a8172267732f93412c0187c66ba0d5bb79645a7ae52)
The result seems incorrect. How can I fix it?
Top Answer
marmot
This is a very first attempt to answer the question. You will need the latest version of [3dtools](https://github.com/marmotghost/tikz-3dtools). I started adding some goodies in the end which I collected from various sources, or created myself. 
```
\documentclass[border=2mm,tikz]{standalone} 
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools,intersections}
\tikzset{protect/.code={
		\clip[overlay,even odd clip,use named path=#1]
		(-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt);
}}
\begin{document} 
\tdplotsetmaincoords{70}{120} 
\begin{tikzpicture}[scale=1,tdplot_main_coords,line join = round, line cap = round, declare function={a = 3;b = 4;}]
 \path
    (0,0,2*a+2) coordinate (M)
    (0,-a,-a) coordinate (N)
    (0,a,2*a+2) coordinate (M')
    (0,a-5,-a-4) coordinate (N')
    ;
  \foreach \X [count=\Y from 0] in {B,A,C} 
  {\begin{scope} [canvas is xy plane at z=\Y*a] 
	\draw[thick,save named path=\X,name path global=p\X] (-a,-a) rectangle (a,a); 
  \end{scope}}
 
  \path[3d/plane with normal={(0,0,1) through (0,0,0) named p1},
  3d/plane with normal={(0,0,1) through (0,0,a) named p2},
  3d/plane with normal={(0,0,1) through (0,0,2*a) named p3}];
  \path[3d/line through={(M) and (N) named lMN}];
  \path[overlay][3d/intersection of={lMN with p1}] coordinate (B)
  	[3d/intersection of={lMN with p2}] coordinate (A)
	[3d/intersection of={lMN with p3}] coordinate (C);
  \path[3d/line through={(M') and (N') named lM'N'}];
  \path[overlay][3d/intersection of={lM'N' with p1}] coordinate (B')
   [3d/intersection of={lM'N' with p2}] coordinate (A')
   [3d/intersection of={lM'N' with p3}] coordinate (C');
  %
  \foreach \X [count=\Y from 0] in {,'}
  {\draw[blue] (M\X)--(C\X);
  \begin{scope}
	\clip[use named path=C];
	\draw[blue,dashed,name path global=lAC\X] (C\X) -- (A\X);
  \end{scope}
  \draw[blue,name intersections={of=pC and lAC\X,by=iAC\X}] (iAC\X) -- (A\X);
  \begin{scope}
	\clip[use named path=A];
	\draw[blue,dashed,name path global=lAB\X] (A\X) -- (B\X);
  \end{scope}
  \draw[blue,name intersections={of=pA and lAB\X,by=iAB\X}] (iAB\X) -- (B\X);
  \begin{scope}
	\clip[use named path=B];
	\draw[blue,dashed,name path global=lBN\X] (B\X) -- (N\X);
  \end{scope}
  \draw[blue,name intersections={of=pB and lBN\X,by=iBN\X}] (iBN\X) -- (N\X);
  \path foreach \p in {A,B,C,M,N}
  {(\p\X) node[inner sep=0pt,minimum width=2pt,circle,fill,
  	label={180+180*\Y}:{$\p\X$}](n\p\X){}};
  }
  \path foreach \p in {A,B,C} {(n\p) edge[red] (n\p')};
 \end{tikzpicture} 
\end{document}
```
![Screen Shot 2020-12-15 at 2.46.30 PM.png](/image?hash=043a7db2c01851ba3caf44ffcf31406f5edca31e15fef202ee97dd90b6d95616)
One can definitely make it more versatile.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.