diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2023-08-26 11:34:03 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2023-08-26 11:34:03 +0200 |
| commit | d4283a02e30348e73bce786e67e2b1a17955c679 (patch) | |
| tree | 27576b3a1b71ea4c73f782f891012ea75880c364 /geometry.go | |
| parent | 03adccc9ec7a84a08f9d62287b42e09ce2b2963e (diff) | |
feat: Move to destination
Diffstat (limited to 'geometry.go')
| -rw-r--r-- | geometry.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/geometry.go b/geometry.go index 89eb1ed..0d90c6f 100644 --- a/geometry.go +++ b/geometry.go @@ -1,6 +1,21 @@ package main -import "image" +import ( + "image" + "math" +) -type Rectangle = image.Rectangle type Point = image.Point +type Rectangle = image.Rectangle + +func Distance(p1, p2 Point) float64 { + return math.Sqrt(math.Pow(float64(p1.X-p2.X), 2) + math.Pow(float64(p1.Y-p2.Y), 2)) +} + +func Length(p Point) float64 { + return Distance(p, Point{0, 0}) +} + +func Normalize(p Point) Point { + return p.Div(int(Length(p))) +} |
