Author Topic: Which planet is closest to earth?  (Read 5751 times)

0 Members and 1 Guest are viewing this topic.

Offline david_uwi

  • Newbie
  • Posts: 71
    • View Profile
Which planet is closest to earth?
« on: March 25, 2019, 10:41:24 am »
https://physicstoday.scitation.org/do/10.1063/PT.6.3.20190312a/full/

I came across this article which claims that on average mercury is actually closest to the earth.
If you analyse the geometry it is actually fairly obvious.
Anyway they made quite a big deal about their calculation so I thought why not try it in QBasic.

Code: QB64: [Select]
  1. pi = 3.141593
  2. rmer = 57
  3. rven = 108 'average distance
  4. re = 150 'from the sun 1000 km
  5. rmar = 228
  6. FOR th = 1 TO 360000 'angle in degrees (1000 years)
  7.     thr = th * (pi / 180)
  8.     a1 = (re - rven * COS(thr)) ^ 2
  9.     a2 = (-rven * SIN(thr)) ^ 2
  10.     d = SQR(a1 + a2)
  11.     dcum = dcum + d
  12.     j = j + 1
  13.     thr1 = thr * 5.044 'synodic period adjustment
  14.     a1 = (re - rmer * COS(thr1)) ^ 2
  15.     a2 = (-rmer * SIN(thr1)) ^ 2
  16.     d1 = SQR(a1 + a2)
  17.     dcum1 = dcum1 + d1
  18.     thr2 = thr * .749 'synodic period adjustment
  19.     a1 = (re - rmar * COS(thr2)) ^ 2
  20.     a2 = (-rmar * SIN(thr2)) ^ 2
  21.     d2 = SQR(a1 + a2)
  22.     dcum2 = dcum2 + d2
  23.     IF d < d1 AND d < d2 THEN v = v + 1
  24.     IF d1 < d AND d1 < d2 THEN m = m + 1
  25.     IF d2 < d1 AND d2 < d THEN mar = mar + 1
  26.  
  27. NEXT th
  28. PRINT "average distances (au)  mercury    venus    mars"
  29. PRINT SPACE$(22); dcum1 / j / re; dcum / j / re; dcum2 / j / re
  30. tot = (m + v + mar) / 100
  31. PRINT "percent of time closest  mercury    venus    mars"
  32. PRINT SPACE$(25); m / tot; v / tot; mar / tot

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Which planet is closest to earth?
« Reply #1 on: March 25, 2019, 12:05:32 pm »
Watch the numbers build for awhile?
Code: QB64: [Select]
  1. pi = 3.141593
  2. rmer = 57
  3. rven = 108 'average distance
  4. re = 150 'from the sun 1000 km
  5. rmar = 228
  6. FOR th = 1 TO 360 *1000 'angle in degrees (1000 years)
  7.     thr = th * (pi / 180)
  8.     a1 = (re - rven * COS(thr)) ^ 2
  9.     a2 = (-rven * SIN(thr)) ^ 2
  10.     d = SQR(a1 + a2)
  11.     dcum = dcum + d
  12.     j = j + 1
  13.     thr1 = thr * 5.044 'synodic period adjustment
  14.     a1 = (re - rmer * COS(thr1)) ^ 2
  15.     a2 = (-rmer * SIN(thr1)) ^ 2
  16.     d1 = SQR(a1 + a2)
  17.     dcum1 = dcum1 + d1
  18.     thr2 = thr * .749 'synodic period adjustment
  19.     a1 = (re - rmar * COS(thr2)) ^ 2
  20.     a2 = (-rmar * SIN(thr2)) ^ 2
  21.     d2 = SQR(a1 + a2)
  22.     dcum2 = dcum2 + d2
  23.     IF d < d1 AND d < d2 THEN v = v + 1
  24.     IF d1 < d AND d1 < d2 THEN m = m + 1
  25.     IF d2 < d1 AND d2 < d THEN mar = mar + 1
  26.     IF th < 100 OR th MOD 100 = 0 THEN
  27.         CLS
  28.         PRINT "Days:"; th
  29.         PRINT "average distances (au)  mercury    venus    mars"
  30.         PRINT SPACE$(22); dcum1 / j / re; dcum / j / re; dcum2 / j / re
  31.         tot = (m + v + mar) / 100
  32.         PRINT "percent of time closest  mercury    venus    mars"
  33.         PRINT SPACE$(25); m / tot; v / tot; mar / tot
  34.         _DISPLAY
  35.         _DELAY 1
  36.     END IF
  37. NEXT th
  38.  
  39.  

