Find a gps point knowing starting point distance and compass direction

166 views Asked by At

I am building an anchor watch application and I am finding some issue to calculate a GPS point (anchor position called point B), what I know are my actual location GPS coordinates (point A), distance between my actual location (A) and the anchor location (B) in meters, and the magnetic angle calculate with a digital compass so from 000° to 360°.

Anybody can help me with this?

Thank you !! Phil

2

There are 2 answers

0
Rhys Clarke On

Pretty simple trig not really programming but as an answer here is a program to do it, code is self explanitary.

Dim Distance, Bearing As Double
Dim Radius As Double = 6372.795477598

Distance = (Distance /Radius)
LatB = ASinD(SinD(LatA) * Cos(Distance/Radius) + CosD(LatA) * Sin(Distance/Radius) * CosD(Bearing))
LonB = LonA + ATan2D(SinD(Bearing) * Sin(Distance / Radius) * CosD(LatA), Cos(Distance / Radius) - SinD(LatA) * SinD(LatB))
0
slash-dev On

If you are using an Arduino like your tags suggest, the NeoGPS library has simple methods for this "offset" operation:

if (gps.available( gpsPort )) {
 gps_fix = gps.read(); // get the current location

 Location_t B( fix.location );  // start at "A"
 B.OffsetBy( distanceKm / Location_t::EARTH_RADIUS_KM, northAngleRadians ); // step to "B"

Used in an example program here.

BTW, there will be a slight difference between Magnetic North and True North. Either hard-code the declination in your sketch for local use, or investigate models and look-up tables for global use.