Initial vs Constant Orbital Velocity I am working on some basic physics simulation for a game and need to simulate gravity. I have a system working that is behaving more or less correctly so far, but I want to see if I can send a projectile into a stable orbit by giving it an initial velocity.
I understand that the following equation expresses the velocity of a stable orbit around a mass,
$$v = \sqrt{\frac{GM}{r}}$$
I am able to use this equation to create a stable orbit but not from setting a starting velocity and then letting the gravity do the work. It only works if I calculate the {x, y} components of v and set that vector as the projectiles velocity each time I render the scene. The direction of the vector is always calculated to be perpendicular in direction to the line representing the gravitational force towards the center of the mass.  
So my question is essentially whether this equation is even intended for finding an appropriate initial velocity, and if not, is there another way? I am not clear on whether there is any meaningful distinction between calculating v as a stable orbital velocity versus v as an initial velocity that resolves into a stable orbit. 
Or alternatively might it be more appropriate to say that I need to give the projectile and initial force or acceleration that resolves into a stable orbit (like an escape velocity, sort of).
Thanks. 
EDIT -- here is how I calculate the gravitational acceleration vector at a certain point. Let (x, y) be the point of interest, (x1, y1) be the center of mass, dx be the x-component acceleration, and dy be the y-component acceleration:
        1) seperation of the points

        sep_x = x1 - x;
        sep_y = y1 - y;

        2) effect of gravity given distance between points

        gravity = (G * mass) / radialDistance ^ 2

        3) break down into components

        dx = (gravity * sep_x) / radialDistance ^ 3
        dy = (gravity * sep_y) / radialDistance ^ 3

 A: Satellite will remain on stable orbit if its initial speed is less than $v_{crit}=\sqrt{2GM/r}$ unless orbit pericenter is too low in which case satellite will crash into central body. In particular if satellite speed is $\sqrt{GM/r}$ and perpendicular to $\vec{r}$ it will remain on stable circular orbit.
It's very easy to see that from energy balance. Let write down kinetic and potential energy of satellite.
$$U = -\frac{GMm}{r}; \qquad T = \frac{1}{2}mv^2 $$
If total energy of satellite is negative it can't go to the infinity and is confined to 
neighbourhood of central body and will reside on elliptical orbit. If total energy is positive it will fly away.
I suspect that you solve equations of motion wrongly. For any initial coordinate and speed satellite will either circle on elliptic (or circular orbit) or fly away on hyperbolic orbit.
Solve equations
In order to calculate trajectory of satellite your need to solve motion equations. Analytical solution exists for two body case. But if you want to add more more massive bodies or take into account thrusters or athmospheric drag you'll have to use numerical integration. Let write them down. I wrote them in form suitable for numerical integration.
$$ \frac{d\vec x}{dt} = \vec v; \qquad \frac{d\vec v}{dt} = \vec a = -\frac{GM}{r^3}\vec{r} + \vec{F}_{whatever}/m$$
Solution must also satisfy initial conditions
$$ \vec v(t_0) = \vec v_0; \qquad \vec x(t_0) =x_0 $$
Here is very simple rule for numeric integration. $\Delta t$ is time step for integration and $\vec{a}(t_i)$ is acceleration at i'th moment of time.
$$ \vec{x}_{i+1} = \vec{x}_i + \vec{v}_i \Delta t$$
$$ \vec{v}_{i+1} = \vec{v}_i + \vec{a}(t_i) \Delta t$$
This particular method is poor choice for simulation. There much better methods, for example Runge-Kutta. 
A: On reading the many comments I have several concerns


*

*On the matter of how gravity and orbits work 
I'm a little bit concerned by the use of the phrase "falling into orbit", which is convenient but philosophically dicey. A body on a parabolic or hyperbolic approach (i.e. literally falling in) does not obtain a closed path (i.e. orbit) without thrust or the intervention of a outside force (e.g. gravitational perturbations from a third body). In that sense there is no difference between the initial velocity in a particular orbit and the evolving velocity on that same orbit.
Injecting bodies into orbit is a important problem, but I don't get the sense that this is what Sean is up to.

*On the matter of what is meant by a vector
It is not true that vector must be expressed as $(x, y)$ to be meaningful, $(V, \phi)$ is just as meaningful. It is generally more convenient to use Cartesian representations in a simulation, but that is not fundamental

*On the matter of how simulations work
If you are simulating gravity in the naive way (and that is how you should do it until you are comfortable with simulation), then you should not be recalculating the orbit from $$ v= \sqrt{\frac{GM}{r} }$$ on each iteration. You should be updating the behavior of each body in the simulation with Newton's second law and universal gravitation (albeit in a discretized form).
Orbits turn out to be a tricky cases, so I would suggest that you alternate between updating positions on one step and velocities on the next (it's well known that this leap-frog approach preserves orbital energy when other naive methods do not).
$$ v_{x,n+1} = v_{x,n-1} + \frac{F_{x,n}}{m}\Delta t, v_{y,n+1} = v_{y,n-1} + \frac{F_{y,n}}{m}\Delta tt $$
and 
$$ x_{n+2} = x_n + v_{x,n+1} \Delta t, y_{n+2} = y_n + v_{y,n+1} \Delta t $$
where the $F$'s come from Newton's Law of Gravitation and the $n$'s represent the steps of you simulation. The $\Delta t$s here represent the time between step $n$ and step $n+2$ as I've numbered them.  (You are free to eliminate the $F/m$ but by finding $a$ directly.)
A: You screwed up your code. You are taking the components of gravity by dividing by 1/r^2 a second time, when you already did it in the original step of calculating the gravitational force.
You should set G to 1. This just redefines the unit of mass, but it prevents confusions because in ordinary units G is enormously small.
Here is the correct algorithm. It just removes the cubes from the acceleration components.
        1) seperation of the points

        sep_x = x1 - x;
        sep_y = y1 - y;

        2) effect of gravity given distance between points

        gravity = (G * mass) / radialDistance ^ 2

        3) break down into components

        dx = (gravity * sep_x) / radialDistance 
        dy = (gravity * sep_y) / radialDistance

Your original simulation is still interesting--- it is calculating the motion in a 1/r^4 force field, a 1/r^3 potential. This type of thing is not physically relevant for the solar system, but it is a nice mathematical exercise. You can see that you didn't do it right because the orbits precess in such a field, instead of making closed ellipses.
To get the new velocities, I assume you multiply dx and dy by a small quantity and subtract them from v_x and v_y, the x and y components of the velocity, as you should, because you do not have a minus sign in your force formula. You then add v_x and v_y times the same small quantity to the current position. All this is assuming a unit mass, which is fine, because I assume you don't move your gravitational center at all during the simulation.
