Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University,...

7
Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013

description

Problem We want to calculate this distance! (9, -4) (0, 0)

Transcript of Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University,...

Page 1: Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013.

Distance Challenge

By: Chris BrownUnder the direction of Prof. Susan Rodger

Duke University, January 2013

Page 2: 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

Page 3: Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013.

ProblemWe want to calculate this distance!

(9, -4)

(0, 0)

Page 4: Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013.

Problem

• Now, Jimmy wants to go from the theme park to the museum…

(9, -4)

(-6, -6)

Page 5: Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013.

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.

Page 6: Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013.

world.distance

Fill this in!

Page 7: Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University, January 2013.

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.