Lat/long pair to compass bearing, gcd.
More...
Go to the source code of this file.
|
subroutine | w3fb10 (dlat1, dlon1, dlat2, dlon2, beard, gcdkm) |
| Given a pair of points (1) and (2) given by latitude and longitude, w3fb10() computes the bearing and great circle distance from point (1) to point (2) assuming a spherical Earth.
|
|
Lat/long pair to compass bearing, gcd.
- Author
- Peter Chase
- Date
- 1988-08-29
Definition in file w3fb10.f.
◆ w3fb10()
subroutine w3fb10 |
( |
real |
dlat1, |
|
|
real |
dlon1, |
|
|
real |
dlat2, |
|
|
real |
dlon2, |
|
|
real |
beard, |
|
|
real |
gcdkm |
|
) |
| |
Given a pair of points (1) and (2) given by latitude and longitude, w3fb10() computes the bearing and great circle distance from point (1) to point (2) assuming a spherical Earth.
The north and south poles are special cases. If latitude of point (1) is within 1e-10 degrees of the north pole, bearing is the negative longitude of point (2) by convention. If latitude of point (1) is within 1e-10 degrees of the south pole, bearing is the longitude of point (2) by convention. If point (2) is within 1e-6 radians of the antipode of point (1), the bearing will be set to zero. If point (1) and point (2) are within 1e-10 radians of each other, both bearing and distance will be set to zero.
Program history log:
- Peter Chase 1988-08-29
- Peter Chase 1988-09-23 Fix dumb south pole error.
- Peter Chase 1988-10-05 Fix bearing ambiguity.
- Ralph Jones 1990-04-12 Convert to cft77 fortran.
- Parameters
-
[in] | DLAT1 | REAL Latitude of point (1) in degrees north. |
[in] | DLON1 | REAL Longitude of point (1) in degrees east. |
[in] | DLAT2 | REAL Latitude of point (2) in degrees north. |
[in] | DLON2 | REAL Longitude of point (2) in degrees east. |
[out] | BEARD | REAL Bearing of point (2) from point (1) in compass degrees with north = 0.0, values from -180.0 to +180.0 degrees. |
[out] | GCDKM | REAL Great circle distance from point (1) to point (2) in kilometers. |
- Note
- According to the nmc handbook, the Earth's radius is 6371.2 kilometers. This is what we use, even though the value recommended by the smithsonian meteorological handbook is 6371.221 km. (I wouldn't want you to think that I didn't know what the correct value was.)
-
Method: The poles are special cases, and handled separately. otherwise, from spherical trigonometry, the law of cosines is used to calculate the third side of the spherical triangle having sides from the pole to points (1) and (2) (the colatitudes). then the law of sines is used to calculate the angle at point (1). A test is applied to see whether the arcsine result may be be used as such, giving an acute angle as the bearing, or whether the arcsine result should be subtracted from pi, giving an obtuse angle as the bearing. This test is derived by constructing a right spherical triangle using the pole, point (2), and the meridian through point(1). The latitude of the right-angled vertex then provides a test–if latitude (1) is greater than this latitude, the bearing angle must be obtuse, otherwise acute. If the two points are within 1e-6 radians of each other a flat Earth is assumed, and the four-quadrant arctangent function is used to find the bearing. The y-displacement is the difference in latitude and the x-displacement is the difference in longitude times cosine latitude, both in radians. distance is then the diagonal.
-
Fundamental trigonometric identities are used freely, such as that cos(x) = sin(pi/2 - x), etc. See almost any mathematical handbook, such as the c.r.c. standard math tables under 'relations in any spherical triangle', or the national bureau of standards 'handbook of mathematical functions' under section 4.3.149, formulas for solution of spherical triangles.
-
Double precision is used internally because of the wide range of geographic values that may be used.
- Author
- Peter Chase
- Date
- 1988-08-29
Definition at line 70 of file w3fb10.f.