Einen Winkel zwischen zwei Vektoren zeichnen?

Einen Winkel zwischen zwei Vektoren zeichnen?

Ich möchte einen Winkel zwischen zwei Vektoren zeichnen:

\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}

Aus irgendeinem Grund ist der Winkel viel größer als erwartet?

Bildbeschreibung hier eingeben

Irgendwelche Ratschläge, wie man das richtig macht?

Antwort1

Der Grund hierfür ist, dass du die Koordinaten für den Winkel falsch definierst. Wenn du schreibst \draw (0,0) -- (-2,2) node (a) [anchor=north east] {$a$};, dann definierst du (a)als Referenz auf den Knoten für die Beschriftung $a$, dessen Mittelpunkt, wie du ihn definierst, north eastauf der Koordinate liegt (-2,2). Es ist aber die Koordinate (-2,2), die du eigentlich für den Winkel benötigst.

Sie sollten also lieber Folgendes tun:

\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}

Als Alternative können Sie Folgendes verwenden 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}

Bildbeschreibung hier eingeben

Antwort2

Dies ist ganz einfach möglich mit pstricks– genauer gesagt mit 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} 

Bildbeschreibung hier eingeben

Antwort3

Die Knoten liegen nicht an den Endpunkten, sondern etwas daneben, die Koordinaten müssen so angegeben werden

\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}

verwandte Informationen