Orbital motions still follow Newton's laws, so you can always use
$$F=m\vec a=m\frac{\mathrm d^2\vec x}{\mathrm dt^2},$$
where $\vec F$ is the net force, $\vec a$ the acceleration, $m$ the mass and $\vec x$ the time-dependent position. For two bodies, the gravitational force is,
$$\vec F_{21}=G\frac{m_1m_2}{\vert \vec x_2-\vec x_1\vert^3}\times\left(\vec x_2-\vec x_1\right)
$$
with $G$ the gravitational constant and where $\vec F_{12}=-\vec F_{21}$.
For these types of simulations, however, it is more convenient to break that formula into two equations:
\begin{align} \vec F&=m\frac{\mathrm d\vec v}{\mathrm dt}\approx m\frac{\Delta \vec v}{\Delta t} \\ \vec v&=\frac{\mathrm d\vec x}{\mathrm dt}\approx\frac{\Delta \vec x}{\Delta t}\end{align}
with $\vec v$ the velocity and $\Delta$ meaning a (finite) change in position/velocity/time. These can be re-arranged to be a two-step process for evolving the orbital motion:
\begin{align}
\vec v_\text{new}&=\vec v_\text{old}+\frac{\vec F}{m}\Delta t \\
\vec x_\text{new}&=\vec x_\text{old}+\vec v_\text{new}\Delta t
\end{align}
Note that this is applied for each object in the system you are considering, though you only need to compute half the forces since $\vec F_{12}=-\vec F_{21}$.
A simple outline of an algorithm would be,
// initialize variables such as masses, times, etc
while (t < t_end) {
for (body1 in bodies) {
for (body2 in bodies) {
if (body1 == body2) continue;
// compute force returns a vector G.m1.m2.(x1-x2)/|x1-x2|^3
accel_12 = compute_force(body1, body2);
accel[body1] = accel_12;
accel[body2] = -accel_12;
}
}
for (body in bodies) {
body.v += accel[body] * dt / body.m;
body.x += body. * dt;
}
// do your displaying positions/velocities/accel here?
t += dt
}
Your object body
ought to contain mass, velocity and position data for the object (though if you want to animate this, you might need more than just that, I'm not really sure).
Wikipedia has a decent boilerplate for our solar system in C/C++ that should be easily adaptable to your case. Rosetta code has a Java implementation that might be useful for you.
I just be happy to get a solution for the simple stationary case. I assume the fixed velocity case wouldn't be hard for me to figure out once I have a formula. I also assume that it might be slightly more complex if the satellite has enough mass such that they rotate about the center of mass.
– Dan Wood May 26 '22 at 04:05