4

I am trying to draw this 3D shape

arrows on cylinder

I draw the 4 arrows and the cylinder, but can't rotate the arrows in 3D to put them on the top.

\documentclass{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.arrows}

\begin{document}    
%,rotate around={30:(0,1,1)}

\begin{tikzpicture}
        \node[cylinder, draw=white,fill=blue, shape aspect=0.7,rotate=90,minimum height=0.7cm, minimum width=2cm] {hh};
        \node [fill=red,single arrow, draw=none, rotate=90,minimum height=1cm,minimum width=0.7cm]at(0,0) {};
        \node [fill=blue,single arrow, draw=none, rotate=-90,minimum height=1cm,minimum width=0.7cm] at (0,1.5) {};
        \node [fill=red,single arrow, draw=none, rotate=-180,minimum height=1cm,minimum width=0.7cm]at(-0.75,0.7) {};
        \node [fill=blue,single arrow, draw=none, rotate=-360,minimum height=1cm,minimum width=0.7cm] at (0.75,0.7) {};
    \end{tikzpicture}
\end{document}
4

A solution with arrows.meta library

\documentclass[border =3mm]{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows.meta,calc}

\begin{document}    
%,rotate around={30:(0,1,1)}
\tikzset{Ultra thick/.style={line width=2.5pt}}
\begin{tikzpicture}
        \node[cylinder, draw=white,fill=blue, shape aspect=0.7,rotate=90,minimum height=0.7cm, minimum width=2cm,aspect=1.5](c) {hh};
   \begin{scope}[white,-{Triangle[angle=45:1pt 2]},inner sep=0.5pt]
        \node(topt) at (c.-5){};
        \node(topl) at (c.50){};
        \node(topc) at ($(c.before top)!0.5!(c.after top)$){};
        \node(topb) at ($(topc)!-1!(topt)$){};
        \node(topr) at ($(topc)!-1!(topl)$){};
        % draw arrows      
        \draw[Ultra thick](topc)--(topt); 
        \draw[Ultra thick](topc)--(topb);
        \draw[Ultra thick](topr)--(topc);
        \draw[Ultra thick](topl)--(topc);
  \end{scope}
\end{tikzpicture}

\end{document}

Output [added by cfr]:

cylinder and arrows

|improve this answer|||||
  • I hope that you do not mind my adding an image to show the output. What is the point of the hh? (I know it is in the original code, but it is not in the target picture and it looks rather odd to me. But perhaps I'm missing the significance.) – cfr Dec 13 '15 at 21:52
6

Here's another version with uses the 3D library and paints a custom arrow.

The code between \makeatletter and \makeatother is used to correct an error in the implementation of canvas is xy plane at z=. As far as I know it was first fixed by Jake in TikZ: How to draw an isometric drawing.

Code

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{calc, 3d}

\makeatletter
    \tikzoption{canvas is xy plane at z}[]%
    {   \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
        \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
        \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
        \tikz@canvas@is@plane
    }
\makeatother  

\newcommand{\Arrow}[4]%
% start, direction, length, width
{   \fill[white] (#1) -- ++ (#2+90:#4/2) -- ++ (#2:#3-#4) -- ++ (#2+90:#4/2) -- ++ (#2-45:1.414214*#4) -- ++ (#2-135:1.414214*#4) -- ++ (#2+90:#4/2) -- ++ (#2-180:#3-#4) -- cycle;
}

\begin{document}    
\begin{tikzpicture}
[   xy/.style={canvas is xy plane at z=#1},
    x={(-20:1cm)},
    y={(20:1cm)},
    z={(90:1cm)},
]
    \fill[cyan!50!gray, draw=white] (-135:4) arc (-135:45:4) -- ++ (0,0,2) arc(45:-135:4) -- cycle;
    \fill[cyan!50!gray, draw=white] ($(225:4)+(0,0,2)$) arc (-135:225:4)
        coordinate[pos=0.20] (n1)
        coordinate[pos=0.55] (n2)
        coordinate[pos=0.70] (n3)
        coordinate[pos=0.95] (n4)
     -- cycle;
    \begin{scope}[xy=2]
        \foreach \A in {1,...,4}
        { \Arrow{{\A*90-60-180*mod(\A,2)}:{3.6-3.2*mod(\A,2)}}{\A*90-60+180}{3.2}{0.5}
        }
    \end{scope}
\end{tikzpicture}

\end{document}

Output

enter image description here

|improve this answer|||||
  • What is \tikzoption? Don't recall seeing that. Seems to be a noop here as removing it does not seem to change the image. Also it does not appear to be documented in the TikZ/PGF manual. – Peter Grill Dec 13 '15 at 23:45
  • That's a fix for the not properly working canvas is xy plane at z=. If you use it unpatched, it draws everything in planar coordinates instead of xyz if I recall correctly. – Tom Bombadil Dec 13 '15 at 23:54
  • I can't see any difference in the output with TexLive2013, 2014 and 2015, so perhaps that was patched a while ago. But, furthermore, I don't see any documentation on \tikzoption. I assume it just saves settings that are applied to the start of each tikzpicture. – Peter Grill Dec 14 '15 at 1:55
  • Hmm, probably it works here for some reason, but for instance \begin{tikzpicture} [ x={(-10:1cm)}, y={(200:1cm)}, z={(90:1cm)}, ] \draw[canvas is xy plane at z=0] (0,0) rectangle ++ (2,2); \draw[canvas is xz plane at y=0] (0,0) rectangle ++ (2,2); \draw[canvas is yz plane at x=0] (0,0) rectangle ++ (2,2); \end{tikzpicture} fails miserably. – Tom Bombadil Dec 14 '15 at 8:18
  • 1
    Wow, will have to remember this question if I run into that. BTW, if you have a reference to a question here that provides this fix you should post it in your answer. The best reference I can find is TikZ: How to draw an isometric drawing in tikz. – Peter Grill Dec 14 '15 at 11:41

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.