Formula for simulating orbital motion (2D)

Zaiks
Messages
3
Reaction score
0
Hello. I'm new on this forum and I hope I'm posting this in the right place. This is not for a homework assignment but a spare-time project I'm working on.

Homework Statement


The goal with this project is to make a simple program that simulates an object that orbits a single fixed point. This behavior will be drawn on a 2D canvas, for instance in a web browser. The program will draw the object's position for each frame. This program looks somewhat like what I'm trying to accomplish, but it lacks an "algebraic" formula, so the orbit here is unstable. Since I want the orbit to be stable, I can't just keep adding to the speed and acceleration variables, since this would give noticeable rounding errors over time.

What I need is a formula to find the distance traveled for any given time with only these variables:

pi - Initial position
ti - Initial time
vi - Initial velocity (speed along x and y axis)
ri - Initial radius (which gives the acceleration)
tf - Final time

The problem is that if the orbit is not circular, the radius will change over time, and so will the acceleration. I'll probably need to use derivatives. Once I have this formula working for a one-dimensional scenario (i.e. a vertical drop), I'll be able to solve for horizontal and vertical displacement.

Homework Equations


I'm trying to keep things simple for now, just so I can understand the concept.
F = ma. Assuming m = 1 gives F = a
F = Gm1m2/r^2 simplifies to a = 1/r^2 (assuming G = m1 = m2 = 1).
a = Δd/t^2
Δd = vi*t + at^2/2

The Attempt at a Solution


I was thinking of just substituting a with 1/r^2, like this:
Δd = vi*t + (1/r^2) * t^2/2 =
Δd = vi*t + t^2/2r^2

But this somehow feels wrong.

Another thing that came to mind is that the functions Δd(a) and Δa(r) look very similar. I've been refreshing my calculus skills lately but I feel like I'm in way over my head here. :rolleyes:

Any helpful input is much appreciated.
 
Last edited:
Physics news on Phys.org
You cannot separate the two components.
This setup is known as Kepler problem, and there are formulas you can use.
 
Thank you for your reply.
mfb said:
You cannot separate the two components.
This setup is known as Kepler problem, and there are formulas you can use.

Which components are you referring to? As far as I can see I am only trying to merge two formulas, and it seems very doable. It would help me if you could explain why this will not work.

I'm making some statements here; if any of them are wrong please tell me:
- The average velocity of a moving object can tell us how far it has moved in a certain time frame, given constant acceleration.
- If acceleration is not constant, the average acceleration should give the same result, that is, how far an object has moved (in a time frame).
- In a scenario with two objects orbiting each other, the acceleration will change with the radius (the distance between their centers of mass, by inverse square law).
- Given the above, if I know the initial and final radius in a time frame, I could use that to calculate the average acceleration, and with that find the distance moved (either as a vector, or by calculating separately for the x and y axis).I read your link on the Kepler problem but I don't see how it directly relates to what I'm trying to do. The formulas presented on the wiki can be tedious to understand. I will look into it though. I want to know how formulas work before I use them in my program.
 
Which components are you referring to?
The two coordinates. You cannot solve the motion independently for both (apart from some trivial examples where the motion is 1-dimensional), as the radius (which influences the gravitational acceleration) depends on both at the same time.

- The average velocity of a moving object can tell us how far it has moved in a certain time frame, given constant acceleration.
Right. But acceleration in an orbit is not constant.
- If acceleration is not constant, the average acceleration should give the same result, that is, how far an object has moved (in a time frame).
This is wrong. Consider two different objects, both start at x=0 and t=0.
A accelerates with 10m/s^2 for one second, and keeps its velocity of 10m/s for 9 seconds afterwards. Final velocity: 10m/s. Average acceleration: 1m/s^2. Total distance travelled: 95m.
B keeps motionless for 9 seconds, and accelerates with 10m/s^2 afterwards. Final velocity: 10m/s. Average acceleration: 1m/s^2. Total distance travelled: 5m.
- In a scenario with two objects orbiting each other, the acceleration will change with the radius (the distance between their centers of mass, by inverse square law).
Not just with the radius, as the direction of acceleration changes as well.
 
mfb said:
The two coordinates. You cannot solve the motion independently for both (apart from some trivial examples where the motion is 1-dimensional), as the radius (which influences the gravitational acceleration) depends on both at the same time.

Ah. I forgot to mention I will be using the Pythagorean theorem to find the x and y components, since a vector with an angle can also be represented using only its x and y components. Ex: An object moving 5 units with a positive 60 degree angle relative to the x-axis will have moved 4 units in the y-direction and 3 in the x-direction. This concept works for movement and velocity, and it should for acceleration as well.

mfb said:
Right. But acceleration in an orbit is not constant.

True.

mfb said:
This is wrong. Consider two different objects, both start at x=0 and t=0.
A accelerates with 10m/s^2 for one second, and keeps its velocity of 10m/s for 9 seconds afterwards. Final velocity: 10m/s. Average acceleration: 1m/s^2. Total distance travelled: 95m.
B keeps motionless for 9 seconds, and accelerates with 10m/s^2 afterwards. Final velocity: 10m/s. Average acceleration: 1m/s^2. Total distance travelled: 5m.
[...]
Not just with the radius, as the direction of acceleration changes as well.

You're right, thanks for correcting me. It should be possible, though, to estimate how far an object has moved given varying acceleration as long as it can be expressed as a function. If I were to graph your example with velocity along the y-axis and time along the x-axis, the area between the graph and the x-axis would equal the distance traveled. This concept wouldn't change even if the graph function was exponential (integration is required to find the area though). The relationship between radius and acceleration is fixed, so this should be graphable somehow.

Imagine this scenario:
In a 2D coordinate system, a projectile accelerates towards a point (0,0). At time t = 0, its initial position is (2,-10). The initial velocity is (6, 2) units/time in the x- and y-directions respectively. The initial radius is given by the position. The initial acceleration is given by the radius. The direction of the acceleration will change over time, but it will always point towards (0,0). Given these initial conditions, at any final time, there is only one possible position the projectile may be in. So there must exist a formula that correctly graphs this path.
 
If you know the acceleration as function of time, you can calculate the position, sure. But you have no easy way to determine this, as acceleration depends on position, and those influence each other all the time.
As I posted, there are solutions, but they (and their derivation) are not as easy as you might hope.
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top