๐ Solar System in Processing ๐ช
Hello, budding astronomers and programmers! Letโs embark on an interstellar journey to create a model of our solar system at a certain point in time. Donโt worry, soon weโll make those celestial bodies revolve! ๐ First, however, you should click on the gif below to decide which phase of our solar system you will simulate.
Click to learn about the solar system

๐ป Plan ๐ป
Answers these for planning
1. What are you going to build?2. What colors will you use?
3. What shapes will you use?
4. What future actions will you want your planets/stars to do?
5. How will you know you are done?
7. What are your variables
9. What is your input
11. What is your output?
๐ Peer Review ๐
Before moving on, you must have your idea/plan peer-reviewed by three other students. Peer review is the crux of all science
First, gain and give 3 Peer reviews. In this class, peer review is simple. Give a ๐ glow ๐, ๐ฟ grow ๐ฟ, and an ๐ฌ insight ๐ฌ as a comment. Less than a paragraph is not helpful, more than a few paragraphs is scary.
๐ฆโ๐ฅ When Being reviewed ๐ฆโ๐ฅ
- Create a flow chart of your program logic. - Explain how said logic will represent the science aspect of our solar system by doing x, y, and z. - Explain how said logic will represent the artistic aspect of our solar system by doing x, y, and z credit.Flow Chart
Code Review Example
def circle_area(radius):
pi = 3.14
return pi * radius * radius
Peer Review:
๐ Glow ๐: Great job on keeping the function concise and to the point! The function name circle_area is descriptive, and it's clear what the function is intended to do. Using a clear variable name like radius also makes the code easy to understand.
๐ฟ Grow ๐ฟ: Consider using the built-in math.pi instead of hardcoding the value of pi to 3.14. This would make the calculation more accurate and also show that you're utilizing Python's built-in libraries effectively.
๐ฌ Insight ๐ฌ: Did you know that the formula you used is derived from the integral of r with respect to ฮธ from 0 to 2ฯ in polar coordinates? It's fascinating how math and programming often intersect in such ways!
โญ Step 1: Set up the Cosmic Canvas
๐พ Code Example
๐ฆฎ Hint
The `size(800, 600);` sets our universe's width and height. Feel free to make it bigger or smaller!๐ Step 2: Light Up the Stars
๐พ Code Example
๐ฆฎ Hint
The `ellipse(400, 300, 100, 100);` function draws the sun. The first two values set the position (x, y), and the last two values set the width and height of the ellipse.
You already have been making flow charts and using conditionals! Here is a basic condition in Java!
๐ฒ Step 3: If ๐ do
Look up and add user input and a conditional to your program. I suggest using the mouse, but you can use whichever method you like.
๐ Input Hint
Input is the first thing I think about. What data does the program need? Check out this link to see how processing allows a programmer to create interactive works of art! [Processing Mouse Example](https://processing.org/examples/mousefunctions.html)๐ฆฎ If/Else Hint
If statements in Java are the same as in every language. The only change is in the structure of the words, i.e., syntax.Flow Chart
Here is the actual Java code!
๐ช Step 4: Add New Components
Use three new methods and use three arguments by using the processing documentation.
Can you add the moons, asteroid belts, or scale planet sizes? Soon, we will make this solar system spin :) Perhaps the stars are just coming to life, or itโs the end of the solar system.
Methods & Arguments
๐ ๏ธ Method ๐ ๏ธ
Imagine you have a toy robot ๐ค. This robot can do different things like walk ๐ถ, dance ๐, and sing ๐ค. Each of these actions is like a "method" for the robot. In Python, objects (like our robot) can have methods that allow them to do specific tasks. In Python, you can chain methods together
# Calling a Method
robot.dance()
# Chaining methods
robot.dance().backfilp()
answer = input("what is the answer?")
anwser.find(string.upper())
Here, `dance` is a method that makes the robot dance.
๐ Argument ๐
Now, let's say your robot can also paint ๐จ, but it needs to know which color to use. You tell the robot the color by giving it a small box ๐ with the paint inside. This box is like an "argument" you give to the method.robot.paint("blue")
Here, `"blue"` is the argument you're giving to the `paint` method to tell the robot which color to use.
So, in simple terms: - A ๐ ๏ธ method ๐ ๏ธ is an action or task that something can do.
- An ๐ argument ๐ is extra information you give to help the method do its job. I hope that helps! ๐
๐ฆ Step 5: Presentations
Pick a topic below to research, demo, and teach your classmates. This will happen, in the next class! First come first choice. I will update this list as it progresses.
Present
- Sequence- Input
- Parameters
- Conditionals
- Data types
You will be required to give a short assessment at the end of the presentation. The class average of your assessment will be your presentation grade! You may not go over 10 mins. The format is however you wish to teach!
๐Step 6: User Interaction๐
To step up for the triva game, we need to learn how to handle user inputs to control our canvas. To start, we will use the functions:
map()mouseX()mouseY()
We will make the background changed based on where the mouse is at!
๐ Step 7: Am I Done ๐?
Check List
- Peer review document (3 reviews given, 3 reviews received)
- Flow Chart (Image)
- User input used (commented in code)
- Conditional Statement used with AND & OR (commented in code)
- Art aspect clear (commented in code)
The science aspect is clear (commented in code)
- 3 unique shapes (commented in code)
- 3 unique colors (commented in code)
- Create Class Lesson (Your choice of medium)
- Use three new methods (commented in code)
- use three arguments (commented in code)