TikZ-PGF – How to Draw Convex, Strictly Convex, and Nonconvex Sets

pstrickstikz-pgf

How can I draw these convex, strictly convex and nonconvex sets?

enter image description here

Best Answer

Here's a starting point. You may want to learn about Bézier curves if you want to do that.

convex set

\documentclass{article}
\usepackage{tikz}

\tikzset{
    convexset/.style = {line width = 0.75 pt, fill = orange},
    ext/.style = {circle, inner sep=0pt, minimum size=2pt, fill=black},
    segment/.style = {line width = 0.75 pt}
        }
\begin{document}
    \begin{tikzpicture}
        \draw[convexset]
                (0,0) .. controls + (0.2,2) and + (-0.2,1) ..
                (2,1) .. controls + (0.2,-0.5) and + (0.5,0) ..
                (1.2,-3) .. controls + (-0.5,0) and + (-0.1,-1) ..
                (0,0) -- cycle;
        \draw[segment] (1,-1) node[ext]{} -- (1.5,1) node[ext]{};
    \end{tikzpicture}%
    \hspace*{2cm}%  
    \begin{tikzpicture}[scale=0.75]
        \draw[convexset]
                (0,0) .. controls + (0.2,0) and +(-1,0) ..
                (2,-2) .. controls + (1,0) and + (-0.2,0) ..
                (4,0) .. controls + (0.2,0) and + (1,0) ..
                (2,-7) .. controls + (-1,0) and + (-0.2,0) ..
                (0,0) -- cycle;
        \draw[segment] (0.5,-1.5) node[ext]{} -- (3.5,-1.5) node[ext]{};
    \end{tikzpicture}
\end{document}

EDIT: How it's done

You can see below how the curves are done. The dots are the control points for the Bézier curves. Note that here I used a relative positioning of the control points (i.e. controls + (-1,0) which means place the control point at 1 cm to the left of the anchor point of the curve).

first one second one