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.

Download as: [PDF] [TEX]

Membrane-like surface

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Membrane-like surface
% Author: Yotam Avital
  \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      
      \shade[ball color=red] ({\i+\dx+\rot},{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)}) circle(0.45);
      \shade[ball color=gray] (\i+\dx,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-0.9}) circle(0.45);
      \shade[ball color=gray] (\i+\dx-\rot,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-1.8}) circle(0.45);
      % bottom layer
      \shade[ball color=gray] (\i+\dx+\rot,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-2.8}) circle(0.45);
      \shade[ball color=gray] (\i+\dx,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-3.7}) circle(0.45);
      \shade[ball color=red] (\i+\dx-\rot,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-4.6}) circle(0.45);


  • #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.

Adding comments is currently not enabled.