calculate radius distance between two coordinates php code example

Example 1: javascript distance between two points

Math.hypot(x2-x1, y2-y1)

Example 2: distance between two points latitude longitude c#

float DeltaFi = (float)ConvertToRadians(lat2 - lat1);
float DeltaLambda = (float)ConvertToRadians(lon2 - lon1);
float a = Mathf.Sin(DeltaFi / 2) * Mathf.Sin(DeltaFi / 2) + Mathf.Cos(fi1) * Mathf.Cos(fi2) * Mathf.Sin(DeltaLambda / 2) * Mathf.Sin(DeltaLambda / 2);
float c = 2 * Mathf.Atan2(Mathf.Sqrt(a), Mathf.Sqrt(1 - a));
float distance = earthD * c;