EDIT: not 364.25 days * 1000 years because want angle.
« Last Edit: March 25, 2019, 12:10:27 pm by bplus »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Which planet is closest to earth?
« Reply #2 on: March 25, 2019, 01:37:18 pm »
Hey, how interesting!  And by the same token, the Sun is closest to us cf. Mercury, Venus & Mars (1 AU).  Without thinking about it, you wouldn't think that averages behave like that.  This means that we have to be careful of language:  referring to Venus, we should say "Which planet gets closest to Earth?".  Thank you David & bplus.

« Last Edit: March 25, 2019, 01:46:41 pm by Qwerkey »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Which planet is closest to earth?
« Reply #3 on: March 25, 2019, 02:32:08 pm »
hmm... I tried an independent plot of planets around sun and realized I was missing a vital bit of information

NASA these are radius in millions of K
rmer = 57
rven = 108 'average distance
re = 150 'from the sun 1000 km
rmar = 228

but we also have to know how fast they are going compared to earth or how many days for each planet to complete 1 orbit. I am not seeing that with David's calculations. ?

Oh the "synodic period adjustment"! ;) OK I'm in over my head :D

« Last Edit: March 25, 2019, 02:39:34 pm by bplus »

Offline david_uwi

  • Newbie
  • Posts: 71
    • View Profile
Re: Which planet is closest to earth?
« Reply #4 on: March 25, 2019, 02:55:50 pm »
I am using the synodic period. So effectively I am looking at the motion of mars,venus and mecury relative to a static sun-eath reference frame.
I have tried to do an animation, I can't seem to get the colours to work.

Code: QB64: [Select]
  1. pi = 3.141593
  2. xsca = 640: ysca = 640
  3. SCREEN _NEWIMAGE(xsca + 160, ysca + 130, 2)
  4. '_PALETTECOLOR 1, _RGB32(255, 0, 0)
  5. rmer = 57
  6. rven = 108 'average distance
  7. re = 150 'from the sun 1000000 km
  8. rmar = 228
  9. FOR th = 1 TO 360000 'angle in degrees (1000 years)
  10.     thr = th * (pi / 180)
  11.     a1 = (re - rven * COS(thr)) ^ 2
  12.     a2 = (-rven * SIN(thr)) ^ 2
  13.     d = SQR(a1 + a2)
  14.     dcum = dcum + d
  15.     j = j + 1
  16.     thr1 = thr * 5.044 'synodic period adjustment
  17.     a1 = (re - rmer * COS(thr1)) ^ 2
  18.     a2 = (-rmer * SIN(thr1)) ^ 2
  19.     d1 = SQR(a1 + a2)
  20.     dcum1 = dcum1 + d1
  21.     thr2 = thr * .749 'synodic period adjustment
  22.     a1 = (re - rmar * COS(thr2)) ^ 2
  23.     a2 = (-rmar * SIN(thr2)) ^ 2
  24.     d2 = SQR(a1 + a2)
  25.     dcum2 = dcum2 + d2
  26.     IF d < d1 AND d < d2 THEN v = v + 1
  27.     IF d1 < d AND d1 < d2 THEN m = m + 1
  28.     IF d2 < d1 AND d2 < d THEN mar = mar + 1
  29.     Z1MAR = re - rmar * COS(thr2)
  30.     Z2MAR = -rmar * SIN(thr2)
  31.     CLS
  32.     _PALETTECOLOR 1, _RGB32(255, 0, 0)
  33.     CIRCLE (600 - Z1MAR, 300 + Z2MAR), 10, 1, , , 1
  34.     PAINT (600 - Z1MAR, 300 + Z2MAR), 1
  35.     Z1V = re - rven * COS(thr)
  36.     Z2V = -rven * SIN(thr)
  37.     _PALETTECOLOR 3, _RGB32(255, 255, 255)
  38.     CIRCLE (600 - Z1V, 300 + Z2V), 10, 3, , , 1
  39.     PAINT (600 - Z1V, 300 + Z2V), 3
  40.     Z1MER = re - rmer * COS(thr1)
  41.     Z2MER = -rmer * SIN(thr1)
  42.     _PALETTECOLOR 3, _RGB32(255, 255, 255)
  43.     CIRCLE (600 - Z1MER, 300 + Z2MER), 10, 3, , , 1
  44.     PAINT (600 - Z1MER, 300 + Z2MER), 3
  45.     CIRCLE (600 - re, 300 + 0), 20, 3, , , 1
  46.     PAINT (600 - re, 300 + 0), 3
  47.     CIRCLE (600 - 0, 300 + 0), 10, 3, , , 1
  48.     PAINT (600 - 0, 300 + 0), 3
  49.  
  50.     'PRINT a1; a2
  51.     FOR i = 1 TO 1280000: NEXT i
  52. NEXT th
  53. PRINT "average distances (au)  mercury    venus    mars"
  54. PRINT SPACE$(22); dcum1 / j / re; dcum / j / re; dcum2 / j / re
  55. tot = (m + v + mar) / 100
  56. PRINT "percent of time closest  mercury    venus    mars"
  57. PRINT SPACE$(25); m / tot; v / tot; mar / tot
  58.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Which planet is closest to earth?
