Question: In this problem you should create a solar system, like in the following video: I upload picture because not valid to upload video. using processing

 In this problem you should create a solar system, like in

In this problem you should create a solar system, like in the following video:

I upload picture because not valid to upload video.

using processing :

If you notice, there is a sun, there are two planets going in opposite direction, and one of the planets has a moon. The problem is to reproduce what you saw in the video (it should have the same features, but doesn't have too look exactly the same).

What we will use for this is trigonometry on the circle.

You will need to tell time, so you should include (outside the game loop)

Drawing the sun should be simple. You draw a disk in the middle of the screen - it never moves.

The planet should follow a circular trajectory around the sun. Here is the pseudo-code for calulating the position of a planet moving around around the sun

planetx = sunx + distsun * cos(angvel * t)

planety = suny + distsun * sin(angvel * t)

Here "distsun" is the distance to the sun, and "angvel" is the angular velocity. An angular velocity of 2

means the planet will need 1 second for one rotation around the sun.

You should now implement drawing the sun, the two planets and the moon, similar to the video above. More precisely,

  • The inner planet needs 5 seconds per rotation around the sun. The rotation should be clockwise.
  • The outer planet needs 10 seconds per rotation around the sun. The rotation should be counterclockwise.
  • The moon should move around the outer planet in clockwise rotation taking 3 seconds per rotation.

In theory, a counterclockwise should be done using positive angles. But that is not the case. Can you explain why??

Submit your source code with the comments.

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!