Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

would like to check what kind of codes can i write to orbit a circle for 300 pixels? Start by running the solarSystemTEMPLATE sketch using

would like to check what kind of codes can i write to orbit a circle for 300 pixels?
image text in transcribed
image text in transcribed
Start by running the solarSystemTEMPLATE sketch using your p5 editor (e.g. Brackets, vS code etc.). What you'll see is a function called celestialObj() which draws any celestial object you want, whether it's the sun, a planet or a moon. It takes a color and a diameter. When you first run it, the sketch already shows the sun. There's also a variable called speed which you will use in order to rotate objects at various speeds. The variable speed is equivalent to the frameCount variable of p5js, the variable that measures how many frames have been displayed on the canvas. Step 1: Create an earth of color blue and size 80. Move it to orbit 300 pixels. Hint: You should only use transformations to achieve this. Step 2: Rotate the earth around the sun at velocity "speed". Make sure you use the radians() function inside the rotate) call. Step 3: Make the earth spin around its axis at velocity "speed" too. You should now have an earth that rotates around its axis and around the sun. Step 4: Add a moon of color white and size 30 to the earth at an orbit of 100 pixels. Make the moon rotate at velocity -speed"2 so it spins the opposite way to the way the earth rotates. Make sure that your moon, while spinning around the earth, always shows the same side to earthlings (ie earthlings should not be able to see the so-called 'dark side of the moon'). Step 5: Make the sun spin around its axis, as it really does, at a slow speed/3. Step 6: Extend the sketch by adding one more celestial body by implementing one of the ideas for further development

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions