2

This is my first question, I apologize for any inconvenient.
I have two coaxial circumferences that are the basis of a cone. I would like to fill the area between them, as the lateral surface of a cone. How can I do it? Here is what I have.

\documentclass[tikz,multi,border=10pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta,angles,quotes,calc}
\begin{document}
\begin{tikzpicture}
     
\begin{scope}[canvas is yz plane at x=1]
     \draw [NavyBlue,line width=.2mm,dashed](0,0) circle (1cm);
   \end{scope}
   \begin{scope}[canvas is yz plane at x=1.4]
     \draw [NavyBlue,line width=.2mm,dashed](0,0) circle (1.8cm){};
      
   \end{scope}   
   \end{tikzpicture}
\end{document}

enter image description here

1 Answer 1

4

You can calculate the tangent points and fill the area. You can also use a surf plot from PGFPlots like this

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[declare function={radius(\h)=-1+2*\h;}]
\begin{axis}[
hide axis,
x=1cm, y=1cm, z={(-3.85mm,-3.85mm)},
anchor=origin, at={(0,0,0)},
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=-2, zmax=2,
]
\addplot3[
surf,
shader=interp,
samples=50, domain=0:360, variable=a,
samples y=2, domain y=1:1.4, variable y=h,
colormap/violet,
]( {h} , {radius(h)*cos(a)} , {radius(h)*sin(a)} );
\end{axis}
\draw[cyan, thick, dashed, canvas is yz plane at x=1] (0,0) circle[radius=1];
\draw[cyan, thick, dashed, canvas is yz plane at x=1.4] (0,0) circle[radius=1.8];
\end{tikzpicture}
\end{document}

truncated violet cone

I do not know what you need the figure for, so I made the coordinate system match inside and outside the axis. If there is no need to align the cone with anything else, then everything could be drawn inside axis and no consideration of unit vectors and origin would be needed.

Edit: With rotation. Method taken from: https://tex.stackexchange.com/a/199715/8650

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\newcommand{\ViewAzimuth}{20}
\newcommand{\ViewElevation}{20}
\tikzset{viewport/.style 2 args={
x={({cos(-#1)*1cm},{sin(-#1)*sin(#2)*1cm})},
y={({-sin(-#1)*1cm},{cos(-#1)*sin(#2)*1cm})},
z={(0,{cos(#2)*1cm})}
}}
\begin{document}
\begin{tikzpicture}[viewport={\ViewAzimuth}{\ViewElevation}]
\begin{axis}[
hide axis,
view={\ViewAzimuth}{\ViewElevation},
every axis plot/.style={very thin},
disabledatascaling,
anchor=origin,
viewport={\ViewAzimuth}{\ViewElevation},
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=-2, zmax=2,
]
\addplot3[
surf,
shader=interp,
samples=50, domain=0:360, variable=a,
samples y=2, domain y=1:1.4, variable y=h,
colormap/violet,
]( {h} , {(-1+2*\h)*cos(a)} , {(-1+2*\h)*sin(a)} );
\end{axis}
\draw[cyan, thick, dashed, canvas is yz plane at x=1] (0,0) circle[radius=1];
\draw[cyan, thick, dashed, canvas is yz plane at x=1.4] (0,0) circle[radius=1.8];
\end{tikzpicture}
\end{document}

Truncated cone rotated Truncated cone rotated

9
  • Thank you very much. But if I use this in my tikzpicture I don't see the drawn area matching the circumferences. Is this what you were talking about with unit vector and origin's consideration? Dec 2, 2022 at 15:21
  • I use this in your tikzpicture and the circumferences do match. -so you must have changed something!? Dec 2, 2022 at 19:32
  • This is what I have: \tdplotsetmaincoords{20}{20} \begin{tikzpicture}[declare function={radius(\h)=-1+2*\h;},tdplot_main_coords,scale=1.8,cone back/.style={draw=brown,left color=gray!50,right color=brown}, cone front/.style={draw=brown,left color=brown}] \coordinate (O) at (0,0,0); \begin{scope}[canvas is yz plane at x=1] \draw [NavyBlue,line width=.2mm,dashed](0,0) circle (1cm); \end{scope} \begin{scope}[canvas is yz plane at x=1.4] \draw [NavyBlue,line width=.2mm,dashed](0,0) circle (1.8cm); \end{scope} \begin{tikzpicture} Dec 3, 2022 at 10:53
  • You rotate and you scale your tikzpicture! Dec 3, 2022 at 11:29
  • 1
    No need to write thank you - just remember to accept the answer. The code as is compiles perfectly. Maybe you again change something? - I can only guess. Does this help? tex.stackexchange.com/questions/420448/… Dec 6, 2022 at 19:26

You must log in to answer this question.

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