4
$\begingroup$

I found the following simulation of an orbit given the semi-major axis of the ellipse, eccentricity, initial velocity, the mass of the object being orbited, and initial position of the orbiting satellite.

The program basically starts off with the following initial conditions:

$$ h \to stepSize\\ a \to semiMajorAxis\\ e \to eccentricity\\ g \to GM/a\\ \vec{X_0} = (a(1+e), 0, 0)\\ \vec{V_o} = (0, \sqrt{\frac{g(1-e)}{(1+e)}},0) $$

Given these initial conditions, the next state is calculated as follow:

$$ \vec{X_{temp}} = \vec{X_0} + (\frac h2)\vec{V_0}\\ r^3 \to (\sqrt{x_0^2 + y_o^2})^3\\ \vec{Acc_{temp}} = \frac{-GM}{r^3}(\vec{X_{temp}})\\ \vec{V_1} = \vec{V_0} + h*\vec{Acc_{temp}}\\ \vec{X_1} = \vec{X_{temp}} + \frac h2 \vec{V_1}\\ $$

The approximations continue accordingly with accuracy increasing for smaller stepSize values.

Assuming I presented this in a way that makes sense, my question is in regards to my result. Look at my simulation here:

http://zixg.com/orbits/

Take note of the two stationary blue dots. These represent the apogee and perigee of an ellipse with semi-major axis 'a' and eccentricity 'e' (Hence, the sun-like object is centered at a corresponding focal point). So it seems that this method doesn't approximate the initial ellipse at all, but rather results in a orbital trajectory that is much larger than the initially assumed ellipse. I'm not sure what to make of this?

$\endgroup$
3
  • $\begingroup$ I certainly had trouble figuring out where to stick this one. Perhaps that is the best place? Anyone else? $\endgroup$
    – Tyrick
    May 29, 2013 at 19:18
  • $\begingroup$ Whatever you do, don't crosspost. Flag for migration instead. $\endgroup$
    – Qmechanic
    May 29, 2013 at 19:19
  • $\begingroup$ Done, I flagged it with a message requesting appropriate migration. Thanks $\endgroup$
    – Tyrick
    May 29, 2013 at 20:05

1 Answer 1

3
$\begingroup$

Looking at your code:

var v = new Array(0, Math.sqrt((g*(1-e))/1+e), 0);

You seem to be missing a set of parenthesis around (1+e). Should be:

var v = new Array(0, Math.sqrt((g*(1-e))/(1+e)), 0);
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.