Jump to content

For the true Lat/Lon Trig Geeks


Guest Markwell

Recommended Posts

Guest Markwell

I've asked "Dr. Math", I've asked Jeremy (but I know he's far too busy), so I'll post this out for the Math Professors in the forum.

 

I have my own little Microsoft Access database on which I keep Cache info for local caches and others I plan on visiting. I'm trying to make it as robust as possible for my own use.I've even got a little side query that calculates the decimal degree version of the coordinates.

 

I've also got a table of fixed landmarks (interstate intersections, airports, my house, etc.) that I have decimal versions of the coordinates as well.

 

What I'm looking for is a wholistic formula or visual basic add-in for Access that takes the degree coordinates and gives me a resulting degree bearing. Example: moving from N41° W88° to N42° W87° you have an initial bearing of roughly 36.5° (I've got an add-in for Excel, but not Access).

 

I have the formulas for calculating the distance in Radians, KM and miles (boy is THAT long), but I'm still looking for the formula to do the bearing. Any ideas? Any sources?

 

Markwell

MarkLent60544@aol.com

Link to comment
Guest ClayJar

I have no answers, but you'd need to take into account the curvature of the earth to get a true point-to-point result, right? (That's where my two-second overview skills stop and my "Do I want to spend a few hours doing the derivations?" skills kick in.)

Link to comment
Guest Markwell

les: (Atn(-(Cos([FixedLat]*PI/180)*Cos([CacheLat]*PI/180)

*Cos(([CacheLong]-[FixedLong])*PI/180)

+Sin([FixedLat]*PI/180)*Sin([CacheLat]*PI/180))

/Sqr(-(Cos([FixedLat]*PI/180)

*Cos([CacheLat]*PI/180)

*Cos(([CacheLong]-[FixedLong])*PI/180)

+Sin([FixedLat]*PI/180)*Sin([CacheLat]*PI/180))

*(Cos([FixedLat]*PI/180)*Cos([CacheLat]*PI/180)

*Cos(([CacheLong]-[FixedLong])*PI/180)

+Sin([FixedLat]*PI/180)*Sin([CacheLat]*PI/180))+1))

+2*Atn(1))*3959

 

And that's just the distance

 

icon_wink.gif

Link to comment
Guest Markwell

les: (Atn(-(Cos([FixedLat]*PI/180)*Cos([CacheLat]*PI/180)

*Cos(([CacheLong]-[FixedLong])*PI/180)

+Sin([FixedLat]*PI/180)*Sin([CacheLat]*PI/180))

/Sqr(-(Cos([FixedLat]*PI/180)

*Cos([CacheLat]*PI/180)

*Cos(([CacheLong]-[FixedLong])*PI/180)

+Sin([FixedLat]*PI/180)*Sin([CacheLat]*PI/180))

*(Cos([FixedLat]*PI/180)*Cos([CacheLat]*PI/180)

*Cos(([CacheLong]-[FixedLong])*PI/180)

+Sin([FixedLat]*PI/180)*Sin([CacheLat]*PI/180))+1))

+2*Atn(1))*3959

 

And that's just the distance

 

icon_wink.gif

Link to comment
Guest Markwell

quote:
From website:

An alternative formula, not requiring the pre-computation of d, the distance between the points, is:

 

tc1=mod(atan2(sin(lon1-lon2)*cos(lat2),

cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)

*cos(lon1-lon2)), 2*pi)


 

First the equation above this one inserts the variable "d" as distance - I'm having a problem with that - is that distance in Radians?

 

I also have to convert the formulas to some simpler terms as not all trig functions are available in Access like they are in Excel. So, Mod() and atan2() are foreign to me. Whenever I tried to use this formula (and I have) I've gotten a lot of "Error#" results.

 

Again, I think I've exhausted the internet resources - including "Dr. Math" where a live human tried to answer my questions. I may have to call up my old trig professor. tongue.gif

 

I'd be MORE than willing to e-mail my tried and failed formula to a mathematician to have him proof it.

 

EEEEK!

Link to comment
Guest JIntorcio

You might be able to eliminate the two offending functions. Mod is sure for Modulo. It means ?remainder?. Mod(X,2ð) means the remainder when X is divided by 2ð. You can fake this b recursively subtracting 2ð until the resulting value is less than 2ð. Atan2 is just another form of atan or arctangent that doesn?t explode at the ð/2 and - ð/2 points. It may be that, if Access has an arctangent function, it handles those cases or, it may be that the won?t really happen in your case so you don?t care? Try faking the Mod and using the built in atan and see what you get!

 

------------------

>>> John <<<

Link to comment
Guest Markwell

Thanks John and everybody else, I got it. It ain't pretty, and Access has to churn away quite a while, but it's pretty cool. I would be remiss if I didn't publically thank Dr. Math, the Mathematical Equivalent of Ask Jeeves.

 

I can now see the cache on a screen and see in a list the fixed known locations from the closest to the farthest and the bearing the cache is from the fixed location.

 

I can also do a radial search, say on "O'Hare Aiport" and find not only the distance but the bearing in degrees (and consequestly an approximate direction) - and list the caches from the closest out.

 

Any other Access geek out there that wants further information can contact me at MarkLent60544@aol.com

 

Markwell

Link to comment
Guest Cape Cod Cache

For some heavy duty cartography, hit the National Image and Mapping Agency http://www.nima.mil/

It's rather interesting, you paid for it, use it ... They are trying to get USGS to smarten up and use WGS 84 for one thing, and have a major database of all maps/chart be uniform. Math stuff I care not to think about as well, I don't sleep well as it is .

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...