In this simulation, you will be able to add the missing planets of our solar system, and possibly more! The universe has endless space, after all. To do this, you will be looking at data. Data is a way for the computer to store massive amounts of values into a single variable, which means you can select the data whenever you type the name of the variable. For example:
var somedata = ["apples", "oranges","pineapple"];
This is a type of variable, called an 'array', in which to store data. This is much more efficient than trying to use a bunch of variables, like:
fruit1 = "apples";
fruit2 = "oranges";
fruit3 = "pineapple";
With data, you can loop through it, which becomes very efficient, compared to creating code for each variable, or in our case, each planet.
In order to access a value in data, you would use:
somedata[0];
This code would select the first value in somedata. The order in an array actually starts from 0, rather than 1.
In data, we can also use numbers, text(usually called strings), and objects. Objects are variables that can store multiple 'properties'. They look like this:
var human = {"name": "Tom", "height": 5.5, "coolness": "9/10", "favorite_movie": "Deadpool"}
If you wanted to get the human's coolness, you would use:
human.coolness
You can store multiple objects in array easily, so we could actually store the attributes of everyone in this class into a single variable.
In this simulation, I have created data for Earth. It looks like this:
var data = [{name: "Earth", mass: 5.97, diameter: 12756 }];
Mass is in units of 10²⁴ kilograms, and diameter is in units of kilometers.
Here are hints to finding the diameter of each planet.
| Name | Radius | Circumference | Surface Area | Diameter | Mass |
|---|---|---|---|---|---|
| Sun | 1392000π | 1988500 | |||
| Mercury | 2439.5 | 0.330 | |||
| Venus | 38025.8 | 4.87 | |||
| Earth | 6378 | 12756π | 162715536π | 12756 | 5.97 |
| Moon | 12075625π | 0.073 | |||
| Mars | 6792π | 0.642 | |||
| Jupiter | 64228053049.5 | 1898 | |||
| Saturn | 378675 | 568 | |||
| Uranus | 25559 | 86.8 | |||
| Neptune | 2453022784π | 102 | |||
| Pluto | 7445.6 | 0.0146 |
Remember:
- Diameter = 2 × r
- Circumference = 2 × π × r
- Surface Area = 4 × π × r²
It will be your job to to add the missing planets. To do this, you'll need to navigate to main.js in the code file. It is in the js folder. There is a variable that you'll want to change. It looks like this:
var planetData = {"data":[
{name: "Earth", mass: 5.97, diameter: 12756 },
]
};
It is an object with an attribute as an array of objects. As you can see, we only have Earth. Let's fix that! After all, we wouldn't want our lovely planet Earth to be lonely now, would we? And what would be the point of looking at the simulations if there was nothing to compare planet Earth to? ;)
There are several ways to get the code for the simulation onto your computer:
If you choose to use git, then you'll first to want to open Terminal. Search Terminal on your computer and open it. Type:
cd Documents
and hit enter to navigate to the Documents folder within Terminal (it's just like the Finder). Then you'll want to type in the following git commands. You can just copy and paste the entire block and hit enter. Git will do the work for you. Believe in Git.
git clone https://github.com/CelestialSimulations/Relative-Sizes-of-Planets.git
cd Relative-Sizes-of-Planets
git submodule init
git submodule update
After a few seconds, a folder named Relative-Sizes-of-Planets should appear within the Documents folder! Open up Atom (you can just search for it on the computer) using spotlight, can drag your folder to the Atom application. You should see all of the code.
Downloading it is fairly simple. However, there is a repository within this code, so you'll need to download that as well. First, navigate to this button on this repository,
Click Dowload ZIP. Then navigate to the inner repository, and download it as well. Expand the ZIPs, and move both folders to the Documents folder. Drag the contents of the Viewer-components folder to the empty lib folder in the Relative-Sizes-of-Planets folder. The code should then have what it needs in order to work. Open up Atom (you can just search for it on the computer), and drag your folder to the Atom application. You should see all of the code.
In order to 'fork' a repository, which is to say, copy a version to it to your own account, you'll need to create a Github account — and it's never too soon to try Github. Once you've done that, return to this repository, and click the Fork button.
Now open Github Desktop, click the plus icon, and select the Clone tab.
You should see your forked repository in the list. Click that, and click the button 'Clone Relative-Sizes-of-Planets'. Github Desktop will ask where you want your file, and you'll be able to place it and name it. It should promptly start cloning the repository, and you will find it in the location where you chose it to be. Open up Atom (you can just search for it on the computer), and drag your folder to the Atom application. You should see all of the code.
I'm sure you'll want to preview and see if the code appears to work. To do this, simply open the folder in finder, and double click on index.html. It will automatically open in the browser.
Also, you'll probably want to rename the folder so that you know it's yours and won't conflict for the next person who needs to get the code for themselves on the same computer.


