6

I'm trying to draw the following concentric cylinder design in 3D:enter image description here

but have had trouble colouring the sides of the lower diagram and getting the circular design in the centre.

I am trying to get the drawings side-by-side and have the surface of the 3d drawing look the same as the 2d drawing! Any help would be appreciated!

 \documentclass{article}
 \usepackage{pgfplots}
 \usepackage{caption}
 \usepackage{tikz}
 \usetikzlibrary{arrows,backgrounds,patterns,shapes.geometric,arrows.meta}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}
\filldraw[even odd rule,inner color=red,outer color=red, opacity = 0.4] 
(0,0) circle (3cm)
(0,0) circle (3.1cm);
\filldraw[even odd rule,inner color=white,outer color=blue, opacity = 0.1] 
(0,0) circle (1.0cm)
(0,0) circle (3cm);
\draw[thick, fill = gray] (0,0) circle (0.1cm);
\draw[thick] (0,0) circle (3cm);
\draw[thick] (0,0) circle (3.1cm);
\draw[->, rotate around={45:(0,0)}] (0,0) -- (3,0)  node [near end,] {$r_0$};

\draw[-latex] (0,-1.9) arc (274:180:1.5cm) node[thick,midway,right] {$\Omega$};
\draw[thick, opacity = 1] (0,0) circle (1.0cm);

\draw[thick, fill = white]
\foreach \i in {1,2,...,14} {%
    [rotate=(\i-1)*36] 
    (0:1.0)  arc (0:18:1.0) {[rounded corners=8pt] -- ++(18: 0.26)  arc (18:36:1.9) } -- ++(36: -0.26) 
};
\draw[->, rotate around={-40:(0,0)}] (0,0) -- (1.2,0)  node [midway,fill = white] {$r_i$};
\end{tikzpicture}
\end{figure}

\begin{tikzpicture}

 \draw[thick] (-4,4) -- (-4,3) arc (180:360:4cm and 1cm) -- (4,4) ++ (-4,0) 
 circle (4cm and 1cm);
 \draw[thick]  -- (-1.5,3) arc (180:360:1.5cm and 0.25cm) -- (1.5,4) ++ 
 (-1.5,0) circle (1.5cm and 0.25cm);
 \draw[thick] (4,4) ++ (-4,0) circle (3.9cm and 0.9 cm);
 \filldraw[even odd rule,inner color=white,outer color=blue, opacity = 0.2] 
 (4,4) ++ (-4,0) circle (4cm and 1 cm);
 \filldraw[even odd rule,inner color=white,outer color=blue, opacity = 0.2] 
  (4,4) ++ (-4,-1) circle (4cm and 1 cm);
  \filldraw[even odd rule,inner color=white,outer color=white, opacity = 1]
  (1.5,4) ++ (-1.5,0) circle (1.5cm and 0.25cm);

  \filldraw[even odd rule,inner color=red,outer color=red, opacity = 0.2] 
  (4,4) ++ (-4,0) circle (4cm and 1 cm)
  (4,4) ++ (-4,0) circle (3.9cm and 0.9 cm);
  \draw[thick] (1.5,4) ++ (-1.5,0) circle (0.25cm and 0.05cm);
  \fill[color = gray] 
  (1.5,4) ++ (-1.5,0) circle (0.25cm and 0.05cm);
  %\draw[thick,-latex] (5,0,0) -- (9,0,0) node[anchor=north east]{$y$};
  %\draw[thick,-latex] (5,0,0) -- (5,5,0) node[anchor=north west]{$z$};
  %\draw[thick,-latex] (5,0,0) -- (5,0,5) node[anchor=south east]{$x$};

   \end{tikzpicture}  
    \end{document}

1 Answer 1

7

Using tikz-3dplot.

This is basically the same thing I did here : XYZ Coordinate System Drawing

Some things have to be changed, since rotate don't seem to work with tikz-3dplot (I don't understand why...)

I cheat a bit for the circular gears, by setting an adjusted angle to fake continuity.

The output

enter image description here

The code

\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
%% viewing angles %%
\def\angThe{70}   %%
\def\angPhi{0}    %%
%%%%%%%%%%%%%%%%%%%%

