Code Monkey home page Code Monkey logo

nbody-worker's Introduction

2D n-body particle simulation

A Javascript-based N-body simulation for calculating gravitational and electrostatic interactions between an arbitrary number of particles

Features

  • Adjustable simulation parameters
    • G, K, timestep, mass, velocity, etc.
  • Body tracking to visualize relative velocity
  • Body collisions
    • Elastic, inelastic, perfectly inelastic
  • Forces
    • Gravity
    • Electrostatic
    • Spring (softbody)
  • Conservation laws
    • Momentum, energy, charge
  • Various draw options
    • Trace paths
    • Color based on speed
    • Gravitational field visualization (VERY SLOW)
      • Can show the Lagrange points
    • Center of mass
    • Velocity, acceleration vectors
    • etc.
  • Presets and generators
    • Planets
    • Planets with moons
    • Galaxy collision
    • Solar system generator
    • Binary system generator
    • Soft bodies (hit it with other objects)
    • Many others
  • Interactive

Demonstrating physics principles

AP Physics 1

  1. Kinematics
    • Position, velocity, acceleration - particle motion
  2. Dynamics
    • Gravitational field (uniform acceleration)
    • Newton's laws
    • Spring forces (softbody)
  3. Circular motion and gravitation
    • Gravity calculated based on Newtonian gravity
    • Centripetal force and acceleration - galaxy and other orbit generators
  4. Energy
    • Conservation of energy
    • Gravitational potential energy
  5. Momentum
    • Conservation of momentum
    • Elastic and inelastic collisions
  6. Simple harmonic motion
    • Springs (softbody)

AP Physics 2

  1. Electrostatics
    • Electric force
    • Conservation of charge
    • Electric field and potential Soon(tm)
  2. Magnetism
    • Magnetic fields and Lorentz force Soon(tm)

Controls

  • U/V: toggle sidebar
  • Arrows/WASD/Mouse: pan view
  • Space: cycle tracked body
  • Esc: cancel tracking
  • Home/0: center viewport
  • Scroll/Z/X: zoom in/out
  • Others listed in control panel

Issues

  • Single core CPU-bound, very inefficient
    • Setting G to 1 helps with large numbers of bodies

Planned

  • EM forces
  • Resonant orbit generator
  • Particle trajectory prediction
  • Move calculations to gpu (especially field calcs)
  • Implement optimized algorithms
  • 3D version

nbody-worker's People

Contributors

huj31415 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.