绘制具有特定形状的集合

绘制具有特定形状的集合

我想要绘制一个非凸集,如下图所示,并且我喜欢从我的 MWE 开始:

在此处输入图片描述

\documentclass[12pt,a4paper]{book}

\usepackage{tikz}
\usetikzlibrary{calc, shadings} 
\usetikzlibrary{positioning,arrows.meta}

\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1},
  extended line/.style={shorten >=-#1,shorten <=-#1},
  extended line/.default=1cm]

\coordinate (A) at (0,2);
\coordinate (B) at (4.5,0);

\draw (A)--(B) node[anchor=north west] {\small $p'x=\alpha$} coordinate[midway] (M) coordinate[pos=0.85](k);

\draw[-latex] (M) node[dot=above left:$x_{0}$] at (M) {} --($(M)!2cm!90:(B)$) node[anchor=north west]{$p$};

\end{tikzpicture}
\end{document}

也许类似的东西可能会有用,但我不知道这种语法是如何工作的(这是来自>子图中 TikZ 图片的对齐

 \draw[fill=gray!30] (0,0) to [out=140,in=90] (-1,-1) node[anchor=south west]{$A$}
    to [out=-90,in=240] (0.8,-0.6)
    to [out=60,in=-60] (1.2,1.2)
    to [out=120,in=90] (0.3,0.7)
    to [out=-90,in=20] (0.3,0)
    to [out=200,in=-40] (0,0);

    \draw (-0.5,-0.5) -- (0.7,0.7);
    \fill (-0.5,-0.5) circle[radius=1.5pt];
    \fill (0.7,0.7) circle[radius=1.5pt];

答案1

\documentclass[12pt,a4paper]{book}

\usepackage{tikz}
\usetikzlibrary{calc, shadings} 
\usetikzlibrary{positioning,arrows.meta}

\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1},
  extended line/.style={shorten >=-#1,shorten <=-#1},
  extended line/.default=1cm]

\coordinate (A) at (0,2);
\coordinate (B) at (4.5,0);

\draw (A)--(B) node[anchor=north west] {\small $p'x=\alpha$} coordinate[midway] (M) coordinate[pos=0.85](k);

\draw[-latex] (M) node[dot=above left:$x_{0}$] at (M) {} --($(M)!2cm!90:(B)$) node[anchor=north west]{$p$};
\pgfmathsetmacro{\myslope}{atan2(2,-4.5)}
\draw[fill=gray!30] (M) to[out=\myslope,in=0] ++ (-2,0.5) to[out=180,in=90] ++ (-1,-0.5)
 to[out=-90,in=90] ++ (2,-2) to[out=-90,in=90] ++ (-3,-1)
 to[out=-90,in=180] ++(4,-1) to[out=0,in=\myslope+180] cycle;
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容