May 31, 2022
Gravity simulation for the kids
It's amazing how short the core of Newton's law of gravity is:
theta = angle(sun.x,sun.y, sat.x, sat.y)
dist = distance(sun.x,sun.y, sat.x,sat.y)
accelx = K*cos(theta)/dist/dist
accely = K*sin(theta)/dist/dist
velx = velx + dt*accelx
vely = vely + dt*accely
posx = posx + velx
posy = posy + vely
plot(posx,posy)
This post is part of my Freewheeling Apps Devlog.
Comments gratefully appreciated. Please send them to me by any method of your choice and I'll include them here.