3

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

2
8

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

5

With solution provided by Harish Kumar in Can we mirror a part in tikz? as Torbjørn suggested, it is easy to get this

enter image description here

If this is what you want, the code is:

\documentclass[12pt]{article}
\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);

\begin{scope}[xscale=1,yscale=-1]
\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{scope}
\end{tikzpicture}

\end{document}

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.