phd-thesis-en/figures/collision.tikz

97 lines
3.1 KiB
Plaintext

\documentclass[crop,tikz]{standalone}
\input{common-headers}
\input{sigles}
\begin{document}
\newcounter{bacteria}
\tikzset{coord/.style={fill,inner sep=0.5mm, circle, black}}
\def \mybact#1#2#3#4#5{
\stepcounter{bacteria};
\coordinate (p#5) at #1; % position vector
\coordinate (d#5) at #2; % direction vector
\coordinate (n#5) at ($ (0,0)!1! 90:(d#5) $); % orthogonal vector
\coordinate (ft#5) at ($ (p#5) + { #3+#4 }*(d#5) + #4*(n#5) $);
\coordinate (fb#5) at ($ (p#5) + { #3+#4 }*(d#5) - #4*(n#5) $);
\coordinate (bt#5) at ($ (p#5) + {-(#3+#4)}*(d#5) + #4*(n#5) $);
\coordinate (bb#5) at ($ (p#5) + {-(#3+#4)}*(d#5) - #4*(n#5) $);
\draw[black,rounded corners=#4cm]
(bt#5) -- (bb#5) -- (fb#5) -- (ft#5) -- cycle;
%
\coordinate (f#5) at ($ (p#5) + #3*(d#5) $);
\coordinate (b#5) at ($ (p#5) - #3*(d#5) $);
% \node[coord,label=$p_{#5}$] at (p#5) {};
%
\coordinate (ff#5) at ($ (p#5) + {2*#3}*(d#5) $);
\coordinate (bb#5) at ($ (p#5) - {2*#3}*(d#5) $);
\draw[very thin] (ff#5) -- (bb#5);
}
% Usage:
% \mybact {|position vector|} {|direction vector|} {width}{height}{name};
\begin{tikzpicture}
\draw [help lines] (0,0) grid (6,2);
\mybact{(3,1)}{(1,0)}{2}{1}{\arabic{bacteria}};
\node[coord,label=above:$f_\arabic{bacteria}$] at (f1) {};
\node[coord,label=below:$b_\arabic{bacteria}$] at (b1) {};
\end{tikzpicture}
\newcommand{\bactsPosAndAngle}{%
\coordinate (PosA) at ( 0 ,3);
\coordinate (AngA) at ($ (0,0) !1! 28:(1,0) $);
\coordinate (PosB) at (-0.7,0);
\coordinate (AngB) at ($ (0,0) !1! -3:(1,0) $);
\mybact{(PosA)}{(AngA)}{2}{1}{1};
\mybact{(PosB)}{(AngB)}{2}{1}{2};
}
\begin{tikzpicture}
\bactsPosAndAngle
\node[coord,label=above:$f_1$] at (f1) {};
\node[coord,label=below:$f_2$] at (f2) {};
\node[coord,label=below:$b_2$] at (b2) {};
\coordinate (po) at ($ (b1)!(f2)!(f1) $);
\draw[dashed] (f2) -- (po);
% \draw[rotate=-9] (po) rectangle ++(1mm,-1mm);
\node[coord,red,label=above:$\perp_{f_2}$] at (po) {};
\coordinate (pp) at ($ (b2)!(b1)!(f2) $);
\draw[dashed,thick,red] (b1) -- (pp);
\node[coord,red,label=below:$\perp_{b_1}$] at (pp) {};
\coordinate (pq) at ($ (b2)!(f1)!(f2) $);
\draw[dashed] (f1) -- (pq);
\node[coord,label=$b_1$] at (b1) {};
\node[coord,red,label=right:$\perp_{f_1}$] at (pq) {};
\coordinate (pr) at ($ (b1)!(b2)!(f1) $);
\draw[dashed] (b2) -- (pr);
\node[coord,red,label=above:$\perp_{f_2}$] at (pr) {};
\end{tikzpicture}
\begin{tikzpicture}
\bactsPosAndAngle
\coordinate (col) at ($(b1)!.5!(pp)$);
\node[coord] at (f1) {};
\node[coord] at (f2) {};
\node[coord] at (b2) {};
\node[coord] at (b1) {};
\node[coord,red] at ($ (b2)!(b1)!(f2) $) {};
%\node[coord,label=left:$P$] at (col) {};
\node[coord,label=left:$p_1$] at (p1) {};
\node[coord,label=below:$p_2$] at (p2) {};
\draw[-Stealth] (p1) to node[auto] {$\orr{r_1}$} (col);
\draw[-Stealth] (p2) to node[auto,swap] {$\orr{r_2}$} (col);
\draw[-Stealth] (col) to node[auto] {$\orr{n}$} ($(col)!.4!(b1)$);
\end{tikzpicture}
\end{document}