Planetary attraction

What did you draw?
Post Reply
A Random Player
Posts: 523
Joined: Mon Jun 03, 2013 4:54 pm

Planetary attraction

Post by A Random Player »

Draw a stationary planet. Now fling an asteroid next to it such that the predicted path is approximately circular. The asteroid does not follow the predicted path, and flies away quite hyperbolically.

Now, you may think this is a bug with the fling drawer (I did at first), but try this. Take a basic star-asteroid orbit (circular is best):

Code: Select all

Gravity Fun at TestTubeGames.com: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0], [x0: 22,y0: -43,vx: 0,vy: 0,t0: 0,who: 1,m: 1000], [x0: 116,y0: -31,vx: 0.41,vy: -3.22,t0: 0,who: 3,m: 0]
This, of course, is stable. Now change the star to a planet with the same mass:

Code: Select all

Gravity Fun at TestTubeGames.com: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0], [x0: 22,y0: -43,vx: 0,vy: 0,t0: 0,who: 2,m: 1000], [x0: 116,y0: -31,vx: 0.41,vy: -3.22,t0: 0,who: 3,m: 0]
And the asteroid flies away.

What is going on? Is this a bug?
$1 = 100¢ = (10¢)^2 = ($0.10)^2 = $0.01 = 1¢ [1]
Always check your units or you will have no money!
User avatar
testtubegames
Site Admin
Posts: 1148
Joined: Mon Nov 19, 2012 7:54 pm

Re: Planetary attraction

Post by testtubegames »

Whoa, boy, that sure looks like one! And a big one at that.

I'm tracking it down right now... there seems to be a hint in that if you raise the planet's mass to 6000 instead of 1000, the circular orbit returns. That at least gives me a clue...

Edit: and if you do the same transform for the Lagrange Points thread, (making the planet's mass 600 instead of 100), it fixes that, too. The LP is still unstable, but sticks around for nearly a full rotation... which sounds more reasonable.

Edit2: Great! Random, thank you for finding that, I can't believe how long that bug stuck around! Turns out, the RK4 algorithm was working nicely to keep things in orbits around stars... but it was completely broken for planets. Planets would attract at about 1/6 the strength, and with way less precision. Which is why I never really managed to get a moon in a nice orbit around a planet before... and why the Lagrange points weren't working... etc etc. Thank you thank you thank you!

Check out this new setup, then, with a moon in orbit around a planet (a highly elliptical orbit, granted... I didn't spend too much time setting inital conditions. But before this fix, the asteroid would be quickly flung off with the same setup. Now, it is trapped in the planet's gravity well.)

Code: Select all

Gravity Fun at TestTubeGames.com: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0], [x0: 3,y0: -8,vx: 0,vy: 0,t0: 0,who: 1,m: 1000], [x0: 102,y0: 15,vx: 0.71,vy: -3.06,t0: 70.2,who: 2,m: 100], [x0: 109,y0: -50,vx: -1.09,vy: -2.75,t0: 496.8,who: 3,m: 0]
Post Reply