3

This question already has an answer here:

At first, I try to draw a cylinder which is much different from what I want....

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{60}{-30}
\tdplotsetrotatedcoords{0}{90}{90}%
\begin{document}
\begin{tikzpicture}
  [tdplot_rotated_coords,
    scale=3,
    mdc/.style={fill=blue, color=blue,draw=none, opacity=.4,line join=round},
    length/.style={<->,thick,line cap=round}]
  \def\d{1}
  \def\r{\d*.45}

    % Cylinder 
  \foreach \t in {0,12,...,348}
    \draw[mdc] ({cos(\t   )*\r+\d/2},  0, {sin(\t   )*\r+\d/2}) % side vertice of cylinder
            -- ({cos(\t+12)*\r+\d/2},  0, {sin(\t+12)*\r+\d/2})
            -- ({cos(\t+12)*\r+\d/2}, \d, {sin(\t+12)*\r+\d/2})
            -- ({cos(\t   )*\r+\d/2}, \d, {sin(\t   )*\r+\d/2})
            -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

I am curious to know that it is possible to draw shell figures with TikZ (like bellow pictures), but the above code and figures below are far different from what I want....

enter image description here enter image description here enter image description here

marked as duplicate by cfr tikz-pgf Mar 29 '17 at 0:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    Yes, it's certainly possible but rather than asking people to do all of the work for you you should show us what you have tried. Posting a minimal working example makes it easier for people to help you, since they have some code to start from, and much more likely that some one will try to help you. – Andrew Oct 27 '16 at 3:44
  • OK thank you, I try to draw a cylinder, but there is much different between what I have and what I want. – sayros Oct 27 '16 at 6:52
  • 1
    Instead ofTikZ you could try with Asymptote – Ignasi Oct 27 '16 at 7:03
  • Related tikz example: texample.net/tikz/examples/spherical-polar-pots-with-3dplot – Andrew Oct 27 '16 at 11:34
  • TikZ is not a good choice for this as it only draws in 2D. You can fake 3D in simple cases. Also, what do you want? If you don't want either what your code produces or the figures shown at the bottom of your post, how do we know what other non-specified thing you are trying to achieve? – cfr Feb 26 '17 at 23:43
0

I use the following code, which may not be perfect:

\documentclass{standalone}
\usepackage{tikz}
\tikzset{
pics/.cd,
shell/.style = {
    code = {
      \path [top color = black!25, bottom color = white]
        (0,.05*6/3) ellipse [x radius = 3-.05, y radius = 2-.032];
      \path [left color = black!25, right color = black!25, middle color = white]
        (-3,0) -- (-3,-2) arc (180:360:3 and 2)
               -- (3,0) arc (360:180:3 and 2);
      \foreach \r in {225,315}
        \foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
          \fill [black, fill opacity = 1/50]
            (0,0.2) -- (\r+\s-\i:3 and 2) -- ++(0,-2)
            arc        (\r+\s-\i:\r-\s+\i:3 and 2) -- ++(0,2) -- cycle;
      \foreach \r in {45,135}
        \foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
          \fill [black, fill opacity = 1/50]
            (0,0.2) -- (\r+\s-\i:3 and 2)
            arc (\r+\s-\i:\r-\s+\i:3 and 2)  -- cycle;
      \path [top color = white, bottom color = white]
        (0,.05*6/3) ellipse [x radius = 2-.05, y radius = 4/3-.05*4/3];
    }
  }
}
\begin{document}
\begin{tikzpicture}
  \path (0,0,0) pic {shell} ;
\end{tikzpicture}
\end{document}

shell

  • Please post a complete minimal working example (MWE), instead of pieces to put togheter... – CarLaTeX Feb 26 '17 at 8:59
  • Isn't this part of Mark's answer to another question? – cfr Feb 26 '17 at 23:47

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