added method to determine distance between points

should be valuable to know what distance between two points is. Also
added testing
This commit is contained in:
dm
2016-08-26 11:37:18 -07:00
parent b5a9726d2d
commit b9bc23566f
2 changed files with 35 additions and 0 deletions
+6
View File
@@ -1,5 +1,11 @@
package rect
import "math"
type Point struct {
X, Y float64
}
func distance(p1, p2 Point) float64 {
return math.Sqrt(math.Pow((p1.X-p2.X), 2) + math.Pow((p1.Y-p2.Y), 2))
}