# How do you draw homotopy diagrams?

I want to draw diagrams like the ones in the picture of this question.

Is there a tikz package for that? If not, do you have any LaTeX code to look at? I can't find anything.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{subfig}
\begin{document}
\begin{figure}
\subfloat{
\begin{tikzpicture}
\coordinate (O) at (0,0);
\coordinate (P) at (5,5);
\draw[-latex] (O) -- ++(6,0) node[above]{$s$};
\draw[-latex] (O) -- ++(0,6) node[left]{$t$};
\draw (O|-P) coordinate (OP)--(P)--(O-|P);
\draw[thick] (O) -- ([xshift=2cm]O|-P) coordinate (P1);
\path (O|-P) -- (P1) node[midway,above] {$c_p$};
\node at (barycentric cs:O=1,P1=1,OP=1) {$p$};
\path (P1) -- (P) node[midway,above]{$f$} coordinate[pos=1/4] (P2)
coordinate[pos=1/2] (P3) coordinate[pos=3/4] (P4);
\path (O) -- (O-|P)    coordinate[pos=1/4] (O2)
coordinate[pos=1/2] (O3) coordinate[pos=3/4] (O4) node[midway,below]{$f$};
\foreach \i in {2,3,4}
{\draw (O\i) -- (P\i);}
\end{tikzpicture}
}
\subfloat{
\begin{tikzpicture}
\coordinate (O) at (0,0);
\coordinate (P) at (5,5);
\draw[-latex] (O) -- ++(6,0) node[above]{$s$};
\draw[-latex] (O) -- ++(0,6) node[left]{$t$};
\draw (O|-P) coordinate (OP)--(P) coordinate[midway](top) --(O-|P) coordinate
(PO);
\path (O|-P) -- (top) node[midway,above]{$f$} coordinate[pos=1/4](x1)
coordinate[pos=1/2](x2) coordinate[pos=3/4](x3);
\path (top) -- (P) node[midway,above]{$f^{-1}$} coordinate[pos=1/4](y3)
coordinate[pos=1/2](y2) coordinate[pos=3/4](y1);
\draw[thick,name path=triangle] (O) -- (top) -- (PO);
\foreach \i in {1,2,3}
{\path[name path=X\i] (x\i)--(x\i|-O);
\path [name intersections={of=triangle and X\i,by={A\i}}];
\path[name path=Y\i] (y\i)--(y\i|-O);
\path [name intersections={of=triangle and Y\i,by={B\i}}];
\draw (x\i) -- (A\i) -- (B\i) -- (y\i);
}
\path (O) -- (O-|P) node[midway,below] {$c_p$};
\end{tikzpicture}
}
\end{figure}
\end{document} 