Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to know if it is possible to draw an image like this in 3D using tikz? I am having some text around this picture, which looks great in tikz, but I am unable to draw this kind of 3D figure in tikz. Also the shadows around it looks quite complex to me.

Any examples, ideas, suggestions?

enter image description here

Thank You !

share|improve this question
    
yes, it is possible. You can have a look here tex.stackexchange.com/questions/58633/… or here tex.stackexchange.com/questions/42812/3d-bodies-in-tikz for some ideas on lighting and 3D-body-generation. –  LaRiFaRi May 5 at 13:14
    
Do you need other stuff in this graphic? Like this, it looks much more as work for INKSCAPE. Will be a lot of work to program this including shadows and so on. –  LaRiFaRi May 5 at 13:16
    
I will say that this reminds me of a standard icon pack I used back in the day. That pack came with vectors for each icon; if you have a vector for the image, there is little purpose in trying to create it with TikZ (but you can have Inkscape 'convert' it for you). –  Sean Allred May 5 at 13:16
1  
In my opinion this is not suited for TikZ, here you have something “similar”. –  Manuel May 5 at 13:26
1  
@Raj Yes, I would recommend against using TikZ if you have a vector already available. If you have the vector in the same folder, you can just use \includegraphics{my-vector}—no need for TikZ. I would recommend you convert whatever you have to PDF first, just for ease of use. –  Sean Allred May 5 at 13:37

2 Answers 2

up vote 19 down vote accepted

Definitely not perfect in any respect but anyway...

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

\path (0,0) pic {disc bottom} (0,1.25) pic {disc} (0,2.5) pic {disc};

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
2  
this is amazing ! :) –  Raj May 5 at 14:20

I'm afraid I also could not resist giving it a shot with Asymptote. Unlike the TikZ solution, this actually uses an underlying 3d model. In particular, the "white ring" around the top emerged naturally as a result of rounding the corner, together with Asymptote's shading capabilities.

\documentclass[margin=10pt,convert]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=disk}
    settings.outformat = "png";
    settings.render=16;
    unitsize(2cm);
    import three;
    import roundedpath;
    currentprojection = orthographic(0,4,1);

    int nslices = 20;
    pen colorfunction(int u, real v) {
        real t = (v/nslices)*4pi;
        static pen dark = gray(0.3);
        static pen light = white;
        return interp(dark, light, (sin(t)+1)/2);
    }

    real radius = 2.0, height = 1.0;

    path3 to_revolve = path3(roundedpath((0,0) -- (radius,0) -- (radius,height) -- (0.9 radius, height) -- (0,height), R=0.05), YZplane);
    surface disk = surface(to_revolve, c=O, axis=Z, n=nslices, color = colorfunction);
    draw(disk);

    pen undercolorfunction(int u, real v) {
        pen overpen = colorfunction(u,v);
        real r = point(to_revolve, u).y;
        return interp(black, overpen, (r/radius)^5);
    }

    surface underdisk = surface(to_revolve, c=O, axis=Z, n=nslices, color=undercolorfunction);

    draw(shift(-1.2*height*Z)*underdisk);
    draw(shift(-2.4*height*Z)*underdisk);

\end{asypicture}
\end{document}

The result:

share|improve this answer
1  
Added bonus is that you can embed the model into the PDF. –  bb010g May 6 at 1:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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