Question: Can help me check my codes on where I should include the velocity speed to rotate ? Question : Step 1: Create an earth of

Can help me check my codes on where I should include the velocity "speed" to rotate ?

Question :

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.

My Codes :

var speed;

var angle1 = 0;

var angle2 = 0;

var angle3 = 0;

function setup() {

createCanvas(900, 700);

}

function draw() {

background(0);

speed = frameCount;

// drawing of SUN

push();

translate(width/2, height/2);

rotate(angle1);

speed/3 ;

celestialObj(color(255,150,0), 200); // SUN

angle1 += 0.01;

pop();

// drawing of earth

push();

translate(width/2, height/2);

rotate(angle1);

translate(300,0);

rotate(angle2);

celestialObj(color(0,0,255), 80); // EARTH

angle2 += 0.01;

pop();

//drawing of moon

push();

translate(width/2, height/2);

rotate(angle1);

translate(300,0);

rotate(angle2);

translate(100,0);

rotate(angle3);

celestialObj(color(255,255,255), 30); // MOON

angle3+=0.01;

pop();

}

function celestialObj(c, size){

strokeWeight(5);

fill(c);

stroke(0);

ellipse(0, 0, size, size);

line(0, 0, size/2, 0);

}

can you please reply following my codes? Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!