diff options
author | Gene Pasquet <dev@etenil.net> | 2025-05-29 21:40:32 +0100 |
---|---|---|
committer | Gene Pasquet <dev@etenil.net> | 2025-05-29 21:40:32 +0100 |
commit | 684dab2e0e702440929a7f45b328d5372998eb2c (patch) | |
tree | bbed0d4b3b8ae9d64457b4f6e4a01b1904a4f2f7 /src/macroknight/utils.hy | |
parent | 71ca9de9cadfcbd41327cbc37a94f54794d2316d (diff) |
More pymunkpymunk
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)))) |