Skip to content

a simple browser simulation of the 3 body problem. Available on https://3m0.de

Notifications You must be signed in to change notification settings

hannesmoehring/3bp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3-Body Problem Simulation

This project visualizes a simplified simulation of the 3-body problem using HTML, JavaScript, and the Canvas API. The simulation allows users to interactively adjust the masses of three celestial bodies and observe their gravitational interactions in real-time.

Features

  • Interactive Mass Adjustment: Adjust the masses of the three bodies using sliders before starting the simulation.
  • Collision Handling: Bodies may collide and merge based on their masses.
  • Real-Time Rendering: Bodies leave trails that visualize their paths over time.
  • Drag and Drop: Adjust the initial positions of the bodies by dragging them on the canvas before starting the simulation.

How to Run

  1. Clone or download the project files.
  2. Open index.html in a web browser to start the simulation.

Files

  • index.html: Main HTML file that sets up the structure.
  • main.js: Contains the logic for the 3-body simulation, including physics calculations and rendering.
  • styles.css: Styles for the UI elements and canvas.

Controls

  • Adjust the masses of the bodies using the sliders in the pop-up window.
  • Click the Start button to begin the simulation.
  • Drag the bodies to change their initial positions before starting.
  • The simulation centers on the heaviest body for better visualization.

Technologies Used

  • HTML, CSS, JavaScript
  • Canvas API for rendering the simulation