YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Lunar Orbit Solution - Differential Equations in Action

Get Embed Code
3 Languages

Showing Revision 4 created 05/24/2016 by Udacity Robot.

  1. So in the solution to this problem set, we've added a for loop whose index

  2. ranges from 0 to the number of steps.
  3. We put the number of steps plus 1 as the argument for range
  4. because i will go up to the number inside minus 1.
  5. Inside the loop, we've created a variable called angle, which is equal to 2π times the index
  6. divided by the number of steps that are taken in the trajectory.
  7. Have you look over this picture. You can sort of see what's happening.
  8. The moon starts in this position, then after 1 time step,
  9. it's into this position and so on and so forth.
  10. The number of segments will equal the number of steps
  11. and the number of lines will equal the number of steps plus 1.
  12. After this, we use the array x to define the horizontal
  13. and vertical positions of the moon at any given time step.
  14. It's at this point that we have to remember our trigonometric functions--sine and cosine.
  15. In this first line right here, we're defining the horizontal position of x for the i-the timestep.
  16. In the second line, which is a sine, is what's going to show us the vertical position.
  17. This is one of those cases where being able to see a right triangle in this picture is very helpful.
  18. Looking at our picture, this horizontal line right here that extends from the earth out to the moon's orbit
  19. is the 0 radian or the 0 degree line.
  20. We're measuring all of the angles that the moon is going to be marked at up from this line.
  21. That means that at any given moment, we can draw a line from the moon down to this horizontal line
  22. to create a right triangle, which will then allow us to use sine and cosine in conjunction with this angle
  23. to determine the moon's vertical and horizontal distance from the earth.
  24. Going back to our code, after all of these is filled in, if we run the program,
  25. we end up with a perfect circle, just like we were hoping to get
  26. for the trajectory of the moon around the earth in this ideal simulation.