Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013
Problem • It’s Jimmy’s first time in a new city, and we need to help him find his way around! He knows where he is located in the center at (0, 0) to start, and he also knows the coordinates of each place he wants to visit. Your job will be to fill in the distance function, to calculate the distance from Jimmy to his destination. You can move around the city by clicking on the different places of interest that you want to visit. • 1 unit = 1 meter
Problem We want to calculate this distance! (0, 0) (9, -4)
Problem • Now, Jimmy wants to go from the theme park to the museum… (9, -4) (-6, -6)
world.distance • Each time the distance function is called, four parameters are passed in with information you will need. It provides you with Jimmy’s x value, Jimmy’s y value, the destination’s x value, and the destination’s y value. It is your job to correctly return the distance from Jimmy to his destination in this function. • Hint: What is the distance formula? It can be derived from Pythagorean’s Theorem.
world.distance Fill this in!
Bonus Challenge! • Go into the Alice Object Gallery to add new places, with an original animation every time Jimmy visits that place. Make sure to create variables for your location’s x and y position to be passed into your distance function later on.