I need some math help. I need to make a BR program figure out the distance between two zip codes using longitude and latitude.
Using these two zips
Zip code 61360 is Seneca Illinois, Lat is 41.311N Long is -88.609W
Zip Code 60541 is Newark Illinois, Lat is 41.537N Long is -88.583W
Anyone know how to do the math to tell me the distance in miles between these two zip codes???
wolframalpha can be used to determine all kinds of mathmatecial calculations
passing:
41.311deg N, 88.609deg E, 41.537deg N, 88.583deg E
to wolframalpha returns:
Thats pretty cool, but I need to know the formula to calculate that. I need to develop a program that allows a user to enter two zip codes which I then use to look up the longitude and latitude values in a file.
Then I need to calculate the distance in miles between those two and show the user.]
I'm on BR 3.93 or something like that.....yeah I know, really old.
Zip1$, LAT1 & LONG1 are required
Zip2$, LAT2 & LONG2 are required
I am not exactly sure about the "N" & "W", but Both LAT & LONG need to be (+) Values IE:
"61360" LAT =41.3267 LONG =88.6042
"60541" LAT =41.5266 LONG = 88.5274
100 LET CNV1=180/PI
110 LET A=SIN(LAT1/CNV1)*SIN(LAT2/CNV1)+COS(LAT1/CNV1)*COS(LAT2/CNV1)*COS(LONG2/CNV1-LONG1/CNV1)
120 LET DIST=3959*ATN(SQR(ROUND((1-A**2),10))/A)
Ever wondered when you would use your math from high school in real life?
The distance between "61360","60541" = 7.302294 miles
Funny though, mapquest says that these towns are 17 miles apart....I know traveling on roads would be longer than the "straight line" between two points.
I'll have to check into the validity of the data I have. But the formula works.