
2 つのベクトル間の角度を描画します。
\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}