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.

How can I draw the following mirrored cylinder, together with the mirrored “Muon”, in TikZ? Thanks in advance! mirrored cylinder

share|improve this question
add comment

1 Answer 1

up vote 14 down vote accepted

Here's one possible solution (which, of course, can be improved):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,decorations.markings}

\newlength\mylena
\newlength\mylenb

\newcommand\Cylinder[3]{%
\begin{scope}
\tikzset{every node/.style={cylinder, shape border rotate=90, draw,cylinder uses custom fill,   
  cylinder end fill=green!25!black,cylinder body fill=green!60!black,minimum height=5cm,
  minimum width=2cm,opacity=.4}}
  \node (#3) at (#1,#2) {};
  \draw[dashed] (#1+1,-2+#2) arc [start angle=0, end angle=180,
    x radius=1cm, y radius=3mm];
\end{scope}
}

\begin{document}

\begin{tikzpicture}[>=stealth, aspect=2.5]
  % the cylinders
  \Cylinder{0}{0}{a}
  \Cylinder{6}{1}{b}

  % we extract the x-coordinates to obtain the center of the top of the cylinder
  \pgfextractx\mylena{(a.after top)}
  \pgfextractx\mylenb{(a.before top)}
  \addtolength\mylena{-\mylenb}

  % the "spin" lines
\begin{scope}[decoration={markings,mark= at position .5 with {\arrow{stealth}}}]
  \draw[thick,postaction={decorate}] (-1,0.5) arc [start angle=120, end angle=420,
    x radius=2cm, y radius=5mm];
\draw[thick,postaction={decorate}] (7,1.5) arc [start angle=60, end angle=-240,
    x radius=2cm, y radius=5mm];
\end{scope}

  % the vectors at the top and bottom of the cylinders
\begin{scope}[ultra thick,->,green!20!black]
  \draw (1.5\mylena,2.5) -- (1,3.5);
  \draw (1.5\mylena,2.5) -- (-1,3.5);
  \draw (1.5\mylena,2.5) -- (0,3.5);
  \draw (1.5\mylena,-2.3) -- (0,-3);
  \draw[xshift=-7] (1.5\mylena,-2.3) -- (-0.7,-3);
  \draw[xshift=7] (1.5\mylena,-2.3) -- (0.7,-3);
\end{scope}

\begin{scope}[ultra thick,->,xshift=6cm,yshift=1cm,green!20!black]
  \draw (1.5\mylena,2.5) -- (1,3.5);
  \draw (1.5\mylena,2.5) -- (-1,3.5);
  \draw (1.5\mylena,2.5) -- (0,3.5);
  \draw (1.5\mylena,-2.3) -- (0,-3);
  \draw[xshift=-7] (1.5\mylena,-2.3) -- (-0.7,-3);
  \draw[xshift=7] (1.5\mylena,-2.3) -- (0.7,-3);
\end{scope}

  % the mirror
  \draw (3,-3) -- (3,8) -- (9,5) -- (9,-3);
  \draw (3.2,8.1) -- (9.2,5.1) -- (9.2,-3);
  \draw (3.2,8.1) -- (3,8);
  \draw (9.2,5.1) -- (9,5);

  % the labels
  \node[xscale=-1] at (8,0) {Muon};
  \node at (7,7) {Mirror};
  \node at (0,5) {Dacay electrons};
\end{tikzpicture}

\end{document}

EDIT: an improved version of the code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,decorations.markings}

% Syntax: \Cylinder{<x-coordinate>}{<y-coordinate>}{<name>}
\newcommand\Cylinder[3]{%
\tikzset{Cylin/.style={ cylinder , shape border rotate = 90 , draw , cylinder uses custom fill ,   
  cylinder end fill = green!25!black , cylinder body fill = green!60!black , minimum height = 5cm,
  minimum width = 2cm , opacity = 0.4 , aspect = 2.5}}
  \node[Cylin] (#3) at (#1,#2) {};
  \draw[dashed] (#1+1,-2+#2) arc [start angle=0, end angle=180,
    x radius=1cm, y radius=3mm];
\begin{scope}[ultra thick,->,green!20!black]
  \foreach \bear in {40,90,140}
    \draw ($(#3.center)+(0,2.5)$) -- +(\bear:1.5);
  \foreach \angle/\bear in {264/220,270/270,276/320}
    \draw (node cs:name=#3,angle=\angle) -- +(\bear:1.2);
\end{scope}
}

\begin{document}

\begin{tikzpicture}
  % the cylinders
  \Cylinder{0}{0}{A}
  \Cylinder{6}{1}{B}

  % the "spin" lines
\begin{scope}[decoration={markings,mark= at position .5 with {\arrow{stealth}}} , thick]
  \draw[postaction={decorate}] (-1,0.5) arc [start angle=120, end angle=420,
    x radius=2cm, y radius=5mm];
\draw[postaction={decorate}] (7,1.5) arc [start angle=60, end angle=-240,
    x radius=2cm, y radius=5mm];
\end{scope}

  % the mirror
  \draw (3,-3) -- (3,8) -- (9,5) -- (9,-3);
  \draw (3.2,8.1) -- (9.2,5.1) -- (9.2,-3);
  \draw (3.2,8.1) -- (3,8);
  \draw (9.2,5.1) -- (9,5);

  % the labels
  \node[xscale=-1] at (8,0) {Muon};
  \node at (7,7) {Mirror};
  \node at (0,5) {Decay electrons};
\end{tikzpicture}

\end{document}
share|improve this answer
1  
Nice! +1 for the how you reversed the Muon! –  Alan Munn Apr 5 '11 at 2:36
    
Muchas gracias, Gonzalo! –  Thanos D. Papaïoannou Apr 5 '11 at 14:49
add comment

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.