« Reply #5 on: March 25, 2019, 03:17:40 pm »
That's a great illustration of why it's Mercury on average as always closer to Earth.

I could help with color if you used 32 in _newImage instead of 2, then it's just _RGB32(r, g, b).
« Last Edit: March 25, 2019, 03:19:17 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Which planet is closest to earth?
« Reply #6 on: March 25, 2019, 04:46:12 pm »
Ha! Looks like we are still building clocks!
Code: QB64: [Select]
  1. _TITLE "Checkout Which Planet Closet to Earth Most of the Time" 'B+ mod started 2019-03-25
  2. ' inspired by david_uwi post: https://www.qb64.org/forum/index.php?topic=1184.0
  3.  
  4. CONST xmax = 700
  5. CONST ymax = 700
  6. CONST CX = 350
  7. CONST CY = 350
  8. SCREEN _NEWIMAGE(xmax, ymax, 32)
  9.  
  10. TYPE planetType
  11.     x AS SINGLE '             track position after so many Earth Days
  12.     y AS SINGLE
  13.     name AS STRING '          data
  14.     radius AS SINGLE '        millions of KM  data
  15.     edy AS SINGLE '           earth day year data
  16.     oneDayAngle AS SINGLE '   calc 2 * PI / edy
  17.     distFromEarth AS SINGLE ' calc when run model
  18.     closest AS INTEGER '      calc when run model
  19.     cum AS SINGLE '           calc when run model
  20.  
  21. 'load planet data from Internet
  22. DIM planet(1 TO 4) AS planetType
  23. FOR i = 1 TO 4
  24.     READ planet(i).name
  25.     READ planet(i).radius
  26.     READ planet(i).edy
  27.     planet(i).oneDayAngle = _PI(2 / planet(i).edy)
  28. 'review data check load
  29. FOR i = 1 TO 4
  30.     PRINT planet(i).name; " is "; planet(i).radius; " million KM from sun and covers an radian angle of"; planet(i).oneDayAngle; " in one Earth day."
  31. INPUT "<Enter> Model of Solar System", wate$
  32.  
  33. 'run model
  34. FOR days = 1 TO 365.26 * 1000
  35.  
  36.     FOR i = 1 TO 4
  37.         planet(i).x = CX + planet(i).radius * COS(planet(i).oneDayAngle * days)
  38.         planet(i).y = CY + planet(i).radius * SIN(planet(i).oneDayAngle * days)
  39.     NEXT
  40.     FOR i = 1 TO 4
  41.         planet(i).distFromEarth = SQR((planet(i).x - planet(3).x) ^ 2 + (planet(i).y - planet(3).y) ^ 2)
  42.         planet(i).cum = planet(i).cum + planet(i).distFromEarth
  43.     NEXT
  44.  
  45.     IF planet(1).distFromEarth < planet(2).distFromEarth AND planet(1).distFromEarth < planet(4).distFromEarth THEN planet(1).closest = planet(1).closest + 1
  46.     IF planet(2).distFromEarth < planet(1).distFromEarth AND planet(2).distFromEarth < planet(4).distFromEarth THEN planet(2).closest = planet(2).closest + 1
  47.     IF planet(4).distFromEarth < planet(1).distFromEarth AND planet(4).distFromEarth < planet(2).distFromEarth THEN planet(4).closest = planet(4).closest + 1
  48.  
  49.     'display
  50.     CLS
  51.     PRINT "Days:"; days
  52.  
  53.     PRINT "average distances ", "Mercury", "Venus", "Mars"
  54.     PRINT SPACE$(22); planet(1).cum / days, planet(2).cum / days, planet(4).cum / days
  55.  
  56.     PRINT "fraction of time closest", "Mercury", "Venus ", "Mars"
  57.     PRINT SPACE$(22), planet(1).closest / days, planet(2).closest / days, planet(4).closest / days
  58.     CIRCLE (CX, CY), 6, _RGB32(255, 255, 0)
  59.     FOR i = 1 TO 4
  60.         CIRCLE (planet(i).x, planet(i).y), i, &HFFFFFFFF
  61.         SELECT CASE i
  62.             CASE 1: c~& = &HFFFF0000
  63.             CASE 2: c~& = &HFF00FFFF
  64.             CASE 3: c~& = &HFF0000AA
  65.             CASE 4: c~& = &HFFAA6600
  66.         END SELECT
  67.         PAINT (planet(i).x, planet(i).y), c~&, &HFFFFFFFF
  68.     NEXT
  69.     _DISPLAY
  70.     _LIMIT 30
  71.  
  72.  
  73. DATA "Mercury",57.9,87.97
  74. DATA "Venus",108.2,224.7
  75. DATA "Earth",149.6,365.26
  76. DATA "Mars",227.9,686.98
  77.  
