Created
March 30, 2016 21:15
-
-
Save nknize/384a60df159159c5a7b7b3657a12b385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Finds a point along a bearing from a given lon,lat geolocation using great circle arc | |
* | |
* @param lon origin longitude in degrees | |
* @param lat origin latitude in degrees | |
* @param bearing azimuthal bearing in degrees | |
* @param dist distance in meters | |
* @param pt resulting point | |
* @return the point along a bearing at a given distance in meters | |
*/ | |
public static final double[] pointFromLonLatBearingGreatCircle(double lon, double lat, double bearing, double dist, double[] pt) { | |
if (pt == null) { | |
pt = new double[2]; | |
} | |
lon *= TO_RADIANS; | |
lat *= TO_RADIANS; | |
bearing *= TO_RADIANS; | |
final double cLat = SloppyMath.cos(lat); | |
final double sLat = SloppyMath.sin(lat); | |
final double sinDoR = SloppyMath.sin(dist / GeoProjectionUtils.SEMIMAJOR_AXIS); | |
final double cosDoR = SloppyMath.cos(dist / GeoProjectionUtils.SEMIMAJOR_AXIS); | |
pt[1] = SloppyMath.asin(sLat*cosDoR + cLat * sinDoR * SloppyMath.cos(bearing)); | |
pt[0] = TO_DEGREES * (lon + Math.atan2(SloppyMath.sin(bearing) * sinDoR * cLat, cosDoR - sLat * SloppyMath.sin(pt[1]))); | |
pt[1] *= TO_DEGREES; | |
return pt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment