# B Simulating orbit trajectory based on position and velocity

1. Sep 21, 2016

### AlenC

Hi!

I hope I'm posting in the correct section. I found this very similar topic in this forum: https://www.physicsforums.com/threads/orbital-ellipse.482713/

Aside from very helpful formula for calculating semi-major axis, the question was left unanswered.

I have a working simulation of orbital motion of satellites and spaceships, but I'd like to visually represent this flight path based on distance from planet's center of mass and satellite's velocity.

I assume the best way to do this is by drawing an ellipse, for which I need to know semi-major axis, semi-minor axis and eccentricity or focus. What would be the best process to do this? I don't mind doing some research and reading myself, but I'd like to understand at least the sequence of calculations I need to do.

Edit: I forgot to mention that I'm simulating everything in two dimensional plane.

Last edited: Sep 21, 2016
2. Sep 21, 2016

### snorkack

Position in two dimensional plane is determined by single variable - distance. Right?
And for velocity, you need two variables: radial and tangential velocity. Correct?

3. Sep 21, 2016

### AlenC

Yes. I know these values. What can I do next based on this?

4. Sep 21, 2016

### snorkack

Calling the velocities Vr and Vt, we can note that kinetic energy Ek=mv2/2=m(Vr2+Vt2)/2 - at every point of orbit.

5. Sep 21, 2016

### AlenC

Ok, I'm still with you.

6. Sep 21, 2016

### snorkack

The second constraint is that the potential energy Ep=-MmG/R.
Now, conservation of energy means that the total energy
E=m[(Vr2+Vt2)/2-MG/R]
is constant. If it´s positive, then the orbit is hyperbolic and the satellite escapes; if it is zero then the orbit is parabolic and the satellite also escapes..
If the energy is negative then the orbit is elliptical or circular.
Now, the tangential velocity has another constraint: second law of Kepler:
VtR must be constant.
Therefore Vt, and therefore also Vt2 cannot go to zero.

7. Sep 21, 2016

### snorkack

So: E/m=(Vr2+Vt2)/2-MG/R
Also Vt=(L/m)/R, for every R.
Thus: E/m=Vr2/2+[(L/m)2/2]/R2-MG/R
rearranging, I get
Vr2/2=E/m+MG/R-[(L/m)2/2]/R2
multiplying by 2
Vr2=2(E/m)+2MG/R-(L/m)2/R2
Observe that this is a quadratic equation for (1/R).

Last edited: Sep 21, 2016
8. Sep 21, 2016

### AlenC

I'll need some time to process this, but I think I understand the general meaning: I can calculate energy from velocity and distance.

Would you just mind explaining what M, L and R stand for?

9. Sep 21, 2016

### snorkack

Now, Vr2 as a square cannot be negative. Whereas the member -(L/M)2/R2 is negative and can get arbitrarily small (?) as 1/R increases.
Therefore, you can solve the quadratic equation for Vr2=0, and get the two R values where Vr2=0.
These R values are the distances to apsides.
Major axis of ellipse is Rmax+Rmin.
Eccentricity is (Rmax-Rmin)/(Rmax+Rmin)

10. Sep 21, 2016

### snorkack

M is the mass of the planet.
L is the angular momentum of the satellite. I preferred to use the expression (L/m), where m is the mass of satellite.
R is the distance between planet and satellite.

11. Sep 22, 2016

### AlenC

I tried using these equations in my simulation, but I'm getting strange results. Either too big or too small. Would you mind checking my numbers?

I first tried calculating total energy:

E = 10000000kg*( (7563.49ms²/2) - ((6E+24kg*6.67408E-11)/7000000m) )
Mass of the planet is approximate. I didn't include radial velocity, because at this point is zero. Tangential velocity is calculated by the simulation for a circular orbit and it works correctly (as far as I can tell). If I boost this value manually, orbit becomes an ellipse and satellite returns to its starting position.

Result calculated by the computer is: -286032000000000
But this is the result I got from windows calculator: -57206399999713968094999500

I'm obviously making a mistake somewhere...

12. Sep 22, 2016

### snorkack

I get:
Vt2/2=+2,8E+7
GM=4E+14
GM/R=-5,7E+7
Your Windows calculator looks like you´ve put too many zeros to the GM/R part.
Yes: if you increase tangential speed from a circular orbit, the point becomes a perigee. If the speed remains below the escape speed, the satellite will acquire an elliptical orbit and return to the point of origin.

13. Sep 22, 2016

### AlenC

I checked the results coming out of program and they match with your calculations and my original value of E: -286032000000000

So now comes the difficult part where I'm probably making a mistake. If I understood correctly, next I have to solve quadratic equation with two results:
Vr2=2(E/m)+2MG/R-(L/m)2/R2

I used this formula:

R_1={ -B + [ sqrt(B²- (4AC) ) ] } / 2 * A
R_2={ -B - [ sqrt(B²- (4AC) ) ] } / 2 * A

I identified these elements from the formula you provided:

A = (L/m)²*-1 (should this be negative?)
B = 2MG
C = 2*(E/m)

Am I doing this correctly? Also, if I understand what you said, the result is actually 1/R, so I should multiply the result with itself?

14. Sep 22, 2016

### snorkack

Yes - solve it for Vr=0
Yes, negative - so no -1 there
A=-(L/m)2
No. You need to take inverse - divide 1 by 1/R
As it happens, the expression you need to take inverse of is already expressed as a ratio, so that´s easy:
1/R1=[-B+sqrt(B2-4AC)]/2A
therefore
R1=2A/[-B+sqrt(B2-4AC)]

15. Sep 22, 2016