2

I would like to draw a non-convex set as in the following image and I like to start from my MWE:

enter image description here

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

Maybe something like that could turn out to be useful, but I don't know how this syntax works (this is from > Alignment of TikZ pictures in subfigures)

 \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
    The syntax is very simple: in is the angle of the ingoing path, and out the one of the outgoing. if you ensure that the next out and the previous differ by 180, the path won't have corners, i.e. look smooth. – marmot Jun 12 at 17:30
3
\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.