TikZ 中带切线的气球形状

TikZ 中带切线的气球形状

在此处输入图片描述我想在 Latex 中绘制我在 PowerPoint 中绘制的附图,我找不到绘制切线的简单方法,我想将气球形状绘制为 3d 图

\documentclass[tikz,border=5pt]{standalone}
\begin{document}

\begin{tikzpicture}[scale=0.5]
   \draw[rotate=180] (-2,0.25)--++(8,0);
  \draw[rotate=180, fill=gray!30] (2,0.25) .. controls (9,6) and (-5,6) .. (2,0.25);
\begin{scope}[xshift=6cm, yshift=-10cm]
  \def\rx{4}    % horizontal radius of the ellipse
  \def\ry{0.5}  % vertical radius of the ellipse
  \def\z{2}     % distance from center of ellipse to origin

  \pgfmathparse{asin(\ry/\z)}
  \let\angle\pgfmathresult

  \coordinate (h) at (0, \z);
  \coordinate (O) at (0, 0);      
  \coordinate (A) at ({-\rx*cos(\angle)}, {\z-\ry*sin(\angle)});
  \coordinate (B) at ({\rx*cos(\angle)}, {\z-\ry*sin(\angle)});
   \coordinate (C) at (3, 2);

  \draw[fill=gray!50] (A) -- (O) -- (B) -- cycle;
  \draw[fill=gray!30] (h) ellipse ({\rx} and {\ry});
  \end{scope}
\end{tikzpicture}
\end{document}

答案1

在此处输入图片描述

\documentclass[tikz,border=5pt]{standalone}
\begin{document}

\usetikzlibrary{decorations.markings}

\begin{tikzpicture}[scale=0.5]
   \draw[rotate=180] (-2,0)--++(8,0);
   \draw[ball color=gray!5, looseness=1.5] (0,0) to[out=-20,in=0] node[sloped, pos=0.3](P){} (0,-3) to[out=180, in=180+20] node[sloped, fill=black, inner xsep=40pt, inner ysep=0, yscale=0.4, pos=0.9](Q){} cycle;
\begin{scope}[xshift=6cm, yshift=-10cm]
  \def\rx{2.5}    % horizontal radius of the ellipse
  \def\ry{0.3}  % vertical radius of the ellipse
  \def\z{1.5}     % distance from center of ellipse to origin

  \pgfmathparse{asin(\ry/\z)}
  \let\angle\pgfmathresult

  \coordinate (h) at (0, \z);
  \coordinate (O) at (0, 0);      
  \coordinate (A) at ({-\rx*cos(\angle)}, {\z-\ry*sin(\angle)});
  \coordinate (B) at ({\rx*cos(\angle)}, {\z-\ry*sin(\angle)});
  \coordinate (C) at (3, 2);
  \draw[left color=gray!50,right color=white] (A) -- (O) -- (B) -- cycle;
  \draw[fill=gray!30] (h) ellipse ({\rx} and {\ry});
\end{scope}

\draw[<->, shorten >= -23pt] (O) -- (P);
\end{tikzpicture}
\end{document}

看看这个问题:如何在 TikZ 中绘制路径上任意点的切线也一样。

相关内容