# tikz-3dplot: Drawing an arc with the let syntax in 3d

How can I use the let syntax to draw an arc when using tikz-3dplot? At the present, the arc is drawn but doesn't look right.

\documentclass[tikz, convert = false]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc}
\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords]
\coordinate (O) at (0, 0, 0);
\node[coordinate] (P) at (3, 4, 5) {};

\draw[-latex] (O) -- +(4, 0, 0) node[font = \small, pos = 1.1] {$$x$$}
coordinate (X);

\draw[dashed, gray] (P) -- +(0, 0, -5) coordinate (P1) -- (O);

\draw[-latex] let
\p0 = (O),
\p1 = (X),
\p2 = (P1),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {1cm},
\n4 = {(\n1 + \n2) / 2}
in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\end{tikzpicture}
\end{document}


-
Why doesn’t it look right? If you add \draw (O) circle [radius=1cm]; you will see that the arrow tip adds a small nudge to the arc but otherwise it looks correct. See for a similar problem (and no solution) Why are bent arrows with arrow tips not symmetric in TikZ? – Qrrbrbirlbel Sep 7 '13 at 21:23
@Qrrbrbirlbel it doesn't look natural. It looks skewed or bowed. – dustin Sep 7 '13 at 21:24
@Qrrbrbirlbel it isn't the arrow tip that is the problem. It is the arc. – dustin Sep 7 '13 at 22:05
Are you sure? Have you compared your arc with the circle path I posted earlie? If I remove -latex from the arc they nicely overlap; with the arrow tip the arc does not overlap perfectly with the circle. – Qrrbrbirlbel Sep 7 '13 at 22:19
@Qrrbrbirlbel I see what you are saying now. Is there anything that can be done here? – dustin Sep 7 '13 at 22:23

This can now be solved with the combination of the arrows.meta and bending libraries of TikZ/pgf v3.0.0. Switch -latex to -Latex (the comparable arrows.meta variant). Loading bending automatically sets /pgf/arrow keys/flex=1, which is what's needed to make the arrowed path follow the non-arrowed path (red, dashed path in the sample) exactly.

I also had to swap the arguments of atan2 in your example for use with v3.0.0

\documentclass[tikz, convert = false]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,arrows.meta,bending}
\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords]
\coordinate (O) at (0, 0, 0);
\node[coordinate] (P) at (3, 4, 5) {};

\draw[-latex] (O) -- +(4, 0, 0) node[font = \small, pos = 1.1] {$$x$$}
coordinate (X);

\draw[dashed, gray] (P) -- +(0, 0, -5) coordinate (P1) -- (O);

\draw[-Latex] let
\p0 = (O),
\p1 = (X),
\p2 = (P1),
\n1 = {atan2(\y1 - \y0,\x1 - \x0)},
\n2 = {atan2(\y2 - \y0,\x2 - \x0)},
\n3 = {1cm},
\n4 = {(\n1 + \n2) / 2}
in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\draw[red,dashed] let
\p0 = (O),
\p1 = (X),
\p2 = (P1),
\n1 = {atan2(\y1 - \y0,\x1 - \x0)},
\n2 = {atan2(\y2 - \y0,\x2 - \x0)},
\n3 = {1cm},
\n4 = {(\n1 + \n2) / 2}
in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\end{tikzpicture}
\end{document}


-