Worldlines - An Interactive Special Relativity Visualization

Tyler Florez
Physics Department
California Polytechnic State University
San Luis Obispo, California
March 15, 2010
© 2010 Tyler Florez

“Worldlines” is an interactive visualization of Special Relativity which presents particle paths in a 3D slice (2 space + 1 time) of the 4D Minkowski spacetime. The displayed coordinate space can be changed between the world frame and the frame of a “target” particle by toggling the space and time components of the Lorentz transformation for the currently targeted frame. Scenarios and phenomena presented include the twin paradox (time dilation), length contraction and Bell's spaceship paradox. Graphical elements include particle paths, coordinate axes, simultaneity planes and their particle intersections, pulsing clocks, and clock tick history. Scripted and free-exploration modes are available, with a focus on intuitive controls for accelerating to, and steering near, light speed.


1.1 Time Dilation & the Lorentz Factor

Special Relativity (SR) is fascinating because it suggests that some of the seemingly foundational aspects of normal experience (and the physical reality which underpins it) aren't quite so in general. The forward flow of time, which once seemed an inescapable constant, uniform for all observers, turns out to be completely dependent upon the relative velocity of entities. Frames of reference in relative motion record each other's clocks as advancing more slowly, as given by the time dilation factor:
γ dt/d τ  , the Time Dilation Factor
Here d τ and dt are infinitesimal time increments, where d τ corresponds to the proper time τ measured between events by a clock at rest in a given frame, and dt corresponds to the time intervals t between the same events given by the first clock, but as measured in another coordinate frame. Thus γ gives the ratio of time intervals as measured by a pair of clocks in different frames.
The time dilation factor is given by the Lorentz term, which is crucial in SR:
γ (v)= 1 1- v 2 / c 2  , the Lorentz Factor
Where v is the speed of one frame relative to another, and c is the speed of light. Because all objects with mass move slower than light, as their speed v<c increases, then 1- v 2 / c 2 <1 approaches 0 , and thus γ >1 goes to positive infinity.
Thus, we can see how clocks at relativistic speeds are seen to advance at a reduced rate, as proper time intervals Δ τ in the clock's rest frame appear stretched according to the time dilation factor:
Δ t= γ Δ τ
This gives the relation between the proper time τ (measured by a clock at rest in an inertial frame, present at events e 1 and e 2 ) and the general time t associated with the span between the same events (for example by a pair of separate, synchronized clocks in an arbitrary inertial frame, each only present at one event).
(See Section 2.2 on the Twin Paradox for the classic Time Dilation example.)

1.2 Universal Speed of Light and Velocity Addition

The speed of light, a constant according to SR, shatters another foundation of our experience - the idea that we can generally approach the velocity of objects moving relative to us by accelerating out of our old frame of reference. This is not true in the case of light, as time dilation conspires to ensure that our clocks slow down as we approach the velocity of photons (as seen from an external frame) so that they always seem to remain at c relative to us.
Our inability to catch up with light is a special case of SR's contradiction of Galilean velocity addition; in SR, if we are interested in the velocity u of an object, then finding the velocity u B as measured in frame B with known velocity u A as measured in frame A is no longer as simple as saying:
u B = u A - v B,A = u A + v A,B
 Galilean velocity addition ( not generally true )
(Where the notation u B reads “the velocity u as measured in B” and v A,B reads “the velocity of frame A as measured in B.”) Instead, we now have the following relation for parallel velocities:
u B = u A + v A,B 1+ u A v A,B / c 2  , velocity addition in SR

1.2.1 Velocity Addition Example

For example, if u represents the speed of a light particle, and frame A moves away from B at half of light speed, then using geometrized natural units (here defining the unit velocity as the speed of light, with c=1 ) we have: u photon,A =c=1 and v A,B =0.5 , so:
u photon,B = 1+0.5 1+1*0.5 = 1.5 1.5 =1
This is no surprise, since the relation u B =1 holds for any relative speed v A,B between the two frames when u A =1 :
u B = 1+ v A,B 1+1* v A,B / 1 2 = 1+ v A,B 1+ v A,B =1

1.3 Length Contraction

