Use the following method to determine the "great circle" distance, in miles, between two geological coordinates. Latitude is positive north of the equator. Longitude is negative west of Greenwich:
public static double DistanceBetweenLocations(double Lat1Degrees,
double Lon1Degrees,
double Lat2Degrees,
double Lon2Degrees)
{
double Angle = AngleBetweenLocations(Lat1Degrees, Lon1Degrees,
Lat2Degrees, Lon2Degrees);
double Circumference = 24830.0; // miles at equator
return Circumference * Angle / (2.0 * Math.PI);
}
public static double AngleBetweenLocations(double Lat1Degrees,
double Lon1Degrees,
double Lat2Degrees,
double Lon2Degrees)
{
double Lat1Radians = Radians(Lat1Degrees);
double Lon1Radians = Radians(Lon1Degrees);
double Lat2Radians = Radians(Lat2Degrees);
double Lon2Radians = Radians(Lon2Degrees);
double a = Lon1Radians - Lon2Radians;
if (a < 0.0)
{
a = -a;
}
if (a > Math.PI)
{
a = 2.0 * Math.PI - a;
}
return Math.Acos(
Math.Sin(Lat2Radians) * Math.Sin(Lat1Radians) +
Math.Cos(Lat2Radians) * Math.Cos(Lat1Radians) * Math.Cos(a)
);
}
public static double Radians(double degrees)
{
return degrees * Math.PI / 180.0;
}
| Title | Date |
| Node.js + Express: How to Block Requests by User-Agent Headers | January 7, 2026 |
| Vault 3 is Now Available for Windows on ARM Machines! | December 13, 2025 |
| Vault 3: How to Include Outline Text in Exported Photos | October 26, 2025 |
| .NET Public-Key (Asymmetric) Cryptography Demo | July 20, 2025 |
| Raspberry Pi 3B+ Photo Frame | June 17, 2025 |
| EBTCalc (Android) Version 1.53 is now available | May 19, 2024 |
| Vault 3 Security Enhancements | October 24, 2023 |