
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am trying to write a function to determine in which quadrant of a given shape a point is, with other words, which is the corner of the shape that is the nearest to the point.
The shape is a closed polyline and doesn't have to be a rectangle. The point is a point entity.
I need to embed the function in another function, so neither the point nor the polyline should be given per user's input. I thought I could set the point and the polyline as arguments of the function, but something doesn't seem to work. When I run the code I get the error:
error : improper DEFUN argument list : 56.6021110540261
where the number is the x coordinate of the point.
I guess the problem is that the point is actually a list of coordinates, and I don't know how to pass this argument to the function. Can somebody help? Thank you.
Here's my code:
(defun pospt (/pt bnd)
(setq bminx (apply 'min (mapcar 'car (poly-pts bnd)))
bmaxx (apply 'max (mapcar 'car (poly-pts bnd)))
bminy (apply 'min (mapcar 'cadr (poly-pts bnd)))
bmaxy (apply 'max (mapcar 'cadr (poly-pts bnd)))
)
(setq xllpt (car pt)
yllpt (cadr pt))
(if (and
(<(abs (- xllpt bmaxx))(abs (- xllpt bminx)))
(<(abs (- yllpt bminy))(abs (- yllpt bmaxy)))
)
(setq pospt "bottom-right")
(if (and
(>(abs (- xllpt bmaxx))(abs (- xllpt bminx)))
(<(abs (- yllpt bminy))(abs (- yllpt bmaxy)))
)
(setq pospt "bottom-left")
(if (and
(<(abs (- xllpt bminx))(abs (- xllpt bmaxx)))
(>(abs (- yllpt bminy))(abs (- yllpt bmaxy)))
)
(setq pospt "top-left")
(if (and
(<(abs (- xllpt bmaxx))(abs (- xllpt bminx)))
(>(abs (- yllpt bminy))(abs (- yllpt bmaxy)))
)
(setq pospt "top-right")(setq pos "other")))))
)
Poly-pts is a function I found on the forum that returns a list with the vertices of the polyline.
Solved! Go to Solution.