2

I am trying to draw this figure on TIKZ but I am a bit stuck on the first one in the following two points: 1 colors fill the circles with red color 2 instead of circles i want more general "shapes" enter image description here

This is what I ve done so far with just circles :

\begin{tikzpicture}[scale=0.8]
% Initial and target points
\coordinate (start) at (0,0);
\coordinate (end) at (10,3);

% Circle 1
\draw (2.5,2) circle (1.2);
%\node at (2.5,2) {$t_1$};

% Circle 2
\draw (7.5,2) circle (1.2);
%\node at (7.5,2) {$t_3$};

% Trajectory
\draw[smooth,thick] plot[smooth] coordinates{(0,0) (1,0.3) (2,1.5) (2.25,1.75) (2.5,2) (2.75,1.75) (3,1.5) (4,0) (5,0) (6,0) (7.5,2) (8.5,2.5) (9,5) (10,3)};

% Time axis
\draw[->] (0,-1) -- (10,-1) node[right] {$t$};
\foreach \t/\label in {0/$0$,2/$t_1$,3/$t_2$,6/$t_3$,7/$t_4$,10/$T$} {
    \draw (\t,-0.9) -- (\t,-1.1) node[below] {\label};
}

 \filldraw (0,0) circle (2pt);
  \filldraw (10,3) circle (2pt);
% Label for initial and target points
\node[above] at (start) {Initial point};
\node[above] at (end) {Target point};

\end{tikzpicture}

which generates the following:

enter image description here

1
  • Hello. Maybe you can describe clearer what you intend to do? Are you happy with the top part but just want the bottom part? If so how exactly are they connected? Can you simplify your question or just focus on one part? That would highly increase the chance of getting an answer. May 6, 2023 at 11:56

1 Answer 1

3

Welcome to TeX.SE!!!

You can draw both shapes and lines with Bézier or as I did, with to[in=...,out=...]. For example

\draw (A) to[out=30,in=120] (B);

draws a curve starting at A with a 30 degrees angle and ending at B with a 120 degrees one (both angles w.r.t x-axis).

A complete example could be:

\documentclass[tikz,border=1.618]{standalone}

\tikzset{point/.style={circle,draw=black,fill=white,inner sep=1pt}}

\begin{document}
\begin{tikzpicture}[thick]
% dimensions and coordinates
\def\xa{1.5}
\def\xb{4}
\def\xc{5.3}
\def\xd{8.3}
\coordinate (P1) at (\xa,2.5);
\coordinate (P2) at (\xb,2.3);
\coordinate (P3) at (\xc,2.2);
\coordinate (P4) at (\xd,2);
% axes and blue dashed lines
\foreach\i in {0,-4.5}
{
  \draw[blue]    (-0.5,\i) --   (10,\i);
  \draw[blue]   (0,\i+0.1) --++ (0,-0.2) node[below] {\strut$0$};
  \draw[blue] (9.5,\i+0.1) --++ (0,-0.2) node[below] {\strut$T$};
}
\foreach[count=\ii]\i in {\xa,\xb,\xc,\xd}
{
  \draw[blue,dashed] (P\ii)    -- (\i,0)    node[below] {\strut$t_\ii$};
  \draw[blue,dashed] (\i,-1.5) -- (\i,-4.5) node[below] {\strut$t_\ii$};
}
% shapes
\draw[thin,fill=red!40] (P1) to[out=120,in=170] ++ (1,1.2)   to[out=-10,in=180] ++ (0.7,0.2) to[out=0,in=50]
                        (P2) to[out=230,in=0]   ++ (-2,-1)   to[out=180,in=-60] cycle;
\draw[thin,fill=red!40] (P3) to[out=110,in=210] ++ (1.3,1.5) to[out=30,in=90]   ++ (2,-1) to[out=270,in=30]
                        (P4) to[out=210,in=0]   ++ (-2,-0.6) to[out=180,in=-70] cycle;
% curves
\draw (0,1.8) node[point] {} to[out=30,in=190] (P1) to[out=10,in=170]  (P2) to[out=-10,in=190]
                        (P3) to[out=10,in=150] (P4) to[out=-30,in=170] (9.5,1.5) node[point] {};
\draw[red,dashed] (0,-4) to[out=70,in=110] ++ (0.8,0.6) to[out=-70,in=240] (\xa,-2.5);
\draw[red]        (\xa,-2.3) -- (\xb,-2.3);
\draw[red,dashed] (\xb,-3.3) to[out=20,in=200] (\xc,-1.7);
\draw[red]        (\xc,-4) -- (\xd,-4);
\draw[red,dashed] (\xd,-3.3) to[out=0,in=180] (9.5,-3.7);
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .