diff options
Diffstat (limited to 'src/macroknight/utils.hy')
-rw-r--r-- | src/macroknight/utils.hy | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/macroknight/utils.hy b/src/macroknight/utils.hy index 05412e8..464bae5 100644 --- a/src/macroknight/utils.hy +++ b/src/macroknight/utils.hy @@ -61,6 +61,20 @@ #((- (get point2 0) (get point1 0)) (- (get point2 1) (get point2 1)))) +(defn add-tuples [tup1 tup2] + #((+ (get tup1 0) (get tup2 0)) + (+ (get tup1 1) (get tup2 1)))) + +(defn normalise-tuple [tup min-tup max-tup] + #((min (get max-tup 0) + (max (get min-tup 0) (get tup 0))) + (min (get max-tup 1) + (max (get min-tup 1) (get tup 1))))) + +(defn null-tuple [tup] + (and (= (get tup 0) 0) + (= (get tup 1) 0))) + (defn distance [point1 point2] (sqrt (+ (** (- (get point1 0) (get point2 0)) 2) (** (- (get point1 1) (get point2 1)) 2)))) |