Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Created June 7, 2019 16:44
Show Gist options
  • Save BrunoCaimar/c912d4996d4aaf6a4fee861f6ef955b4 to your computer and use it in GitHub Desktop.
Save BrunoCaimar/c912d4996d4aaf6a4fee861f6ef955b4 to your computer and use it in GitHub Desktop.
GetGeographicalDegrees
private static double GetGeographicalDegrees(IPolyline shape)
{
var radian2 = Math.Atan2(shape.ToPoint.Y - shape.FromPoint.Y,
shape.ToPoint.X - shape.FromPoint.X);
var radian = radian2 - (Math.PI / 2);//# turn minus 90°
var degrees = 0.0;
if (radian > 0)
{
degrees = 360 - (radian * 360) / (2 * Math.PI);
}
else
{
degrees = 360 - ((2 * Math.PI + radian) * 360) / (2 * Math.PI);
}
Debug.WriteLine($"radian2: {radian2} radian {radian} degrees {degrees} Cos(rad) {Math.Cos(radian)} Sin(rad) {Math.Sin(radian)}");
Debug.WriteLine($"radian2: {radian2} radian {radian} degrees {degrees} Cos(degree) {Math.Cos(degrees)} Sin(rad) {Math.Sin(degrees)}");
return degrees;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment