From 684dab2e0e702440929a7f45b328d5372998eb2c Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Thu, 29 May 2025 21:40:32 +0100 Subject: More pymunk --- src/macroknight/utils.hy | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/macroknight/utils.hy') 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)))) -- cgit v1.2.3