如何用 TiKZ 绘制闭合曲线?

如何用 TiKZ 绘制闭合曲线?

我想要绘制下面的图。

在此处输入图片描述

我已尝试使用以下 Latex 命令:

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{graphicx,wrapfig,tikz}
 \begin{document}

 \begin{tikzpicture}
 \draw (0,4) ellipse ( 2cm and .6cm);

  \draw (2,4) -- (2,0);
 \draw[fill] (0,0) circle (1pt);
 \end{tikzpicture}
 \end{document}

如何使用 tikzpicture 绘制该图表?

答案1

使用hobby包(\usetikzlibrary{hobby})并且calc对于具有坐标的操作我们得到这个(PGF / Tikz 3.0.x)

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{graphicx,wrapfig,tikz}
\usetikzlibrary{calc,hobby} % To draw the smooth curve
 \begin{document}
\tikzset{
    circ/.pic={ % Defines a `circle` to mark the coordinates.
    \fill (0,0) circle (2pt);
    }
}
\begin{tikzpicture} 
\coordinate (a1) at (0,0);
\coordinate (a2) at (3.3,-0.3);
\coordinate (a3) at (4.5,0.2);
\coordinate (a4) at (2,1.5);
\coordinate (a5) at (3,3);
\coordinate (a6) at (2.4,3.2);
\coordinate (a7) at (1,2);
\coordinate (O) at ($(a1)-(1,2)$);
\draw[thick] (O)--($(a3|-O)+(1,0)$);
\foreach \i in {5,6,7} \draw[densely dotted] (a\i)-- (a\i|-O);
\begin{scope}
\clip[use Hobby shortcut] ([out angle=-90]a1)..(a2)..([in angle=-90]a3); 
\foreach \i in {5,6,7} \draw[red] (a\i)-- (a\i|-O);
\end{scope}
\begin{scope}
\clip[use Hobby shortcut] ([out angle=90]a3)..(a4)..(a5)..(a6)..(a7)..([in angle=90]a1);
\foreach \i in {5,6,7} \draw[red] (a\i)-- (a\i|-O);
\end{scope}
\draw[use Hobby shortcut,thick] ([out angle=-90]a1)..(a2)..([in angle=-90]a3); 
\draw[use Hobby shortcut,thick] ([out angle=90]a3)..(a4)..(a5)..(a6)..(a7)..([in angle=90]a1);
\foreach \i in {1,3} \draw (a\i)-- (a\i|-O);
\foreach \i in  {1,3,5,6,7} {\draw (a\i) pic {circ};} 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容