我使用以下方法绘制了下图tikz
:
但我不知道如何让矢量精确地结束在圆上。有什么简单的方法吗?
代码
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}% To get more advances positioning options
\usetikzlibrary{arrows}
\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\draw[step=1cm,gray!25!,very thin] (-5,-5) grid (5,5);
\draw[thick,->] (-3,0) -- (3,0) node[anchor=north west] {x axis};
\draw[thick,->] (0,-3) -- (0,3) node[anchor=south east] {y axis};
\draw[thick,->] (0,0) -- (2,2) node[midway,above] {$\vec{a}$};
\draw[thick,->] (-2,0) -- (2,2) node[midway, above] {$\vec{a'}$};
\draw[blue, thick,->] (-2,0) -- (0,0) node[midway, above] {$\Delta x$};
\draw[red, thick] (0,0) circle (2 cm);
\end{tikzpicture}
\end{document}
答案1
您可以使用极坐标。而且您不需要在此处加载的库,无论如何我都希望arrows.meta
。arrows
也不mathtools
使用。而且我会标记重复坐标,以便图表更容易调整。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=latex]
\draw[step=1cm,gray!25!,very thin] (-5,-5) grid (5,5);
\draw[thick,->] (-3,0) -- (3,0) node[anchor=north west] {x axis};
\draw[thick,->] (0,-3) -- (0,3) node[anchor=south east] {y axis};
\draw[thick,->] (0,0) coordinate (O) -- (50:2) coordinate (oc)
node[midway,below] {$\vec{a}$};
\draw[thick,->] (-2,0) coordinate (L) -- (oc) node[midway, above] {$\vec{a'}$};
\draw[blue, thick,->] (L) -- (O) node[midway, above] {$\Delta x$};
\draw[red, thick] (O) circle (2 cm);
\end{tikzpicture}
\end{document}