IUP Computer Science
COSC 110     Spring 2007

Project #2
(Map Distances)
(Due 14 Feb 2007)

John is trying to make a very accurate map of a forested area.  He has come upon a pit and a large boulder which he wants to mark on the map.  John has carefully measured the distance between the pit and the boulder as 37.5 meters.  Also, using his compass, he has measured the bearing from the pit to the boulder to be 22 degrees.   To add the new features to the map, John needs to use some trigonometry and a known mapped feature to help.

The known mapped feature is a utility pole which can be seen from the edge of the pit and from the boulder.  The pole is already accurately marked on the map; it is generally off in an easterly direction.  John reasons that if he takes bearings from both the pit and the boulder to the pole, he can calculate the distances from the pit to the pole and from the boulder to the pole and therefore place the two new features accurately on the map.

You are to write a program that prompts John for the two bearings and then calculates a range of distances within which the correct distances lie.  The reason for the range calculation, rather than an exact calculation, is that compass bearings are not very accurate; they may be off by as much as 2 degrees (plus or minus).

A bearing is a measurement of the directional angle to somewhere, measured from north (in this case, from magnetic north).  Bearings are in the range 0 to 360 degrees.  Thus, a bearing of 0 degrees is due north; 90 degrees is due east; 180 degrees is due south; and 270 degrees is due west.   We are going to assume that John took a very accurate bearing between the pit and the boulder; so, we assume the 22 degrees is correct.  However, the bearings from the pit and the boulder to the pole cover a longer distance and may be off by as much as 2 degrees.

Your program is to calculate the distances from the pit to the pole and the boulder to the pole twice.  In the first calculation, the program should assume that both bearings John enters are 2 degrees too high.  Then, the program should assume that both bearings John enters are 2 degrees too low.  From this approach, the program can display a range for the possible distance from the pit to the pole and another range for the possible distance from the boulder to the pole.  The drawing shows an example in which angle W (the bearing from the pit) is 81 degrees and angle Y (the bearing from the boulder) is 114 degrees.  With these values, the program should calculate distance from pit to pole as between 68.8529 to 68.6852 meters and the distance from boulder to pole as between 57.7449 to 60.2201 meters.

The recommended approach to calculating the distance is to use the "Sine Law".  It says that in any triangle the ratio of a side to the sine of its opposite angle is the same for all three sides.  That is,

  a         b         c
-----  =  -----  =  -----
sin A     sin B     sin C

where sides a, b, and c are opposite angles A, B, and C, respectively.  Using the bearing values entered, you should be able to calculate the ratio for the angle at the pole and then use that value to determine the distances from the pit to the pole and the boulder to the pole because you have the angles opposite those sides.

Hand in a well commented printout of your program and a printout of the output using the bearings which I will provide.  Three days before the program is due, I will specify what the bearings are that I want you to use when you capture the execution (the 81 degrees and 114 degrees used above are just an example).  You should name the .cpp file after yourself; for example, I would call mine wolfep2.cpp  Copy your .cpp file to the handin folder on the P: drive for your section of COSC 110.  The method of capturing the output to print and copying to the P: drive will be demonstrated in class.