\tdplotsetmaincoords{\angThe}{\angPhi}
\begin{tikzpicture}[tdplot_main_coords, scale=1.7]
  \def\topDisk
  {
    \filldraw
    [
      even odd rule,
      inner color=red,
      outer color=red,
      fill opacity = 0.4,
      draw=black, thick,
    ]
    (0,0) circle (3)
    (0,0) circle (3.1);

    \filldraw
    [
      even odd rule,
      inner color=white,
      outer color=blue,
      fill opacity = 0.1,
      draw=black, thick,
    ]
    (0,0) circle (1.0)
    (0,0) circle (3);

    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick, fill = white] (\a:1) circle (.26) ;
    }
    \fill [white] (0,0) circle (1) ;
    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick] (\a:1) arc (\a:\a+21:1);
    }

    \filldraw[thick, fill = gray] (0,0) circle (0.1);

    \draw[-latex] (0,-1.9) arc (274:180:1.5) node[thick,midway,below] {$\Omega$};
    \draw[->, ] (0,0) -- (45:3)  node [below=5pt,near end,] {$r_0$};
    \draw[->, ] (0,0) -- (-40:1.2)  node [midway,fill = white] {$r_i$};
  }

  \topDisk

  \def\r{3.1}
  \def\z{-1}
  \pgfmathsetmacro{\angPhiOpp}{\angPhi-180}

  \draw [fill=pink] (\angPhi:\r) arc (\angPhi:\angPhiOpp:\r) 
  {[shift={(0,0,\z)}]
                    -- (\angPhiOpp:\r) arc (\angPhiOpp:\angPhi:\r) 
  } -- cycle;

  \begin{scope}[x=1cm,y=1cm,yshift=5cm]
    \topDisk
  \end{scope}
\end{tikzpicture}

\end{document}

a e s t h e t h i c

enter image description here

\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
%% viewing angles %%
\def\angThe{70}   %%
\def\angPhi{0}    %%
%%%%%%%%%%%%%%%%%%%%

