degree between two points latitude longitude c# code example

Example: degree between two points latitude longitude c#

float lambda1 = (float)ConvertToRadians(lon1);
float lambda2 = (float)ConvertToRadians(lon2);
float fi1 = (float)ConvertToRadians(lon1);
float fi2 = (float)ConvertToRadians(lon2);

float y = Mathf.Sin(lambda2 - lambda1) * Mathf.Cos(fi2);
float x = Mathf.Cos(fi1) * Mathf.Sin(fi2) - Mathf.Sin(fi1) * Mathf.Cos(fi2) * Mathf.Cos(lambda2 - lambda1);
float degree = (float)ConvertToDegree(Mathf.Atan2(y, x));

Tags:

Misc Example