From 4ec779a31486fdedf038c35f975723b3abc04c8c Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 27 Jul 2022 08:04:24 -0500 Subject: [refactor] to [optimize] a few numeric functions --- src/utils.lisp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils.lisp b/src/utils.lisp index 7357325..f6af42c 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -18,18 +18,22 @@ "A B and C are vectors created by 3d-vectors:vec, each representing a 2d point. Returns T if the three are supplied in counterclockwise order, nil if not." + (declare (type single-float ax ay bx by cx cy)) (> (* (- bx ax) (- cy ay)) (* (- by ay) (- cx ax)))) (defun points-equal-p (x1 y1 x2 y2) + (declare (type single-float x1 x2 y1 y2)) (and (= x1 x2)) (= y1 y2)) (defun segments-intersect-p (ax ay bx by cx cy dx dy) "A B C and D are vectors of the sort created by 3d-vectors:vec, each representing a 2d point. Returns T if the line segment between A and B intersects the linesegment between C and D, NIL otherwise." + (declare (optimize (speed 3) (safety 0))) + (declare (type single-float ax ay bx by cx cy dx dy)) (or (points-equal-p ax ay cx cy) (points-equal-p ax ay dx dy) (points-equal-p bx by cx cy) @@ -41,6 +45,7 @@ and B intersects the linesegment between C and D, NIL otherwise." (defun paths-intersect-p (path1 path2) "Paths are lists of vectors, each of which represents a 2d point." + (declare (optimize (speed 3) (safety 0) )) (loop for ((ax ay) (bx by) . more1) on path1 while bx thereis (loop for ((cx cy) (dx dy) . more2) on path2 -- cgit v1.2.3