\tdplotsetmaincoords{\angThe}{\angPhi}
\begin{tikzpicture}[tdplot_main_coords, scale=1.7]
  \def\topDisk
  {
    \filldraw
    [
      even odd rule,
      fill=purple!79!blue,
      fill opacity = 0.6,
      draw=black, thick,
    ]
    (0,0) circle (3)
    (0,0) circle (3.1);

    \filldraw
    [
      even odd rule,
      inner color=white,
      outer color=teal,
      fill opacity = 0.2,
      draw=black, thick,
    ]
    (0,0) circle (1.0)
    (0,0) circle (3);

    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick, fill = white] (\a:1) circle (.26) ;
    }
    \fill [white] (0,0) circle (1) ;
    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick] (\a:1) arc (\a:\a+21:1);
    }

    \filldraw[thick, fill = gray] (0,0) circle (0.1);

  }

  \topDisk

  \def\r{3.1}
  \def\z{-1}
  \pgfmathsetmacro{\angPhiOpp}{\angPhi-180}
  \pgfmathsetmacro{\angPhiMid}{\angPhi-90}

  \def\around[#1]<#2:#3>
  {
    \path
    [
      #1
    ]
    (#2:\r) arc (#2:#3:\r) 
    {[shift={(0,0,\z)}]
                      -- (#3:\r) arc (#3:#2:\r) 
    } -- cycle;
  }
  \begin{scope}[transparency group,opacity=.35]
    \around
    [
      fill,
      left color=blue,
      right color=red,
    ]<\angPhi:\angPhiMid>

    \around
    [
      fill,
      left color=red,
      right color=blue,
    ]<\angPhiMid+1:\angPhiOpp>
  \end{scope}
  \around[draw=thick]<\angPhi:\angPhiOpp>


  \begin{scope}[x=1cm,y=1cm,yshift=5cm]
    \topDisk
     \draw[-latex] (0,-1.9) arc (274:180:1.5) node[thick,midway,below] {$\Omega$};
     \draw[->, ] (0,0) -- (45:3)  node [below=5pt,near end,] {$r_0$};
     \draw[->, ] (0,0) -- (-40:1.2)  node [midway,fill = white] {$r_i$};
  \end{scope}
\end{tikzpicture}

\end{document}

Or like this ?

enter image description here

\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
%% viewing angles %%
\def\angThe{70}   %%
\def\angPhi{0}    %%
%%%%%%%%%%%%%%%%%%%%

\tdplotsetmaincoords{\angThe}{\angPhi}
\begin{tikzpicture}[tdplot_main_coords, scale=1.7]
  \definecolor{blueish}{HTML}{2AA198}
  \definecolor{backg}{HTML}{EC93D3}

  \def\topDisk
  {
    \filldraw
    [
      even odd rule,
      inner color=red,
      outer color=red,
      fill opacity = 0.4,
      draw=black, thick,
    ]
    (0,0) circle (3)
    (0,0) circle (3.1);

    \filldraw
    [
      even odd rule,
      inner color=white,
      outer color=blue,
      fill opacity = 0.1,
      draw=black, thick,
    ]
    (0,0) circle (1.0)
    (0,0) circle (3);

    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick, fill = white] (\a:1) circle (.26) ;
    }
    \fill [white] (0,0) circle (1) ;
    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick] (\a:1) arc (\a:\a+21:1);
    }

    \filldraw[thick, fill = gray] (0,0) circle (0.1);
  }

  \topDisk

  \def\r{3.1}
  \def\z{-1}
  \pgfmathsetmacro{\angPhiOpp}{\angPhi-180}

  \def\around[#1]<#2:#3>
  {
    \path[#1] (#2:\r) arc (#2:#3:\r) 
    {[shift={(0,0,\z)}]
                      -- (#3:\r) arc (#3:#2:\r) 
    } -- cycle;
  }
  \begin{scope}[transparency group,opacity=.65]
    \def\thet{20}
    \pgfmathsetmacro{\by}{\angPhiOpp+\thet}
    \pgfmathsetmacro{\to}{\angPhi-\thet}
    \foreach \k [evaluate=\k as \kk using \k+.5*\thet, evaluate=\k as \kkk using \k+\thet] in {\angPhiOpp,\by,...,\to}
    {
      \around[fill=blue]<\k:\kk>
      \around[fill=red]<\kk:\kkk>
    }
  \end{scope}
  \around[draw,thick]<\angPhi:\angPhiOpp>

\end{tikzpicture}

\end{document}

As a stack

enter image description here

\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
%% viewing angles %%
\def\angThe{70}   %%
\def\angPhi{0}    %%
%%%%%%%%%%%%%%%%%%%%

\tdplotsetmaincoords{\angThe}{\angPhi}
\begin{tikzpicture}[tdplot_main_coords, scale=1.7]
  \definecolor{blueish}{HTML}{2AA198}
  \definecolor{backg}{HTML}{EC93D3}

  \def\topDisk
  {
    \filldraw
    [
      even odd rule,
      inner color=red,
      outer color=red,
      fill opacity = 0.4,
      draw=black, thick,
    ]
    (0,0) circle (3)
    (0,0) circle (3.1);

    \filldraw
    [
      even odd rule,
      inner color=white,
      outer color=blue,
      fill opacity = 0.1,
      draw=black, thick,
    ]
    (0,0) circle (1.0)
    (0,0) circle (3);

    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick, fill = white] (\a:1) circle (.26) ;
    }
    \fill [white] (0,0) circle (1) ;
    \foreach \i in {1,2,...,14} 
    {
      \pgfmathsetmacro{\a}{(\i-1)*36}
      \draw[thick] (\a:1) arc (\a:\a+21:1);
    }

    \filldraw[thick, fill = gray] (0,0) circle (0.1);
  }

  \def\r{3.1}
  \def\h{-.3}
  \pgfmathsetmacro{\angPhiOpp}{\angPhi-180}

  \def\around[#1]|#2,#3|
  {
    \begin{scope}[shift={(0,0,\h*(#2))}]
      \path [#1] (\angPhi:\r) arc (\angPhi:\angPhiOpp:\r) 
      {[shift={(0,0,\h*(#3))}]
                        -- (\angPhiOpp:\r) arc (\angPhiOpp:\angPhi:\r) 
      } -- cycle;
    \end{scope}
  }
    \def\N{5}
  \begin{scope}[transparency group,opacity=.65]
    \foreach \k  in {0,...,\N}
    {
      \around[fill=blue]|\k,.5|
      \around[fill=red]|\k+.5,.5|
    }
  \end{scope}
  \around[draw,thick]|0,\N+1|

  \topDisk

\end{tikzpicture}
\end{document}
6
  • I don't know about the four blue lines that show up on the PNG, they don't seem to appear on the pdf...
    – marsupilam
    Aug 11, 2017 at 19:42
  • 2
    You are an artist sir.
    – simitar
    Aug 11, 2017 at 22:44
  • how could I adjust the code so that the 3d drawing pink part has 2 different colors that go like blue-pink-blue (of equal size). I want to add this to represent different components
    – simitar
    Aug 12, 2017 at 19:26
  • 1
    @simitar like this ?
    – marsupilam
    Aug 12, 2017 at 19:49
  • 1
    @simitar ah this is easy !
    – marsupilam
    Aug 13, 2017 at 9:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .