Physics

2D Gravity Simulation

An interactive Newtonian gravity sandbox with predicted trajectories, force-field feedback, panning, and user-created bodies.

JavaScript
p5.js
Physics
2D gravity simulation with orbiting bodies and predicted trajectory paths

Employer signal

What This Project Shows

The project demonstrates numerical simulation work where the model, controls, and visual explanation all have to stay synchronized.

Problem

What Needed To Be Solved

Gravity is simple as a formula but difficult to reason about once multiple bodies, velocities, and distances interact. A useful tool needs to show not only where objects are, but where the current state implies they are going.

Approach

How I Built The Solution

I modeled every body with position, velocity, acceleration, and mass, then used a separate prediction system to clone the current state and step it forward. That lets the user see trajectory consequences before the actual state reaches them.

Outcome

What It Demonstrates

This is evidence of comfort with vector math, simulation loops, and interface features that help users understand an invisible physical model.

Evidence From Source

Source signal

The p5 sketch uses `predictionLength = 1000`, `predictanddraw()`, and `calculateForce(...)` to separate live updates from projected motion.

Design value

The prediction layer is the important design step because it turns the app from a visual animation into a reasoning tool.