« Last Edit: March 25, 2019, 04:50:26 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Which planet is closest to earth?
« Reply #7 on: March 25, 2019, 07:12:48 pm »
The term "closest" seems to be subjective.

There are only 2 possible reasons as to why Mercury could possibly be closer to Earth than any other inner planet.

1) Mercury's orbit is so elliptical (similar to Pluto), that Mercury's orbit 'crosses' the orbit of Venus. As the eccentricity of the orbits of Venus and Earth are almost circular, their distances from the Sun only varies slightly and Mercury's orbit is about 7 degrees eccentric, that would place Mercury well inside the orbit of Venus. Mercury always stays between Venus and the Sun and cannot possibly cross the orbit of Venus and

2) The ONLY logical reason that Mercury could possibly be closer to Earth is if Venus and Mars were on the other side of the Sun, leaving Mercury the only planet nearest the Earth.

After all... It's not rocket science... Oh wait... Maybe it is... lol
Logic is the beginning of wisdom.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Which planet is closest to earth?
« Reply #8 on: March 25, 2019, 10:04:32 pm »
Sure, it you drive through the sun to get there. In other words, if the earth is to the left of the sun, and all the other planets are to the right of the sun, Mercury is the first planet you hit when you travel from Earth, through the sun, and come out on the right side. So a bit over 50% of the time, yes, Mercury is closer.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Which planet is closest to earth?
« Reply #9 on: March 26, 2019, 01:14:57 am »
I am not referring to "drive through the sun". Point 2 is referring to Mercury AND Earth on ONE side of the Sun whilst Venus and Mars are on the OTHER side. My apologies for not making myself clearer.
Logic is the beginning of wisdom.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Which planet is closest to earth?
« Reply #10 on: March 26, 2019, 10:09:20 am »
I am not referring to "drive through the sun". Point 2 is referring to Mercury AND Earth on ONE side of the Sun whilst Venus and Mars are on the OTHER side. My apologies for not making myself clearer.

Actually, I wasn't referring directly to your post, but to the question in general. Questions like these are fun, because it takes thinking outside of the box. We were all taut the solar system as a linear model of planets all one one side of the sun. From this post, I imagined how that model could be changed by moving the other planets to the opposite side of the sun, and you imagined Mercury and Earth on one side, and the other planets on the opposite side. Both models help explain how it is possible that Mercury is the closest planet to Earth, but my vision is more scenic, as your trip excludes a nice drive through the sun! 

