0
$\begingroup$

I am making a simple coding project where a white dot is orbiting another dot. I could not find a mathematical formula to change the speed of the dot based on its movement direction proportional to the gravity. I have not taken physics yet so all of this is still very hard to me. While I know this is not stackoverflow.com, I thought that this issue would we relevant to me in both places. My source code is here: https://jsfiddle.net/L9bxa5km/2/

I know most of you are not coders, so I will break it down for you. The dot moves in a certain direction with a speed. Its angle of movement is affected by gravity to move towards the center. The only issue I have is the need for the speed of the ship to change based on the gravitational pull.

$\endgroup$
  • 1
    $\begingroup$ Is the motion in 3D/2D space? $\endgroup$ – user122637 Apr 26 '18 at 19:27
  • $\begingroup$ @Subho95 , this motion is in a 2d space $\endgroup$ – Athdot Apr 26 '18 at 20:06
  • $\begingroup$ Would Computational Science be a better home for this question? $\endgroup$ – Qmechanic Apr 27 '18 at 1:35
  • $\begingroup$ I am a programmer too, do you want me to look at it? What language did you write it in? $\endgroup$ – Árpád Szendrei Apr 27 '18 at 9:57
  • $\begingroup$ Possibly useful: physics.stackexchange.com/a/159259/25301 $\endgroup$ – Kyle Kanos Apr 27 '18 at 21:22
0
$\begingroup$

If you know the concept of centrifugal force and the approximate mass of the middle object in reference to the orbiting object and the distance between, then try to place it like a planet in the solar system with a similar ratio. This should give you the speed. Hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.