add tag
Anonymous 1123
This is my code that I drew a cylinder is inscribed in a prism. 
```
\documentclass[border=1mm,12pt,tikz]{standalone}
\usetikzlibrary{calc,3d,angles}
\usepackage{tikz-3dplot}
\usetikzlibrary{intersections,calc,backgrounds}
\usepackage{fouriernc}
\begin{document}
	\def\a{4}%
	\def\R{4}%
	\def\h{4}%
	\pgfmathsetmacro{\myr}{1}
	\foreach \X in {10,20,...,350}  
	{\tdplotsetmaincoords{70}{\X}
		\begin{tikzpicture}[tdplot_main_coords,line join = round, line cap = round]
			\begin{scope}[canvas is xy plane at z=0]
				
				\coordinate (O) at (0,0);
				
				\coordinate (A) at (-1, -1);
				\coordinate (B) at (2, -1);
				\coordinate (C) at (-1, 3);
				
				\draw[dashed] (\tdplotmainphi:\myr) arc(\tdplotmainphi:\tdplotmainphi+180:\myr);
				
				\draw[dashed] (\tdplotmainphi:\myr) coordinate(BR) arc(\tdplotmainphi:\tdplotmainphi-180:\myr) coordinate(BL);
			\end{scope}
			\begin{scope}[canvas is xy plane at z=\h]
				
				\coordinate (O') at (0,0);
				
				\coordinate (A') at (-1, -1);
				\coordinate (B') at (2, -1);
				\coordinate (C') at (-1, 3);
				
				\draw [dashed](BR) -- (\tdplotmainphi:\myr) (BL) -- (\tdplotmainphi-180:\myr); % vẽ hai đường sinh
				
				\draw[thick] (\tdplotmainphi:\myr) arc(\tdplotmainphi:\tdplotmainphi+180:\myr);
				
				\draw[thick] (\tdplotmainphi:\myr) coordinate(BR) arc(\tdplotmainphi:\tdplotmainphi-180:\myr) coordinate(BL);
				
				\draw [thick](BR) -- (\tdplotmainphi:\myr) (BL) -- (\tdplotmainphi-180:\myr); % vẽ hai đường sinh
			\end{scope}
			\foreach \v/\position in { B/below,O/right,A/left,B'/above,O'/right,A'/above,C/below,C'/above} {\draw[draw =black, fill=black] (\v) circle (1pt) node [\position=0.2mm] {$\v$};
			}
			
			
			\draw[dashed]   (O) -- (O') (B)  --(A) --(C) (A) -- (A');
			\draw[thick]  (A') --(B')  -- (C')-- cycle (B) -- (B') (C) -- (C');
			\draw[thick]  (B)  -- (C) ;
			\node[anchor=north east] at (current bounding box.north east) {$\theta=\tdplotmaintheta^\circ,\phi=\tdplotmainphi^\circ$};
	\end{tikzpicture}}
	
\end{document}   
```
How to draw it with `3dtools`?
Top Answer
user 3.14159
Since your code already contains all the geometric data, it is rather easy: a prism is a polyhedron, for which `3dtools` provides tools. The cylinder is just a circle on the top, which is always visible for the view angles under consideration, as well as a hidden circle on the bottom and two hidden parallel lines that connect the two circles. This leaves us with a comparatively (by the standards of 3d pictures in Ti*k*Z) short code.
```
\documentclass[border=1mm,12pt,tikz]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {5,15,...,355}  
{\begin{tikzpicture}[3d/install view={phi=\Angle,psi=0,theta=70},
	line join = round, line cap = round,same bounding box=A,
	declare function={h=4;myr=1;}]
 \path (0,0,0) coordinate (O) (-1,-1,0) coordinate (A)
 	(2,-1,0) coordinate (B) (-1,3,0) coordinate (C)
	(0,0,h) coordinate (O') (-1,-1,h) coordinate (A')
 	(2,-1,h) coordinate (B') (-1,3,h) coordinate (C')
	(0,0,h/2) coordinate (O'');
 \tikzset{3d/polyhedron/.cd,O={(O'')},
 	fore/.append style={fill=none,/tikz/3d/visible}, 
	back/.append style={fill=none,/tikz/3d/hidden},
 	draw face with corners={{(A)},{(B)},{(B')},{(A')}},
	draw face with corners={{(B)},{(C)},{(C')},{(B')}},
	draw face with corners={{(C)},{(A)},{(A')},{(C')}},
	draw face with corners={{(A')},{(B')},{(C')}}} 
 \draw[3d/hidden] (O) circle[radius=myr] 
 ([xshift=-myr*1cm]O) -- ([xshift=-myr*1cm]O')
 ([xshift=myr*1cm]O) -- ([xshift=myr*1cm]O');	
 \draw[3d/visible] (O') circle[radius=myr];
\end{tikzpicture}}	
\end{document}
```
![ani.gif](/image?hash=dcd6ea4fad247f8079d4626f3e4214fcec8f8c2abd6eaabf04819a69b1792754)
Answer #2
Anonymous 1123
Many thanks to marmot for my question. In this code, I  use `3dtools` to find `radius` of the incicre `ABC` without using `myr= 1`.

```
\documentclass[border=1mm,12pt,tikz]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {5,15,...,355}  
	{\begin{tikzpicture}[3d/install view={phi=\Angle,psi=0,theta=70},line join = round, line cap = round,same bounding box=A,declare function={a=3;b=4;h=4;}]
			\path (0,0,0) coordinate (A)
			(a,0,0) coordinate (B) (0,b,0) coordinate (C)
		(0,0,h) coordinate (A')
		(a,0,h) coordinate (B') (0,b,h) coordinate (C')	
		(1,1,h/2) coordinate (O'');
\path pic[red,3d/hidden]{3d incircle={% 
		A={(A)},B={(B)},C={(C)},center name=I}}
 pic[blue,3d/visible]{3d incircle={% 
			A={(A')},B={(B')},C={(C')},center name=I'}};	
		\tikzset{3d/polyhedron/.cd,O={(O'')},
			fore/.append style={fill=none,/tikz/3d/visible}, 
			back/.append style={fill=none,/tikz/3d/hidden},
			draw face with corners={{(A)},{(B)},{(B')},{(A')}},
			draw face with corners={{(B)},{(C)},{(C')},{(B')}},
			draw face with corners={{(C)},{(A)},{(A')},{(C')}},
			draw face with corners={{(A')},{(B')},{(C')}}} 
		\pgfmathsetmacro{\myr}{tddistance("(I')","(tmppa)")}
		\draw[3d/hidden] 
	([xshift=-\myr*1cm]I) -- ([xshift=-\myr*1cm]I')
	([xshift=\myr*1cm]I) -- ([xshift=\myr*1cm]I');
	\end{tikzpicture}}
\end{document}

```
![marmot.gif](/image?hash=f50817d5da0cb22dac60825900a4f2677fd0f088157072df8b598b4fbffcbcd4)

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.