34-Assignment-7-Where-Am-I

34-Assignment-7-Where-Am-I - CS107 Spring 2007 Handout 34...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS107 Handout 34 Spring 2007 May 21, 2007 Assignment 7: Where am I? Assignment written by Nick Parlante and polished off by Jerry. Here is the problem: You are in a two-dimensional space, and you are lost. Although you don't know your location, you do have a fairly accurate map that indicates where all the stars are in the space. To sort things out, you measure the approximate distance to several of the stars around you. Using the map and the distance measurements, figure out where you are. Due: Tuesday, May 29 th at 11:59 p.m. Consider the three-star system below. Suppose your observe a star which is one unit away, another star which is two units away, and a third which is three units away. You do not know the identities of the stars observed. Knowing that you are X units away from a star is equivalent to knowing that you are somewhere on a circle of radius X around that star. Below are circles of radius one, two, and three plotted around stars A, B, and C. Your location should be somewhere where three circles intersect. From that point, you must have looked out and saw the stars at their respective distances. ß and are potential points. However, cannot be your location— although it is one away from B, unfortunately it is three away from both A and C. ß must be your location. The star that was one away was B, the star that was two away was A, and the star that was three away was C. A B C ß
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 This problem demands a sophisticated algorithm. The expressiveness of the Scheme language allows you to concentrate on the ample challenges of the problem. The problem is presented in the form a problem set— you are asked to write many small functions. For the last step you will combine all of the small functions to solve the whole problem. This helps you to acclimate to Scheme-style decomposition— many short but conceptually dense functions. For each function, I have given some sample output. You should take advantage of this to test each function when it is written. Scheme is well suited to this sort of piecemeal approach. Scheme code is so dense, that debugging more than a few lines at a time becomes impossible, so you need to deal with things in little steps. I have also provided code to support the types 2-d "point" and "circle". There are routines to compute the distance between two points (easy) and to find the points of intersection of two circles (a pain). Strategy Overview What follows is one strategy for solving the problem. It's probably not the best, it's just the first solution I worked out. Feel free to experiment and try something different. Just document what you're doing. You should make extensive use of map . As raw material, you have a star map and several distance measurements. Each distance corresponds to some star, but you don't yet know which one. Pairing each distance with a particular star yields a "guess" which may or may not be right. Matching a distance with a star defines a circle, so you can think of a guess as a set of circles. So for example given the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course CS 107 taught by Professor Cain,g during the Spring '08 term at Stanford.

Page1 / 6

34-Assignment-7-Where-Am-I - CS107 Spring 2007 Handout 34...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online