The Solar System
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
NETLOGO DEMO-3
Solar system: optimized code & adjusted scale (optional)
This is also a computermodel of the Solar System, but now using optimized programming code and adjusted scale (optional)!
Distance of 8 planets to the Sun is in Astronomical Units (AU): 1 AU = 149.6 * 1000000 km = distance Earth to Sun. The default distance to the sun and size (diameter) of the planets is to scale.
The interface consists of 5 elements:
- the first Switch can be used to put a background image of the universe (stars) on the screen*
- the second Switch can be used to adjust the scale. That is, an equal distance between the different orbits is used and a relative size of the planets. This makes the differences more apparent.
- the Setup button puts the sun and its 8 planets on the screen
- the Go button makes the planets orbit the sun; the process is stopped after the button is pressed again
- input field for entering the max. number of years the planets will orbit
- the Slider (top) can be used to adjust the speed of the moving planets; every tick corresponds to 1 day
The (end) result can be viewed in both 2D and 3D. Image coordinates of the Lower-Left Corner and Upper-Right Corner are: LLC = -35,-35; URC = 35,35.
*If the "backImage?" Switch is turned ON, a popup menu will appear during program execution, where the file "stars.jpg" must be selected!
Comments and Questions
; NETLOGO DEMO-3 ; Computermodel of the Solar System ; Optimized programming code & adjusted scale (optional) ! ; © Drs. Ioannis Guertsonii, 2024 ; ------------------------------------------------------------------------- globals [ ; GLOBAL VARIABLES sun ; sun object ss ; size sun (diameter) xc ; x-coordinate center solar system yc ; y-coordinate center solar system xb ; x-coordinate planet yb ; y-coordinate planet ] turtles-own [ ; TURTLE ATTRIBUTES name ; name planet dfs ; distance from sun ot ; orbit time a ; angle a1 ; angle in 1 day ] to setup ; SETUP BUTTON clear-all if (backImage?) [ ; get background image of the universe (optional) import-drawing "stars.jpg" ] setup-sun ; call sun procedure setup-planets ; call planets procedure reset-ticks end to setup-sun ; SUN PROCEDURE create-turtles 1 [ set shape "circle" set color yellow set ss (5) ; not to scale ! set size ss setxy 0 0 set sun self ] end to setup-planets ; PLANETS PROCEDURE ifelse not(trueScale?) [ ; NO True Scale let planet-data [ ; name, distance from sun (relative), orbit-time (days), color, size (relative) ["Mercury" 4 880 violet 1] ["Venus" 8 225 pink 3] ["Earth" 12 365 green 4] ["Mars" 16 687 red 2] ["Jupiter" 20 4332 brown 8] ["Saturn" 24 10759 grey 7] ["Uranus" 28 30688 cyan 6] ["Neptune" 32 60182 blue 5] ] foreach planet-data [ ?1 -> create-turtles 1 [ set name item 0 ?1 set dfs item 1 ?1 set ot item 2 ?1 set color item 3 ?1 set size (item 4 ?1) / 2 set shape "circle" setxy (ss / 2 + dfs) 0 set label name ] ] ] [ ; TRUE Scale let planet-data [ ; name, distance from sun (AU), orbit-time (days), color, size (diameter) ["Mercury" 0.4 880 violet 0.5] ["Venus" 0.7 225 pink 1.2] ["Earth" 1 365 green 1.3] ["Mars" 1.5 687 red 0.7] ["Jupiter" 5.2 4332 brown 7.15] ; actual size = 14.3 ["Saturn" 9.5 10759 grey 6.0] ; actual size = 12.0 ["Uranus" 19 30688 cyan 5.1] ["Neptune" 30 60182 blue 4.9] ] foreach planet-data [ ?1 -> create-turtles 1 [ set name item 0 ?1 set dfs item 1 ?1 ; Astronomical Unit (AU): 1 AU = 149.6 * 1000000 km set ot item 2 ?1 set color item 3 ?1 set size (item 4 ?1) / 2 ; Actual diameter = size * 10000 km set shape "circle" setxy (ss / 2 + dfs) 0 set label name ] ] ] end to go ; GO BUTTON -> Procedure will be repeated until Button is pushed again tick ; next day ask turtles with [self != sun] [ if ticks > 0 [ pen-down ] set a1 (360 / ot) set a (a + a1) set xb (xc + (ss / 2 + dfs) * cos(a)) ; calculate new position planet set yb (yc + (ss / 2 + dfs) * sin(a)) setxy xb yb ; move to new position ] if (ticks = nrYears? * 365) [ stop ] ; standard stop after entered number of years end
There is only one version of this model, created 11 months ago by Ioannis Guertsonii.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
stars.jpg | jpeg | Background image of the Solar System | 11 months ago, by Ioannis Guertsonii | Download |
The Solar System.png | preview | Preview for 'The Solar System' | 11 months ago, by Ioannis Guertsonii | Download |
This model does not have any ancestors.
This model does not have any descendants.