Author Topic: Solar System Model  (Read 4199 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Solar System Model
« on: September 20, 2020, 01:03:42 am »
I'm not sure if I ever made one of these as a windows program, if I did it was over a year ago probably. But here is a model of the Solar System with 8 planets and Pluto. The distance isn't true of course, but the orbital periods are real compared to Earth's. I used NASA figures on those. Use your mouse wheel to speed it up and slow back down. You can't stop it, just slow it down to how it was when it started. I may add more detail to this someday. But I like it. :)

Code: QB64: [Select]
  1. _TITLE "Ken's Solar System - Use the mouse wheel to control speed."
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. orbit = 30
  4. speed = 0
  5. t = 0
  6.     _LIMIT 30
  7.     mouseWheel = 0
  8.         mouseWheel = mouseWheel + _MOUSEWHEEL
  9.         IF mouseWheel > 0 THEN speed = speed - .005
  10.         IF mouseWheel < 0 THEN speed = speed + .005
  11.         IF speed < 0 THEN speed = 0
  12.     LOOP
  13.     t = t + .05 + speed
  14.     'Mercury
  15.     x = (SIN(t / 0.241) * orbit) + 400
  16.     y = (COS(t / 0.241) * orbit) + 300
  17.     FOR sz = .25 TO 2 STEP .25
  18.         CIRCLE (x, y), sz, _RGB32(127, 127, 127)
  19.     NEXT sz
  20.     orbit = orbit + 20
  21.     'Venus
  22.     x = (SIN(t / 0.615) * orbit) + 400
  23.     y = (COS(t / 0.615) * orbit) + 300
  24.     FOR sz = .25 TO 4 STEP .25
  25.         CIRCLE (x, y), sz, _RGB32(255, 0, 0)
  26.     NEXT sz
  27.     orbit = orbit + 20
  28.     'Earth
  29.     x = (SIN(t) * orbit) + 400
  30.     y = (COS(t) * orbit) + 300
  31.     FOR sz = .25 TO 4 STEP .25
  32.         CIRCLE (x, y), sz, _RGB32(0, 0, 255)
  33.     NEXT sz
  34.     orbit = orbit + 30
  35.     'Mars
  36.     x = (SIN(t / 1.88) * orbit) + 400
  37.     y = (COS(t / 1.88) * orbit) + 300
  38.     FOR sz = .25 TO 3 STEP .25
  39.         CIRCLE (x, y), sz, _RGB32(255, 0, 0)
  40.     NEXT sz
  41.     orbit = orbit + 40
  42.     'Jupiter
  43.     x = (SIN(t / 11.9) * orbit) + 400
  44.     y = (COS(t / 11.9) * orbit) + 300
  45.     FOR sz = .25 TO 10 STEP .25
  46.         CIRCLE (x, y), sz, _RGB32(238, 155, 127)
  47.     NEXT sz
  48.     orbit = orbit + 40
  49.     'Saturn
  50.     x = (SIN(t / 29.4) * orbit) + 400
  51.     y = (COS(t / 29.4) * orbit) + 300
  52.     FOR sz = .25 TO 7 STEP .25
  53.         CIRCLE (x, y), sz, _RGB32(255, 127, 127)
  54.     NEXT sz
  55.     CIRCLE (x, y), 11, _RGB32(255, 127, 127)
  56.     orbit = orbit + 30
  57.     'Uranus
  58.     x = (SIN(t / 83.7) * orbit) + 400
  59.     y = (COS(t / 83.7) * orbit) + 300
  60.     FOR sz = .25 TO 8 STEP .25
  61.         CIRCLE (x, y), sz, _RGB32(128, 127, 255)
  62.     NEXT sz
  63.     orbit = orbit + 30
  64.     'Neptune
  65.     x = (SIN(t / 163.7) * orbit) + 400
  66.     y = (COS(t / 163.7) * orbit) + 300
  67.     FOR sz = .25 TO 8 STEP .25
  68.         CIRCLE (x, y), sz, _RGB32(83, 183, 255)
  69.     NEXT sz
  70.     orbit = orbit + 40
  71.     'Pluto
  72.     x = (SIN(t / 247.9) * orbit) + 400
  73.     y = (COS(t / 247.9) * orbit) + 300
  74.     FOR sz = .25 TO 2 STEP .25
  75.         CIRCLE (x, y), sz, _RGB32(166, 127, 127)
  76.     NEXT sz
  77.     orbit = 30
  78.     _DELAY .1
  79.     _DISPLAY
  80.     CLS
  81.     FOR sz = .25 TO 4 STEP .25
  82.         CIRCLE (400, 300), sz, _RGB32(255, 255, 127)
  83.     NEXT sz
  84.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Solar System Model
« Reply #1 on: September 20, 2020, 01:18:50 am »
I was right, I did make another one, in fact a better one in August 2019. But the only thing my newer one has (above) is the ability to speed up and slow down the planets. The older one doesn't. But the older one you can zoom in and also tilt the planetary rotation. Here is the older one from last year. This one even has our Moon going around the Earth, with the help of STxAxTIC. If you go through the code of the older one and compare with the newer one, there's a LOT more code and I used the older way of making a circle which also uses more code. This older one also lets you put your mouse over each planet to get the names of them.

Code: QB64: [Select]
  1. 'Ken G. made thie program on August 18, 2019,
  2. 'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with The Moon orbit!
  3.  
  4. _TITLE "Solar System Simulator by Ken G. Use Mouse Over Planets, Mouse Wheel to Zoom, and Up and Down Arrow Keys To Tilt."
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. DIM z(10)
  7. mercury = 0.241
  8. venus = 0.6152
  9. mars = 1.8809
  10. jupiter = 11.8618
  11. saturn = 29.457
  12. uranus = 84.0205
  13. neptune = 164.8
  14. angle = 180
  15. tilt = 1
  16. one:
  17. _LIMIT 500
  18. mouseWheel = 0
  19.     mouseX = _MOUSEX
  20.     mouseY = _MOUSEY
  21.     mouseLeftButton = _MOUSEBUTTON(1)
  22.     mouseRightButton = _MOUSEBUTTON(2)
  23.     mouseMiddleButton = _MOUSEBUTTON(3)
  24.     mouseWheel = mouseWheel + _MOUSEWHEEL
  25. IF mouseWheel < 0 THEN angle = angle - 10
  26. IF mouseWheel > 0 THEN angle = angle + 10
  27.  
  28. IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun    "
  29. IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"
  30. IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus  "
  31. IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth  "
  32. IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars   "
  33. IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"
  34. IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "
  35. IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "
  36. IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune"
  37.  
  38. a$ = INKEY$
  39. IF a$ = CHR$(27) THEN END
  40. IF a$ = CHR$(0) + CHR$(72) THEN tilt = tilt + 1
  41. IF a$ = CHR$(0) + CHR$(80) THEN tilt = tilt - 1
  42. IF angle > 360 THEN angle = 360
  43. IF angle < 10 THEN angle = 10
  44. IF tilt > 50 THEN tilt = 50
  45. IF tilt < 1 THEN tilt = 1
  46. seconds = seconds + .01
  47. s1 = (60 - seconds) * 6 + 180 / mercury
  48. s2 = (60 - seconds) * 6 + 180 / venus
  49. s3 = (60 - seconds) * 6 + 180 'Earth and Moon
  50. s4 = (60 - seconds) * 6 + 180 / mars
  51. s5 = (60 - seconds) * 6 + 180 / jupiter
  52. s6 = (60 - seconds) * 6 + 180 / saturn
  53. s7 = (60 - seconds) * 6 + 180 / uranus
  54. s8 = (60 - seconds) * 6 + 180 / neptune
  55.  
  56.  
  57. 'Mercury
  58. oldx1 = x1
  59. x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400
  60. y1 = INT(COS(s1 / 45 * 3.141592) * (angle / 4) / tilt) + 300
  61.  
  62. 'Venus
  63. oldx2 = x2
  64. x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400
  65. y2 = INT(COS(s2 / 90 * 3.141592) * (angle / 2) / tilt) + 300
  66.  
  67. 'Earth
  68. oldx = x
  69. x = INT(SIN(s3 / 180 * 3.141592) * angle) + 400
  70. y = INT(COS(s3 / 180 * 3.141592) * angle / tilt) + 300
  71.  
  72. 'Mars
  73. oldx3 = x3
  74. x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400
  75. y3 = INT(COS(s4 / 270 * 3.141592) * (angle * 1.5) / tilt) + 300
  76.  
  77. 'Moon
  78. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + x
  79. y4 = INT(COS(19 * s3 / 270 * 3.141592) * (angle / 10) / tilt) + y
  80.  
  81. 'Outer Planets
  82. 'Jupiter
  83. oldx5 = x5
  84. x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400
  85. y5 = INT(COS(s5 / 450 * 3.141592) * (angle * 3) / tilt) + 300
  86.  
  87. 'Saturn
  88. oldx6 = x6
  89. x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400
  90. y6 = INT(COS(s6 / 630 * 3.141592) * (angle * 4.5) / tilt) + 300
  91.  
  92. 'Uranus
  93. oldx7 = x7
  94. x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400
  95. y7 = INT(COS(s7 / 810 * 3.141592) * (angle * 6) / tilt) + 300
  96.  
  97. 'Neptune
  98. oldx8 = x8
  99. x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400
  100. y8 = INT(COS(s8 / 990 * 3.141592) * (angle * 7.5) / tilt) + 300
  101.  
  102.  
  103. 'Sun
  104. CIRCLE (400, 300), 5, _RGB32(249, 240, 22)
  105. PAINT (400, 300), _RGB32(249, 240, 22)
  106.  
  107. IF tilt > 6 THEN
  108.     IF x1 > oldx1 AND x1 > 375 AND x1 < 425 THEN z(1) = 1
  109.     IF x2 > oldx2 AND x2 > 375 AND x2 < 425 THEN z(2) = 1
  110.     IF x3 > oldx3 AND x3 > 375 AND x3 < 425 THEN z(3) = 1
  111.     IF x5 > oldx5 AND x5 > 375 AND x5 < 425 THEN z(4) = 1
  112.     IF x6 > oldx6 AND x6 > 375 AND x6 < 425 THEN z(5) = 1
  113.     IF x7 > oldx7 AND x7 > 375 AND x7 < 425 THEN z(6) = 1
  114.     IF x8 > oldx8 AND x8 > 375 AND x8 < 425 THEN z(7) = 1
  115.     IF x > oldx AND x > 375 AND x < 425 THEN z(8) = 1
  116.  
  117.     IF x1 > oldx1 AND x1 > 424 THEN z(1) = 0
  118.     IF x2 > oldx2 AND x2 > 424 THEN z(2) = 0
  119.     IF x3 > oldx3 AND x3 > 424 THEN z(3) = 0
  120.     IF x5 > oldx5 AND x5 > 424 THEN z(4) = 0
  121.     IF x6 > oldx6 AND x6 > 424 THEN z(5) = 0
  122.     IF x7 > oldx7 AND x7 > 424 THEN z(6) = 0
  123.     IF x8 > oldx8 AND x8 > 424 THEN z(7) = 0
  124.     IF x > oldx AND x > 424 THEN z(8) = 0
  125.  
  126.  
  127.     IF x1 < oldx1 THEN z(1) = 0
  128.     IF x2 < oldx2 THEN z(2) = 0
  129.     IF x3 < oldx3 THEN z(3) = 0
  130.     IF x5 < oldx5 THEN z(4) = 0
  131.     IF x6 < oldx6 THEN z(5) = 0
  132.     IF x7 < oldx7 THEN z(6) = 0
  133.     IF x8 < oldx8 THEN z(7) = 0
  134.     IF x < oldx THEN z(8) = 0
  135.  
  136.     IF z(1) = 0 THEN
  137.         'Mercury
  138.         CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  139.         PAINT (x1, y1), _RGB32(120, 98, 102)
  140.     END IF
  141.  
  142.     IF z(2) = 0 THEN
  143.         'Venus
  144.         CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  145.         PAINT (x2, y2), _RGB32(161, 67, 39)
  146.     END IF
  147.  
  148.     IF z(8) = 0 THEN
  149.         'Earth
  150.         CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  151.         PAINT (x, y), _RGB32(0, 0, 255)
  152.         'Moon
  153.         CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  154.         PAINT (x4, y4), _RGB32(179, 179, 181)
  155.     END IF
  156.     IF z(3) = 0 THEN
  157.         'Mars
  158.         CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  159.         PAINT (x3, y3), _RGB32(240, 72, 22)
  160.     END IF
  161.     IF z(4) = 0 THEN
  162.         'Outer Planets
  163.         'Jupiter
  164.         CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  165.         PAINT (x5, y5), _RGB32(255, 166, 127)
  166.     END IF
  167.     IF z(5) = 0 THEN
  168.         'Saturn
  169.         CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  170.         PAINT (x6, y6), _RGB32(255, 127, 127)
  171.         FOR rings = 4 TO 5
  172.             CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .2
  173.         NEXT rings
  174.     END IF
  175.     IF z(6) = 0 THEN
  176.         'Uranus
  177.         CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  178.         PAINT (x7, y7), _RGB32(127, 166, 255)
  179.     END IF
  180.     IF z(7) = 0 THEN
  181.         'Neptune
  182.         CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  183.         PAINT (x8, y8), _RGB32(0, 78, 255)
  184.     END IF
  185.  
  186.  
  187.     'Mercury
  188.     CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  189.     PAINT (x1, y1), _RGB32(120, 98, 102)
  190.  
  191.     'Venus
  192.     CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  193.     PAINT (x2, y2), _RGB32(161, 67, 39)
  194.  
  195.     'Earth
  196.     CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  197.     PAINT (x, y), _RGB32(0, 0, 255)
  198.     'Moon
  199.     CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  200.     PAINT (x4, y4), _RGB32(179, 179, 181)
  201.  
  202.     'Mars
  203.     CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  204.     PAINT (x3, y3), _RGB32(240, 72, 22)
  205.  
  206.     'Outer Planets
  207.     'Jupiter
  208.     CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  209.     PAINT (x5, y5), _RGB32(255, 166, 127)
  210.  
  211.     'Saturn
  212.     CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  213.     PAINT (x6, y6), _RGB32(255, 127, 127)
  214.     FOR rings = 1 TO 2
  215.         CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  216.     NEXT rings
  217.  
  218.     'Uranus
  219.     CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  220.     PAINT (x7, y7), _RGB32(127, 166, 255)
  221.  
  222.     'Neptune
  223.     CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  224.     PAINT (x8, y8), _RGB32(0, 78, 255)
  225.  
  226. IF seconds > 99999 THEN
  227.     CLS
  228.     seconds = 0
  229.     GOTO one:
  230. GOTO one:
  231.  
« Last Edit: September 20, 2020, 01:21:32 am by SierraKen »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Solar System Model
« Reply #2 on: September 20, 2020, 05:10:25 am »
Cool model... I particularly like the tilt and zoom... Nicely done.

I have been interested in Astronomy since primary school when I first saw Saturn through one of those 'collapsible' telescopes. Once I started working, I purchased my own telescope, until my working hours conflicted with 'viewing' hours. My cousin 'inherited' my scope. Then I bought a copy of "Practical Astronomy with your calculator". Armed with a scientific calculator, pencil and paper... 45 minutes later I could calculate the next Lunar Eclipse and if it could be seen from my current location....  It took about the same time to calculate the approximate position for each planet... 8 to 10 hours... and that was for just 'one' point in time...

I wore out that calculator decades ago... My eyesight is not what it used to be... Computer models are a BIG interest now... Your model has reminded me of the joy of Astronomy... Thank you.
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Solar System Model
« Reply #3 on: September 20, 2020, 12:23:10 pm »
Wow that's great Johno! Earlier this year I took a free online college course about using an online telescope. I've used online telescopes for almost 10 years now but I finally took the course. It's from the Open University in England. If anyone is interested, it's here:
https://www.open.edu/openlearn/science-maths-technology/astronomy/astronomy-online-telescope/content-section-overview?active-tab=description-tab

Plus there's the simple (and free) NASA/Harvard/Smithsonian online telescope anyone can do here:
https://mo-www.cfa.harvard.edu/OWN/index.html


Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Solar System Model
« Reply #4 on: September 20, 2020, 04:40:12 pm »
Real Solar System from Russia

 
solarka.gif


1\3 MB

« Last Edit: November 24, 2020, 06:47:07 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Solar System Model
« Reply #5 on: September 21, 2020, 08:08:26 am »
Good work Ken, I've been working on my star system simulator a good bit lately and I credit you for getting me out of my coder's block. It was those cool looking buttons on your calculator ap that did it. After that, the ideas kept coming.

Interesting gif that Danilin put up, I've come up against the complexity of ship movement in a system of such a dynamic nature.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Solar System Model
« Reply #6 on: September 21, 2020, 01:29:37 pm »
Thanks OldMoses! I totally forgot about my calculator. :)
« Last Edit: September 21, 2020, 01:31:40 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Solar System Model
« Reply #7 on: September 21, 2020, 02:07:25 pm »
And is the sun in orbit to some center of gravity of the Milky way? And is the Milky way in orbit to some Universe center of gravity?

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Solar System Model
« Reply #8 on: September 21, 2020, 03:15:46 pm »
Galactic cluster, not the universe. That would imply some kind of grand universal center anyway, for which there is probably none
You're not done when it works, you're done when it's right.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Solar System Model
« Reply #9 on: October 20, 2020, 01:33:27 am »
Visualization of Solar system explains
impossibility of traveling in time:

transported to another time
there will be no Earth
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Solar System Model
« Reply #10 on: October 20, 2020, 05:34:29 am »
Pretty, and the ring around Saturn is a nice touch.

The Moon shouldn't be in front of Earth all the time tho.
QB64 has the power to include at least 10,000 asteroids. 
It works better if you plug it in.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Solar System Model
« Reply #11 on: October 20, 2020, 11:41:23 am »
SierraKen, DANILIN - cool guys - really, really cool.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Solar System Model
« Reply #12 on: October 20, 2020, 01:47:17 pm »
Thanks Dimster. :D

Offline Kernelpanic

  • Newbie
  • Posts: 94
    • View Profile
Re: Solar System Model
« Reply #13 on: October 20, 2020, 07:14:36 pm »
A nice program. It gave me the idea to "construct" a rocket - let's see whether also it takes off. ;)
Mark Twain
"Als wir das Ziel endgültig aus den Augen verloren hatten, verdoppelten wir unsere Anstrengungen."
„Having lost sight of our goals, we redoubled our efforts.“