Recently I used the package tikz-3dplot to draw a figure until I was confronted to a very strange issue. I finally build a Minimal Working Example to isolate the problem and fully annotated it to simplify comprehension. My observation is simple. In a Cartesian frame I draw a vector using two methods. The first one, simply from its x,y,z coordinates and the second one from its polar coordinates. With the numerical values used, these two vectors, P and M (or N, using another method), must must be drawn identically as a vector collinear to the (1,1,1) vector. But they are not ! Maybe I am doing something wrong ???

% Origin
\coordinate (O) at (0,0,0) node[above left=1.0mm]{\large$O$};
% Point P, polar coordinates
\pgfmathsetmacro{\Prho}{5} %
\pgfmathsetmacro{\Ptheta}{45} %
\pgfmathsetmacro{\Pphi}{45} %
% Drawt P as a vector
\draw[very thick,-latex,color=red] (O) -- (P) node[above left]{$P$};
% Draw P projection on xy plane
\draw[thick,dotted,color=red] (P) -- (Pxy) -- (O);
% Adjust frame axis lengthes (cosmetic)
% Cartesian frame
\draw[thick,-latex] (O) -- (\X,0,0) node[anchor=north east]{$x$};
\draw[thick,-latex] (O) -- (0,\Y,0) node[anchor=north west]{$y$};
\draw[thick,-latex] (O) -- (0,0,\Z) node[anchor=south]{$z$};
% Point M : cartesian coordinates
% Draw M
\draw[thick,-latex,color=blue] (O) -- (\ax,\ay,\az) node[above right]{$M$};
% Point N : compute its polar coordinates from M coordinates
\pgfmathsetmacro{\Nrho}{sqrt(\ax*\ax + \ay*\ay + \az*\az)}
\pgfmathsetmacro{\Nphi}{atan2(\ay, \ax)}
% Define and draw N using the preceding definitions
\draw[very thick,-latex,color=blue] (O) -- (N) node[below right]{$N$};
% Draw projection of N on xy plane
\draw[thick,dotted,color=blue] (N) -- (Nxy) -- (O);
% Draw the arc for phi on xy plane
\tdplotdrawarc[thick,-latex,color=blue]{(O)}{\Prho}{0}{45} {below,color=black} {$\phi=45$}
% Second method : compute for N its polar coordinates
% Arc for beta of P on (phi, z)  plane
\tdplotdrawarc[tdplot_rotated_coords,thin,-latex,color=red]{(O)}{\Prho}{0}{45} {left,color=black} {$45 = \theta$}
% Arc for beta of M or N on (phi, z)  plane
\tdplotdrawarc[tdplot_rotated_coords,thin,-latex,blue]{(O)}{6}{0} {\tdplotrestheta}{right,color=black}{$\theta' = \tdplotrestheta$}


See text for explanations

  • 1
    Welcome in this great community named TeX.SE.
    – Sebastiano
    Commented Jun 14, 2021 at 11:57
  • You might want to look at github.com/marmotghost/tikz-3dtools
    – JeT
    Commented Jun 14, 2021 at 14:14
  • @JeT : I know tikz-3dtools but don't want to use this package. Please try the code above and look at this strange result ! I have no explanation except I am doing something wrong.
    – PatDae
    Commented Jun 14, 2021 at 16:00
  • @PatDae am a little padawan vs marmot. Maybe you can mention your question on tex top answers? You'll certainly get an answer.
    – JeT
    Commented Jun 14, 2021 at 16:26
  • Figure replaced by a simpler one.
    – PatDae
    Commented Jun 15, 2021 at 7:43

1 Answer 1


Juan, you understand correctly my question and you are right, the 3 angles between (1,1,1) and the 3 axis are of 54.73914° not 45°. Then vectors P and M are not collinear. I am sorry. Intuition can be a bad advisor. Thanks a lot. However, I was obliged to build a simple procedure to verify that this is true. I was not able to find an equivalent in tikz-3dplot, thus I give it to all. It works obviously in 3d :

  \pgfmathsetmacro{\VectorNormU}{sqrt(#1*#1 + #2*#2 + #3*#3)}%
  \pgfmathsetmacro{\VectorNormV}{sqrt(#4*#4 + #5*#5 + #6*#6)}%
  \pgfmathsetmacro{\ScalarProduct}{#1*#4 + #2*#5 + #3*#6}%
  Angle of vectors (#1, #2, #3) and (#4, #5, #6) : \AOTVtheta\\

Thanks a lot again,


This question can be noted as [SOLVED].


You must log in to answer this question.

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