Skip to content

Instantly share code, notes, and snippets.

@benrules2
Last active November 16, 2016 13:30
Show Gist options
  • Save benrules2/9da10412b243fdff40c0f22a4533b7ee to your computer and use it in GitHub Desktop.
Save benrules2/9da10412b243fdff40c0f22a4533b7ee to your computer and use it in GitHub Desktop.
Python N-Body Orbit Simluation
def compute_velocity(bodies, time_step = 1):
for body_index, target_body in enumerate(bodies):
acceleration = calculate_single_body_acceleration(bodies, body_index)
target_body.velocity.x += acceleration.x * time_step
target_body.velocity.y += acceleration.y * time_step
target_body.velocity.z += acceleration.z * time_step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment