# Convex set picture

I'm trying to do this:

This is my attempt:

\documentclass[12pt,a4paper]{book}

\usepackage{tikz}

\usetikzlibrary{positioning,arrows.meta}

\begin{document}

\begin{tikzpicture}

\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}


Can you help me?

\documentclass[12pt]{book}
\usepackage{caption, subcaption}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
bbox}

\begin{document}
\begin{figure}[ht]
\centering
\captionsetup[subfigure]{labelformat=simple}
\renewcommand\thesubfigure{}
\subfloat[][Convex set]%
{
\begin{tikzpicture}[bezier bounding box]
\draw[fill=gray!30]
(0,0) .. controls +(0,3) and + (0,2) .. (5,1)
.. controls +(0,-3) and + (0,-2) ..
cycle;
\draw[Circle-Circle]
(1,-0.2)    node[above] {$x_1$} -- ++ (3,1)
node[above] {$x_2$};
\end{tikzpicture}
}
\hfil
\subfloat[][Non-convex set]%
{
\begin{tikzpicture}[bezier bounding box]
\draw[fill=gray!30]
(0,0) .. controls +(0,4) and + (-1,0) .. (3,1)
.. controls +(1,0) and + ( 0,2) .. (5,0)
.. controls +(0,-2) and + (1,0) .. (2,0)
.. controls +(-1,0) and + (0,-2) ..
cycle;
\draw[Circle-Circle]
(1,-0.2)    node[above] {$x_1$} -- ++ (3,0)
node[above] {$x_2$};
\end{tikzpicture}
}
\end{figure}
\end{document}


TikZ library bbox is available on CTAN.

• Once again, you point a very useful library to us. This bbox is simple and efficient for those of us using constantly Bézier curves. Thanks, Zarko. Commented Mar 1, 2022 at 9:48