使用时如何使用let
语法绘制圆弧tikz-3dplot
?目前,圆弧已绘制但看起来不正确。
\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}
答案1
现在可以通过结合使用 TikZ/pgf v3.0.0 的arrows.meta
和库来解决这个问题。切换到(可比较的变体)。加载会自动设置,这是使带箭头的路径完全遵循无箭头路径(示例中的红色虚线路径)所需要的。bending
-latex
-Latex
arrows.meta
bending
/pgf/arrow keys/flex=1
我还必须将您示例中的参数换成atan2
与 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}