diff options
Diffstat (limited to 'src/utils.lisp')
-rw-r--r-- | src/utils.lisp | 27 |
1 files changed, 4 insertions, 23 deletions
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))))) |