GetGPSxxDistFromMeInThisDirection and GetHeadingForThisGPSCord

Hello

I am looking to write a two functions manage GPS/heading inputs

The first function will take the user sGPS(lat,lon) and another set of cords(lat,lon)  and return a heading (compass direction for the second cocords from the users position).

heading = GetHeadingForThisGPSCord(myCurLon, myCurLat, targetLon,targetLat)

 > input (-30, 150, -30, 155)

 > Returns say 90 deg (East).

The second function will return he GPS cords of a place say 100k away from the users current cords in a known angle.

{targetLon TargeyLat} = GetGPSxxDistFromMeInThisDirection(myCurLon, myCurLat, facingThisDirection, distanceAway)

 > input (-30, 150, 78, 100km)

 > returns the direction in degrees to the target from user

Still plucking data together on GPS math in Corona

Any code snippets that people are aware of?

1/3 the way there

function Geo\_Distance(lat1, lon1, lat2, lon2) if lat1 == nil or lon1 == nil or lat2 == nil or lon2 == nil then return nil end local dlat = math.rad(lat2-lat1) local dlon = math.rad(lon2-lon1) local sin\_dlat = math.sin(dlat/2) local sin\_dlon = math.sin(dlon/2) local a = sin\_dlat \* sin\_dlat + math.cos(math.rad(lat1)) \* math.cos(math.rad(lat2)) \* sin\_dlon \* sin\_dlon local c = 2 \* math.atan2(math.sqrt(a), math.sqrt(1-a)) -- 6378 km is the earth's radius at the equator. -- 6357 km would be the radius at the poles (earth isn't a perfect circle). -- Thus, high latitude distances will be slightly overestimated -- To get miles, use 3963 as the constant (equator again) local d = 6378 \* c return d end

1/3 the way there

function Geo\_Distance(lat1, lon1, lat2, lon2) if lat1 == nil or lon1 == nil or lat2 == nil or lon2 == nil then return nil end local dlat = math.rad(lat2-lat1) local dlon = math.rad(lon2-lon1) local sin\_dlat = math.sin(dlat/2) local sin\_dlon = math.sin(dlon/2) local a = sin\_dlat \* sin\_dlat + math.cos(math.rad(lat1)) \* math.cos(math.rad(lat2)) \* sin\_dlon \* sin\_dlon local c = 2 \* math.atan2(math.sqrt(a), math.sqrt(1-a)) -- 6378 km is the earth's radius at the equator. -- 6357 km would be the radius at the poles (earth isn't a perfect circle). -- Thus, high latitude distances will be slightly overestimated -- To get miles, use 3963 as the constant (equator again) local d = 6378 \* c return d end

This may help

http://www.rcgroups.com/forums/showthread.php?t=2181441

I have cracked the bearing code, check out my blog http://simon.fearby.com/blog/?p=2117

This may help

http://www.rcgroups.com/forums/showthread.php?t=2181441

I have cracked the bearing code, check out my blog http://simon.fearby.com/blog/?p=2117