
Quiero dibujar un ángulo entre dos vectores:
\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}
Por alguna razón, ¿el ángulo es mucho mayor de lo esperado?
¿Algún consejo sobre cómo hacer esto correctamente?
Respuesta1
La razón de esto es que definiste mal las coordenadas del ángulo. Si escribes \draw (0,0) -- (-2,2) node (a) [anchor=north east] {$a$};
, entonces defines (a)
como referencia al nodo para la etiqueta $a$
, cuyo centro es, tal como lo defines, north east
a la coordenada (-2,2)
. Pero es la coordenada (-2,2)
la que realmente necesitas para el ángulo.
Entonces, mejor deberías hacer:
\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}
Como alternativa, puedes utilizar 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}
Respuesta2
Esto es muy fácil de hacer pstricks
, más específicamente con 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}
Respuesta3
Los nodos no están en los puntos finales, sino en algo al lado, es necesario especificar las coordenadas de esa manera.
\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}