aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.lisp')
-rw-r--r--src/utils.lisp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/utils.lisp b/src/utils.lisp
index 165f29a..bcb4cb2 100644
--- a/src/utils.lisp
+++ b/src/utils.lisp
@@ -41,8 +41,14 @@ and B intersects the linesegment between C and D, NIL otherwise."
while b2
thereis (segments-intersect-p a1 a2 b1 b2))))
-(defun path-contains-point (path pt)
+
+(defun closed-path-p (path)
+ (equalp (first path)
+ (first (last path))))
+
+(defun path-encloses-point-p (path pt)
"Path is a list of vectors, pt is a single vector."
+ (assert (closed-path-p path) () "Enclosing path must be a closed path.")
(let* ((bounds
(path-bounds path))
(corner
@@ -57,8 +63,16 @@ and B intersects the linesegment between C and D, NIL otherwise."
finally
(return (oddp intersection-count)))))
-(defun path-encloses-p (path other)
- )
+
+
+(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.")
+ (and
+ (loop for (p1 p2 . more) on path-b
+ while p2
+ always (path-encloses-point-p path-a p1))
+ (not (paths-intersect-p path-a path-b))))
(defun path-bounds (path)
"Path is a list of vectors representing 2d points. Returns the