phd-thesis-en/figures/bacteria.tikz
2017-07-08 17:42:46 +02:00

198 lines
6.4 KiB
Text

\documentclass[crop,tikz]{standalone}
\input{common-headers}
\newcounter{bacteria}
\begin{document}
\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) {};
\node[coord,label=below:$f_{#5}$] at (f#5) {};
\node[coord,label=$b_{#5}$] at (b#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);
}
\begin{tikzpicture}
%\draw [help lines] (-4,-2) grid (4,2);
\coordinate (p) at (0,0); % position vector
\coordinate (d) at ($ (0,0)!1! 33:(1,0) $); % direction vector
\coordinate (n) at ($ (0,0)!1! 90:(d) $); % orthogonal vector
\coordinate (ft) at ($ (p) + { 2+1 }*(d) + 1*(n) $);
\coordinate (fb) at ($ (p) + { 2+1 }*(d) - 1*(n) $);
\coordinate (bt) at ($ (p) + {-(2+1)}*(d) + 1*(n) $);
\coordinate (bb) at ($ (p) + {-(2+1)}*(d) - 1*(n) $);
\draw[black,rounded corners=1cm]
(bt) -- (bb) -- (fb) -- (ft) -- cycle;
\coordinate (f) at ($ (p) + 2*(d) $);
\coordinate (b) at ($ (p) - 2*(d) $);
%
\node[coord,label=below:$f_{}$] at (f) {};
\node[coord,label=$b_{}$] at (b) {};
%
\draw[|<->|,shorten >=3pt,shorten <=3pt,dashed] (f) to node[below] {$2l$} (b);
\draw[|<->|,shorten >=1pt,shorten <=3pt,dashed] (b) to node[below] {$r$} +(180:1);
\draw[|<->|,shorten >=1pt,shorten <=1pt,dashed] ($(p) + 0.8*(d)$) to node[right] {$r$} +(n);
\clip (-3,-2.5) rectangle (3,2.5);
%\draw[black!50,nearly transparent] (-3,-2.5) rectangle (3,2.5);
\end{tikzpicture}
\begin{tikzpicture}
%\draw [help lines] (-4,-3) grid (4,5);
\mybact{(0 ,3)}{($ (0,0)!1! 61:(1,0) $)}{2}{1}{1};
\mybact{(0.4,0)}{($ (0,0)!1! 33:(1,0) $)}{2}{1}{2};
\coordinate (po) at ($ (b1)!(f2)!(f1) $);
\draw[dashed] (f2) -- (po);
%\draw[rotate=-9] (po) rectangle ++(1mm,-1mm);
\node[coord,red,label=$\perp_{21}$] at (po) {};
\coordinate (pp) at ($ (b2)!(b1)!(f2) $);
\draw[dashed] (b1) -- (pp);
\node[coord,red,label=$\perp_{12}$] at (pp) {};
\coordinate (pq) at ($ (b2)!(f1)!(f2) $);
\draw[dashed] (f1) -- (pq);
\node[coord,red,label=$\perp_{12}$] at (pq) {};
\coordinate (pr) at ($ (b1)!(b2)!(f1) $);
\draw[dashed] (b2) -- (pr);
\node[coord,red,label=$\perp_{21}$] at (pr) {};
\end{tikzpicture}
% scalar_t r1 = bact1->r;
% scalar_t r2 = bact2->r;
% scalar_t l1 = bact1->l;
% scalar_t l2 = bact2->l;
% scalar_t r = r1 + r2;
% scalar_t rr = r * r;
% vector_t b1 = p1 - l1 * d1;
% vector_t f1 = p1 + l1 * d1;
% vector_t b2 = p2 - l2 * d2;
% vector_t f2 = p2 + l2 * d2;
% scalar_t mu2_f1 = clamp (dot2D_2_2 (d2, f1 - p2), -l2, l2);
% scalar_t mu2_b1 = clamp (dot2D_2_2 (d2, b1 - p2), -l2, l2);
% scalar_t mu1_f2 = clamp (dot2D_2_2 (d1, f2 - p1), -l1, l1);
% scalar_t mu1_b2 = clamp (dot2D_2_2 (d1, b2 - p1), -l1, l1);
% vector_t h2_f1 = p2 + mu2_f1 * d2;
% vector_t h2_b1 = p2 + mu2_b1 * d2;
% vector_t h1_f2 = p1 + mu1_f2 * d1;
% vector_t h1_b2 = p1 + mu1_b2 * d1;
% vector_t nf1_2 = (h2_f1 - f1);
% vector_t nb1_2 = (h2_b1 - b1);
% vector_t n1_f2 = - (h1_f2 - f2);
% vector_t n1_b2 = - (h1_b2 - b2);
% scalar_t dist2_mu2_f1 = dot2D_2_2 (nf1_2, nf1_2);
% scalar_t dist2_mu2_b1 = dot2D_2_2 (nb1_2, nb1_2);
% scalar_t dist2_mu1_f2 = dot2D_2_2 (n1_f2, n1_f2);
% scalar_t dist2_mu1_b2 = dot2D_2_2 (n1_b2, n1_b2);
\begin{tikzpicture}
\mybact{(0 ,3)}{($ (0,0)!1! 0:(1,0) $)}{2}{1}{1};
\mybact{(1 ,0)}{($ (0,0)!1! 33:(1,0) $)}{2.2}{1.2}{2};
\node[coord,label=$p_2$] at (p2) {};
\draw[|->] (p2) -- ($ (b2)!(f1)!(f2) $);
\end{tikzpicture}
\end{document}
% \begin{document}
%
% \tikzset{cell color/.style={black!20}}
%
% \newcommand{\common}{%
% \coordinate (ll) at (0cm,-1cm);
% \coordinate (ur) at (5cm, 3cm);
% \draw (ll) rectangle (ur);
% \clip (ll)+(0.1cm,0.1cm) rectangle ([shift={(-0.1cm,-0.1cm)}]ur);
% }
%
% \begin{tikzpicture}[
% every node/.style={draw, inner sep=0cm,
% minimum width=10pt, minimum height=10pt},
% arrowed/.style={-Stealth, out=-90, in=90}]
% \common
%
% \node (h1) at (1,2) {};
% \node (h2) at (2,2) {};
% \node (h3) at (3,2) {};
% \node (h4) at (4,2) {};
%
% \node (m1) at (1,1) {};
% \node (m2) at (2,1) {};
% \node (m3) at (3,1) {};
% \node (m4) at (4,1) {};
%
% \node (b1) at (1,0) {};
% \node (b2) at (2,0) {};
% \node (b3) at (3,0) {};
% \node (b4) at (4,0) {};
%
% \draw[arrowed] (h1) to (m2.north) (h3) to (m2.north) (h2) to (m2.north);
% \draw[arrowed,dashed] (h2) to (m3.north) (h4) to (m3.north) (h3) to (m3.north);
%
% \draw[arrowed] (m1) to (b2.north) (m3) to (b2.north) (m2) to (b2.north);
% \draw[arrowed,dashed] (m2) to (b3.north) (m4) to (b3.north) (m3) to (b3.north);
% \end{tikzpicture}
%
% \begin{tikzpicture}[
% c/.style={draw, inner sep=0cm,
% minimum width=10pt, minimum height=10pt},
% arrowed/.style={-Stealth, out=-90, in=90},
% mix/.style={draw, circle, inner sep=1pt}]
% \common
%
% \node[c] (h1) at (1,2) {};
% \node[c] (h2) at (2,2) {};
% \node[c] (h3) at (3,2) {};
% \node[c] (h4) at (4,2) {};
%
% \node[mix] (q1) at (1.5,1.5) {};
% \node[mix] (q2) at (3.5,1.5) {};
%
% \node[c] (m1) at (1,1) {};
% \node[c] (m2) at (2,1) {};
% \node[c] (m3) at (3,1) {};
% \node[c] (m4) at (4,1) {};
%
% \node[mix] (q3) at (2.5,0.5) {};
%
% \node[c] (b1) at (1,0) {};
% \node[c] (b2) at (2,0) {};
% \node[c] (b3) at (3,0) {};
% \node[c] (b4) at (4,0) {};
%
% \draw[arrowed] (h1) to (q1) (q1) to (m1);
% \draw[arrowed] (h2) to (q1) (q1) to (m2);
% \draw[arrowed] (h3) to (q2) (q2) to (m3);
% \draw[arrowed] (h4) to (q2) (q2) to (m4);
%
% \draw[arrowed] (m2) to (q3) (q3) to (b2);
% \draw[arrowed] (m3) to (q3) (q3) to (b3);
% \end{tikzpicture}
% \end{document}