- Aug 30, 2006Thanks, been looking for something like that. Just ordered a copy.

**From:**tracker2@yahoogroups.com [mailto:tracker2@yahoogroups.com]**On Behalf Of**James Jefferson Jarvis**Sent:**Wednesday, August 30, 2006 9:13 AM**To:**tracker2@yahoogroups.com**Subject:**Re: [tracker2] Distance calculation reduxThere is a very good book on this subject called:

"Math Toolkit for Real-Time Programming" by Jack Chrenshaw

It's actually about embedded systems, not real-time. It will answer all of

your questions and provide with you real code and techniques for 8-bit

micros.

Highly recommended. I use mine all of the time.

-Jim

On Wednesday 30 August 2006 00:32, scott@opentrac. org wrote:

> My first attempt at a distance calculation (using a floating point

> implementation of the haversine formula) required 5 trigonometric function

> calls, two square roots, and several floating point divisions. It also

> needed 3 watchdog resets to keep the CPU from timing out during the

> calculation! Floating point math is NOT the HC08's strong suit.

>

> I rewrote it using mostly integer math, applying the pythagorean theorem

> and dividing each hemisphere into 8 latitude bands to compensate for the

> convergence of the meridians. I think it's accurate enough for this

> application, and it's pretty fast. It's got one square root call and no

> division.

>

> I also added the ability to use compressed mode with a fixed position.

> This was important because the distance calculation works from the

> compressed integer representation of the coordinates, so the conversion had

> to be done anyway.

>

> Something's still not quite right - two points with the same coordinates

> show a distance of 323 feet. Gotta track that one down. But it seems to

> be good enough for distances in miles - everything seems to be within about

> 10% of what it should be.

>

> I was thinking that a cool use for this would be to add a scripting option

> to trigger an action based on distance to a station. A T2 at your house

> could see your car coming and turn the driveway light on when it's within a

> mile, or your mobile station could turn on a proximity alarm light when you

> come within a certain distance of another station on the road.

>

> Now for bearing calculation. Anyone know how to fake an arctangent

> calculation?

>

> Scott

>

>

>

>

>

>

> Yahoo! Groups Links

>

>

> - << Previous post in topic Next post in topic >>