Re: Floating point questions



Bill Gunshannon wrote:
In article <ZrydnXatrricSD7ZnZ2dnUVZ_q-dnZ2d@xxxxxxxxxx>,
Dave Froble <davef@xxxxxxxxxxxxx> writes:
Bill Gunshannon wrote:
In article <pbmdnWPxweiwrD7ZnZ2dnUVZ_rSdnZ2d@xxxxxxxxxx>,
Dave Froble <davef@xxxxxxxxxxxxx> writes:
JF Mezei wrote:
briggs@xxxxxxxxxxxxxxxxx wrote:
Doesn't help if you have to convert from float binary to float decimal
to perform the comparison.

We haven't been told what format the source data is in.
Source data is a GPS that provides litten endian IEEE 32 bit value.

Someone mentioned that 1.0e25 could not be precisely represented in such
a 32 bit entity ? Is that really the case ? Isn't it just a case of
representing 1.0 and then "25" in the field that defines where the
decimal is located ?
In your particular case you're dealing in latitude and longitude,
usually expressed in degrees, minutes, seconds, and fractions thereof.

It will not be hard to convert such to whatever measurement you wish to
use, meters, feet, yards, miles, etc.

Not hard????

What is the distance between:
70d0m0s E 70d0m0s N and 80d0m0s E 70d0m0s
and now:
70d0m0s E 10d0m0s N and 80d0m0s E 10d0m0s

Somehow I have to believe the math needed to compute distance
based on latitude and longitude is complex enough to not qualify
as "not hard". :-)
Of course, if there is a simple method I would love to see it. I
assumed the this difficulty is why the military always used UTM
rather than Lat/Lon.

bill


Assume a sphere. Ok, I'm aware that the Planet is not really so
uniform, but for most purposes the assumption is adequate.

There was a time when I'd have been able to do the math. That was about
40 years ago, and I'm not going to dig out the books for this question.

I've got a couple under $100 GPS units that will give me distance from
one point to another. It is doable.

I wasn't arguing that it wasn't doable. Just that because the
distance between lines of longitude are not uniform varying with
latitude the math is more complex. When someone tells me some
math problem is "not hard" I assume that means the average person
can do it nn their head. Somehow I doubt that the linear distance
between two arbitrary points on the globe meets that definition.


Now if altitude is also a consideration, then the math is a bit more
complex. However, once the formulas are set up, it's just a matter of
plugging in the numbers.

But that's true about any math formula no matter how complex. The
initial programming is the part that doesn't meet the "not hard"
criteria.


Look up "great circle distances"

Assume Earth is a perfect sphere of radius 6371.2 km:
Convert longitude and latitude to radians (multiply by pi/180),
then compute as follows:

theta = lon2 - lon1
distance = acos(sin(lat1) × sin(lat2) + cos(lat1) × cos(lat2) ×
cos(theta))
if (distance < 0) distance = distance + pi
distance = distance × 6371.2

The "perfect sphere" assumption yields very close approximations.
Variant tables would be used to obtain greater accuracy.

In math programming terms, I consider "not hard" to mean there's
existing code or an existing formula you can convert so you don't need
to invent one. I was tasked to write a great circle distance program
once on a computer that had only 13 assembler instructions (no higher
language) with only integer decimal math. Doing asin,sin,cos *were*
challenges.

.



Relevant Pages

  • Re: Calculating a Distance on the Surface of the Earth
    ... latitude and longitude. ... I'd actually be above the surface of the earth due to the ... to the surface of the earth, I'd like to know the distance between ... longitude of the second point. ...
    (sci.geo.satellite-nav)
  • Re: Could PIC handle this?
    ... Doesn't that mean comparing the distance ... magnitude of the distance, not the actual distance. ... differences between the longitude and latitude of each pair of points you ...
    (comp.arch.embedded)
  • Re: decimal longitude and latitude problem
    ... distance from a specific decimal longitude and latitude. ... latitude is 60 nautical miles, while one degree of longitude is 60*sin L ...
    (sci.math)
  • Re: decimal longitude and latitude problem
    ... distance from a specific decimal longitude and latitude. ... latitude is 60 nautical miles, while one degree of longitude is 60*sin L ...
    (sci.math)
  • Re: Questions (Space)
    ... The longitude and latitude I'd say are ... vector quantities; ... defines a distance in a particular direction. ...
    (rec.arts.sf.composition)

Loading