This question remind me of why Russia never made it to the moon. Russian spacecraft travels at 2304 miles per hour, and makes a straight shot for the moon. It takes nearly 4.5 days to reach the distance to the moon, but since they forgot the moon orbits at .64 miles per second... the same max speed as their rocket... they spend forever in space chasing moon and squirrel.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Which planet is closest to earth?
« Reply #11 on: March 26, 2019, 10:59:21 am »
Guys, would you just confirm that I have understood this properly?  In your models, I assume that you are taking the scalar average of the distances to the Earth of (the Sun), Mercury, Venus and Mars over time - and then you get the results that Mercury has the lowest value (with result close to 1AU).  I imagine that if you were to take a vector average of the distances, all would come out at 1AU: the average vector distance from the Sun of each planet is zero (by symmetry).

So the reason that any of the planets has an average scalar distance above 1AU is that contributions to distance when the planet is to the side of the Earth-Sun line do not cancel out (contributions to distance when the planet is along the Earth-Sun line do cancel out).

Some of the simplest things do perplex!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Which planet is closest to earth?
« Reply #12 on: March 26, 2019, 11:27:17 am »
Guys, would you just confirm that I have understood this properly?  In your models, I assume that you are taking the scalar average of the distances to the Earth of (the Sun), Mercury, Venus and Mars over time - and then you get the results that Mercury has the lowest value (with result close to 1AU).  I imagine that if you were to take a vector average of the distances, all would come out at 1AU: the average vector distance from the Sun of each planet is zero (by symmetry).

So the reason that any of the planets has an average scalar distance above 1AU is that contributions to distance when the planet is to the side of the Earth-Sun line do not cancel out (contributions to distance when the planet is along the Earth-Sun line do cancel out).

Some of the simplest things do perplex!

I am using standard distance calculation from the X and Y legs of a right triangle and dist = the Hypotenuse:
X^2 + y^2 = dist^2
so, dist = SQR(X^2 + Y^2)
 
X = difference of x's of Earth and other planet
Y = difference of y's between Earth and another planet

The planets start in alignment in circular orbits around the Sun (origin 0, 0).
They are plotted each day on their orbit according to an Earth day's change in angle calculated by:
2*PI / (Planet's Year in Earth Days)

eg Mercury's change in angle in 1 Earth day = 2*PI / 88 (days) because in 88 Earth days Mercury will have made one complete orbit.

so MercuryX = SunX + MercuryOrbitRadius * (COS(EarthDays * MercuryAngleChangeInDay))
    MercuryY = SunY + MercuryOrbitRadius * (SIN(EarthDays * MercuryAngleChangeInDay))

Earth x, y calc'd the same way, SunX, SunY are 0 because origin of Simplified Solar System with Circular Orbits.

DistEarthMerc = SQR( (EarthX - MercX)^2 + (EarthY -MercY)^2)

The distance are accumulated each day, divide by days to get average.

Also each day the distances are compared and the one closest to Earth gets counted as closest that day.

The scalar units are Millions of KM.

x and y coordinates are vectors so "average vector" makes no sense to me.
« Last Edit: March 26, 2019, 11:37:57 am by bplus »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Which planet is closest to earth?
« Reply #13 on: March 26, 2019, 01:03:20 pm »
bplus, thanks.  It is as I thought.  Your SQR() function does make the distances scalar.  The vector thing goes as follows:  the average distance of the Earth to the Sun is 1AU; the average position of the Earth wrt the Sun is zero.  The vector average* would require the signs of x- & y- to be taken into account.  The SQR() removes sign.

Thanks, david, for a very interesting problem.

* I expect that that is not the correct mathematical term.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Which planet is closest to earth?
« Reply #14 on: March 26, 2019, 01:32:20 pm »
bplus, thanks.  It is as I thought.  Your SQR() function does make the distances scalar.  The vector thing goes as follows:  the average distance of the Earth to the Sun is 1AU; the average position of the Earth wrt the Sun is zero.  The vector average* would require the signs of x- & y- to be taken into account.  The SQR() removes sign.

Thanks, david, for a very interesting problem.

* I expect that that is not the correct mathematical term.

HA! In one year, the average position of the Earth to the Sun is (0, 0) though, Thank God!, the Earth was never there!