# CMS Wiki Pages

### Site Tools

latex:example_spherical_coordinates

Simple example of 3D axes with spherical coordinates. You can find more diagrams of coordinate systems here, and here for the CMS conventional coordinate system. More figures related to Particle Physics can be found at https://tikz.net/category/physics/particle-physics/.

axes3D.tex
% Author: Izaak Neutelings (June 2017)
% taken from https://tex.stackexchange.com/questions/159445/draw-in-cylindrical-and-spherical-coordinates

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\tikzset{>=latex} % for LaTeX arrow head

% split figures into pages
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1pt}%

\begin{document}

% 3D axis with spherical coordinates
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[scale=3,tdplot_main_coords]

% variables
\def\rvec{.8}
\def\thetavec{30}
\def\phivec{60}

% axes
\coordinate (O) at (0,0,0);
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};

% vectors
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
\draw[-stealth,red] (O)  -- (P) node[above right] {$P$};
\draw[dashed,red]   (O)  -- (Pxy);
\draw[dashed,red]   (P)  -- (Pxy);
\draw[dashed,red]   (Py) -- (Pxy);

% arcs
\tdplotdrawarc[->]{(O)}{0.2}{0}{\phivec}
{anchor=north}{$\phi$}
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[->,tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}
{anchor=south west}{$\theta$}

\end{tikzpicture}

% CMS conventional coordinate system with LHC and other detectors
\tdplotsetmaincoords{75}{50} % to reset previous setting
\begin{tikzpicture}[scale=2.7,tdplot_main_coords,rotate around x=90]

% variables
\def\rvec{1.2}
\def\thetavec{40}
\def\phivec{70}
\def\R{1.1}
\def\w{0.3}

% axes
\coordinate (O) at (0,0,0);
\draw[thick,->] (0,0,0) -- (1,0,0) node[below left]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[below right]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[below right]{$z$};
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}

% vectors
\draw[->,red] (O) -- (P) node[above left] {$P$};
\draw[dashed,red] (O)  -- (Pxy);
\draw[dashed,red] (P)  -- (Pxy);
\draw[dashed,red] (Py) -- (Pxy);

% circle - LHC
\tdplotdrawarc[thick,rotate around x=90,black!70!blue]{(\R,0,0)}{\R}{0}{360}{}{}

% compass - the line between CMS and ATLAS has a ~12° declination (http://googlecompass.com)
\begin{scope}[shift={(1.1*\R,0,1.65*\R)},rotate around y=12]
\draw[<->,black!50] (-\w,0,0) -- (\w,0,0);
\draw[<->,black!50] (0,0,-\w) -- (0,0,\w);
\node[above left,black!50,scale=0.6] at (-\w,0,0) {N};
\end{scope}

% nodes
\node[left,align=center] at (0,0,1.1) {Jura};
\node[right] at (\R,0,0) {LHC};
(O) circle node[left=4pt,below=2pt] {CMS};
\draw[thick] (0.02,0,0) -- (0.5,0,0); % partially overdraw x-axis and CMS point
(2*\R,0,0) circle
node[right=4pt,below=2pt,scale=0.9] {ATLAS};
({\R*sqrt(2)/2+\R},0,{ \R*sqrt(2)/2}) circle
node[left=2pt,below=2pt,scale=0.8] {ALICE};
({\R*sqrt(2)/2+\R},0,{-\R*sqrt(2)/2}) circle
node[below=2pt,right=2pt,scale=0.8] {LHCb};

% arcs
\tdplotdrawarc[->]{(O)}{0.2}{0}{\phivec}
{above=2pt,right=-1pt,anchor=mid west}{$\phi$}
\tdplotdrawarc[->,rotate around z=\phivec-90,rotate around y=-90]{(0,0,0)}{0.5}{0}{\thetavec}
{anchor=mid east}{$\theta$}

\end{tikzpicture}

\end{document}