XaiJu
pavelsevecek
pavelsevecek

patreon


Object tracking and the Ship of Theseus

We often need to follow a specific object during the simulation, or in other words, track its position with the camera over a period of time. How to do it?

The problem seems easy to solve at first, but gets progressively more difficult when one starts thinking about the specifics. Why? It ties into a fundamental philosophical problem of identity.

Tracking an object? What object?

In SpaceSim, an object is simply a collection of particles that overlap one another. A user can set up a number of objects, but these objects can change during the simulation - two planets can collide and merge into one, they can disintegrate due to tidal forces, moons can form from a disk of particles, etc.

Determining objects in the simulation and their positions, velocities, average densities, etc. is an easy part. It's done using the friends-of-friends algorithm, picking a starting "seed" particle and recursively growing a body by adding particles that overlap one of the particles already added. Then we can simply point the camera to the center of mass of this object. The problem is - how do we know that a collection of particles in two different times represents the same object? What does it even mean for an object to be the "same"?

Ship of Theseus

The problem is nicely illustrated in the following thought experiment. Consider a ship, made of wooden planks, mast, sails, etc. You take a single plank out of the ship, put it aside, and replace it with a new plank, so that the ship is whole again. Then, you repeat the process - take a plank out, put it aside, replace it with a new one. You continue doing this until you replace every single part of the ship. Then, you take all the parts put aside and assemble them into a second ship.

The question is: which ship is the original one? If you had to point out which ship is the "same" as the original one, would it be: Boat A, the one with all new planks, or Boat B, the one with the old planks from the boat we started with?


This is an old philosophical problem that people have been trying to resolve for 2000 years.

“The ship wherein Theseus and the youth of Athens returned had thirty oars, and was preserved by the Athenians down even to the time of Demetrius Phalereus, for they took away the old planks as they decayed, putting in new and stronger timber in their place, insomuch that this ship became a standing example among the philosophers, for the logical question of things that grow; one side holding that the ship remained the same, and the other contending that it was not the same.

Plutarch, Vita Thesei, 22-23

How does it relate to tracking planets?

We can easily create a similar scenario that - while not being something that can realistically happen during the simulation - nicely shows the problem. Say you want to track a planet. You remove a particle and put another particle in its place. You keep doing this until you replace every particle in the object. Then you take the particles you removed and create a new planet. Which planet is the "same" as the one we started with? And if you wanted to track the planet's position, what exactly should you track?

Of course, this is a completely arbitrary scenario, but we have the exact same problem even with realistic simulations. If we track a planet and it merges with another planet, what do we track then? What if the planet breaks apart into five pieces? What if it explodes completely into a cloud of particles?

What's the solution?

Just like the Ship of Theseus has no right answer, there it no single good solution for object tracking. It depends on the situation and on what we expect the object tracker to do. There are two options:

Option 1: Track a fixed set of particles

This is the current tracking method (as of version 0.5). We simply remember the indices of particles belonging to the tracked body and then track those particles, regardless of whether they belong to a single body or not. This means that when a planet splits into five pieces, we don't track any specific object anymore but rather the center of mass of those five objects. If applied to the Ship of Theseus, this would correspond to following the individual ship planks, or the Boat B.

This method of tracking is naturally smooth and continuous over time, as the motion of individual particles is also smooth and the set of particles that is being tracked is unchanged. However, as the camera is not necessarily centered at any specific object, the object we wish to track can move out of the center of the view or completely disappear from the screen, which defeats the purpose of tracking

Option 2: Adaptively change the particle set during the simulation

This one is a bit more difficult to explain. We look at the current bodies in the simulation, each made of a set of particles, and change the set of tracked particles to the particles of the body that has the largest intersection with the set we tracked previously. We thus always track a body - when bodies in the simulation change, so does the set of particles we track. If we used this method on the Ship of Theseus, we would track the position of the Boat A.

This tracking method works nicely in situations where bodies change slowly during the simulation, such as when a planet accretes particles from a surrounding cloud or loses particles due to radiation pressure. However, the tracked position can abruptly change between two consecutive steps when two bodies collide. For this reason, the tracked position has to be smoothed explicitly.

This option will be the new default in the next version. The tracking option 1 can still be set in the parameters of the camera tracker, if needed.


More Creators