Skip to content

Instantly share code, notes, and snippets.

@jamesamiller
Last active July 7, 2020 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesamiller/dbf0bee09b38a0be50760fab353c2dce to your computer and use it in GitHub Desktop.
Save jamesamiller/dbf0bee09b38a0be50760fab353c2dce to your computer and use it in GitHub Desktop.
Another variation of a Tortoise and Hare Race (special relativity; spacetime diagram) #special_relativity #figure #text_notes
\documentclass[crop=true, border=10pt]{standalone}
\usepackage{comment}
\begin{comment}
:Title: Tortoise and Hare - Variation III
:Author: J A Miller, UAH Physics & Astronomy, millerja@uah.edu
2020/07/06
Spacetime diagram of a tortoise-hare race. The third variation.
References:
1. https://www1.phys.vt.edu/~takeuchi/relativity/practice/problem05.html
2. Basic plot style and colors from
https://gist.github.com/mcnees/45b9f53ad371c38ba6f3759df5880fb1
---------------------------------------------------------------------
Problem to accompany figure
---------------------------------------------------------------------
See the above reference.
---------------------------------------------------------------------
Figure caption
---------------------------------------------------------------------
\caption{
Spacetime diagram of a relativistic race between a tortoise and a hare. \textit{Blue arrows:} The unprimed $x$-$t$ frame of the ground and the referee, and the worldline of the finish line. \textit{Red arrows:} The primed frame of the tortoise, with the tortoise worldline being the $t^\prime$ axis. \textit{Green arrows:} The double primed frame of the hare, along with its worldline. \textit{Orange arrows:} Light rays from points H and B. \textit{Dashed lines:} Lines of simultaneity in the appropriate frame.
}
---------------------------------------------------------------------
Solution to problem
---------------------------------------------------------------------
See reference.
\end{comment}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{xcolor}
\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4}
\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529}
\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941}
\definecolor{scarlet}{rgb}{0.8, 0, 0}
\definecolor{brick}{rgb}{0.64314, 0, 0}
\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0}
\definecolor{lightblue}{rgb}{0.15,0.35,0.75}
% ----------------------- parameter specifications ------------------------
% the speed of the primed frame (tortoise)
% NOTE: this can be varied within reasonable limits.
\newcommand*\vp{0.4}
% the speed of the double primed frame (hare)
\pgfmathsetmacro{\vpp}{-\vp} % note negative
% starting location of hare
% NOTE: this can be varied within reasonable limits.
\newcommand*\xs{7.0}
% finish line
\pgfmathsetmacro{\xf}{\xs/2}
% graph boundaries
\newcommand*{\xa}{-3} % lower left corner
\newcommand*{\ya}{-4}
\newcommand*{\xb}{12} % upper right corner
\newcommand*{\yb}{14}
% x and y scales
\newcommand*{\xscale}{1cm}
\newcommand*{\yscale}{1cm}
% some more calculations now ...
% gamma and eta factors for the primed frame
\pgfmathsetmacro{\gamp}{1/sqrt(1-\vp*\vp)}
\pgfmathsetmacro{\etap}{\vp*\gamp}
% gamma and eta factors for the double primed frame
\pgfmathsetmacro{\gampp}{1/sqrt(1-\vpp*\vpp)}
\pgfmathsetmacro{\etapp}{\vpp*\gampp}
% ----------- other functions (may not always use) ------------------
% Extract coordinate
% https://tex.stackexchange.com/questions/477075/coordinates-unit-in-pt-although-default-is-cm-in-tikz
% Example:
% \ExtractCoordinate{x};
% \node[above] at (\XCoord,\YCoord) {node};
\newdimen\XCoord
\newdimen\YCoord
\newcommand*{\ExtractCoordinate}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}
% ------------------------ begin figure ------------------------------
\begin{document}
\begin{tikzpicture}[
scale=1,
domain=\xa:\xb,
x=\xscale,y=\yscale,
axisarrow/.style=-{Latex[inset=0pt,length=10pt]},
minor gridlines/.style={cornflower!30,step=0.2,thin},
major gridlines/.style={cornflower!60,step=1.0,thin},
axes/.style={cornflower,thick,axisarrow}, % unprimed axes
primed axes/.style={scarlet,thick,axisarrow}, % primed axes
primed major gridlines/.style={scarlet!60,thin},
double primed axes/.style={chameleon,thick,axisarrow}, % double primed axes
double primed major gridlines/.style={chameleon!60,thin},
LOS/.style={cornflower,thick,dashed}, % line of simultaneity in unprimed frame
LOS primed/.style={scarlet,thick,dashed}, % line of simultaneity in primed frame
LOS double primed/.style={chameleon,thick,dashed}, % line of simultaneity in primed frame
light ray/.style={sunrise,thick,axisarrow},
textnode/.style={inner sep=0pt}, % for a text only node
dot/.style={circle,draw=scarlet!70,fill=scarlet!20,inner sep=1.5pt}
]
% This figure has a lot of major ticks. Need to increase the font size.
\tikzset{every node/.style={scale=1.3}};
% some coordinates
\coordinate (O) at (0,0);
\coordinate (H) at (\xs,0);
% Draw the grid for the unprimed frame
%\draw [minor gridlines] (\xa,\ya) grid (\xb,\yb);
\draw [major gridlines] (\xa,\ya) grid (\xb,\yb);
% Draw unprimed axes
\draw[axes,name path=taxis] (0,\ya) -- (0,\yb);
\node[textnode] at (0.25,\yb-0.5) {$t$};
\draw[axes,name path=xaxis] (\xa,0) -- (\xb,0);
\node[textnode] at (\xb-0.5,-0.25) {$x$};
% Draw the primed axes
\draw[primed axes,name path=tpaxis] (\vp*\ya,\ya) -- (\vp*\yb,\yb) node (tp) {};
\node[textnode] at ($(tp)+(0,-0.5)$) {$t^\prime$};
\draw[primed axes,name path=xpaxis] (O) -- (\xb,\vp*\xb) node (xp) {};
\node[textnode] at ($(xp)+(-0.2,-0.4)$) {$x^\prime$};
% Draw the double primed axes
\draw[double primed axes,name path=tppaxis] (O) -- (\xa,\xa/\vpp) node (tpp) {};
\node[textnode] at ($(tpp)+(0.5,0)$) {$t^{\prime\prime}$};
\draw[double primed axes,name path=xppaxis] (O) -- (\ya/\vpp,\ya) node (xpp) {};
\node[textnode] at ($(xpp)+(-0.2,0.4)$) {$x^{\prime\prime}$};
% worldline for the hare
\draw[double primed axes,name path=wlh] (\vpp*\ya+\xs ,\ya) -- (\vpp*\yb+\xs, \yb);
% finish line
\draw[axes,name path=finish] (\xf,\ya) -- (\xf,\yb);
% make some points...
\coordinate (E) at (\xf,\xf/\vp);
\coordinate (G) at ({(\xs/\vpp)/(1/\vpp-\vp)},{ \vp*(\xs/\vpp)/(1/\vpp-\vp)});
\coordinate (H) at ({\xs},{0)});
\coordinate (I) at ({ \xs*\gampp*\gampp },{\vpp*\xs*\gampp*\gampp });
% light rays from B and H
\coordinate (F) at ({(\xs/\vpp)/(1/\vpp-1)},{((\xs/\vpp)/(1/\vpp-1) - \xs)/\vpp});
\draw[light ray] (O) -- (F);
\coordinate (D) at ({ \xs/(1/\vp+1) },{ \xs/(1/\vp+1)/\vp });
\draw[light ray] (H) -- (D);
% lines of simultaneity
\pgfmathsetmacro{\tpH}{\gamp*(-\vp*\xs)};
\pgfmathsetmacro{\tppH}{\gampp*(-\vpp*\xs)} % they should differ in sign
\coordinate (A) at ({\etap*\tpH},{ \gamp*\tpH });
\draw[LOS primed] (H) -- (A);
\coordinate (C) at ({ (\tppH/\gampp)/(1/\vp - \vpp) },{ (\tppH/\gampp)/(1/\vp - \vpp)/\vp });
\draw[LOS double primed] (H) -- (C);
% label the nodes at the end
\node[dot,label={right:E}] at (E) {};
\node[dot,label={right:G}] at (G) {};
\node[dot,label={right:H}] at (H) {};
\node[dot,label={above right:I}] at (I) {};
\node[dot,label={above left:B}] at (O) {};
\node[dot,label={right:F}] at (F) {};
\node[dot,label={left:D}] at (D) {};
\node[dot,label={left:A}] at (A) {};
\node[dot,label={left:C}] at (C) {};
% couple of labels, manually set
\node[textnode,label={right: Tortoise Worldline}] at (5.0,12.5) {};
\node[textnode,label={right: Hare Worldline}] at (4.1,7.2) {};
\node[textnode,label={Finish Line}] at (3.4,-3.6) {};
\end{tikzpicture}
\end{document}
@jamesamiller
Copy link
Author

fig-hareIII

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment