Planetary Orbits: Force needed for circular orbit

In summary: Unity doesn't like negative numbers?No, the reason Unity doesn't like negative numbers is because it would cause the planet to go flying off into space.
  • #1
maltmana
5
3
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
 
  • Like
Likes RusdiMustafa
Physics news on Phys.org
  • #2
maltmana said:
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.
 
  • Like
Likes maltmana
  • #3
Drakkith said:
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.
 
  • Like
Likes RusdiMustafa
  • #4
maltmana said:
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?
 
  • Like
Likes RusdiMustafa
  • #5
Drakkith said:
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.
 
  • Like
Likes RusdiMustafa
  • #6
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?
 
  • Like
Likes RusdiMustafa
  • #7
Drakkith said:
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.
 
  • #8
Okay. Well, try setting the velocity and see if your simulation works.

maltmana said:
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?
 
  • #9
Drakkith said:
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.
 
  • #10
maltmana said:
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).

Hmmm. Looking around it appears some other folks have had the same problem of the force needing to be 50x what it should be.

What function calls are you using to apply the force?
Are the function calls inside the Update() or FixedUpdate() function?
 
  • Like
Likes RusdiMustafa

What is a planetary orbit?

A planetary orbit is the path that a planet takes around another celestial object, such as a star or a moon, due to the force of gravity.

What is the force needed for a circular orbit?

The force needed for a circular orbit is known as centripetal force, which is the force that keeps an object moving in a circular path. In the case of a planetary orbit, this force is provided by the gravitational pull of the central object.

How is the force needed for a circular orbit calculated?

The force needed for a circular orbit can be calculated using Newton's second law of motion, which states that force equals mass times acceleration. In the case of a circular orbit, the acceleration is the centripetal acceleration, which is equal to the velocity squared divided by the radius of the orbit.

What factors affect the force needed for a circular orbit?

The force needed for a circular orbit is affected by the mass of the central object and the radius of the orbit. The larger the mass of the central object, the greater the force needed for the orbit. Similarly, the larger the radius of the orbit, the smaller the force needed for the orbit.

Why is the force needed for a circular orbit constant?

The force needed for a circular orbit is constant because the centripetal force and the gravitational force are always equal and opposite. As long as the mass of the central object and the radius of the orbit remain constant, the force needed for the orbit will also remain constant.

Similar threads

  • Classical Physics
3
Replies
84
Views
4K
Replies
4
Views
737
Replies
3
Views
1K
Replies
86
Views
4K
  • Classical Physics
Replies
7
Views
827
  • Classical Physics
Replies
18
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
1K
Replies
12
Views
2K
  • Classical Physics
Replies
2
Views
729
Replies
26
Views
2K
Back
Top