# Planetary Orbits: Force needed for circular orbit

• I
Hi! first time poster here.

I'm making an orbital simulation and I am having a problem with one minor detail.

The gravity is working great, and I've programmed it using this formula:

A force vector is applied = DirectionOfCentralBodyNormalized * ((GravConstant * centralbodymass * orbitalbodymass) / (distance^2)

This works great and there are no problems here as far as I'm concerned.

Now here is the problem:
I want the orbital body to start off with enough angular velocity to orbit in a perfect circle. So I use this:

AngularForceVectorAdded = PerpindicularToDirectionOfCentralBody * (SQRT(centralbodymass * orbitingbodymass * gravConstant) / planetObjectDistance))

The problem is that this formula only works when I set the mass of the orbiting body to 0.0004. If I increase the mass of the orbiting body, not enough force is applied. If I decrease the mass, too much force is applied.

I have also tried multiplying by the mass of the orbiting body, but this causes the inverse to occur: increasing mass causes too much force to be applied and decreasing mass causes too little to be applied.

The orbit is nice and circular no matter where I place the orbiting object relative to the central body, but I really have no idea what I need to add to make this work for any amount of mass!!

Thank you

RusdiMustafa

## Answers and Replies

Drakkith
Staff Emeritus
AngularForceVectorAdded = PerpindicularToDirectionOfCentralBody * (SQRT(centralbodymass * orbitingbodymass * gravConstant) / planetObjectDistance))

This looks almost like the formula for centripetal force solved for velocity. You just have an extra mass term that isn't needed. Try: $$v=\sqrt{\frac{GM}{r}}$$
That should give you the velocity needed at any given radius. Note that the mass of the orbiting body doesn't matter, as it ends up getting divided out of the original formula.

maltmana
This looks almost like the formula for centripetal force solved for velocity. You just have an extra mass term that isn't needed. Try: $$v=\sqrt{\frac{GM}{r}}$$
That should give you the velocity needed at any given radius. Note that the mass of the orbiting body doesn't matter, as it ends up getting divided out of the original formula.

Hey Drakkith,

What you gave me ended up working fantastically. I feel a bit silly for not realizing earlier that I was adding in the extra mass term. I was beginning to think the universe was wrong, but it turns out it was just my mistake!

Strangely, I had to multiply the whole thing by 50 in order to get Unity (the software I'm using) to give enough force for circular orbit. I have no idea why I had to multiply by 50... But it is now working for all different masses of both central and orbital body and at all kinds of different distances, so I'm happy :D

Here is the functioning code:

forceAdded = -perpendicularOffset * 50 * GetComponent<Rigidbody2D>().mass * (Mathf.Sqrt(gConstant * centralBodyMass / planetObjectDistance));

Thanks.

RusdiMustafa
Drakkith
Staff Emeritus
Strangely, I had to multiply the whole thing by 50 in order to get Unity (the software I'm using) to give enough force for circular orbit. I have no idea why I had to multiply by 50... But it is now working for all different masses of both central and orbital body and at all kinds of different distances, so I'm happy :D

Hmm... what happens if you don't multiply it by 50? Does the planet go flying off into space?

RusdiMustafa
Hmm... what happens if you don't multiply it by 50? Does the planet go flying off into space?

No, the planet just falls into the sun because it needs 50 * the force. As far as I can tell everything is working realistically besides that.

RusdiMustafa
Drakkith
Staff Emeritus
I'm sorry, I'm a bit confused. Are talking about a force applied to the object, or the velocity of the object? Planets in orbits do not experience any force except for the force of gravity. What other force are you referring to?

RusdiMustafa
I'm sorry, I'm a bit confused. Are talking about a force applied to the object, or the velocity of the object? Planets in orbits do not experience any force except for the force of gravity. What other force are you referring to?

I apologize. I just realize that I've been confusing force and velocity all along.

In my simulation in Unity, I am adding force in order to create the initial velocity. I totally forgot this until you just mentioned it now!

So to get a circular orbit, I have to multiply the √(GM/r) by 50 and by the mass of the orbiting planet. This is reflected in my code:
forceAdded = 50 * orbitingBodyMass * (Mathf.Sqrt(gConstant * centralBodyMass / planetObjectDistance));

You're probably not aware of this, but every post of yours has been a grand illumination for me. The reason I've been having so many problems all along is that I have been adding force to the planets instead of just setting their velocity! The original equation v=√GMr would have worked fine for me if I was doing it properly...

So I am guessing that the reason I have to multiply by 50 and by the orbiting body mass has something to do with the way force works in unity... maybe it takes 50 units of force to move an object of 1 unit of mass by 1 unit of velocity or something like that.

Thank you.

Drakkith
Staff Emeritus
Okay. Well, try setting the velocity and see if your simulation works.

So I am guessing that the reason I have to multiply by 50 and by the orbiting body mass has something to do with the way force works in unity... maybe it takes 50 units of force to move an object of 1 unit of mass by 1 unit of velocity or something like that.

I don't know the details of how Unity works or how you're programming your simulation. Are you "manually" doing all the calculations, including the positions, velocities, and such of the objects, or are you using some kind of built-in physics code where you're only setting some initial conditions and then letting Unity do everything else for you?

Okay. Well, try setting the velocity and see if your simulation works.

I don't know the details of how Unity works or how you're programming your simulation. Are you "manually" doing all the calculations, including the positions, velocities, and such of the objects, or are you using some kind of built-in physics code where you're only setting some initial conditions and then letting Unity do everything else for you?

It works perfectly by setting the velocity thanks.

Mass, force, velocity and all the basics are all built in. I didn't have to program the way force affects mass to create velocity from scratch and I don't know exactly how a "unit" of force affects a "unit" of mass in this engine (I should find out).

I only programmed the planetary gravity using the built in mass and velocity functions. And now, with you're help, I've also programmed in an initial velocity for planets that gives them a nice circular orbit.

My next step is to get a complete output of all the classical orbital elements, periapsis, apoapsis, and , eventually, I really want to have nice orbit lines drawn all over the screen with periapsis and apoapsis clearly marked out.

My simulation is two dimensional, so it shouldn't be too difficult for me.

Drakkith
Staff Emeritus