我最近一直在尝试学习 Tikz,并构建了一个图表用于我的论文,以帮助显示一个向量被拆分成与另一个向量 (B) 平行 (v_b) 和垂直 (v_g) 的分量。还显示了一个垂直于平面的向量 (n)。
我遇到的困难是添加圆弧来显示向量之间的角度。我希望将 n 到 v_i 的角度标记为 theta_vn,将 n 和 v_b 之间的角度标记为 theta_bn,将 v_b 和 v_i 之间的角度标记为 psi。
我查看了其他人是如何管理这个问题的,并尝试复制,但它抛出了一条错误消息:“Package pgf 错误:没有已知的名为 origin 的形状。”其中“origin”是我指定的坐标之一。任何帮助或任何关于改进我的代码的评论都将不胜感激。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm,z=0.3cm,>=stealth]
%Defining coordinates
\coordinate (origin) at (0,0,0);
\coordinate (v_i) at (2,-14,3);
\coordinate (v_b) at (0,-4,-14);
\coordinate (normal) at (0,-10,0);
%Drawing vectors
\draw[->,thick] (normal) -- node[left]{$\vec{n}$} (origin);
\draw[->,thick] (origin) -- node[right]{$\vec{v_i}$} (v_i);
\draw[->,thick] (origin) -- node[left]{$\vec{v_b}$} (v_b);
\draw[->,thick] (v_b) -- node[below]{$\vec{v_g}$} (v_i);
%Drawing other lines
\draw (v_b) -- (0,1,3.5) node[above]{$\vec{B}$};
\draw (normal) -- (v_i);
\draw (normal) -- (v_b);
%Drawing angles - throwing error
\pic ["$\theta_{vn}$", angle eccentricity = 1.2, angle radius = 3cm] {angle = normal -- origin -- v_i};
\pic ["$\theta_{bn}$", angle eccentricity = 1.2, angle radius = 3cm] {angle = normal -- origin -- v_b};
\pic ["$\psi$", angle eccentricity = 1.2, angle radius = 3cm] {angle = v_i -- origin -- v_b};
\end{tikzpicture}
\end{document}
答案1
部分答案:通过删除角度节点定义中的字间距并让tex
引擎知道它必须满足draw
我们的任何要求:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{angles}
\begin{document}
% a bit of a help from: https://tex.stackexchange.com/questions/267201/tikz-angle-between-two-vectors-and-a-projection
\begin{tikzpicture}[x=0.5cm,y=0.5cm,z=0.3cm,>=stealth]
%Defining coordinates
\coordinate (origin) at (0,0,0);
\coordinate (vi) at (2,-14,3);
\coordinate (vb) at (0,-4,-14);
\coordinate (normal) at (0,-10,0);
%Drawing vectors
\draw[->,thick] (normal) -- node[left]{$\vec{n}$} (origin);
\draw[->,thick] (origin) -- node[right]{$\vec{v_i}$} (vi);
\draw[->,thick] (origin) -- node[left]{$\vec{v_b}$} (vb);
\draw[->,thick] (vb) -- node[below]{$\vec{v_g}$} (vi);
%Drawing other lines
\draw (vb) -- (0,1,3.5) node[above]{$\vec{B}$};
\draw (normal) -- (vi);
\draw (normal) -- (vb);
\pic [draw, angle eccentricity=1.2, angle radius = 3cm] {angle = normal--origin--vi};
\pic [draw, angle eccentricity=1.2, angle radius = 3cm] {angle = normal--origin--vb};
\pic [draw, angle eccentricity=1.2, angle radius = 3cm] {angle = vi--origin--vb};
\end{tikzpicture}
\end{document}
您可以获得:
完整答案:现在通过包含附加包\usepackage{quote}
(我认为):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}
\begin{document}
% a bit of help from: https://tex.stackexchange.com/questions/267201/tikz-angle-between-two-vectors-and-a-projection
\begin{tikzpicture}[x=0.5cm,y=0.5cm,z=0.3cm,>=stealth]
%Defining coordinates
\coordinate (origin) at (0,0,0);
\coordinate (vi) at (2,-14,3);
\coordinate (vb) at (0,-4,-14);
\coordinate (normal) at (0,-10,0);
%Drawing vectors
\draw[->,thick] (normal) -- node[left]{$\vec{n}$} (origin);
\draw[->,thick] (origin) -- node[right]{$\vec{v_i}$} (vi);
\draw[->,thick] (origin) -- node[left]{$\vec{v_b}$} (vb);
\draw[->,thick] (vb) -- node[below]{$\vec{v_g}$} (vi);
%Drawing other lines
\draw (vb) -- (0,1,3.5) node[above]{$\vec{B}$};
\draw (normal) -- (vi);
\draw (normal) -- (vb);
\pic [draw, angle eccentricity=1.2, angle radius = 3cm] {angle = normal--origin--vi};
\pic [draw, "$\theta$", angle eccentricity=1.2, angle radius = 3cm] {angle = normal--origin--vb};
\pic [draw, "a", angle eccentricity=1.2, angle radius = 3cm] {angle = vi--origin--vb};
\end{tikzpicture}
\end{document}
你最终会得到
我擅自重命名了你的变量。
更新 1:要制作内角,只需制作angle = vb--origin--vi
。这样就可以了。
\pic [draw, "$\theta$", angle eccentricity=1.2, angle radius = 3cm] {angle = vb--origin--vi};
这将给你