在两个向量之间画一个角度?

在两个向量之间画一个角度?

我想在两个向量之间画一个角度:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles,quotes,babel,plotmarks}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[decoration=brace]


% orthogonal ground line
\draw[thick] (-3,0) -- (3,0);

% Origin
\draw[fill=black] (0,0) node(O)[anchor=north] {$O$};

% vector a
\draw[thick,->] (0,0) -- (-2,2) node(a)[anchor=north east] {$a$};

% vector b
\draw[thick,->] (0,0) -- (2.5,1.5) node(b)[anchor=west] {$b$};


\pic [draw, -, angle eccentricity=1.2, angle radius=1cm,, "$\gamma$"] {angle=b--O--a};

\end{tikzpicture}
\end{document}

由于某些原因,绘制的角度比预期的要大?

在此处输入图片描述

有什么建议关于如何正确做到这一点?

答案1

原因是您错误地定义了角度的坐标。如果您写入\draw (0,0) -- (-2,2) node (a) [anchor=north east] {$a$};,则您将 定义(a)为对标签 的节点的引用$a$,其中心(如您所定义)north east为 坐标(-2,2)。但这(-2,2)实际上是您所需的角度坐标。

因此,你应该这样做:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}

\begin{document}
\begin{tikzpicture}

% orthogonal ground line
\draw[thick] (-3,0) -- (3,0);

% Origin
\draw[fill=black] (0,0) coordinate (O) node [anchor=north] {$O$};

% vector a
\draw[thick,->] (0,0) -- (-2,2) coordinate (a) node[anchor=north east] {$a$};

% vector b
\draw[thick,->] (0,0) -- (2.5,1.5) coordinate (b) node[anchor=west] {$b$};

\pic[draw, angle eccentricity=1.2, angle radius=1cm,, "$\gamma$"] {angle=b--O--a};

\end{tikzpicture}
\end{document}

或者,您可以使用labels

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}

\begin{document}
\begin{tikzpicture}

% orthogonal ground line
\draw[thick] (-3,0) -- (3,0);

% Origin
\draw[fill=black] (0,0) coordinate[label={below:$0$}] (O);

% vector a
\draw[thick,->] (0,0) -- (-2,2) coordinate[label={below left:$a$}] (a);

% vector b
\draw[thick,->] (0,0) -- (2.5,1.5) coordinate[label={right:$b$}] (b);

\pic [draw, angle eccentricity=1.2, angle radius=1cm,, "$\gamma$"] {angle=b--O--a};

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

这很容易做到pstricks– 更具体地说是pst-eucl

    \documentclass[pstricks, border=6pt]{standalone}
    \usepackage{pst-eucl}

    \begin{document}

    \begin{pspicture}(-3,-1)(3,3)
    \psset{arrowinset=0.12,labelsep=3pt}
    \pstGeonode[PointSymbol=none, PosAngle={-90,135, 45}](0,0){O}(-2,2){a}(2.5,1.5){b}
    % orthogonal ground line
    \psline (-3,0)(3,0)
    \ncline{->}{O}{a}\ncline{->}{O}{b}
    \pstMarkAngle[linewidth=0.3pt, LabelSep=0.6]{b}{O}{a}{$\gamma$}%
    \end{pspicture}

    \end{document} 

在此处输入图片描述

答案3

节点不在端点,而是在其他地方,你需要像这样指定坐标

\begin{tikzpicture}[decoration=brace]
% orthogonal ground line
\draw[thick] (-3,0) -- (3,0);

% Origin
\coordinate (O) at (0,0);
\draw[fill=black] (O) node[anchor=north] {$O$};

% vector a
\coordinate (a) at (-2,2);
\draw[thick,->] (O) -- (a) node[anchor=south east] {$a$};

% vector b
\coordinate (b) at (2.5,1.5);
\draw[thick,->] (O) -- (b) node[anchor=south west] {$b$};

\pic [draw, -, angle eccentricity=1.2, angle radius=1cm,, "$\gamma$"] {angle=b--O--a};
\end{tikzpicture}

相关内容