Skip to content

Instantly share code, notes, and snippets.

@manveru
Created May 24, 2010 13:40
Show Gist options
  • Save manveru/411874 to your computer and use it in GitHub Desktop.
Save manveru/411874 to your computer and use it in GitHub Desktop.
package main
import "math"
type Point struct {
x int
y int
}
func (p0 Point) distanceTo(p1 Point) float64{
return math.Sqrt(float64((p0.x-p1.x)*(p0.x-p1.x) + (p0.y-p1.y)*(p0.y-p1.y)))
}
func main() {
p0 := Point{10, 10}
p1 := Point{20, 20}
p0.distanceTo(p1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment