Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 681 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 681 Bytes

haversine

The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. Important in navigation, it is a special case of a more general formula in spherical trigonometry, the law of haversines, that relates the sides and angles of spherical triangles.

Example

package main

import (
	"fmt"

	haversine "github.com/lexor/haversine"
)

func main() {
	whiteHouse := haversine.Coord{Lat: 38.89768, Lon: -77.03653}
	eighteenAndF := haversine.Coord{Lat: 38.89736, Lon: -77.04173}

	fmt.Printf("%f\n", float64(haversine.Distance(whiteHouse, eighteenAndF)))
	// Return: 451.411074 (float64)
}