# 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
Unfortunately I did not find a similar topic here. If this issue has already been resolved, I apologize.

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

Itâ€™s a point.

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?

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.

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

d = distance/R;Â  //arc length

phi2 = asin(sin(phi1)*cos(d) + cos(phi1)*sin(d)*cos(theta));

*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;