Skip to content

Instantly share code, notes, and snippets.

@jamesamiller
Created July 6, 2020 17:41
Show Gist options
  • Save jamesamiller/804e6432a01ce4e27a4734b7eb073b93 to your computer and use it in GitHub Desktop.
Save jamesamiller/804e6432a01ce4e27a4734b7eb073b93 to your computer and use it in GitHub Desktop.
Spacetime diagram of a rescue mission to a planet (special relativity)
\documentclass[crop=true, border=10pt]{standalone}
\usepackage{comment}
\begin{comment}
:Title: Supernova Rescue
:Author: J A Miller, UAH Physics & Astronomy, [email protected]
2020/07/01
A starship rescue for a planet about to be hit by supernovae gamma rays
References:
1. https://www1.phys.vt.edu/~takeuchi/relativity/practice/problem13.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 the starship Einstein on a rescue mission to a planet about to be destroyed by a supernovae in another system. \textit{Blue arrows:} The unprimed frame of the pre-supernova star and planet (assumed to be at rest with respect to each other). \textit{Red arrows:} The primed frame of the Einstein. (The $t^\prime$ axis is the worldline of the Einstein in the star-planet frame.) \textit{Purple arrows:} The worldlines of the star and planet. \textit{Green arrows:} Light rays from the supernova. \textit{Dashed lines:} Lines of simultaneity. For Exercise \ref{exer-superrescue}.
}
---------------------------------------------------------------------
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
\newcommand*\vp{0.6666}
% time when star explodes
\newcommand*\tex{7.5}
% x location of star
\newcommand*\xs{3}
% x location of planet
\newcommand{\xp}{6}
% graph boundaries
\newcommand*{\xa}{-1} % lower left corner
\newcommand*{\ya}{-1}
\newcommand*{\xb}{10} % upper right corner
\newcommand*{\yb}{14}
% x and y scales
\newcommand*{\xscale}{1cm} % square up the diagram a bit
\newcommand*{\yscale}{0.75cm}
% some calculations now ...
% gamma and eta factors for the primed frame
\pgfmathsetmacro{\gamp}{1/sqrt(1-\vp*\vp)}
\pgfmathsetmacro{\etap}{\vp*\gamp}
% ---------------- 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={chameleon,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}
]
% some coordinates
\coordinate (O) at (0,0);
\coordinate (S) at (\xs,\tex);
% 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] (O) -- (\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$};
% Worldlines for star and planet
\draw[thick,plum,axisarrow,name path=wstar] (\xs,0) -- (\xs,\tex);
\draw[thick,plum,axisarrow,name path=wplanet] (\xp,0) -- (\xp,\yb);
% Light from star explosion
\draw[light ray,name path=wlsleft] (\xs,\tex) -- (0,\tex+\xs);
\draw[light ray,name path=wlsright] (\xs,\tex) -- (\xs+\yb-\tex,\yb);
\coordinate (C) at (6,\tex+3);
\coordinate (H) at ( {(\tex-\xs)/(1/\vp-1)}, {(\tex-\xs)/(1/\vp-1)/\vp} );
% some LOS
\draw[LOS] (0,\tex) -- (\xp,\tex);
\draw[LOS] (0,\tex) -- (\xp,\tex);
% find $t^\prime$ for S
\pgfmathsetmacro{\tpS}{\gamp*(\tex-\vp*\xs)}
% LOS from S to G
\coordinate (G) at (\tpS*\etap,\tpS*\gamp);
\draw[LOS primed] (S) -- (G);
\coordinate (D) at (\xp,\vp*\xp+\tpS/\gamp);
% LOS through E
\coordinate (E) at (\xp,\xp/\vp);
\draw[LOS] (0,\xp/\vp) -- (E);
\pgfmathsetmacro{\tpE}{\xp/\etap};
\coordinate (A) at ( {\xs}, {\vp*\xs+\tpE/\gamp} );
\draw[LOS primed] (A) -- (E);
\node[dot,label={above:S}] at (\xs,\tex) {};
\node[dot,label={right:F}] at (\xp,\tex) {};
\node[dot,label={right:G}] at (G) {};
\node[dot,label={above left:D}] at (D) {};
\node[dot,label={above left:C}] at (C) {};
\node[dot,label={left:H}] at (H) {};
\node[dot,label={left:B}] at (\xs,\xs/\vp) {};
\node[dot,label={right:E}] at (E) {};
\node[dot,label={left:A}] at (A) {};
% some manual labels
\node[textnode] at (\xp+0.6,2.5) {Planet};
\node[textnode] at (\xs+0.4,1.2) {Star};
%\node[textnode] at (1.7,10.5) {Supernova Energy};
%\node[textnode] at (\xp+0.5,12.5) {Supernova Energy};
\end{tikzpicture}
\end{document}
@jamesamiller
Copy link
Author

fig-Supernova Rescue

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