title: Get accurate lat/long given current point, distance and bearing
body: <p>Given an existing point in lat/long, distance(inches) and bearing (in degrees converted to radians), I'm trying to calculate the new lat/long. But the resulting is some times inaccurate because I'm trying to measure a small area for the new lat/long. Currently, I'm trying to get the next foot lat/long but some times it has a 1-inch error. I used the following algorithm for this implementation. Referred this thread for the algorithm  <a href="https://stackoverflow.com/questions/7222382/get-lat-long-given-current-point-distance-and-bearing">Get lat/long given current point, distance and bearing</a>.</p>
  
  <pre><code>public LatLng calculateLatLangFromDistance(double brng, double distance, LatLng latLng){
  
      double lat1 = Math.toRadians(latLng.getLatitude());
      double long1 = Math.toRadians(latLng.getLongitude());
      double br = Math.toRadians(brng);
  
  
     double lat2 = Math.asin(Math.sin(lat1)*Math.cos(distance/r) +
             Math.cos(lat1)* Math.sin(distance/r)* Math.cos(br));
  
     double long2 = long1 + Math.atan2(Math.sin(br)*Math.sin(distance/r)*Math.cos(lat1),
             Math.cos(distance/r)-Math.sin(lat1)*Math.sin(lat2));
  
      lat2 = Math.toDegrees(lat2);
      long2 = Math.toDegrees(long2);
  
     LatLng latLng1 = new LatLng();
     latLng1.setLongitude(long2);
     latLng1.setLatitude(lat2);
  
     return latLng1;
  }
  </code></pre>
  
  <p>r is defined as 250826771.6535433 // //Radius of the Earth from inches</p>
  
  <p>I'm using the above implementation to generate a 1-foot grid to mapbox map layer but resulting grid's some lines are 1-inch inaccurate. Is there any way to improve this implementation for better results or is there another way to get accurate lat/long for this?<a href="https://i.stack.imgur.com/N5o3H.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N5o3H.jpg" alt="enter image description here"></a></p>
  
  <p>this is the generated grid and I did a line drawing to get the idea about line length of the some lines in the grid.</p>