Hi!
What I need to achieve is a program which will simulate gravity in 2D plane (only x and y axis), using Euler equation, based on class of an astronomical object and a list of said objects.
As for the object, I need to give it both positions, a mass and a velocity (if it exists from the beginning). Radius is ignored, since I'm not going into collisions.
Then, I was told to recalculate every object's position and velocity accordingly, when I add a new object to the list, based on this new object's mass.
I have no idea how to do this, since all of this should be determined by time, right? It's a constantly changing situation, especially without taking collision into account. This means that all the objects will be inifnitely spinning and flying around, so I can't simply say "well, upon adding a new object, the previous one moved to XY and stayed there".
I tried searching for that before, but most gravity projects use Box2D engine or similar libraries, while everything I need to do is to use a simple class, a list and a formula.
I know the maths behind it, Gravitational Constant, force equations and whatnot, but I have absolutely no clue how to implement this. I'm having a big problem, since the assignment is for Monday, and having a lot of work on my own (I have a freshly started-up company) I forgot a lot from C++ lectures.
I will be really grateful if anyone could help me with that, thanks in advance!
P.S. I've already seen
http://www.cplusplus.com/forum/beginner/60975/ - but it's based on one, big mass in the center, to which every other object relates to. What I need is to create a class, which will be a list for an object class, using pointers, then every new object in the list will change the parameters of the previous objects.