[Tex/LaTex] How to rotate and mirror a tikz picture in latex

rotatingtikz-pgf

I'm wondering if someone knows how to place one tikz picture cone face to the other in the horizontal position.

\documentclass[varwidth,margin=0.5cm]{standalone}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{shadings}

\begin{document}
\begin{tikzpicture}
  \fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (3cm and 0.5cm);
  \fill[left color=gray!50!black,right color=gray!50!black,middle  color=gray!50,shading=axis,opacity=0.25] (3,0) -- (0,6) -- (-3,0) arc (180:360:3cm and 0.5cm);
  \draw (-3,0) arc (180:360:3cm and 0.5cm) -- (0,6) -- cycle;
  \draw[densely dashed] (-3,0) arc (180:0:3cm and 0.5cm);
\end{tikzpicture}
\end{document}

Output

Best Answer

TiKZ 3.0.0 (already available at CTAN) introduces a new concept call pic

A “pic” is a “short picture” (hence the short name...) that can be inserted anywhere in TikZ picture where you could also insert a node. Similarly to nodes, pics have a “shape” (called type to avoid confusion) that someone has defined. Each time a pic of a specified type is used, the type’s code is executed, resulting in some drawings to be added to the current picture. The syntax for adding nodes and adding pics to a picture are also very similar. The core difference is that pics are typically more complex than nodes and may consist of a whole bunch of nodes themselves together with complex paths joining them.

with 'pics' it's easy to shift, rotate, mirror, ... every piece of your drawings. Next you have two examples:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}

\tikzset{
    cone/.pic={
        \fill[top color=gray!50!black, bottom color=gray!10, 
              middle color=gray,shading=axis,opacity=0.25]           
              (0,0) circle (3cm and 0.5cm);
        \fill[left color=gray!50!black, right color=gray!50!black,
              middle  color=gray!50,shading=axis,opacity=0.25] 
              (3,0) -- (0,6) -- (-3,0) arc (180:360:3cm and 0.5cm);
        \draw (-3,0) arc (180:360:3cm and 0.5cm) -- (0,6) -- cycle;
        \draw[densely dashed] (-3,0) arc (180:0:3cm and 0.5cm);
    },
    cone_inverted/.pic={
        \fill[top color=gray!50!black, bottom color=gray!10,
              middle color=gray, shading=axis, opacity=0.25]           
              (0,-6) circle (3cm and 0.5cm);
        \fill[left color=gray!50!black, right color=gray!50!black,
              middle  color=gray!50, shading=axis, opacity=0.25] 
              (3,-6) -- (0,0) -- (-3,-6) arc (180:360:3cm and 0.5cm);
        \draw (-3,-6) arc (180:360:3cm and 0.5cm) -- (0,0) -- cycle;
        \draw[densely dashed] (-3,-6) arc (180:0:3cm and 0.5cm);
    }
}
\begin{document}
\begin{tikzpicture}
    \path (0,0) pic {cone} pic [rotate=180] {cone};
\end{tikzpicture}
\begin{tikzpicture}
    \foreach \i in {0,60,...,360}
    \path (0,0) pic [rotate=\i] {cone_inverted};
\end{tikzpicture}
\end{document}

enter image description here