Re: Floating point questions
- From: Dave Froble <davef@xxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 16:32:40 -0400
Doug Phillips wrote:
Bill Gunshannon wrote:In article <ZrydnXatrricSD7ZnZ2dnUVZ_q-dnZ2d@xxxxxxxxxx>,
Dave Froble <davef@xxxxxxxxxxxxx> writes:
Bill Gunshannon wrote:I wasn't arguing that it wasn't doable. Just that because theIn article <pbmdnWPxweiwrD7ZnZ2dnUVZ_rSdnZ2d@xxxxxxxxxx>,Assume a sphere. Ok, I'm aware that the Planet is not really so
Dave Froble <davef@xxxxxxxxxxxxx> writes:
JF Mezei wrote:Not hard????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.
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
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.
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 moreBut that's true about any math formula no matter how complex. The
complex. However, once the formulas are set up, it's just a matter of
plugging in the numbers.
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.
Thanks. I knew there were great circle formulas available. Didn't really have the desire to go find them. And as I mentioned, it has been 40 years, and I haven't needed to use much of the math from then, and over time the details fade away.
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.
Well, I'd consider it no harder than a college level math assignment, and I really don't consider such 'hard'. That doesn't mean there wouldn't be a bit of research and thinking involved.
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.
Yeah, gotta agree with you on that one. When you first have to develop the tools, that qualifies for 'hard'.
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef@xxxxxxxxxxxxx
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
.
- 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
- Re: Floating point questions
- From: Doug Phillips
- Floating point questions
- Prev by Date: Re: Pathworks Alternative? ('Simple' Windows backup destination)
- Next by Date: Error enabling snapshots on DBMS database
- Previous by thread: Re: Floating point questions
- Next by thread: Re: Floating point questions
- Index(es):
Relevant Pages
|
Loading