I would like to draw a 2D network on the surface of a light-grey non-transparent sphere. In the actual fact, the network represents a 2D square lattice composed of many balls and springs as proposed below in TikZ code (by courtesy of @marmot). The idea is to have a spherical elastic membrane capturing an ideal gas inside. The lattice essentially symbolizes the microscopic structure of the membrane.

This question has its roots in the original one:

Drawing a 2D square lattice (springs + balls) on a convex surface

Thank you greatly for the help in advance.

\clip (-1,-1) rectangle (11,11);
\foreach \X in {-2,0,...,10}
{\foreach \Y in {-2,0,...,10}
 {\draw[decorate,decoration={coil,aspect=0.5,amplitude=1.5mm, segment
length=1.5mm}] (\X,\Y) -- ++(0,2) -- ++(2,0);
color=blue,outer color=black] at (\X,\Y) {+};}}
  • 1
    Can you please add a sketch of what you want to achieve? – user121799 Dec 18 '18 at 11:52
  • The same as the picture from @marmot code (i.stack.imgur.com/Kz0Im.png), but spanned across the entire sphere which is coloured in non-transparent light-grey. – Savchenko Dec 18 '18 at 13:26

Here is a first attempt: solid sphere plus different plot marks. Everything else is as in the last code of this answer.

% Declare nice sphere shading: http://tex.stackexchange.com/a/54239/12440

% Style to set TikZ camera angle, like PGFPlots `view`
\tikzset{viewport/.style 2 args={

% Styles to plot only points that are before or behind the sphere.
\pgfplotsset{only foreground/.style={
    restrict expr to domain={rawx*\CameraX + rawy*\CameraY + rawz*\CameraZ}{-0.05:100},
\pgfplotsset{only background/.style={
    restrict expr to domain={rawx*\CameraX + rawy*\CameraY + rawz*\CameraZ}{-100:0.05}

% Automatically plot transparent lines in background and solid lines in foreground
    \addplot3[#1,only background, opacity=0.25] #2;
    \addplot3[#1,only foreground] #2;

% attempt to do similar things for discrete plots
    %\addplot3[#1,only background,gray!50] #2;
    \addplot3[#1,only foreground] #2;


\tikzset{spring/.style={decorate,decoration={coil,aspect=0.5,amplitude=1.5mm, segment
% pgfmanual p. 1087
 {color(0bp)=(blue!100!black); color(9bp)=(blue!90!black);
 color(18bp)=(blue!70!black); color(25bp)=(blue!50!black); color(50bp)=(black)}

    % Compute camera unit vector for calculating depth
    \path[use as bounding box] (-\R,-\R) rectangle (\R,\R); % Avoid jittering animation
    % Draw a nice looking sphere
        \clip (0,0) circle (\R);
        \begin{scope}[transform canvas={rotate=-20}]
            \shade [ball color=white] (0,0.5) ellipse (\R*1.8 and \R*1.5);
        hide axis,
        view={\ViewAzimuth}{\ViewElevation},     % Set view angle
        every axis plot/.style={very thin},
        disabledatascaling,                      % Align PGFPlots coordinates with TikZ
        anchor=origin,                           % Align PGFPlots coordinates with TikZ
        viewport={\ViewAzimuth}{\ViewElevation}, % Align PGFPlots coordinates with TikZ
        % plot latitude circles
        {\addFGBGSampleplot[spring,domain=0:2*pi, samples=51, samples y=1]
        ({\R*cos(#1)*cos(deg(x))}, {\R*cos(#1)*sin(deg(x))}, {\R*sin(#1)});}
        % plot longitude circles
        {\addFGBGSampleplot[spring,domain=0:2*pi, samples=51, samples y=1]
        ({\R*cos(#1)*cos(deg(x))}, {\R*sin(#1)*cos(deg(x))}, {\R*sin(deg(x))});     
        % plot longitude circles
        {\addFGBGSampleplot[only marks,mark=interesting,samples at={-75,-45,...,75}]
        ({\R*cos(#1)*cos(x)}, {\R*sin(#1)*cos(x)}, {\R*sin(x)});        

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.