The shortest distance between two points on a sphere is shown to be on the arc o
ID: 3820619 • Letter: T
Question
The shortest distance between two points on a sphere is shown to be on the arc of the great circle containing them. If we know the angle between vectors from the center of the earth to the two points defining the arc, we can then estimate the distance as a proportion of the earth's circumference. The best way to compute the shortest distance between two points that are specified in latitude and longitude is through a series of coordinate transformation. We need to use equations that relate latitude and longitude to spherical coordinates, convert spherical coordinates to rectangular coordinates, and that compute the angle between two vectors. spherical coordinates alpha = (90 degree - Latitude") theta = (360 degree - Longitude") beta = 3960 Rectangular coordinates (radians): x = beta sin alpha cos theta y = beta sin alpha sin theta z = beta cos theta Angle between Vectors (dot product): a. b = x_a x_b + y_a y_b + z_a z_b |a| = squareroot (x^2_a + y^2_a + z^2_a cos phi = a b/|a| |b| phi = a cos (a b/|a| |b| Great Circle Distance = beta*phi Write a program that will compute and display the great circle distance between Minneapolis and Sydney, Australia. The latitude and longitude of Minneapolis is 45* N and 93.2* W, respectively, and the latitude and longitude of Sydney is 33.9's and 151.2 degree E, respectively. The program should have a function "main", which calls another function to calculate the great circle distance the "main" function, and the great circle distance displayed.Explanation / Answer
Here is the code to compute the great circle distance. Output is show for the 2 points mentioned in the question. Please don't forget to rate the answer if it helped. Thank you very much.
#include <stdio.h>
#include <math.h>
/*function to calculate the greate circle distance between any 2 points given
the lat,long for the 2 points A and B */
double greate_circle_distance(double latA, double longA, double latB, double longB)
{
double alphaA, alphaB, thetaA, thetaB, beta = 3960;
double xa,ya,za,xb,yb,zb;
double aDotb, moda, modb, cosphi, phi;
double distance;
alphaA = 90 - latA;
thetaA = 360 - longA;
alphaB = 90 - latB;
thetaB = 360 - longB;
xa = beta * sin(alphaA) * cos(thetaA);
ya = beta * sin(alphaA) * cos(thetaA);
za = beta * cos(thetaA);
xb = beta * sin(alphaB) * cos(thetaB);
yb = beta * sin(alphaB) * cos(thetaB);
zb = beta * cos(thetaB);
aDotb = xa * xb + ya * yb + za * zb;
moda = sqrt( xa * xa + ya * ya + za * za);
modb = sqrt( xb * xb + yb * yb + zb * zb);
cosphi = aDotb / (moda * modb);
phi = acos(cosphi);
distance = beta * phi;
printf(" latA = %.2f longA = %.2f",latA,longA);
printf(" latB = %.2f longB = %.2f ",latB,longB);
printf(" alphaA = %.2f thetaA = %.2f",alphaA, thetaA);
printf(" alphaB = %.2f thetaB = %.2f ",alphaB, thetaB);
printf(" xa = %.2f ya = %.2f za = %.2f ",xa,ya,za);
printf(" xb = %.2f yb = %.2f zb = %.2f ",xb,yb,zb);
printf(" a . b = %.2f ",aDotb);
printf(" moda = %.2f modb = %.2f ",moda,modb);
printf(" cosphi = %.2f phi = %.2f ", cosphi, phi);
return distance;
}
int main()
{
double latA = 45, longA = 93.2 ; /*lat long for Minneapolis*/
double latB = 33.9, longB = 151.2; /*lat long for sydney*/
double distance = greate_circle_distance(latA, longA, latB, longB);
printf(" Great circle distance = %.2f ",distance);
}
output
latA = 45.00 longA = 93.20
latB = 33.90 longB = 151.20
alphaA = 45.00 thetaA = 266.80
alphaB = 56.10 thetaB = 208.80
xa = -3276.67 ya = -3276.67 za = -3850.81
xb = -198.66 yb = -198.66 zb = 457.98
a . b = -461737.20
moda = 6025.10 modb = 537.29
cosphi = -0.14 phi = 1.71
Great circle distance = 6787.12
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.