画一个圆锥体,里面还有另一个圆锥体,颜色不同

画一个圆锥体,里面还有另一个圆锥体,颜色不同

大家好,我有这个代码,

\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
    
    \fill[gray!30,shift={(90:\h-\d)},scale=2.5,xslant=-1,yscale=.3] (-1,1) rectangle (1,-1) node[below,black]{$\alpha$};
    
    \begin{scope}[cyan,thick]
        \draw[dashed]
        (\t:{\a} and {\b}) arc(\t:180-\t:{\a} and {\b});
        \draw
        (\t:{\a} and {\b})--(0,\h)--(180-\t:{\a} and {\b})
        arc(180-\t:360+\t:{\a} and {\b});
        
        \begin{scope}[shift={(90:\h-\d)},scale={\d/\h}]
            \draw[dashed]
            (\t:{\a} and {\b}) arc(\t:180-\t:{\a} and {\b});
            \draw
            (\t:{\a} and {\b})--(0,\h)--(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,left]{$12$ cm};
        \draw[<->] (Ld)++(0:.3)--+(90:\d) node[midway,left]{$d$};
    \end{scope}

但我想重现这幅图像,基本上只是将位置颠倒过来,但我不知道如何...... 在此处输入图片描述 谢谢

PS 谁能推荐一本关于数学领域的抽签数学问题的好的 TikZ 书?

答案1

这只是个快速修复,仅此而已。我更改了scale=-1以反转您的图片,然后修复了实线/虚线以获得正确的可见性。

\documentclass[border=2mm,tikz]{standalone}
\usepackage{siunitx} % SI units

\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]{\qty{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}

在此处输入图片描述

相关内容