I'm trying to make one body fly around another, using Coulomb law $F=\frac{q_1 q_2}{r^2}$ and second Newton law $ma=F$. Now I'm doing it this intuitive way:
- Move body1 according to current speed and $dt$;
- Calc new Coulomb force then find acceleration $a=\frac{F}{m}$;
- Add acceleration to current speed;
- Repeat.
This works fine. I know this is very simple Euler method and it's very inaccurate. I'd like to use Runge-Kutta method, but I can't figure out how I should implement it. Here it's described, but
- What is my $f(x, y)$?
- What is my $y'$ and $y''$?
- Where $dt$ goes?
Thank you.
UPD. Thanks for help! Also I've found this nice little article that was quite helpful. Can't insert direct link, but it's first result if google "Many-Body Gravity Simulation Using Multivariable Numerical Integration".