Project #2
(The Lazy Surveyor)
(Due 28 September
05)
Nathan Detroit is a lazy surveyor. Whenever he can, he takes a shortcut in surveying various parcels of land, especially farm land in which he can see all of the corners from some single location near the middle of the property. Nathan walks out to such a place, sets up his transit and has his assistants walk to the corners to hold up the marker. Nathan then records the angle in degrees and distance from where he is to the marker in feet. When he gets back to the office, he figures out the area of the land using simple formulas. Now, Nathan wants you to write a program that will figure out the area from the formulas so he doesn't have to do that either.
Your program should work for land parcels
that have four corners. It should prompt for the angle and
distance to each corner and then display the area of the parcel in square
feet and in acres, correct to at least 3 decimal places. Assume the
land has a shape similar to the image below. Nathan is at the point
near the middle where all the lines come together. He takes four
readings that are labeled NW, NE, SE, and SW and correspond roughly to
the directions Nathan faces to take the readings. Angles are measured
as if due North was 0o and increase clockwise to 359o;
thus, due East is at 90o and due West is at 270o.
Your program may ask Nathan for the readings in any order that you want;
but the program must make it clear to Nathan which one it wants each time
or it will not be able to calculate the area properly.
The
recommended way to calculate the area of the parcel of land is to calculate
the area of the four triangles formed by the NW, NE, SE, and SW lines.
There is a simple formula to do this. When you know the length of
two sides of a triangle and the angle between those sides, the area of
the triangle is simply,
1/2 * side1
* side2 * sin(angle)
Note: if you are doing this using
the math library, the angle must be in radians, not degrees.
There are 2 pi radians in 360o so to convert an angle
in degrees to radians, divide the angle by 360 and multiply by 2 pi.
Also, there are 43560 square feet in an acre.
Hand in a printout of your program and two sets of execution output. I will specify two days before the project is due the readings for the two parcels of land you should use in the execution output. To get the execution output, I recommend that execute the program and copy-and-paste the output to a .txt file using NotePad; then print the .txt file with NotePad. The printout of your program should be made with Visual Studio, not with a word processor; the printout of the output should not be with a word processor either. Also, copy your source program (the .cpp file) to the P: drive (handin folder). Be sure to name the file containing the source program after yourself. For instance, I might name my file wolfe-p2.cpp
Here is a sample of the execution output from the program I wrote to do this project. Your output does not need to look exactly like this; however, the same results should be produced and the output should identify everything that is shown.
What is the angle of and distance to the NW corner?
308 233.4
What is the angle of and distance to the NE corner?
56 359.1
What is the angle of and distance to the SE corner?
164 783.2
What is the angle of and distance to the SW corner?
218 978.5
The area is 597787.417 square feet or 13.723 acres
Here is a second example for a completely square parcel that is 100 feet on each side and Nathan is standing in the exact center.
What is the angle of and distance to the NW corner?
315 70.7
What is the angle of and distance to the NE corner?
45 70.7
What is the angle of and distance to the SE corner?
135 70.7
What is the angle of and distance to the SW corner?
225 70.7
The area is 9996.980 square feet or 0.229 acres
The exact area of this second parcel is
10000 square feet; but the measurements are not exact; so there is a little
error in the program results.