我想要创建这个:
这是我对 3-D 的 MWE:
\documentclass{article}
\usepackage{siunitx} % SI units
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=-1] % <-- inverts the figure
\def\a{2} % major
\def\b{.5} % minor
\def\h{5} % height of the cone
\def\d{3} % height of the section
\pgfmathsetmacro{\t}{asin(\b/\h)} % parameter in the paramater form of the base ellipse x=a cos t, y=b sin t
\begin{scope}[cyan,thick]
\draw (0,0) ellipse ({\a} and {\b});
\draw (\t:{\a} and {\b}) -- (0,\h) -- (180-\t:{\a} and {\b});
\begin{scope}[shift={(90:\h-\d)},scale={\d/\h}]
\fill[blue!20] (\t:{\a} and {\b}) arc(\t:-180-\t:{\a} and {\b}) -- (0,\h) -- cycle;
\draw (\t:{\a} and {\b}) arc(\t:180-\t:{\a} and {\b});
\draw[dashed] (180-\t:{\a} and {\b}) arc(180-\t:360+\t:{\a} and {\b})
(-\a,0) coordinate (L);
\end{scope}
\end{scope}
\begin{scope}[magenta]
\draw[dashed] (-\a,0)--(-2*\a,0) (0,\h)--(-2*\a,\h) (L)--+(180:1) coordinate (Ld);
\draw[<->] (-2*\a+.5,0)--+(90:\h) node[midway,right]{\SI{12}{\centi\meter}};
\draw[<->] (Ld)++(0:.3)--+(90:\d) node[midway,right]{$d$};
\end{scope}
%\fill[gray,opacity=0.3,shift={(90:\h-\d)},scale=2.5,xslant=-1,yscale=.3] (-1,1) rectangle (1,-1) node[below,black]{$\alpha$};
\end{tikzpicture}
\end{document}
答案1
也许是这样,利用fillbetween
所提供的库 pgfplots
:
\documentclass[border=10pt]{standalone}
\usepackage{siunitx} % SI units
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{fillbetween, backgrounds}
\begin{document}
\begin{tikzpicture} % <-- inverts the figure
\def\a{2} % major
\def\b{.5} % minor
\def\h{5} % height of the cone
\def\d{3} % height of the section
\def\e{.5} % thickness of the section
\pgfmathsetmacro{\t}{asin(\b/\h)} % parameter in the paramater form of the base ellipse x=a cos t, y=b sin t
\tikzset{
top section/.append style={shift={(90:\h-\d)}, scale={\d/\h}},
bottom section/.append style={shift={(90:\h-(\d-\e))}, scale={(\d-\e)/\h}}
}
\begin{scope}[cyan, thick, scale=-1]
\draw (0,0) ellipse ({\a} and {\b});
\draw (\t:{\a} and {\b}) -- (0,\h) -- (180-\t:{\a} and {\b});
\draw[top section] (\t:{\a} and {\b}) arc(\t:180-\t:{\a} and {\b});
\draw[top section, dashed, name path=top arc] (180-\t:{\a} and {\b}) arc(180-\t:360+\t:{\a} and {\b})
(-\a,0) coordinate (L);
\draw[bottom section, name path=bottom arc] (\t:{\a} and {\b}) arc(\t:180-\t:{\a} and {\b});
\draw[bottom section, dashed] (180-\t:{\a} and {\b}) arc(180-\t:360+\t:{\a} and {\b})
(-\a,0) coordinate (M);
\pgfonlayer{background}
\fill[red!10, intersection segments={of=top arc and bottom arc, sequence={R* -- L*}}];
\endpgfonlayer
\end{scope}
\begin{scope}[blue]
\draw[->] (-2*\a,-\h) -- +(4*\a,0) node[midway, below] {$0$} node[below] {$x$};
\draw[dashed] (0,-\h) -- (0,-\b);
\draw[->] (0,-\b) -- (0,2*\b) node[right] {$y$};
\end{scope}
\begin{scope}[magenta]
\coordinate (T) at (2*\a,0);
\coordinate (B) at (2*\a,-\h);
\draw[dashed]
(\a,0) -- (T)
(L) -- (T |- L) coordinate (S)
(M) -- (\a,0 |- M) coordinate (N);
\draw[<->] ([xshift=-10pt]T) -- ([xshift=-10pt]S) node[midway, right] {$10 - y$};
\draw[<->] ([xshift=-10pt]S) -- ([xshift=-10pt]B) node[midway, right] {$y$};
\draw[<-] ([xshift=-10pt]\a,0 |- L) -- +(0,0.25);
\draw[<-] ([xshift=-10pt]N) -- +(0,-0.25);
\path ([xshift=-10pt]\a,0 |- L) -- ([xshift=-10pt]N) node[midway] {$\Delta_y$};
\end{scope}
\end{tikzpicture}
\end{document}