# Newtonian Simulation Of Gravity

1. Sep 2, 2015

### DavidZuccaro

I'm working on a computer graphics program that simulates the motion of two point masses as indicated in this diagram:

After applying the laws of conservation of momentum and the conservation of energy I am left with the following equation to solve for e':

Does anyone have any idea how to solve this for e' which is the new velocity vector after a certain delta t?

2. Sep 2, 2015

### Staff: Mentor

It is a quadratic equation. You cannot divide by vectors so you have to be careful while solving it, but there is no magic needed.

3. Sep 2, 2015

### DavidZuccaro

So should I break down e, e' and f into their components?

4. Sep 2, 2015

### Staff: Mentor

I don't think you have to, apart from the last steps maybe.

5. Sep 2, 2015

### nasu

What about b' and c'? You consider these known?

6. Sep 2, 2015

### DavidZuccaro

Yes, because they can be calculated according to b' = b + eδt.

7. Sep 2, 2015

### Drakkith

Staff Emeritus
I've built a small simulation of the Earth orbiting the Sun. My method was to break the force, acceleration, velocity, and position vectors into their components and then calculate each component, updating after each time step. I'm not sure if that helps you or not.

8. Sep 2, 2015

### DavidZuccaro

Thanks Drakkith, yes I have done that already but now I would like the simulation to conserve energy.

This simulation does not conserve energy:

This simulation does conserve energy but there is no orthogonal velocity component.

Still not sure how to solve the above equation. Should I look at the equation for angular momentum too?

9. Sep 3, 2015

### Staff: Mentor

I just noted that your system is underconstrained - you have one equation for e' but two or three unknowns. I guess your acceleration should go in somehow.

10. Sep 3, 2015

### DavidZuccaro

I am treating the two body system as a state system.

b, c, b', c', e, f, mb, mc are all known.

Though b' and c' are calculated by approximation according to the equation b' = b + eδt.

Hope this clarifies what I am trying to achieve. I suspect that by quantizing δt I will not be able to conserve energy and momentum?

Last edited: Sep 4, 2015
11. Sep 3, 2015

### nasu

What is a "state system"?

12. Sep 3, 2015

### DavidZuccaro

What I meant by invoking the term "state system" is a system that consists of a set of well defined states. This system consists of the following vector attributes b,c,e,f the components of which may take on the numbers representable by my computer. That is there is no quantum fuzzyness or real numbers with infinite precision in this simulation.

Hope this clarifies what I meant by "state system".

EDIT: of -> or

Last edited: Sep 3, 2015
13. Sep 3, 2015

### nasu

Not really.
Unless you are talking about a physical system whose state is described by the positions and velocities vectors.
Which is how a mechanical system is usually described.

Is you system made from physical objects or from the set of states of a physical system (made from real objects).

14. Sep 3, 2015

### DavidZuccaro

Yes that is what I am talking about.

My system is a computer simulation similar to those that I have posted previously; the objects are obviously not actually physical objects but like physical objects . The objects obey Newton's laws of motion and gravitation; if they happen to collide then they will rebound elastically. So your latter description is more appropriate.

Do you have any suggestions as to how this equation my be solved for e' given all of the other variables may be considered as known?:

15. Sep 3, 2015

### nasu

I don't think you can. You have three unknowns in the equation: the magnitude of e' and the projections of e' on e and f.
Which is quite normal, isn't it? e' is a vector in 3D so you need three values to describe it.

But if you assume that you know b', c' and f' by some magic, why not take it one step further and assume e' known as well?

16. Sep 4, 2015

### DavidZuccaro

What you say is true, I probably haven't sufficiently explained myself... f' can be eliminated by conservation of momentum as shown above.
b' can be eliminated with this approximation b' = b + eδt. Now I could obtain e' by a similar approximation but that would result in energy not being conserved due to the inherent graininess of the approximation which is the reason why I would like to solve the above equation. I am now looking into the conservation of angular momentum to give additional constraints.