[Tex/LaTex] Drawing a homotopy between two paths

tikz-pgf

I am trying to draw a picture which looks like below
enter image description here

This is what I have tried so far

\begin{tikzpicture}

\node at (0,-1) {$F : I \times I \rightarrow X$};
\node[label=below:$x_1$]  (x1) at (6,0)  {$\bullet$};
\node[label=above:$x_0$]  (x0) at (9,4)  {$\bullet$};  
\node  at (9,1.2)  {$f_0$}; 
\node  at (6.5,3.2)  {$f_1$}; 
\node  at (0,0)  {$f_1$}; 
\node  at (0,4)  {$f_1$}; 
\node  at (-1.2,2)  {$p$};
\node  at (1.2,2)  {$q$};
\draw (x1.center) to [out=5,in=-90]++(2.8,1.8) to[out=90,in=-95](x0.center);
\draw (x1.center) to [out=10,in=-110]++(2.6,2) to[out=70,in=-103](x0.center); 
\draw (x1.center) to [out=15,in=-105](x0.center);
\draw (x1.center) to [out=30,in=-150](x0.center);
\draw (x1.center) to [out=45,in=-170](x0.center); 
\draw (x1.center) to [out=50,in=-105]++(1.2,3)to [out=75,in=-172](x0.center); 

\draw (x1.center) to [out=60,in=-90]++(0.8,3) to[out=90,in=-180] (x0.center);


\begin{scope}[every node/.style={draw, anchor=text, rectangle split,
rectangle split parts=6,minimum width=2cm}]
\node (R) at (0,3){ \nodepart{two} \nodepart{three}
\nodepart{four}\nodepart{five}\nodepart{six}\nodepart{seven}};
\end{scope}
\pgfmathsetmacro{\factor}{1/sqrt(2)};
\coordinate [label=below:A] (A) at (3,-7.1*\factor);
\coordinate [label=left:B] (B) at (0,-4.1*\factor);
\coordinate [label=left:C] (C) at (0,-7.1*\factor);

\draw[->] (0,-5) -- (1.5,-5) node[right] {};
\draw[->] (0,-5) -- (0,-3.5) node[above] {};

\draw[-] (A)--(C)--(B)--cycle; 

\end{tikzpicture}

And the result looks like

enter image description here

which does not fulfill the requirement. Can any one help me to improve the code? I really have no idea. Thank you in advance.

Best Answer

enter image description here

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,calc}
\begin{document}
\begin{tikzpicture}
  [decoration={markings,mark=at position 0.5 with {\arrow{>}}},
   witharrow/.style={postaction={decorate}},
   dot/.style={draw,fill,circle,inner sep=1.5pt,minimum width=0pt}
  ]

  % rectangle
  \begin{scope}
     \draw[thick]
       (0,0) coordinate (a1) -- node[left]     {$p$} (0,2) coordinate (d1)
       (2,0) coordinate (b1) -- node[right](q1){$q$} (2,2) coordinate (c1);
     \draw[xstep=2,ystep=1/3] (a1) grid (c1);
     \draw[thick,witharrow] (d1) -- node[above]    {$f_1$}(c1);
     \draw[thick,witharrow] (a1) -- node[below](f1){$f_0$}(b1);
  \end{scope}

  % triangle
  \begin{scope}[shift={(0,-4)}]
    \node[dot,label={[below left]$p$}] (a2) at (0,0) {};
    \node[dot] (b2) at (2,0) {};
    \node[dot] (c2) at (0,2) {};
    \draw[thick,witharrow] (a2) -- node[left] {$f_1$} (c2);
    \draw[thick,witharrow] (a2) -- node[below]{$f_0$} (b2);
    \draw[thick] (c2) -- node[above](q2){$q$} (b2);
    \clip (a2.center) -- (b2.center) -- (c2.center) -- cycle;
    \foreach \a in {15,30,...,75} \draw (a2) -- (\a:2);
  \end{scope}

  % ellipse
  \begin{scope}[shift={(5,0)}]
    \node[dot,label={[left] $p$}] (a3) at (0,0) {};
    \node[dot,label={[right]$q$}] (b3) at (4,0) {};
    \draw[thick,witharrow] (a3) to[out=50,in=150]node[above]{$f_1$} (b3);
    \foreach \o/\i in {40/160,30/170,20/180,10/190,-10/200}
       \draw (a3) to[out=\o,in=\i]  (b3);
    \draw[thick,witharrow] (a3) to[out=-20,in=-130]node[below]{$f_0$} (b3);
    \draw ($0.5*(a3)+0.5*(b3)$) circle[x radius=2.5,y radius=1.5];
    \node at ($(a3)+(0.5,0.8)$) (X3) {$X$};
  \end{scope}

  % connecting arrows
  \draw[-stealth,shorten >=2mm] (f1) -- node[right]{$b$} (q2);
  \draw[-stealth,dashed,shorten >=6mm] (q2) -- node[above]{$\sigma$} (a3);
  \draw[-stealth,shorten >=4mm] (q1) -- node[above]{$H$} (X3);
\end{tikzpicture}
\end{document}
Related Question