Simulation of gravitational attraction, and motion of particles in 2D space. The purpose is to generate satisfying images.
I found the concept for this program in this video: Chaos, by Rudy Rucker. Between 3:37 and 5:00, it provides a concise visual explanation of how these images are generated.
A number of particles are created and kept stationary; these are the targets.
One particle is created that is mobile; this is the projectile.
The projectile is placed at a certain pixel on the screen, <x,y>
. The projectile experiences a force exerted upon it by the stationary targets. This force is calculated to mimic gravity, so it follows the inverse-square law. The projectile is accelerated and travels in 2D space. If it hits one of the targets during its travels, the initial starting point (the pixel at <x,y>
) is set to the color of the target.
Therefore, the color of each pixel on the image indicates which target the projectile will eventually hit.
If a pixel is black, that indicates the simulation terminated before the projectile hit any target.
Each target is rendered as a large, color-filled circle.
In some areas of the image, small changes in the starting position of the projectile can make it land on different targets. Because of this sensitivity to initial conditions, the image tends to look chaotic in some regions. An example of a chaotic region is the following:
In other regions of the map, the terminal location of the projectile is not very sensitive to initial conditions. In these areas, the image does not look chaotic; rather, it appears simple and well-behaved.
Currently, no user interface exists. As this is just an experimental program, all the particles are specified in the source code.
Click on images to view them at full-resolution in a new tab.
More images can be found in the pics folder in this repository.
Here are some animations that were created by generating a sequence of images, and using ffmpeg to compile them into a video.
Click on any of the pictures below to open the video.