aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-27 08:04:24 -0500
committerColin Okay <colin@cicadas.surf>2022-07-27 08:04:24 -0500
commit4ec779a31486fdedf038c35f975723b3abc04c8c (patch)
treeeece1104f4bb64b78c388f9882a548731fc382b2
parent38b33de4c2e03a6f706fced1b866d975a6296156 (diff)
[refactor] to [optimize] a few numeric functions
-rw-r--r--src/utils.lisp5
1 files changed, 5 insertions, 0 deletions
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