I thought this would be easy, but distances east or west between
degrees of longitude vary, depending on north and south position.
Not only that, but no one seems to agree on the radius of the earth.
so, let's assume we use the data found in the WGS84.
Keep in mind, I am not a mathematical genius :)
Willem
--
Willem van Deursen, The Netherlands
wvandeursen_nospam@nospam_carthago.nl
replace _nospam@nospam_ for @ to get a valid email address
www.carthago.nl
Christopher,
An article that addresses exactly the questions you asked may be found at
http://www.usenet-replayer.com/faq/comp.infosystems.gis.html.
Bob
Bob (Robert G.) Chamberlain | I asked the Oracle at Delphi:
r...@jpl.nasa.gov | "What is the best question to ask?"
Opinions & quips are mine | ...
- or public - not JPL's | Was the reply merely an echo?
I'm still confused how to make this kind of calculation. This is about
absolute shortest path, not on great circle.
Tower 1 in location lat x1 lon y1 has antenna at height z1 meters.
Tower 2 in location lat x2 lon y2 has antenna at height z2 meters.
What is the shortest possible distance between the two antennas. I
can't get it right, I think some trigonometry part is missing in my
brain.
Great circle = shortest path
> Tower 1 in location lat x1 lon y1 has antenna at height z1 meters.
> Tower 2 in location lat x2 lon y2 has antenna at height z2 meters.
>
> What is the shortest possible distance between the two antennas. I
> can't get it right, I think some trigonometry part is missing in my
> brain.
Do you want to include the z levels in this calculation or even go straight
through the Earth, i.e. not following the surface?
I don't want to follow the earth surface, because radio signals don't
follow earth surface.
I understand great circle is shortest path on earth surface but not
shortest linear path.
Indeed very difficult to google this formula because all of them seems
to go on earth surface.
I think the OP wants the Euclidean distance of the chord between two
points in Caretesian space - the distance that a laser beam would
travel from the tip of Tower 1 to the tip of Tower 2.
A straightfoward way to do this that is familiar to someone who's
studied trigonometry, using simplistic model of Earth (as a sphere),
is as follows:
0. Model your space in spherical coordinates: r, theta, phi; where r
is the distance from center of earth, theta is the angle off the
equatorial plane (latitude), and phi is the azimuth about the
interpolar line (longitude).
1. Note value of Pi = 3.14159265358979323846264338327950288.
2. Note radius R of the Earth = 6366.2 meters.
3. Note that distance from center of Earth to top of Tower 1 is r1 = R
+ height of Tower 1.
4. Note that distance from center of Earth to top of Tower 2 is r2 = R
+ height of Tower 2.
The computation of following angles assume latitudes were north and
longitudes were east.
5. Find theta1 = Pi/2 * (latitude1.degrees + latitude1.minutes /
60.0) / 90.0.
6. Find theta2 = Pi/2 * (latitude2.degrees + latitude2.minutes /
60.0) / 90.0.
7. Find phi1 = Pi * (longitude1.degrees + longitude1.minutes / 60.0) /
180.0.
9. Find phi2 = Pi * (longitude2.degrees + longitude2.minutes / 60.0) /
180.0.
If any of the angles were not as assumed, negate as necessary:
10. if (latitude1.S) theta1 = -theta1.
11. if (latitude2.S) theta2 = -theta2.
12. if (longitude1.W) phi1 = -phi1.
13. if (longitude2.W) phi2 = -phi2.
Compute xyz coordinates in Cartesian spaceof both points at tips of
towers:
10. x1 = r1 * cos(theta1) * cos(phi1).
11. x2 = r2 * cos(theta2) * cos(phi2).
12. y1 = r1 * cos(theta1) * sin(phi1).
13. y2 = r2 * cos(theta2) * sin(phi2).
14. z1 = r1 * sin(theta1).
15. z2 = r2 * sin(theta2).
Calculate the Euclidean distance that you seek, using formula that we
are all familiar with:
16. b = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1)).
As you have undoubtedly visualized many times, if both towers are the
same height, r = r1 == r2, b is length of the base of an eqilateral
triangle, and this base connects the tips of the towers. Since surface
waves (http://en.wikipedia.org/wiki/Surface_wave) *do*follow the
curvature of the Earth (to some extent), you might still want to find
the arc length from tip to tip in this case. Your imaginary
equilateral triangle can be split into two smaller right triangles.
Then, the angle between the two tower legs of the equilateral triangle
is alpha, and alpha is exactly double the angle that is determined by
taking the arcsine of the ratio of half the length of the base and the
radius r:
17. alpha = 2 * asin((b / 2) / r).
Compute the arc length from tower tip to tower tip:
18. a = alpha * r.
All angles are in radians, of course.
-Le Chaud Lapin-
Ooops... I meant isosceles, not equilateral.
-Le Chaud Lapin-
That was a nice answer!
However, you left out the possibility that the bases of the two
towers are not necessarily at the same altitude. Those altitudes should
be added into the r1 and r2 calculations.
Mr. Triangeo,
First, since large numbers that are relatively close to each other
are involved, you should make sure your calculations are carried out to
high precision. Otherwise, the roundoff errors are likely to be
significant.
In the unlikely event that you need a very precise answer, you should
consider a better shape for the Earth than a sphere; the "radius" of the
Earth between your two towers depends on latitude and, depending on how
precise a shape you use, perhaps on longitude.
Even without relativity, a precise answer requires consideration of
diffraction. (This topic is discussed in considerable detail in Chapter
10 of Bowditch, American Practical Navigator, which can be accessed at
http://www.irbs.com/bowditch/pdf/chapt10.pdf.)
If you needs an extremely precise answer, you should consult with a
physicist or an astronomer about whether you need to make corrections
for relativistic effects, such as bending of the geodesic path taken by
the radio waves.
Bob (Robert G.) Chamberlain |
r...@jpl.nasa.gov | In theory, there is no difference
Opinions & quips are mine | between theory and practice....
- or public - not JPL's |
In article
<401b23f2-255e-4bac...@n20g2000hsh.googlegroups.com>,
Thanks. I had to do the same thing myself a while ago, so I had it
lying around in C++ code.
> However, you left out the possibility that the bases of the two
> towers are not necessarily at the same altitude. Those altitudes should
> be added into the r1 and r2 calculations.
True.
I also incorrectly gave radius of Earth in meters, when I meant
kilometers. Oh the sloppiness...:|
> First, since large numbers that are relatively close to each other
> are involved, you should make sure your calculations are carried out to
> high precision. Otherwise, the roundoff errors are likely to be
> significant.
>
> In the unlikely event that you need a very precise answer, you should
> consider a better shape for the Earth than a sphere; the "radius" of the
> Earth between your two towers depends on latitude and, depending on how
> precise a shape you use, perhaps on longitude.
>
> Even without relativity, a precise answer requires consideration of
> diffraction. (This topic is discussed in considerable detail in Chapter
> 10 of Bowditch, American Practical Navigator, which can be accessed athttp://www.irbs.com/bowditch/pdf/chapt10.pdf.)
>
> If you needs an extremely precise answer, you should consult with a
> physicist or an astronomer about whether you need to make corrections
> for relativistic effects, such as bending of the geodesic path taken by
> the radio waves.
Yes, lots of issues, including effective permittivity of atmosphere.
-Le Chaud Lapin-
- Bob
In article
<2a7e87a6-e4da-42bf...@e25g2000prg.googlegroups.com>,
Le Chaud Lapin <jaibu...@gmail.com> wrote:
> On Dec 4, 2:11 pm, rgc <Robert.G.Chamberl...@jpl.nasa.gov> wrote:
> > M. Lapin,
> >
> > That was a nice answer!
>
> Thanks. I had to do the same thing myself a while ago, so I had it
> lying around in C++ code.
>
> > However, you left out the possibility that the bases of the two
> > towers are not necessarily at the same altitude. Those altitudes should
> > be added into the r1 and r2 calculations.
>
> True.
>
> I also incorrectly gave radius of Earth in meters, when I meant
> kilometers. Oh the sloppiness...:|
>
> > First, since large numbers that are relatively close to each other
> > are involved, you should make sure your calculations are carried out to
> > high precision. Otherwise, the roundoff errors are likely to be
> > significant.
> >
> > In the unlikely event that you need a very precise answer, you should
> > consider a better shape for the Earth than a sphere; the "radius" of the
> > Earth between your two towers depends on latitude and, depending on how
> > precise a shape you use, perhaps on longitude.
> >
> > Even without relativity, a precise answer requires consideration of
> > diffraction. (This topic is discussed in considerable detail in Chapter
> > 10 of Bowditch, American Practical Navigator, which can be accessed
> > athttp://www.irbs.com/bowditch/pdf/chapt10.pdf.)
> >
> > If you need an extremely precise answer, you should consult with a
Assuming Earth is perfect polished sphere and person is at MSL,
wouldn't the two be the same?
Also, I'd like to say that, to people who don't work in this space,
like myself, it's somewhat shocking to see just how non-trivial geo-
related stuff is. The fact that the Earth is not a sphere but an
oblate spheroid is enough ponder for a long time.
At that point, it becomes not a matter of mathematics, but of
judicious choices.
-Le Chaud Lapin-
- Bob
In article
<2732c2fb-ef7a-4161...@d27g2000prf.googlegroups.com>,
Le Chaud Lapin <jaibu...@gmail.com> wrote:
Thank you very much for your effor to support on this.
Hi trian,
I vaguely recall the same problem with the steps I posted. My
distances were off. I increased precision of Pi and checked my value
for raidius of earth. Didn't help.
However, even if Earth is modeled as sphere, if one looks at d(arc
length)/d(theta) or d(arc length)/d(phi), slight errors in the angles
will result in large variations in arc lengths. Then there is the
oblate spheroid that rgc mentioned.
At this point I guess it's a matter of how badly do you need
accuracy. Might have to do a little fidgetting. :)
-Le Chaud Lapin-
How much longer is "slightly longer"? If the surface distance is only 20
km, the Earth is dang near flat. If there is a difference in altitude or
tower height (that is, if |r1 - r2| > 0), then the straight line
distance is the hypotenuse of a right triangle, which can be expected to
be longer than one 20-km-long side of it, even if that side is slightly
curved (by so little that the curvature is truly negligible).
Suppose |r1 - \r2| = a, ground distance = b, and antenna-to-antenna
distance = c.
Then, c^2 = a^2 + b^2 by the Pythagorean Theorem. (The ^ means "raised
to the power of".)
Thus, c^2 - b^2 = a^2
Equivalently, (c - b) * (c + b) = a^2
Thus, c - b = a^2 / (c + b)
If c approximately = b, then c - b approx = a^2 / 2b
For esample: Suppose b = 20 km = 20,000 m and a = 200 m
Then
c - b approx = 40,000 / 40,000 = 1 meter
This formula should give a good approximation whether you compute b as
the Pythagorean X-Y distance between the antenna bases or as the
Haversine on-surface distance.
- Bob
Bob (Robert G.) Chamberlain |
r...@jpl.nasa.gov | The best thing about mathematics is
Opinions & quips are mine | that it's so much simpler than life.
For any 2 locations in the UK I have both the UK Ordinance Survey
coordinates and the long/lat coordinates.
I'm calculating the distance between 2 points in 2 ways.
i) Using Pythagoras on the Ordinance Survey coordinates, like this:
distance in metres =
sqrt ( ((OS1_x - OS2_x) ^2) + ((OS1_y - OS2_y) ^2) )
ii) Calculating the 'great circle' distance using long/lat and the formula
on the page linked below, that someone in this thread was kind enough to
post. http://williams.best.vwh.net/avform.htm#Dist
The formulas on that page are:
---------------------------------------------------------------
The great circle distance d between two points with coordinates
{lat1,lon1} and {lat2,lon2} is given by:
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
A mathematically equivalent formula, which is less subject to rounding
error for short distances is:
d=2*asin(sqrt((sin((lat1-lat2)/2))^2 +
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
---------------------------------------------------------------
Both 'great circle' formulas of ii) give me the same results for the few
UK coordinates I've so far tested which is re-assuring.
Land's End and John O'Groats are the 2 locations furthest away from each
other on the UK mainland. The distance between them which I get from using
Pythagoras on the Ordinance Survey coordinates is 969425.120 metres and
from using the long/lat great circle method is 967691.445 metres. The
difference between the values is 1733.675 metres.
Using Pythagoras on the Ordinance Survey coordinates does not take the
curvature of the planet into consideration. In which case it should give
me the shorter distance, but it is in fact the longer! Does anyone know
why? Also why the difference is as much as 1.7 km, as a margin of error it
is quite large when you consider the distance between the points is
somewhere about 1000 km?
Many thanks all. Regards, etc..
PS. In case it is needed here's the (pseudo) code of my long/lat distance
calculation:
// Make sure all long and lat are positive
if (lat1 < 0) lat1 = lat1 * -1;
if (lon1 < 0) lon1 = lon1 * -1;
if (lat2 < 0) lat2 = lat2 * -1;
if (lon2 < 0) lon2 = lon2 * -1;
// Convert decimal long/lat to radians
// angle_radians = (pi / 180) * angle_degrees
lat1 = (pi / 180) * lat1;
lon1 = (pi / 180) * lon1;
lat2 = (pi / 180) * lat2;
lon2 = (pi / 180) * lon2;
// Calculate the distance
// d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
val1 = sin(lat1) * sin(lat2);
val2 = cos(lat1) * cos(lat2) * cos(lon1 - lon2);
val3 = v1 + v2;
distance = acos(val3);
// Convert the distance to nautical miles
// distance_nm= ( (180*60) / pi ) * distance_radians
distanceNauticalMiles = ( (180 * 60) / pi) * distance;
// Note: the nautical mile is currently defined to be 1852 meters
metres = distanceNauticalMiles * 1852;
return metres;
>Using Pythagoras on the Ordinance Survey coordinates does not take the
>curvature of the planet into consideration. In which case it should give
>me the shorter distance, but it is in fact the longer! Does anyone know
>why? Also why the difference is as much as 1.7 km, as a margin of error it
>is quite large when you consider the distance between the points is
>somewhere about 1000 km?
>
Your error is in forgetting that the scale of the mercator projection
used by the OS is only correct at the central meridian - elsewhere is
always greater than the true scale. I would expect it to normally give
too great a value. It isn't a question of "not allowing for the
curvature of the earth" is is a question of "How much inevitable scale
distortion is there for the map projection I am using"; remember that
it is impossible to map the curved surface of the earth onto a flat
plane without scale distortion.
Your error would have been bigger if you'd done two points on the same
latitude.
Paul
Thanks very much for pointing this out Paul.
Re: http://williams.best.vwh.net/avform.htm#Dist
Out of interest does anyone know how accurate these formulas are for
calculating the great circle distance? (Obviously ignoring elevation).
--------
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
A mathematically equivalent formula, which is less subject to rounding
error for short distances is:
d=2*asin(sqrt((sin((lat1-lat2)/2))2 +
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))2))
---------
Thanks.
Thanks Willem.
I should use the cartesian coordinates and formulae to get better results (the one you used first in your post), just consider the correction coefficient applied at the site of measure (K is a locally constant value ranging from 0.999x to 1.000x to correct scale due to the non planar surface of the earth when using some kind of grid coordinates ---perhaps you have it pointed to somewhere in the chart used---) This K coefficient depends on the projection used to map earth surface and the point you are considering.
"Matthew" <mat...@spamkiller.com> escribió en el mensaje news:FChaj.65673$c_1....@text.news.blueyonder.co.uk...
"Matthew" <mat...@spamkiller.com> escribió en el mensaje news:DKhaj.65679$c_1....@text.news.blueyonder.co.uk...
Not, his error is in considering the earth as a perfect sphere, as he does in his calculation with spherical trigonometry formulae. He also uses an aproximation of the curvature radius of the earth that is only valid at some 40º latitude north (not in UK) 1850 per nautical mile (it's 1851.80, not the value used) is valid as a constant to convert meters to nautical miles, but not valid to assume it's the right length of a minute of arc of
meridian. That's onli valid at some latitude, but if you consider the earth as an ellipsoid, you'll have to consider the two radii of curvature given by the M(lat) and N(lat) formulas. He is easily to get a 1-2% error in his results as he is getting for sure.
Thanks Luis and everyone - sorry for the delay to get back to you, I took
a 2 week holiday.
Firstly on the subject of nautical miles to meters conversion, I've had a
good look on the web and can't find 1851.80 listed or used anywhere except
in the Wikipedia page (link below) which says it is '= 1,851.851851...
historical metres'. 1852 is the most prevalent value used, but I also
found 1853.27 used by a few conversion engines. So now I'm thoroughly
confused as to which value to use.
http://en.wikipedia.org/wiki/Nautical_mile
I also found another formula for the long/lat distance calculation which
is similar but uses the mean radius of the Earth, here it is:
distance = acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) *
cos(long2-long1)) * (Mean Radius Of Earth = 6372.797 km)
in code that is:
$v1 = sin($lat1) * sin($lat2);
$v2 = cos($lat1) * cos($lat2) * cos($lon2 - $lon1);
$v3 = $v1 + $v2;
$v4 = acos($v3);
$meanRadiusOfEarth = 6372.797;
$v5 = $v4 * $meanRadiusOfEarth;
$distanceKilometres = $v5;
I know this does not address the problem that the Earth is not a perfect
sphere, but my maths is not up to dealing with that and I can't find a
formula online that does it for me. It's not a problem if the accuracy of
the distances are wrong by a small percent. Would I be better off using
this new formula?
There's not much in it between the 2 formulas anyway, as these figures
demonstrate, only 10 km difference in the distance calculated from London
to Ayers Rock in Australia. Still I'd like to know which you think is the
more accurate (especially used just for the UK).
The direct distance between My Home (London) and
Ayers Rock is:
Old Formula: Kilometres: 14965.439
New Formula: Kilometres: 14975.530
The direct distance between My Home (London) and
New York's Empire State Building is:
Old Formula: Kilometres: 5563.685
New Formula: Kilometres: 5567.437
The direct distance between Land's End and John O'Groats is:
(The longest distance possible on the UK mainland).
Old Formula: Kilometres: 967.691
New Formula: Kilometres: 968.344
The direct distance between Mum's Home (Oxford) and
Dad's Home (Oxford) is:
Old Formula: Kilometres: 0.550
New Formula: Kilometres: 0.551
The direct distance between My Home (London) and
Dad's Home (Oxford) is:
Old Formula: Kilometres: 84.858
New Formula: Kilometres: 84.915
Many thanks and regards, etc..
Rereading the thread I see you have already been through the local
grids. So nothing new here...............
Thanks anyway Willem.
>> Not, his error is in considering the earth as a perfect sphere,
Yes!!!
"The mean radius of Earth = 6372.797 km" *IS* the best fit "great-
circle radius" for an ellipsoid, as it is a closed-form approximation
of all of the mean circumferences of an ellipsoid----not just the mean
north-south meridional circumference.
The most rudimentary approximation of the mean ellipsoidal
circumference, "Cr", is the simple average of the mean meridional
circumference, "Mr", and the equatorial radius, a:
Mr ~=~ .5 * [a + b];
Cr ~=~ .5 * [Mr + a],
~=~ .5 * [.5*(a + b) + a] = .25 * [3*a + b];
Just as the arcradius can vary at a given point (depending on the
direction being faced), due to different ways an oblique circumference
can be delineated (geodetically vs. geographically) and defined
(circumferential arc vs. the actual linear radius under the arc), the
"best fit" approximation is the ellipsoidal quadratic mean radius,
"Qr":
Qr = [.25(3*a^2 + b^2)]^.5 ~=~ Cr;
which, for WGS84, approximately equals 6372.797556!
> There's not much in it between the 2 formulas anyway, as these figures
> demonstrate, only 10 km difference in the distance calculated from
> London to Ayers Rock in Australia. Still I'd like to know which you
> think is the more accurate (especially used just for the UK).
It's not so much a question of being "accurate", but having a
conceptual basing and establishing a definitive equation.
Judge for yourself: The mid-oblique circumference (delineated
geodetically, with respect to latitude) is found at Lat_1 = 0, Lat_2 =
45° and Long_2 - Long_1 = 90°----find the distance and divide by half-
pi. Now compare what you get with all of the established "mean
radii": Which is closest?!? P=)
I did a "more verbose explanation" in Talk:Earth:
http://en.wikipedia.org/wiki/Talk:Earth/Archive_7#Mean_radius
~Kaimbridge~
-----
Wikipedia--Contributor Home Page:
http://en.wikipedia.org/wiki/User:Kaimbridge
***** Void Where Permitted; Limit 0 Per Customer. *****