Just as time dilation describes how moving clocks are seen to run slower, length contraction in SR tells us that distances measured outside an object's rest frame appear contracted along the direction of motion. Like the proper time τ , an object's proper length L 0 measured in its frame of rest is related to the length L in general frames of motion by the Lorentz factor:
L= L 0 γ With the proper length divided by γ >1 , we see the distance L 0 will be the longest seen in any frame.

1.4 Coordinate Transformations

The Lorentz equations which map event coordinates ( x,t ) in frame S to ( x',t' ) in frame S' (moving in S along the x direction at speed v ) are:
x' = γ ( x-vt ) t' = γ ( t-vx/ c 2 )
The Lorentz transformation can be expressed using a matrix L which performs an operation mapping column vectors x to x' (mixing the space and time components in the process in a rotation-like fashion). The equation for the transformed space-time component x' takes the general form:
x' = L x
In the Worldlines program, I've used the following explicit matrix form for the Lorentz transformation in the case of one-dimensional motion along the positive x direction:
[ x' y' ct' ]=[ γ 0 - β γ 0 1 0 - β γ 0 γ ][ x y ct ] Where:  β =v/c
Similarly, the inverse Lorentz transform, which takes coordinates in the moving frame just described and maps them into the world frame, has the general form:
x= L -1 x'
Where I've used the following explicit matrix form:
[ x y ct ]=[ γ 0 β γ 0 1 0 β γ 0 γ ][ x' y' ct' ]
This is basically the standard configuration for the Lorentz transformation (but with the time coordinate listed last), in which the difference between the forward and inverse transformations is just a change in sign.

1.4.1 Use in Worldlines

For example, when drawing the axes basis and grid of a particle, the inverse transform corresponding to v particle is used to map r basi s rest , the basis vectors of the particle's coordinate system in its rest frame, into the world frame:
r basi s world = L -1 ( r basi s rest , v particle )
Then, any display transforms for the target particle are applied to the world coordinates of the vector:
r basi s display =L( r basi s world , v target )
Where the functions L and L -1 apply the regular or inverse Lorentz transformation matrix to the vector r , given velocity v .
In constructing L suitable for 2 dimensional velocities v , first an inverse rotation matrix for the particle's heading is applied; this is then multiplied by the 1D Lorentz matrix; last the regular rotation matrix is applied:
L 2D (v)=R( θ v ) L 1D (v) R -1 ( θ v )
Where:  θ v =ta n -1 ( v y / v x )


2.1 Axes Scene - Coordinate Transforms & the Simultaneity Plane

The goal of the axes scene (Figure 1) is to show how the system of rest coordinates for a moving particle are mapped into the rest frame of other particles - here, the “world frame” - within which the first particle is moving. The basis vectors for the world frame are labeled ( x,y,ct ) ; and those for the moving particle are labeled ( x',y',ct' ) .
The vector ct' represents the particle's 3-velocity - here through the (2+1) Minkowski space, analogous to the 4-velocity in real-world 4D spacetime. The point is that ct' is always tangent to the particle's path, and shows where the particle will be if it keeps its current velocity. The vector ct' is notable because in SR, it is not generally perpendicular to the x'y' plane in all frames of reference. That is, space and time between different frames are mixed - motion only along time (parallel to ct' ) for the moving particle in frame S' has a changing spatial component in frame S (along x in Figure 1).
For any frame S' , the x'y' plane gives the surface of simultaneity; events in this plane are simultaneous for observers within the frame. The phenomena of relativity of simultaneity refers to the fact that given events A, B, and C such that A and B are simultaneous in frame S , and B and C are simultaneous frame S' , events A and C will generally not be simultaneous in either frame S or S' .
The axes scene (Figure 2) begins with a few simple particles at rest for reference, and a single “driven particle” whose velocity component v x is defined as a sine wave oscillating between 0 and 0.99c , completing a cycle every 200s in the world frame. The driven particle has been made the “target particle”, meaning it's tracked by the camera, and that any coordinate (Lorentz) transforms later activated for display will be done for γ between it and the world frame.
Clicking on the particle selects it, showing its identification and some information about its state. In Figure 3 for example, we see an already dramatically stretched axes at 0.95c nearly completely collapses with just a ~0.037c increase to 0.988c .
In Figure 4, the particle is again at 0.95c , but now the Lorentz transforms have been activated - meaning the coordinate space used for display now matches the space of the target particle. This is why the ct' and x' basis vectors again appear orthogonal (even at this high speed), since we are now in the the rest frame of the particle. The ct and x basis have been skewed in the opposite directions, stretching off-screen.

2.2 Twin Paradox Scene

2.2.1 The Scenario

In the twin paradox, a pair of identical twins (A and B) begin at a common starting location. Twin B departs at a constant speed v , while twin A remains at rest. Some time later for twin B, Δ τ B , twin B reverses course and returns to A.

2.2.2 The Effect and Observables

If each of the twins carry clocks to record the duration of their trip to be compared upon B's return, they will find a discrepancy between their measurements for the total elapsed time of the trip. That is, the elapsed time τ A observed by twin A (who remained at the initial point of departure) will always be greater than τ B for twin B:
τ A > τ B  , Elapsed Propertime in Twin Paradox
In other words, the twins' age difference should be greater than zero:
Age Difference in Twin Paradox:
Δ τ A-B = τ A - τ B >0
The age difference in the twin paradox is a particular result of time dilation. In general, the inertial (non-accelerating) path through spacetime is the longest possible, whether the length under consideration is simply the proper time, or is formulated as the Lorentz invariant:
The Lorentz Invariant: ( Δ s ) 2 =(c Δ t ) 2 -( Δ x ) 2 -( Δ y ) 2 -( Δ z ) 2
Kogut p.49 (1)
This startling effect becomes more noticeable at very high (i.e. relativistic) speeds; see the Multiple Twins scenario in Section 2.3 for a bit more on this.

2.2.3 Twin Paradox Example

Problem Setup:

Suppose twin B departs at velocity v B (say, 0.9c ) and begins its return at proper time τ turnaround,B (say, 50s ). If twin A remains at rest, we can find the age τ meet for each.

Solving for τ meet,A :

Finding twin B's age is straightforward:
τ meet,B = 2* τ turnaround,B τ meet,B = 2*50s=100s
Similarly, twin A ages by twice B's turnaround time - but in A's own frame:
τ meet,A =2* t turnaround,A
Since twin B's local clock measures proper times τ B which appear dilated when seen as t A for twin A at rest in the world frame, we have:
t A = γ τ B τ meet,A =2* t turaround,A =2*( γ τ turnaround,B )
γ =1/ 1- v B 2 / c 2
γ =1/ 1-0. 9 2 =1/ 1-0.81 =1/ 0.19 =2.294
So finally, τ meet,A =2*2.294*50s=229.4s
This is reasonable, since 229.4s>100s giving τ A > τ B as expected. For reference, their age difference is Δ τ A-B =129.4s .

Check result with simulation:

Figure 7 shows the conclusion of the twin paradox scene with v B =0.9c and τ turnaround,B =50s . Twin B's age can be verified visually, with 10 segments between yellow clock history ticks, each marking an elapse of 10s for the particle's proper time. This gives τ meet,B =10*10s=100s as required in the problem setup.
Twin A is selected, so its age is displayed beneath it. The result is τ A,meet,program =229.6s , which is very close to the 229.4s expected from the calculation. The 0.2s error is due to the time step used to update the particles, and the simple logic used to decide when twin B should begin its return and when the program should consider the particles to have met (pausing the scene).
For convenience, the meter at the bottom shows the currently accumulated age difference between the twins at each step in the simulation, where “current difference” uses twin A's conception of simultaneity in the world rest frame. The resulting age difference shown Δ τ A-B,program =129.53s , also close to the expected value of 129.4s .
The meter gives the user an intuitive sense for how the values are changing as the program runs in real-time. In this case, the sense the user should get is that the age difference accumulates smoothly, as seen in the world frame of twin A.

2.2.4 The Paradox

The “paradox” in this scenario stems from the seeming discrepancy between the symmetry of relative motion between the twins, and the asymmetry between the effect on their rate of temporal experience (and thus, age). See Figure 9 in Section 2.3 for a visualization of the asymmetry resolving the paradox - the fact that Twin B turns around, while Twin A does not.

2.3 Multiple Twins Scene

2.3.1 Scene Layout and Invariant Surfaces

The Multiple Twins Scene shows multiple “B twins” departing at the same time from a single twin A. Twins B.1 through B.8 have velocities spaced 0.1c apart, with v x from 0.1c to 0.8c .
Looking in Figure 8 at the curves formed by ticks corresponding to the same time (ie, tic k 1 =10s ) between the particles (before the turnaround at τ =50s ), one can see the surfaces of “constant time” for a traveler starting at the origin of departure. In worlds like ours for which SR holds true, these surfaces appear curved in any reference frame due to the time dilation effect between different frames. If SR were not true, the surfaces would be flat, indicating an absolute (rather than relative) time between different reference frames.

2.3.2 The Asymmetry of the Turnaround (Resolving the Paradox)

Figures a through d show the asymmetry in the twin paradox. In the world frame (Figure a), by the time twin B reaches τ B =50s (that is, by his clock), twin A has already missed the opportunity to take the action which twin B now takes, changing his frame of reference by reversing his velocity. This is seen by looking at the clock tick history in the last image (Figure d), where we see that just after twin B turns, just over 80s has elapsed for twin A. Figures b and c show how this turnaround looks from the frame of twin B just before and after the acceleration.

2.3.3 Visualizing Twin B Before and After Turnaround

2.4 Length Contraction Scene

2.4.1 Length Contraction Scene Layout

The goal of the Length Contraction Scene is to show how fixed lengths measured in the world frame are contracted in the rest frame of a particle at relativistic speeds. Figure 10 shows the layout of the length contraction scene in the world rest frame - a single driven target particle ( v x oscillating from 0 to 0.99c every 200s ), uniform grid of particles at rest, and their intersections with the target's surface of simultaneity.
To emphasize the contraction effect, the target particle in this scene undergoes dramatic, oscillating acceleration. The simple, dense spacing of the particle field is chosen in hope of leveraging the user's spatial intuition to help give a better feel for the nature of the transformations shown. Particle path intersections with the target's simultaneity plane take focus here, as we use them to show how distances between events simultaneous for the moving particle are contracted in its frame of reference.

2.4.2 Visualizing Lorentz Contraction

2.4.3 Making a Distance Measurement

2.4.4 Checking the measurement

Here, the proper length between particles 1 and 51 is: L 0 =100ls . Plugging in v x,driven =0.989995c , we have:
γ =1/ 1-( v x,driven /c ) 2 =1/ 1-(0.98895 ) 2 =7.087049
L= L 0 / γ =100ls/7.087049=14.1102ls
From this, we see our measurement of 14.1 ls (Figure 17) is just what we would expect from the formula for Lorentz contraction.

2.5 Bell's Spaceship Paradox Scene

This is a fun scene (Figure 18) in which you can control a fleet of ships, which are modeled as idealized rigid bodies. The bodies are “attached” to a particle by defining body vertices at constant points in the particle's rest frame, which are then mapped by an inverse Lorentz transform to the world frame (followed by any active display transforms). Finally, the body is drawn as yellow lines between each body vertex every time the particle's frame changes due to acceleration (along with the body at the current simulation step).
You can accelerate the fleet in synchronization by pressing the arrow keys or the W, A, S, D keys, as demonstrated in Figures 19 and 20 (which show the results of the same acceleration sequence from the perspective of the world frame and the fleet's rest frame).
The paradox
is that each ship receives the same boost in the world frame - so the relative position of each ship in the fleet is preserved; their relative acceleration is 'uniform' by definition. Similarly, the internals of any particular ship appears preserved to its inhabitants, who are in its rest frame, so the acceleration appears 'uniform' to them as well.
Back in the world frame, the length of each moving ship contracts - which would intuitively seem to indicate the distance between the ships increases in their frame. But if the distance between the ships is increasing, what happened to the 'uniformity' of the acceleration observed within each ship?
This preservation of internal distances hinges on how well our idealized rigid bodies holds up. The idea of preservation of distances in the rest frame is known as Born rigidity. Where this rigidity is and is not preserved seems to be at the crux of the paradox. A resolution to the paradox seems to be simply that it's possible to imagine cases where the rigidity is and is not preserved.
If one considers the fleet of ships as an entity, then Born rigidity is not preserved - though their positions are preserved in the world frame, Born rigidity is defined as preservation in the rest frame. In Figure 21, we see the target moving towards the fleet. Holding this velocity, we see from the path intersections that their locations in this frame are vastly stretched, confirming our expectation that the Born rigidity of the fleet is broken.
On the other hand, it seems theoretically plausible that a solidly bound entity like a particular ship (rather than an unconnected fleet) moving at relativistic speeds could have its Born rigidity essentially preserved, perhaps by the application of an external force, or perhaps by the interior attraction between parts of the ship's body, restoring the rigidity once the acceleration ceases.

Program Manual

3.1 Things to Try

3.1.1 Selecting Particles and Intersections

Left click to select particles and intersections. The object's name and state is shown, and a selection reticle is added. Any menu actions later selected will be applied to the currently selected particles.

3.1.2 Camera rotation (Right Mouse click on Background)

3.1.3 Camera zoom (Scroll Middle Mouse)

3.1.4 Change the target particle

Right click a particle, and choose “makeTargetParticle”. The target particle is followed by the camera, and can be accelerated with the keyboard.

3.1.5 Accelerate the target particle

Use the arrow keys or the W, A, S, D keys to boost the particle. Note: it's no use trying to accelerate driven particles - if a driven particle is the only target, try right clicking another particle in the scene, and make that the target. Also, turn on emissions to get a visual sense of the boost being applied to your targets.

3.1.6 Activate Emissions

Click the Use Emissions toggle to display propelled emissions when accelerated with the keyboard.

3.1.7 Attach a Rigid Body

Right click a particle and choose attachRigidBodies to add rigid body vertices.

3.1.8 Add a Distance Measurement

Select two objects, right click one, and select addDistanceMeasurement.

3.1.9 Move Particles

Left click a particle, then drag it to a new position.

3.2 Graphical elements

3.2.1 Worldlines

The particle paths through the 2+1 Minkowski space are shown in 3D as lines tracing the particle's history up to the current simulation step.

3.2.2 Pulsing particle clocks

A bright glowing orb located at each particle's current simulation step pulses with a frequency proportional to the rate proper time currently elapses for it in the simulation.

3.2.3 Clock Ticks

Colored ticks are displayed along each particles path, spaced at even intervals of proper time. Spacing is at intervals of 1 × 1 0 n s , where the exponent n is an integer which controls the tick spacing along each path, incrementing when 20 ticks are reached (to reduce screen clutter and increase performance). The tick size visually increases slightly with each exponent change, accompanied by a shift in color. The corresponding colors for each tick spacing interval are:
  1. 1 0 0 s red
  2. 1 0 1 s yellow
  3. 1 0 2 s orange
  4. 1 0 3 s green
  5. 1 0 4 s blue
  6. 1 0 5 s violet

3.2.4 Particle frame plane of simultaneity

The surface of constant time (corresponding to ct'=0 ) for each particle's current frame appears as a transparent plane defined by the x'y' axes.

3.2.5 Worldline intersections with target plane of simultaneity

Intersections between each particle's path and the target particle's plane of simultaneity are displayed by a selectable glowing clock pulse. These clock pulses now accurately reflect the particle's age in the target's current frame.

3.2.6 Particle frame axes basis

The axes basis for each particle's frame are displayed; mapped first into the world, and then display, coordinates. For the target particle, the labels ( x',y',ct' ) are displayed. Additionally, the basis for the simulation's world frame are displayed, labeled ( x,y,ct ) .

3.2.7 Particle frame axes coordinate grid

The coordinate grid for the target particle and the origin can be activated by toggles under the main panel. Units are displayed in light-seconds ( ls ). The coordinate grid spacing scales up relative to the distance from the camera, keeping the displayed gridlines at a useful density on-screen.

3.3 Gui Controls

3.3.1 Pause

Stops the simulation for user inspection. When stopped, this control changes to “Play.”

3.3.2 Restart

Restarts the currently active scene, keeping the currently set control preferences.

3.3.3 Toggle Spatial Transform & Toggle Temporal Transform

Toggles whether the space and time parts of the Lorentz transform are applied to the final display coordinates shown onscreen. With both off, all events are shown in world frame coordinates. With both on, the events are seen in the coordinates of the target particle; as observers in its rest frame would measure them.

3.3.4 Timestep

Timestep controls the simulation speed by changing the simulated interval per frame. The slider controls the number of seconds of simulation time (either in the world frame or target particle's frame) which pass per second of user time.

3.3.5 ProperTime Scaling

When active, the simulation timestep is multiplied by the time dilation factor of the target particle. Effectively, this lets you experience time as it passes for the targeted particle. For a particle moving at high velocity, rather than it's clock appearing to slow down, all other activity in the simulation is sped up. The effect can be pretty dramatic in combination with the clock pulses.

3.3.6 1-D Control

This restricts user's control of boosts of the target particle's velocity (as applied via the W, A, S, D keys) to the x-direction.

3.3.7 Show Rigid Bodies

Controls whether any rigid bodies (appearing as yellow polygons, as in Bell's Spaceship Scene) which may be attached to the particles are displayed.

3.3.8 Use Emissions

Controls whether emissions are ejected as the user propels a target particle. Gives the user a sense of the direction the boost is being applied.

3.3.9 Show Target & Origin Axes Grid

Shows or hides the respective axes grid.

3.3.10 Show Particle Clock Ticks

Shows or hides all particle's clock tick history.

About the Program

4.1 Tools

4.1.1 Environment: Processing, Java, OpenGL, Git

Processing is a development environment and extension to Sun's Java programming language, focusing on providing ease of use with a minimalistic toolset for creative expression. It also provides the full power of the Java language (through the 1.4 syntax), the many third party libraries, and other pure Java classes. Processing supports OpenGL, accessible through the JOGL implementation of the C interface. Processing provides one-click export to PC, Mac, and Linux binaries - and to Java applets for web use. Git was used for source code management.

4.1.2 Libraries: VTextRenderer, ControlP5, Apache Math Commons

Processing has a great user community, forums, and reference docs. I've used two user-created libraries in particular - V*'s (Victor Martin's) VTextRenderer (2), for OpenGL text labels, one thing lacking in Processing; and Andreas Schlegel's ControlP5 gui library (3).

4.2 Known Bugs

These graphical details could be confusing:
  1. Update (2011.04.25): Clock pulses at worldline intersections of the both the world and target frame are now accurate. Fixed in commit 6cdd02a; refined in b8b8ed3 and 9098a46. Previously: Intersection clock pulses match the timing of the head particles in the world frame. The timing is physically correct for the heads, but fixing the timing for the intersections needs an additional calculation. (Ie, just the elapsed propertime before the head catches up to the intersection for particles on straight paths; divide the head to intersection distance in the world frame by the length of the head's (2+1) 3-velocity).

Works Cited


Additional Sources



Source Notes

A.1 Axes

Stores axes settings and draws axis basis, grid, and labels.

A.2 Control

Wraps and abstracts controlP5 gui controls. Simplifies gui panel construction and provides interface to typed Java values.

A.3 Frame

Stores position and velocity for particle states; provides interface to corresponding velocity lines and simultaneity planes.

A.4 Geom

Simple line and plane implementation to find line-plane intersections, and relative location of points to planes.

A.5 Info

Draws gui panels and console layer.

A.6 Input

Handles the user's mouse & keyboard input by dispatching to program actions.

A.7 Kamera

“Kamera” is an interface to Processing's built-in camera. Allows the user to smoothly control the camera's position (in spherical coordinates) relative to a tracked target. Mouse movement adjusts the azimuth and inclination angles; scrolling adjusts the radial distance.

A.8 Particles Layer

Draws scene objects grouped by type.

A.9 Particle

Models particle, and particle path history as a chain of Frames; finds path intersections with simultaneity Planes.

A.10 Relativity

Builds regular and inverse Lorentz matrix for velocities in 2 spatial dimensions from Velocity objects; performs display transforms.

A.11 Rigid Body

Models the Born rigid bodies by associating body vertex coordinates with a Particle's chain of Frames.

A.12 Scene

Models the main scenes, which can be composites of other scenes.

A.13 Tests

A light testing framework and a few essential tests (checking basic relativistic calculations and transforms).

A.14 Utils

Handles object picking, selection, and labeling; path-plane intersection; and miscellaneous utility functions.

A.15 VTextRenderer

Written by V* (Victor Martin) (2). Renders text in OpenGL.

A.16 Velocity

Models velocity components, direction, gamma, and three-velocity.

A.17 Worldlines

Main program.