How to program gravity field? Answered
I am working on a program to learn about OOP (object oriented programing) and I want to make a program that lets you create planets and fling them around a sun. Here is the current code. Note, I am always actively changing it so the code may be broken at the time you click to open it. Sorry if that happens.
I know the gravity formula is F = (G*M1*M2) / R^2. The problem is that F is a scalar, not a vector. I need to split this equation into X and Y components. But apparently, you cannot just simply define the X components and Y components separately using that formula because it is not a linear/inverse relationship. :( Anyone know what the easiest way to make gravity vector field?