Created
June 10, 2014 03:56
-
-
Save ghelobytes/d2515a9b82748f8020b5 to your computer and use it in GitHub Desktop.
Calculate Next point based on current point, heading, bearing, DMS and distance
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
private double[] NextPoint(double startX, double startY, string heading, string bearing, int degree, int minute, double seconds, double distance) | |
{ | |
double DEG2RAD = 4 * Math.Atan(1) / 180; | |
double azimuth = degree + (minute / 60); | |
string hb = heading + bearing; | |
switch (hb.ToUpper()) | |
{ | |
case "NE": | |
// do nothing | |
break; | |
case "NW": | |
azimuth = 0 - azimuth; | |
break; | |
case "SE": | |
azimuth = 180 - azimuth; | |
break; | |
case "SW": | |
azimuth = -180 + azimuth; | |
break; | |
default: | |
azimuth = 0; | |
break; | |
} | |
azimuth = azimuth * DEG2RAD; | |
double endX = startX + Math.Sin(azimuth) * distance; | |
double endY = startY + Math.Cos(azimuth) * distance; | |
return new double[] { endX, endY }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment