From 53019e4770d1cf9999201e261fd6d93ab3c0d849 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 17 Jul 2022 12:42:42 -0500 Subject: [wip] --- src/utils.lisp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'src/utils.lisp') diff --git a/src/utils.lisp b/src/utils.lisp index 4037b7a..7b68e3d 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -41,7 +41,6 @@ and B intersects the linesegment between C and D, NIL otherwise." while b2 thereis (segments-intersect-p a1 a2 b1 b2)))) - (defun closed-path-p (path) (equalp (first path) (first (last path)))) @@ -63,8 +62,6 @@ and B intersects the linesegment between C and D, NIL otherwise." finally (return (oddp intersection-count))))) - - (defun path-encloses-path-p (path-a path-b) "T if path-b is totally contained in path-a and does not intersect path-a" (assert (closed-path-p path-a) () "Enclosing path must be a closed path.") @@ -115,23 +112,7 @@ the path." `(let ((,value ,value-form)) (setf ,@clauses)))) - -(defmacro with-grid-line - ((x y) (start-x start-y) (end-x end-y) &body body) - "Execute BODY for X and Y assigned to integer values in a line -connecting the integer point START-X , START-Y and END-X, END-Y. " - (with-gensyms (sx sy ex ey distance step progress xdiff ydiff) - `(loop - with ,sx = ,start-x - with ,sy = ,start-y - with ,ex = ,end-x - with ,ey = ,end-y - with ,xdiff = (- ,ex ,sx) - with ,ydiff = (- ,ey, sy) - with ,distance = (max (abs ,xdiff) (abs ,ydiff)) - for ,step from 0 to ,distance - for ,progress = (if (zerop ,distance) 0.0 (/ ,step ,distance)) - for ,x = (round (+ ,start-x (* ,progress ,xdiff))) - for ,y = (round (+ ,start-y (* ,progress ,ydiff))) - do (progn ,@body)))) - +(defun euclidean-dist (x1 y1 x2 y2) + (let ((dx (- x2 x1)) + (dy (- y2 y1))) + (sqrt (+ (* dx dx) (* dy dy))))) -- cgit v1.2.3