October 4, 2010

Use the following method to determine the angle subtended at the earth's center by two geographical coordinates. Latitude is positive north of the equator. Longitude is negative west of Greenwich. Both latitude and longitude are specified in degrees:

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 |

How to decompile Java code with JetBrains IntelliJ IDEA (2018.2.3, Windows 10) | October 5, 2018 |

Java Programming Tip: SWT Photo Frame Program | October 31, 2016 |

Vault 3 (Desktop) Version 1.63 Released | September 9, 2016 |

"Compliance with Court Orders Act of 2016" | April 9, 2016 |

Disable "Visual Voicemail" on Android / T-Mobile | January 17, 2016 |

IPv6 Humor | December 10, 2015 |

Java Programming Tip: Specify the JVM time zone | December 7, 2015 |