tikz add tag
Anonymous 1679
I copy this code
```
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (2cm and 0.5cm);
\fill[left color=gray!50!black,right color=gray!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (0,6) -- (-2,0) arc (180:360:2cm and 0.5cm);
\draw (-2,0) arc (180:360:2cm and 0.5cm) -- (0,6) -- cycle;
\draw[densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);
\draw (-2,0)--(2,0);
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}
\end{document}
```
![ScreenHunter_400 May. 11 11.19.jpg](/image?hash=f69358ada59ed6ddc0c49ba02cdbda287cb7dac9fdf5322a2c0582c9d5ddda11)
from https://tex.stackexchange.com/questions/42812/3d-bodies-in-tikz and I see this paper https://www.researchgate.net/figure/Correct-drawing-of-a-cone_fig2_315620080 from Internet. The paper said that, mypicture seems incorrect cone. How to use TikZ 2D to draw a correct cone?
Top Answer
marmot
It depends on what you mean by 2D. If you mean that you want to have a 2D projection of a cone, you could use [3dtools](https://github.com/marmotghost/tikz-3dtools).
```
\documentclass[border=3mm,tikz]{standalone} 
\usetikzlibrary{calc,3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=110,psi=0,theta=75}]
 \pic{3d/shaded cone={r=2,h=3}};
\end{tikzpicture}
\end{document}
```
![Screen Shot 2021-05-10 at 9.28.38 PM.png](/image?hash=ba1ad7e5c481493e0b0e2d582a2b36f4b9c71691e1cbd175cc32b85d2636b975)

If you mean how to compute the critical angle: it is determined by the aspect ratio, i.e. the ratio between the two "radii" of the ellipse in your example, and the ratio between the height and radius.
```
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
  \fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) 
	circle[x radius=2,y radius=0.5];
  \pgfmathsetmacro{\alphacrit}{acos(1/12)}	
  \draw[left color=gray!50!black,right color=gray!50!black,middle color=gray!50,shading=axis,
  	fill opacity=0.25] 
  	(90-\alphacrit:2 and 0.5) -- (0,6) -- (90+\alphacrit:2 and 0.5) 
	arc[start angle=90+\alphacrit,end angle=450-\alphacrit,x radius=2,y radius=0.5];
  \draw[densely dashed] 
  	(90-\alphacrit:2 and 0.5) 
	arc[start angle=90-\alphacrit,end angle=90+\alphacrit,x radius=2,y radius=0.5];
  \draw (-2,0)--(2,0);
\end{tikzpicture}
\end{document}
```
![Screen Shot 2021-05-10 at 9.39.37 PM.png](/image?hash=bf0c45c2a4ef9eb14b61b4cf2737cc1dbc2aff672722d7548655d87a1b6d51ec)

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.