[夏生生][x_s_s_1]生无可恋 22:35:27
猫王,请教下,用角度和360度判断点在多边形内是否只适合凸多边形?
[夏生生][x_s_s_1]生无可恋 22:35:59
我写的这个好像有bug
[不死猫][nonsmall]不死猫 22:36:16
点在多边形内
有现成的函数
[夏生生][x_s_s_1]生无可恋 22:36:35
?
vl自带的?
[HNFSF](看海) 22:37:10
明经好像有
[夏生生][x_s_s_1]生无可恋 22:37:14
别人写的太长了
[不死猫][nonsmall]不死猫 22:37:21
(defun 3dm_pl_region_GE_PtInPoly (pt vlist flag / NumInts diff cnt online p1 p1code p1x
p1y p2 p2code p2x p2y ttl x xdiff xx y ydiff Idx len
)
(if (not (equal (car vlist) (last vlist)))
(setq vlist (append
vlist
(list (car vlist))
)
)
)
(setq X (car pt)
Y (cadr pt)
len (length vlist)
cnt 0
Idx 0
NumInts 0
OnLine nil
)
(while (and
(not OnLine)
(< cnt len)
)
(setq p2 (nth cnt vlist)
p2x (car p2)
p2y (cadr p2)
p2code (if (>= p2y y)
2
0
)
p2code (if (>= p2x x)
(1+ p2code)
p2code
)
)
(if p1
(setq diff (boole 6 p1code p2code)
ydiff (boole 1 diff 2)
xdiff (boole 1 diff 1)
p1x (car p1)
p1y (cadr p1)
)
)
(if (= ydiff 2)
(progn
(setq xx (+ p1x (* (/ (- p2x p1x) 1. (- p2y p1y)) (- y p1y))))
(cond
((equal xx x 0.0001)
(setq online T)
)
((> xx x)
(setq NumInts (1+ NumInts))
)
)
)
)
(if (and
(= xdiff 1)
(= y p1y p2y)
)
(setq OnLine T)
)
(setq p1code p2code
p1 p2
cnt (1+ cnt)
)
)
(if Online
flag
(= (boole 1 NumInts 1) 0001)
)
)
[夏生生][x_s_s_1]生无可恋 22:37:31
我只判断在凸多边形就行了
[HNFSF](看海) 22:37:44
[LC100]建筑设计 22:38:51
小明要是需要挂上的可以找我嘛。
我电脑常开的
[夏生生][x_s_s_1]生无可恋 22:39:29
谢谢了猫王、看海
我搜过,对我需求的功能都有点太全了 |