ENGR 103 S.F.S.U. Spring 2007 Sec 01/02 School of Engineering A. Tabrizi

Assignment NO 4

A point on a sphere can be characterized by two angles, the polar angle  and the azimuthal angle  (as shown). These angles are related to longitude and latitude as follows:

 = 90o – Latitude (if North)  = 90o + Latitude (if South)

 = Longitude (if West )  = 360o - Longitude (if East )

Furthermore, if the angle of the separation between two points on the sphere is  12 then the expression for the cosine of this angle is:

COS( 12 ) = COS( 1) . COS( 2) + SIN( 1) . SIN( 2) . SIN(  2 -  1 ) and once the angle is determined, the surface distance between the two points is given by D = ( 12).R , where R is the radius of the sphere.

Write a C++ program that will convert the coordinates of a point on the earth given in terms of latitude and longitude in degree into coordinates in terms of the angle ( ,  ) in radian. The input angles should be in the form:

Latitude if north (e.g. xx xxN) use: + xx.xx south (e.g. xx xxS) use: - xx.xx Longitude if west (e.g. xx xxW) use: + xx.xx East (e.g. xx xxE) use: - xx.xx

Write a function that will return the surface distance between 2 points on the earth whose coordinates are given in a terms of angles ( 1 ,  1 ),

( 2 ,  2 ) . The radius of the earth is 3,958.89 miles. Sort the distances in ascending order and verity the cities along with it. In addition display which two cities in the given list have the largest surface separation.

Given data:

Latitude Longitude Vienna 48 15 N 16 22 E Brussels 50 48 N 4 21 E Brasilia 15 52 S 47 55 W Melbourne 37 49 S 144 58 E Cairo 29 52 N 31 20 E Helsinki 60 10 N 24 57 E Bombay 18 54 N 72 49 E Istanbul 40 58 N 28 50 E

Extra credit: For extra credit do the followings: a) Create external files and read the given data from external file (s) b) Not only your out-put should be displayed on the screen, also the same out-put should be copied to another external file.

Display your interactive out-put as well as all the external files.