Available: Friday September 16
Due: Monday
September 26, noon
This assignment is to be done in TEAMS OF TWO PEOPLE. The assignment should be submitted only once by a member of your team, but please ensure that the identification material contains the information for both team members. Follow the instructions in the lab manual for submitting assignments.
Your algorithms should be developed using the format used in class, and it is not permitted to use structures such as branches and loops that have not yet been covered in the lectures. Your algorithm traces should use the format shown in class; a separate table is to be used for each call to each algorithm.
Angles can be measured in degrees and minutes of arc. A degree is partitioned into 60 seconds of arc.
When measuring latitude (lat) and longitude (lon) to provide coordinates on the Earth, the co-ordinates can be in the following ranges:
latitude: −90 degrees ≤ lat ≤ +90 degrees
longitude: −180 degrees < lon ≤ +180 degrees
The zero latitude line is the Earth’s equator. Positive latitudes extend north from the equator up to the North Pole, while negative latitudes extend south from the equator to the South Pole. If the latitude is ± 90 (i.e. at one of the poles), the longitude is undefined.
The zero longitude line is defined as passing through the observatory in Greenwich, England, which is just east of London. Positive longitudes are east of Greenwich around to the 180 degree line near the middle of the Pacific Ocean. Negative longitudes are west from Greenwich.
For example, according to NASA’s web site, the values for Ottawa are:
latitude: +45 degrees, 25 minutes
longitude: −75 degrees, 40 minutes
Angles can also be measured in decimal degrees. For example, an angle of −45.5 degrees is equivalent to an angle of −45 degrees and 30 seconds.
Design an algorithm that will convert an angle specified in degrees and minutes of arc, to an angle measured in decimal degrees. Angles may be any positive or negative value.
Design an algorithm that will convert an angle measured in decimal degrees to an angle measured in radians. Note that π radians are equivalent to 180.0 degrees. Angles may be any positive or negative value.
Suppose that one has the longitude and latitude for two locations, and we would like to calculate the distance one would travel between the two points. This is not as straightforward as you might imagine because the distance is not in a straight line. Instead, one would travel along a great circle defined by the curve of the Earth’s surface and passing through the two locations. Therefore, the actual distance to travel is the distance along the segment of such a great circle.
If the coordinates for location 1 are (θ1, φ1) and the coordinates for location 2 are (θ2, φ2), then the distance from location 1 to location 2 is:
r × arccos( sin(θ1)sin(θ2) + cos(θ1)cos(θ2)cos(φ2-φ1))
where:
Design an algorithm that will calculate the distance between two cities, given the longitude and latitude values measured in degrees and minutes. Your algorithm should make use of your algorithms in parts 1 and 2.
Trace your algorithm for question 3 on the following givens:
Ottawa: latitude = +45 degrees, 25 minutes, longitude = −75 degrees, 40 minutes
Vancouver: latitude = +49 degrees, 15 minutes; longitude = −123 degrees, 10 minutes
Three decimal places is sufficent for real values.