TikZ 中的镜像圆柱体

TikZ 中的镜像圆柱体

如何在 TikZ 中绘制以下镜像圆柱体以及镜像“Muon”?提前致谢! 镜面圆柱体

答案1

这是一个可能的解决方案(当然,可以改进):

\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}

编辑:代码的改进版本:

\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}

相关内容