Minkowski Spacetime Diagram Generator (Matlab)

Page

Matlab code to generate simple Minkowski Spacetime Diagram showing an event in S and S'. Both the S and S' axes are drawn, coinciding at the origin. The tick marks are calculated for the S' axes, and lines are drawn from the event on the S axes, showing intersection with the S' axes. Light wordlines from the origin and from the event to an observer at the origin of S can also optionally be drawn.

The function can be called directly, or via a simple GUI. The GUI only allows one event to be added. Usage

[eventXP, eventTP, gamma, ds] = make_spacetime(ax, v, nEvents, eventX, eventT, [name, pair, ...])

Required Parameters

ax : axes to draw diagram on.
v : velocity of moving observer (S') as a fraction of c.
nEvents : number of events to draw.
eventX : vector of x positions (in S) for each event.
eventT : vector of time (ct) (in S) for each events.

Optional Name-Pair Values

drawLightLine : 1 to draw worldline of light from origin (default is no).
drawLightPaths : 1 to draw light worldline from event to observer S (defualt is no).
scaleLimit : Scales run from -this to +this (default is 10).

Returns

eventXP : vector of x' positions (in S') for each event.
eventTP : vector of time (ct') positions (in S') for each event.
gamma : gamma factor.
ds : space-time distance invariant (squared).

Example

```figure(1);
ax = gca();

v = 0.5; % Velocity of frame S' in units of c
nEvents = 2; % No of events
eventX = [3, 7]; % Event positions
eventT = [3, 2]; % Event times in units of c

[eventXP, eventTP, gamma, ds] = make_spacetime(ax, v, nEvents, eventX, eventT, 'drawLightLine', 1, 'drawLightPath', 1, 'scaleLimit', 15);

axis equal```