6

I've plotted the following graph, using tikz:

circle

But I don't know how to make the vectors end exactly on the circle. Is there any simple way to do it?

CODE

\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}
  • You can use functions like cosine as coordinate x or y… – TeXnician Oct 13 '18 at 19:37
  • You could use polar coordinates, e.g. (60:2) instead of (2,2). – user121799 Oct 13 '18 at 19:38
  • I had a couple of comments, all very minor, so I added an answer. You can still decide to delete the question, I am not doing this for reputation. Yet I do not think that everyone but you knows polar coordinates, so the question is OK IMHO. – user121799 Oct 13 '18 at 19:44
6

You could use polar coordinates. And you do not need the libraries you are loading here, and in any case I would prefer arrows.meta over arrows. mathtools is not used either. And I would label repeating coordinates such that the diagram becomes easier to adjust.

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

enter image description here

| improve this answer | |
  • How to write an short arrow above the circle to give the positive orientation? the -> added to the draw circle doesn't work for that. – pzorba75 Oct 14 '18 at 3:37
  • 1
    @pzorba75 No, it doesn't. Depending on where you want to have the arrow try \draw[red, thick,->] (<angle>:2) arc(<angle>:<angle>+360:2);, where <angle> is the angle you want to have the arrow at. IMHO the result looks better if you use the bending library for that, but spelling this out in detail goes beyond the space of a comment. – user121799 Oct 14 '18 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy