This question already has an answer here:

I am creating a simulation of planets with the help of newton's law(here) and everything works fine but I can't find any source how to calculate the perfect start velocity of a planet in order to orbit another planet in a perfect circular motion given following known parameters of both planets: mass, distance from mass center to mass center, G

following code to calculate acceleration:

calcBodyAcceleration(body1, body2) {

    var G = Settings.get("G");
    var mults = Settings.get("multipliers");

    var pos1 = Vec2.add(body1.position, body1.center);
    var pos2 = Vec2.add(body2.position, body2.center);

    var subtraction = Vec2.subtract(pos1, pos2);
    var dist2 = subtraction.magnitudeSq();
    var dist = Math.sqrt(dist2);

    var mass1 = body1.mass * mults.mass;
    var mass2 = body2.mass * mults.mass;

    var mass = mass1 * mass2;
    var force = G * (mass / dist2);




marked as duplicate by Kyle Kanos, Jon Custer, peterh says reinstate Monica, Qmechanic Jul 31 '17 at 19:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.