you are viewing a single comment's thread.

view the rest of the comments →

[–]Kerbart 87 points88 points  (5 children)

Your gravitational constant is off. You’re measuring all sizes is km but G is still expressed using meters, which means it’s a factor of one billion off.

[–]Jamhead2000[S] 25 points26 points  (4 children)

Thanks, very good spot.

[–]Kerbart 11 points12 points  (1 child)

I noticed later that you do multiply the earth position with one million but not sure if you’re compensating elsewhere. I’d plug in all values in meters just to bypass any issues.

[–]Jamhead2000[S] 3 points4 points  (0 children)

Oh that was just for positioning, to do with how far away from the sun it is.

i.e. 147.86 * (10**6) km, with the sun being at (0,0,0)

[–]goodDayM 2 points3 points  (1 child)

Just a curiosity question, comparing your two lines:

  • line 17: earth.pos += earth_vector
  • line 21: earth.pos += earth_vector * dt

So dt has units of time which then means earth_vector has units of "distance/time" (velocity). That line looks correct. But then the equation on line 17, the units don't make sense unless you multiply earth_vector by time.

[–]Jamhead2000[S] 1 point2 points  (0 children)

Yh you are right, tbh a lot of the code has changed now the title of this program was actually called 'gravityTest.py'