0

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.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords]
\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};
\end{tikzpicture}
\end{document}

enter image description here

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

Update

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.

\tdplotsetmaincoords{0}{0}
\tdplotsetrotatedcoords{0}{-110}{-10}
\begin{tikzpicture}[tdplot_rotated_coords]
\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);
\end{tikzpicture}

enter image description here

5
  • 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)? – Christoph Frings Jan 11 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..) – Stefio Yosse Andrean Jan 11 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 ? – Christoph Frings Jan 12 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}. – John Kormylo Jan 12 at 15:35
  • @ChristophFrings both actually. – Stefio Yosse Andrean Jan 13 at 9:53
3

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:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}

\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);
  \end{scope}
  \draw (C2) circle (#3);
}

\begin{document}
\begin{tikzpicture}
  [ % Don't change the perspective!!
    x={(0.866cm,-0.5cm)},y={(0cm,1cm)},z={(-0.866cm,-0.5cm)},
    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{-\bh}{-\dh}{\br};
\zcylinder{-\dh}{\dh} {\br};
% Detector
\zcylinder{-\dh}{\dh}{\dr};
% Beam line
\zcylinder{\dh}{\bh}{\br};

% 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);
\end{scope}
\begin{scope}[canvas is xy plane at z=-\dh]
  \clip (C) -- (A) -- (P);
  \draw[blue] (C) circle (0.3);
\end{scope}

% 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};
\end{tikzpicture}
\end{document}

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

1

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.