# Example: Membrane-like surface

Published 2012-01-11 | Author: Yotam Avital

A code to generate a membrane-like surface with some curvature and randomness to the "molecules" constituting the surface.

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.

% Membrane-like surface
% Author: Yotam Avital
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\nuPi{3.1459265}
\foreach \i in {11,10,...,0}{% This one doesn't matter
\foreach \j in {5,4,...,0}{% This will crate a membrane
% with the front lipids visible
% top layer
\pgfmathsetmacro{\dx}{rand*0.1}% A random variance in the x coordinate
\pgfmathsetmacro{\dy}{rand*0.1}% A random variance in the y coordinate,
% gives a hight fill to the lipid
\pgfmathsetmacro{\rot}{rand*0.1}% A random variance in the
% molecule orientation
% bottom layer
\pgfmathsetmacro{\dx}{rand*0.1}
\pgfmathsetmacro{\dy}{rand*0.1}
\pgfmathsetmacro{\rot}{rand*0.1}
}
}
\end{tikzpicture}
\end{document}


• #1 Kristofer, July 26, 2012 at 2:40 a.m.

Nice picture! I think your comment "bottom layer" is slightly confusing though, since there are in fact three layers of particles left. You should probably also generate the particles back-to-forth, as some of them seem to be in front of particles that are closer to the observer. Otherwise, really nice illustration with shaded spheres and all.