Re: Floating point questions
- From: "Doug Phillips" <dphill46@xxxxxxxxxxxx>
- Date: 29 Jun 2006 09:14:11 -0700
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:In your particular case you're dealing in latitude and longitude,
Doesn't help if you have to convert from float binary to float decimalSource data is a GPS that provides litten endian IEEE 32 bit value.
to perform the comparison.
We haven't been told what format the source data is in.
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 ?
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.
.
- Follow-Ups:
- Re: Floating point questions
- From: Dave Froble
- Re: Floating point questions
- From: Doug Phillips
- Re: Floating point questions
- References:
- Floating point questions
- From: JF Mezei
- Re: Floating point questions
- From: Tom Linden
- Re: Floating point questions
- From: JF Mezei
- Re: Floating point questions
- From: briggs
- Re: Floating point questions
- From: Tom Linden
- Re: Floating point questions
- From: briggs
- Re: Floating point questions
- From: JF Mezei
- Re: Floating point questions
- From: Dave Froble
- Re: Floating point questions
- From: Bill Gunshannon
- Re: Floating point questions
- From: Dave Froble
- Re: Floating point questions
- From: Bill Gunshannon
- Floating point questions
- Prev by Date: Re: OT: Intel quad core X64 benchmarked
- Next by Date: Re: Pathworks Alternative? ('Simple' Windows backup destination)
- Previous by thread: Re: Floating point questions
- Next by thread: Re: Floating point questions
- Index(es):
Relevant Pages
|
Loading