切頭円錐

\documentclass[tikz,border=10pt]{standalone} 
\usetikzlibrary{angles,calc,decorations.markings}
\begin{document}
\begin{tikzpicture}[thick, draw only after/.style = { preaction
   ={decorate, decoration={markings,mark=at position 0 with
    {\pgfmathsetmacro\mypoff{\pgfdecoratedpathlength*#1}\xdef\mypoff{\mypoff}
     \pgfmathsetmacro\mypl{\pgfdecoratedpathlength}\xdef\mypl{\mypl}}}},
    postaction={draw, dash pattern = on 0pt off \mypoff on \mypl}}]
  \coordinate (o)  at (0,0);
  \coordinate (a1) at (0.72,  1.33);
  \coordinate (a2) at (0.72, -1.33);
  \coordinate (b1) at (5.66,  2.14);
  \coordinate (b2) at (5.66, -2.14);
  \filldraw[fill=yellow!50, fill opacity=0.5]
    (a2) -- (a1) -- (b1) -- (b2) --cycle;
  \filldraw[fill=yellow, rotate=90, yshift=-0.7cm] ellipse (1.33cm and 0.38cm);
  \filldraw[fill=red!50, rotate=90, dashed, draw only after=1/2,
    yshift=-1.95cm] ellipse (1.53cm and 0.5cm);
  \draw[fill=red!30, opacity=0.5, rotate=90, dashed, draw only after=1/2,
    yshift=-1.7cm] ellipse (1.48cm and 0.5cm);
  \filldraw[fill=yellow, rotate=90, dashed, draw only after=1/2,
    yshift=-5.7cm] (0,0) ellipse (2.148cm and 0.6cm);
  \draw[-stealth] (0,-2.8) -- (0,2.8) node[left] {$y$};
  \draw[-stealth] (-0.5,0) -- (7.5,0) node[below] {$x$};
  \draw ($(a1)!0.5!(a2)$) node[above=3pt, anchor=base] {$a$};
  \draw ($(b1)!0.5!(b2)$) node[above=3pt, anchor=base] {$b$};
  \draw (b1) node[above] {$y=f(x)$};
\end{tikzpicture}
\end{document}

Leave a Reply

Your email address will not be published. Required fields are marked *