Skip to content

Fully interactive 3D planetary n-body simulation using Barnes-Hut algorithm with gravitational vector fields

License

Notifications You must be signed in to change notification settings

tran-ethan/celestial-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Celestial Simulator

A fully interactive 3D n-body simulation using Barnes-Hut algorithm with gravitational vector fields

Celestial_Simulator_Demo.mp4

Features

  • N-Body simulation: Predicting the trajectory of celestial objects under the influence gravity according to Newton's Law of Universal Gravitation
  • Gravitational fields: Toggle on/off vector fields for gravity
  • Algorithms: Switch between Direct Sum $O(n^2)$ and Barnes-Hut algorithm $O(n \log n)$ for computing gravitational forces. Option to change Barnes-Hut Criterion (threshold for estimation) and toggling visualization for Barnes-Hut quadrants
  • Camera Controls: Panning, zooming (SCROLL), rotating (RMB), position resetting, locking in 2D view, follow planets, automatic rotation around axis
  • Interacting with bodies: Create bodies with custom radius, mass, textures/colors, positions, velocity. Select/delete bodies, and remove all bodies
  • Simulation parameters: Pausing/playing, simulation speed, gravitational constant, toggling grid/axes
  • Saving and Loading: Save current state and layout of planets into files that can be loaded later after the application is closed
  • Presets: Comes with many presets including a 3-body simulation, a solar system preset and a randomly generated layout

Getting started

Prerequisites

Before you can build and run this project, ensure you have the following software installed on your system:

Installation

Make sure Git is installed on your system before continuing with the installation

  1. Clone the repository
git clone https://github.com/tran-ethan/celestial-simulator.git
  1. Navigate to the project directory
cd celestial-simulator
  1. Build the project
./gradlew build

Usage

Using Gradle Wrapper

Make sure Oracle OpenJDK 21.0.2 is properly configured in the JAVA_HOME environment variable before trying this method. To run the application using the Gradle Wrapper, execute the following command:

./gradlew run

Using IDE

You can run the program by directly executing the main method in the MainApp class directly from within your IDE. Ensure your IDE is configured to use the JDK 21 and has the necessary dependencies in build.gradle installed.

License

This project is licensed under the MIT License

About

Fully interactive 3D planetary n-body simulation using Barnes-Hut algorithm with gravitational vector fields

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages