# graph of pendulum

How can I create the arrows on the ball with captions like the one in the picture?

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,patterns,angles,quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (centro) at (0,0);
\draw[dashed,gray,-] (centro) -- ++ (0,-3.5) node (mary) [black,below]{};
\draw[thick] (centro) -- ++(300:3) coordinate (bob);
\fill (bob) circle (0.1);
\pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = mary--centro--bob};
\end{tikzpicture}
\end{document}

• Now that you started drawing the picture, instead of just asking other people for doing your work, where are you struggling in detail? Your question is unclear. – JMP Apr 18 '16 at 19:49
• @JMP I have just edit the post – Ilmionome456 Apr 18 '16 at 20:07
• To draw the annotations you could for example simply place a node with \node at (x,y) {your text};. Here (x,y) is the coordinate to place your text. – JMP Apr 18 '16 at 20:10
• ok thanks but the problem are the arrow @JMP – Ilmionome456 Apr 18 '16 at 20:10
• The arrows you can draw with \draw[->] (x1,y1) -- (x2,y2);. – JMP Apr 18 '16 at 20:12

Some coordinate calculations, using the syntax of the calc library, and another pic. See section 13.5 Coordinate calculations in the manual of TikZ for a description of the library. Brief explanations for this case:

• ($(bob)!-\Gcos cm!(centro)$): This coordinate is the point that lies along the line from bob to centro, -\Gcos cm away from bob. The negative number means that the coordinate lies "behind" bob.

• ($(bob)!\Gsin cm!90:(centro)$): This coordinate is the point that lies \Gsin cm away from bob, at an angle of 90 degrees away from the line between bob and centro.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,patterns,angles,quotes}
\begin{document}
\begin{tikzpicture}
% save length of g-vector and theta to macros
\pgfmathsetmacro{\Gvec}{1.5}
\pgfmathsetmacro{\myAngle}{30}
% calculate lengths of vector components
\pgfmathsetmacro{\Gcos}{\Gvec*cos(\myAngle)}
\pgfmathsetmacro{\Gsin}{\Gvec*sin(\myAngle)}

\coordinate (centro) at (0,0);
\draw[dashed,gray,-] (centro) -- ++ (0,-3.5) node (mary) [black,below]{};
\draw[thick] (centro) -- ++(270+\myAngle:3) coordinate (bob);
\pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = mary--centro--bob};
\draw [blue,-stealth] (bob) -- ($(bob)!\Gcos cm!(centro)$);
\draw [-stealth] (bob) -- ($(bob)!-\Gcos cm!(centro)$)
coordinate (gcos)
node[midway,above right] {$a\cos\theta$};
\draw [-stealth] (bob) -- ($(bob)!\Gsin cm!90:(centro)$)
coordinate (gsin)
node[midway,above left] {$a\sin\theta$};
\draw [-stealth] (bob) -- ++(0,-\Gvec)
coordinate (g)
node[near end,left] {$g$};
\pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = g--bob--gcos};
\end{tikzpicture}
\end{document}

• ! I can't find file "tikzlibraryangles.code.tex'. which version of pgf you are using? – CroCo Apr 18 '16 at 20:32
• @CroCo The latest that is in TeX Live 2015, which is 3.0.1a. – Torbjørn T. Apr 18 '16 at 20:39
• @CroCo That library was new in pgf/TikZ v3 I think. – Torbjørn T. Apr 18 '16 at 20:40
• @EnricoMariaDeAngelis Not a bad thought, edited. – Torbjørn T. Apr 19 '16 at 7:26
• Shouldn't it be g \sin \theta and g \cos \theta rather -- the vectors are decompositions of g, not of a – user31729 Apr 26 '16 at 20:24

For fun, a solution with pst-eucl:

\documentclass[border=5pt,x11names ]{standalone}

\usepackage{pst-eucl}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{pspicture}
\everypsbox{\scriptsize}
\psset{unit = 1.5, dotsize=6pt, dash=2pt 1.5pt, shortput=nab, arrowinset=0.15,PointName=none,  PointSymbol=none}
\pstGeonode(0,0){O}(2;-60){P}(0,-1.2){g}%(1; -70){T}
\pstTranslation{O}{g}{P}[G]
\pstProjection{O}{P}{G}[C]
\pstSymO{P}{C}[T]
\pstRotation[RotAngle=90]{P}{O}[s]
\pstProjection{P}{s}{G}[S]
{\psset{linestyle=dashed, linewidth=0.5pt}
\psline[](C)(G)(S)
\pstLineAB[nodesepA=-0.5, nodesepB=-2]{O}{g}}
\pstMarkAngle{g}{O}{P}{$\vartheta$}
\pstMarkAngle{G}{P}{C}{$\vartheta$}}
\ncline{P}{G}_{$g$} \ncline{P}{T}
\ncline[nrot=:U]{P}{C}\naput[nrot=:U]{$a\cos θ$}
\ncline[nrot=:U,  arrows=<-]{S}{P}\naput[nrot=:U]{$a\sin θ$}