如何用 tikz 3D 绘制截头圆锥的侧面

如何用 tikz 3D 绘制截头圆锥的侧面

这是我的第一个问题,给您带来的不便,我深表歉意。
我有两个同轴圆周,它们是圆锥的基础。我想填充它们之间的区域,作为圆锥的侧面。我该怎么做?这是我有的。

\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}

在此处输入图片描述

答案1

您可以计算切点并填充面积。您还可以使用surfPGFPlots 中的绘图,如下所示

\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}

截头紫锥花

我不知道你需要这个图形做什么,所以我让坐标系在 的内部和外部匹配axis。如果不需要将圆锥与其他任何东西对齐,那么所有东西都可以画在里面axis,不需要考虑单位向量和原点。

编辑:带旋转。方法取自: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}

旋转的截头圆锥 旋转的截头圆锥

相关内容