# knokap3 - /* * Name - Kimberly Okafor Email -...

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

/* *************************************************** Name - Kimberly Okafor Email - knokafor@uh.edu ECE 3331 Computer Problem 3 Semester - Spring 2010 *************************************************** Purpose - to create a distance table that contains the distance from multiple cities on a given list and to find the farthest city from a new city. *************************************************** Data files cp31010.txt - input data file containing the cities, the latitude (in degress, minutes, N or S) and the longitude (in degrees, minutes, and E or W) cp3new.txt - input data file containing a list of new cities knokacp3.out - output file to which results will be written *************************************************** */ /* Preprocessor Directives */ #include <stdio.h> #include <math.h> #include <type.h> /*Lat function convert latitude in degrees, minutes and direction to equivalent polar angle in radians*/ double Lat(double deg, double min, char dir) { double alpha; double ndeg; ndeg=deg+(min/60); /*solve for alpha*/ if dir==N alpha=90-ndeg; else alpha=90+ndeg; /*retun polar angle in radians*/ return alpha*(acos(-1)/180); } / *_______________________________________________________________________________ ______________*/ /* the Lon function will take longitude in degrees, minutes and direction to equivalent azimuthal angle in radians*/ double Lon(double deg, double min, char dir) { double beta; double ndeg;

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

View Full Document
ndeg=deg+(min/60); /*solve for the azimuthal angle*/ if dir==W beta=ndeg; else beta=360-ndeg; /*return the azimuthal angle in radians*/ return beta*(acos(1-)/180); } / *_______________________________________________________________________________ _____________*/ /* the dist function will use the polar and azimuthal angle to calculate the surface distance between two points*/ double Dist (double loc1[], double loc2[]) { double theta; /*theta12 from the equations*/ double r; /*radius of the earth*/ double distance; /*distance to be returned*/ double alpha1,alpha2,beta1,beta2; /* the polar and azimuthal angles of the two cities*/ /*assign numbers to the variables*/ r=3959.89; alpha1=loc1(0); alpha2=loc2(0); beta1=loc1(1); beta2=loc2(1); /*solve for theta*/ theta=acos(cos(alpha1)*cos(alpha2)+sin(alpha1)*sin(alpha2)*cos(beta2-beta1)); /*solve for the distance*/ distance=theta*r; /*return the surface distance between the two cities*/ return distance; } / *_______________________________________________________________________________ __________*/ /*the Distbl function will create the numeric portion
This is the end of the preview. Sign up to access the rest of the document.

## knokap3 - /* * Name - Kimberly Okafor Email -...

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

View Full Document
Ask a homework question - tutors are online