R
R
Roman2020-03-26 03:17:29
JavaScript
Roman, 2020-03-26 03:17:29

Simulation of body motion in orbit?

Apparently the eye is blurred. I can't find/understand what's wrong.

What I'm trying to do:
A simple simulation of the motion of a body in orbit around a source of gravity.
To do this, a body is randomly set, and for it the following is calculated:
vector directed towards the center of the gravity source => vector of the force of attraction
tangent to the orbit => vector of the object's current velocity (in the first iteration, the calculation is made as the first cosmic one. In subsequent iterations, as the sum of the previous velocity vector and gravity vector in current coordinates)

Expected result:
body moving in a perfectly (well, almost) circular orbit

Result:
In most cases, moving in an elliptical orbit

Suggested cause:
Calculation errors and their sequential accumulation

What will satisfy me as an answer:
A way to significantly reduce these errors or weaken their influence on the model so that visually the orbit looks round, centered on the center of the gravity source

Current implementation:

where:
black body - object in orbit
orange body - source of gravity (fixed/stationary)
red line - connects the centers of the object and the source of gravity
green line - velocity vector directed tangentially to the orbit (increased by an order of magnitude for clarity)
blue line - force vector attraction (for clarity, increased by 2 orders of magnitude)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
RAX7, 2020-03-26
@lastuniverse

https://habr.com/ru/post/341986/

R
Robur, 2020-03-26
@Robur

If you have real physical formulas, then I would say that the expected result is the movement of the body in an elliptical orbit.
All bodies in space fly like that.
Moreover, even this shift of the ellipse on each circle is what happens in reality.
Maybe you have a program on the contrary - it works too correctly?

U
U235U235, 2020-03-26
@U235U235

Try to increase the speed, see how the eccentricity of the ellipse changes.
Maybe at some speed the ellipse will become indistinguishable from a circle.

K
Karpion, 2020-03-27
@Karpion

Read something popular about celestial mechanics. Bodies move in a circle only if they have strictly the first cosmic velocity.
The motion of the body must be solved using the Euler method .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question