TinyGPS++ calculation of coordinates using elevation and distance

Hi, many thanks for this library. I'm solving a problem. TinyGPS++ can calculate the course and the distance between two points. How can I use this library to calculate the coordinates of the second point if I know the coordinates of the first point and the course and distance to the second point? It would help me a lot, the calculation is terrible :slight_smile:
Unfortunately I did not find a similar topic here. If this issue has already been resolved, I apologize.
Thank you for your reply and have a nice day ...

How can I use this library to calculate the coordinates of the second point

It’s a point.
You already KNOW its coordinates.

I know my coordinates, distance and direction to the point.... I don't know the coordinates of the point. I need to calculate the coordinates of that point.

I suppose you did not get any results when you did a internet search on the words

given a known lat lon and distance calculate new position

?

Then how did airplanes get from here to there in WWII?

Google “great circle”.

This stuff used to be secondary school trig.

To calculate the coordinates of a point at some distance and bearing from a given point, use the "bearing shoot" method.

Described here: Destination point given distance and bearing from start point

The code I use for that is specialized for an old version of TinyGPS, which stores internal lat/lon as long integers in degrees * 1 million:

//
// find latitude and longitude (lat2,lon2) of a point,
// given bearing (degrees) and distance (meters), lat1, lon1
//
// **great circle route on spherical Earth assumed**
//
// input and output (lat,lon) are long integers in degrees*1e6
// on ATMegas, this is less accurate due to single precision floats
/*
void bearing_shoot(float bearing, float distance, long lat1, long lon1, long *lat2, long *lon2)
{

	float phi1,lam1,d,phi2;
	float R=6371000.0;  //mean Earth radius in meters
	float theta = bearing*DEG2RAD;

	d = distance/R;  //arc length

	phi1 = DEG2RAD*lat1*1.0e-6;  //convert to radians
	lam1 = DEG2RAD*lon1*1.0e-6;
	phi2 = asin(sin(phi1)*cos(d) + cos(phi1)*sin(d)*cos(theta));

	*lat2 = (long) 1.0e6*phi2*RAD2DEG;
	*lon2 = (long) 1.0e6*(lam1 + atan2(sin(theta)*sin(d)*cos(phi1), cos(d)-sin(phi1)*sin(phi2)))*RAD2DEG;
}

For short distances (up to some km) you can use the "equirectanglar approximation", which is more accurate than the Great Circle method on AVR based Arduinos:

// this version of bearing_shoot uses the equirectangular approximation.
// GPS coordinates assumed to be long integers, degrees*10^6 (10 cm precision)
// tests show it to be more accurate for short distances than the great circle
// version above, but consumes far less program memory

void bearing_shoot (float bearing, float distance, long lat1, long lon1, long *lat2, long *lon2)
{
  float d,phi1;
  float R=6371000.0;  //mean Earth radius in meters
  long dlat, dlon;

  float theta = bearing*DEG2RAD;
  d = RAD2DEG*distance/R;  //arc length in degrees

  phi1 = DEG2RAD*lat1*1.0e-6;  //convert lat to radians
  dlat = d*cos(theta)*1.0e6; //latitude change in degrees*10^6
  dlon = d*sin(theta)*1.0e6/cos(phi1); //longitude change, corrected for latitude

    *lat2 = lat1 + dlat;
    *lon2 = lon1 + dlon;
}