# Calculating an elliptical orbit using position and velocity around a stationary mass

## Main Question or Discussion Point

Hi. I was playing a video game where, in one level, you are in an orbit around an attractor. The game was 2D, so there's no inclination, etc. The game showed the projected path of the body around the attractor. When you used the games controls to thrust in a direction, it would show the projected path changing, to the point of turning red when you would eventually intersected the attractor.

I've been working on a project like this, where spacecraft orbit a planet or moon or something in an elliptical orbit. I can calculate the position along the orbit for any given time t, and can get the velocity from the vis-viva equation and the tangent to the ellipse at that point. To model the orbit I use a semi-major axis, eccentricity, mean anomaly at epoch, and argument of periapsis (I got a lot of this from wikipedia; many of the resources I've been pointed at have been over my head.)

If I apply an acceleration, I would expect the orbit to change. How can I recompute those orbital elements to show the new path?

Also, instead of using the Kepler elements, I could also just use the equations for an ellipse. Would those be easier for doing this sort of work?

Related Astronomy and Astrophysics News on Phys.org

If you want to re-create the game idea you should look into numerical integration methods, e.g. leapfrog/euler:

For timestep n, use mass positions to calculate Force and then use that force to find particles new velocity and position
v(n+1/2) = v(n-1/2) + F*dt/m

x(n+1) = x(n) + v(n+1/2)*dt

where dt = timestep. Look it up for better explanation :-)

If you want to do it analyticaly, maybe a instantaneous acceleration to a new velocity vector and then re-calculate the orbit?

Hope it helps.