[Tex/LaTex] TiKz. Angle between two vectors and a projection


I'm having trouble to draw something with TiKz. What I want to draw I think is simple:
The graph

SIM is a vector in the YZ-plane with a Beta = 38ยบ, source is just a random vector with positive x and y components and negative z. Theta is the angle between SIM and source vectors and Phi is the angle formed by the source projection in the XZ-plane with the X-axis.

Thanks a lot in advance

Best Answer

Here is a tikz-3dplot approach. The arcs are drawn using:

% define three points
\tdplotdefinepoints(vx, vy, vz)(ax, ay, az)(bx, by, bz)
% draw arc using the three points and a radius
\tdplotdrawpolytopearc[draw style]{r}{label options}{label}

The viewpoint can be modified using:

\tdplotsetmaincoords{rotation around x}{rotation around z}

The x-axis and z-axis can be exchanged using:

\let\raarotold\raarot \let\rbarotold\rbarot
\let\rabrotold\rabrot \let\rbbrotold\rbbrot
\let\racrotold\racrot \let\rbcrotold\rbcrot

\let\raarot\racrotold \let\rbarot\rbcrotold
\let\rabrot\rabrotold \let\rbbrot\rbbrotold
\let\racrot\raarotold \let\rbcrot\rbarotold

Note: The -z-axis in the following picture is actually the z-axis. I have just changed the label.

See Symbol 1's answer here for details about coordinate system customization.

tikz-3dplot - angle between vectors



% customized coordinate system
\let\raarotold\raarot \let\rbarotold\rbarot
\let\rabrotold\rabrot \let\rbbrotold\rbbrot
\let\racrotold\racrot \let\rbcrotold\rbcrot

\let\raarot\racrotold \let\rbarot\rbcrotold
\let\rabrot\rabrotold \let\rbbrot\rbbrotold
\let\racrot\raarotold \let\rbcrot\rbarotold


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

  % vector 1
  \draw[very thick,->,red] (0,0,0) -- (\ax,\ay,\az) node[anchor=west]{source};

   % vector 2
  \draw[very thick,->,blue] (0,0,0) -- (\bx,\by,\bz) node[anchor=north]{sim};

   % vector 3 (projection)
  \draw[very thick,green] (0,0,0) -- (\cx,\cy,\cz);

   % dashed lines
%  \draw[dashed,gray] (\ax,\ay,\az) -- (\ax,\ay,0);
  \draw[dashed,gray] (\ax,\ay,\az) -- (\ax,0,\az);
  \draw[dashed,gray] (\ax,\ay,\az) -- (0,\ay,\az);
%  \draw[dashed,gray] (\ax,0,0) -- (\ax,\ay,0) -- (0,\ay,0);
  \draw[dashed,gray] (\ax,0,0) -- (\ax,0,\az) -- (0,0,\az);
  \draw[dashed,gray] (0,0,\az) -- (0,\ay,\az) -- (0,\ay,0);

  % arcs
  \tdplotdrawpolytopearc[<->]{2}{anchor=north west}{$\theta$}

Related Question