diff options
Diffstat (limited to 'src/macroknight/utils.hy')
-rw-r--r-- | src/macroknight/utils.hy | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/macroknight/utils.hy b/src/macroknight/utils.hy index dde8d2e..5de8887 100644 --- a/src/macroknight/utils.hy +++ b/src/macroknight/utils.hy @@ -1,4 +1,5 @@ -(import enum [Enum]) +(import enum [Enum] + math [sqrt]) (defclass Direction [Enum] (setv UP "UP") @@ -44,3 +45,7 @@ (defn sub-points [point1 point2] #((- (get point2 0) (get point1 0)) (- (get point2 1) (get point2 1)))) + +(defn distance [point1 point2] + (sqrt (+ (** (- (get point1 0) (get point2 0)) 2) + (** (- (get point1 1) (get point2 1)) 2)))) |