3

I want to be able to create particle motion diagrams for a calculus or physics class that look like this;

Particle Motion Diagram

This is what I had at the time of posting the question:

    \documentclass[12pt]{article}
enter code here
    \usepackage{mathptmx} % rm & math
    \usepackage[scaled=0.90]{helvet} % ss
    \usepackage{courier} % tt
    \normalfont 
    \usepackage[T1]{fontenc}
    \usepackage{amsmath}
    \usepackage{graphicx}
    \usepackage{amssymb}
    \usepackage{multicol}
    \usepackage{graphpap}
    \usepackage[normalem]{ulem}
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.8}
    \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

    \begin{document}

    \begin{tikzpicture}
      % an arrow
      \draw[-latex][line width=.3mm] (0,0) -- (6,0);
      \node at (5.9, -0.3) {$s$};
      \node at (1,0) {\circle*{4.0}};
      \node at (1, -0.5) {$t = 0$};
      \node at (1, -1.0) {$s = 0$};
      \node at (5,0) {\circle*{4.0}};
      \node at (5, -0.5) {$t = 1$};
      \node at (5, -1.0) {$s = 4$};
    \end{tikzpicture}

    \end{document}
Mike
  • 33
  • 2
    Welcome to TeX.SX! As you've tagged the question with tikz-pgf, what have you tried so far using that package? – siracusa Feb 18 '19 at 01:10

1 Answers1

3

Welcome to TeX.SE! The idea of this site to help you when you have problems with your code, not so much converting screen shots into LaTeX code. For newcomers, sometimes exceptions are made.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{ arrows.meta,bending,decorations.markings,positioning}
\begin{document}
% from https://tex.stackexchange.com/a/430239/121799
\tikzset{% inspired by https://tex.stackexchange.com/a/316050/121799
    arc arrow/.style args={%
    to pos #1 with length #2}{
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{#2/(\pgfdecoratedpathlength)}
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime/3} with {\coordinate(@2);},
        mark=at position {#1-\tmpArrowTime/3} with {\coordinate(@3);},
        mark=at position {#1} with {\coordinate(@4);
        \draw[-{Stealth[length=#2,bend]}]       
        (@1) .. controls (@2) and (@3) .. (@4);},
        },
     postaction=decorate,
     },
fixed arc arrow/.style={arc arrow=to pos #1 with length 2mm}     
}

\begin{tikzpicture}[bullet/.style={circle,inner sep=1.5pt,fill}]
 \pgfmathsetmacro{\rad}{0.3} % arc radius in cm
 \draw[-{Stealth[length=4pt]}] (-1,0) -- (5,0) node[bullet,pos=1/6] (O){} 
 node[bullet,pos=5/6] (X){} node[pos=1,below]{$s$};
 \node[below=0pt of O,align=center]{$t=0$\\ $s=0$};
 \node[below=0pt of X,align=center]{$t=1$\\ $s=4$};
 \draw[cyan,fixed arc arrow/.list={0.15,0.25,...,0.951}] 
  (0,0.5) node[bullet]{} to ++(4-\rad,0) 
  arc(-90:90:\rad) node[midway,bullet]{} to ++(-4+2*\rad,0)
  arc(-90:-270:\rad) node[midway,bullet] (b2){} to ++(5-\rad,0);
 \node[above=\rad*1cm of b2,align=center]{$t=3$\\ $s=0$};
\end{tikzpicture}
\end{document}

enter image description here

  • 2
    Thank you so much! I was not expecting someone to give me all of the code to do this, but this is beyond extremely helpful. Now I can modify this to make any similar diagram of this type. I was just about to upload my code. It is really the blue arrow that I had no idea how to address. This is what I had. – Mike Feb 18 '19 at 02:42
  • 1
    @Mike You're welcome! (For the present application, the arc arrow may a bit of an overkill because the arrows are mainly along straight stretches. On the other hand, this also works if the arrows are along curved stretches, where "works" means the arrows will get bent. If you want save compilation time in this example, you may want to use https://tex.stackexchange.com/a/39282/121799 .) –  Feb 18 '19 at 02:46