0

Parabol physics

I would like not only to know how to do it but also with any help to point out to me some resources in order to be able to draw any Physics figures out there.

1 Answers1

9

There you go.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[>=latex]
  % Ground
  \fill[pattern=north east lines] (-.5,-.3) rectangle (5.5,0);

  % Axes
  \draw[->] (-.5,0) -- (5.5,0) node[above] {$x$};
  \draw[->] (0,-.5) -- (0,2.2) node[right] {$z$};
  \draw[->] (-.5,1.25) node[left] {$\vec{g}$} -- (-.5,.75);

  % Parabola
  \def\a{-.25}
  \def\xn{2.5}
  \draw[dashed,blue,->] plot[domain=0:5] (\x,{\a*((\x-\xn)^2 - (\xn)^2)});

  % Draw initial velocity
  \draw[->] (0,0) -- (.5,{\a*(0-\xn)}) node[above left] {$\vec{v}_0$};
  \draw (.5,0) node[above right] {$\theta$} arc (0:{atan(\a*(0-\xn)/.5)}:.5);

  % Draw ball
  \def\xb{1}
  \node[draw,circle,shade,ball color=red] at (\xb,{\a*((\xb-\xn)^2 - (\xn)^2)}) {};
  \draw[->] (\xb,{\a*((\xb-\xn)^2 - (\xn)^2)}) -- +(.5,{\a*(\xb-\xn)}) node[above] {$\vec{v}(t)$};
\end{tikzpicture}
\end{document}

enter image description here


Just for fun!

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\foreach \xb in {0,.1,...,5} {
  \begin{tikzpicture}[>=latex]
    % Ground
    \fill[pattern=north east lines] (-.5,-.3) rectangle (5.5,0);

    % Axes
    \draw[->] (-.5,0) -- (5.5,0) node[above] {$x$};
    \draw[->] (0,-.5) -- (0,2.2) node[right] {$z$};
    \draw[->] (-.5,1.25) node[left] {$\vec{g}$} -- (-.5,.75);

    % Parabola
    \def\a{-.25}
    \def\xn{2.5}
    \draw[dashed,blue,->] plot[domain=0:5] (\x,{\a*((\x-\xn)^2 - (\xn)^2)});

    % Draw initial velocity
    \draw[->] (0,0) -- (.5,{\a*(0-\xn)}) node[above left] {$\vec{v}_0$};
    \draw (.5,0) node[above right] {$\theta$} arc (0:{atan(\a*(0-\xn)/.5)}:.5);

    % Draw ball
    \node[draw,circle,shade,ball color=red] at (\xb,{\a*((\xb-\xn)^2 - (\xn)^2)}) {};
    \draw[->] (\xb,{\a*((\xb-\xn)^2 - (\xn)^2)}) -- +(.5,{\a*(\xb-\xn)}) node[above] {$\vec{v}(t)$};
  \end{tikzpicture}
}
\end{document}

After typesetting, produce the animated gif using ImageMagick

$ convert -density 300 -delay 8 -loop 0 -background white -alpha remove test.pdf test.gif
Henri Menke
  • 109,596
  • Wow thousand thanks @Henri Menke !!! Please I would like to understand the code as well . Could you point out me resources who go straight to the point learning step by step how to figure out this and the animate gif because it will be useful for Beamer Presentation? – Ousseynou Diagne Oct 13 '16 at 23:54
  • @OusseynouDiagne I learned about all this by reading part I »Tutorials and Guidelines« in the TikZ manual. Don't be scared by the huge page count. Most of the manual is a reference and not intended for actual reading. The tutorials are only about 100 pages but already after the first one you should be able to understand the above answer. – Henri Menke Oct 14 '16 at 06:58
  • Thank you @HenriMenke it makes sense I know what is going on behind the scene. I am going to learn it down the road if I face any problem I will post the question. – Ousseynou Diagne Oct 14 '16 at 10:52
  • Please could I have the animate code @HenriMenke – Ousseynou Diagne Nov 04 '16 at 12:21
  • Please @HenriMenke add a player with a ball and the hoop as my new post. There are difference between the 2 posts. – Ousseynou Diagne Dec 27 '16 at 00:26