Initial commit

This commit is contained in:
Chris Proctor
2025-07-28 13:29:18 -04:00
commit f7fd3e8a7e
18 changed files with 1313 additions and 0 deletions

13
simulation/gravity.py Normal file
View File

@@ -0,0 +1,13 @@
def get_gravity_force(a, b, g):
"""Gravity is a force of attraction between objects.
The attraction between two objects is equal to their masses
multipled together, divided by the square of the distance between them,
times a constant g. This is the real-life definition of gravity.
"""
a_to_b = b.position - a.position
distance = a_to_b.mag()
force = a_to_b.scale(g * a.mass * b.mass / (distance * distance))
return force
a.acceleration += force
b.acceleration -= force