I am trying to reproduce below image using tikz-3dplot.

enter image description here

Immediately I stumbled upon a problem where I cannot draw the cartesian x-y-z axis with the z-axis to the right because \tdplotsetmaincoords{xrotation}{zrotation} does not support rotation around y-axis.

I can trick it by swapping y with z axis and mirror it, but then I get problem later on when defining the polar coordinate.


\draw[thick,->] (-3,0,0) -- (3,0,0) node[anchor=north east]{x};
%% \draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{y};                                                                                                                                                                                                                         
%% \draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{z};                                                                                                                                                                                                                              
\draw[thick,->] (0,3,0) -- (0,-3,0) node[anchor=north west]{z};
\draw[thick,->] (0,0,-3) -- (0,0,3) node[anchor=south]{y};

enter image description here

I hope the experts here can help me with this. Thanks!


Now I used tdplotsetrotatedcoords to rotate so that the z-axis is pointing to right as I want it. But I am still struggling to draw the theta and phi angle to the red vector.

\draw[thick,->] (-3,0,0) -- (5,0,0) node[anchor=north east]{x};
\draw[thick,->] (0,-3,0) -- (0,3,0) node[anchor=north west]{y};
\draw[thick,->] (0,0,-3) -- (0,0,3) node[anchor=south]{z};

\draw[red,->] (0,0,0) -- (3,2.5,-3.5);

enter image description here

  • It would be nice if you could complete your code so that it's directly compilable. Is there a reason for not using the rotated coordinate system (p.16 of the manual)? Jan 11, 2021 at 17:44
  • Thanks for the pointer! I have updated the post using your advice. (Still it is far from what I am trying to achieve..) Jan 11, 2021 at 18:52
  • "But I am still struggling to draw the theta and phi angle to the red vector." Do you mean the arcs, the labels ? Jan 12, 2021 at 12:21
  • 1
    Note that \tdplotsetrotatedcoords performs three rotations, where the first and last can be used to cancel each other. In other words, try \tdplotsetrotatedcoords{90}{45}{-90} and \tdplotsetrotatedcoords{-90}{45}{90}. Jan 12, 2021 at 15:35
  • @ChristophFrings both actually. Jan 13, 2021 at 9:53

1 Answer 1


I would use isometric perspective instead of oblique as in the drawing above, because with oblique perspective the generatrices of the cylinder are going to be a difficult problem. If that's possible, a solution could be the following:

\usepackage    {tikz}

\newcommand\zcylinder[3] % z min, z max, radius
  \coordinate (C1) at (0,0,#1);
  \coordinate (C2) at (0,0,#2);
  \begin{scope}[rotate around z=135]
    \coordinate (A1) at ($(C1)+(#3,0,0)$);
    \coordinate (B1) at ($(C1)-(#3,0,0)$);
    \coordinate (A2) at ($(C2)+(#3,0,0)$);
    \coordinate (B2) at ($(C2)-(#3,0,0)$);
    \fill[white, opacity=0.8]  (B2) -- (B1) -- (B1) arc (180:360:#3) --
                               (A1) -- (A2) -- (A2) arc (0:180:#3);
    \draw  (B2) -- (B1) -- (B1) arc (180:360:#3) -- (A1) -- (A2);
    \draw[gray, very thin] (B1) arc (180:0:#3);
  \draw (C2) circle (#3);

  [ % Don't change the perspective!!
    scale=1.5, line cap=round,line join=round

% Dimensions
\def\al{3.5}     % axis length
\def\bh{3}       % beam line semiheight
\def\br{0.2}     % beam line radius
\def\dh{1.75}    % detector semiheight
\def\dr{1.25}    % detector radius
\def\angP{130}   % point P argument
\def\rP{0.8*\dr} % point P radius
\pgfmathsetmacro\px{\rP*cos(\angP)}; % point P x
\pgfmathsetmacro\py{\rP*sin(\angP)}; % point P y

% Beam line
\zcylinder{-\dh}{\dh} {\br};
% Detector
% Beam line

% Everything else...
\coordinate (O) at (0,0,0);
\coordinate (C) at (0,0,-\dh);
\coordinate (A) at (\dr,0,-\dh);
\coordinate (P) at (\px,\py,-\dh);
\fill (O) circle (1pt);
\fill (P) circle (1pt);
\draw[blue,dashed] (P) -- (C) -- (A);
\draw[red,-latex]  (O) -- (P);
\draw[red,dashed]  (O) -- (C);
\begin{scope}[rotate around z=\angP,canvas is xz plane at y=0]
  \clip (O) -- (C) -- (P);
  \draw[red] (O) circle (0.4);
\begin{scope}[canvas is xy plane at z=-\dh]
  \clip (C) -- (A) -- (P);
  \draw[blue] (C) circle (0.3);

% Axis and labels
\draw[gray, dashed] (0,0,0) -- (\dr,0,0);
\draw[gray, dashed] (0,0,0) -- (0,\dr,0);
\draw[gray, dashed] (0,0,0) -- (0,0,\bh);
\draw[-latex] (\dr,0,0) -- (\al,0,0)
              node [below] {$x$ \footnotesize(center of LHC)};
\draw[-latex] (0,\dr,0) -- (0,\al,0) node [above] {$y$};
\draw[-latex] (0,0,\bh) -- (0,0,\al) node [left]  {$z$}; 
\node[red]  at ($(O)-(0,0,0.4)$) [below] {$\theta$};
\node[blue] at ($(C)+(0.35,0.35,0)$) {$\phi$};
\path (0,0,\dh) -- (C) node [above, midway, sloped, text width=1.2cm] 
      {\footnotesize Colision Point};
\path (-0.7*\dr,0.7*\dr,\dh) -- (-0.7*\dr,0.7*\dr,-\dh)
      node [above, midway, sloped] {\footnotesize Detector};
\path (0,0,\bh) -- (0,0,\dh)
      node [above, midway, sloped] {\footnotesize Beam Line};

The above code would produce this drawing: enter image description here

  • Wow.. this is more than I asked for, thanks a lot! Jan 20, 2021 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .