Skip to content

Instantly share code, notes, and snippets.

@ahmedazizkhelifi
Created August 19, 2020 00:18
Show Gist options
  • Save ahmedazizkhelifi/a86288d188b1b99946292e7e4f1d9ff4 to your computer and use it in GitHub Desktop.
Save ahmedazizkhelifi/a86288d188b1b99946292e7e4f1d9ff4 to your computer and use it in GitHub Desktop.
def gravitationalForce(p1,p2):
G = 1 #real-world value is : G = 6.67e-11
rVector = p1.pos - p2.pos
rMagnitude = vp.mag(rVector)
rHat = rVector / rMagnitude
F = - rHat * G * p1.mass * p2.mass /rMagnitude**2
return F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment