本帖最后由 chlh_jd 于 2011-4-9 19:45 编辑
- ;;;判断点是否在封闭多边形内 .
- ;;;Function : judge a point location with polygon
- ;;;Arg : pt -- a point
- ;;; pts -- points of polygon
- ;;; eps -- allowance
- ;;;return :
- ;;; -1 -- out of polygon , 0 -- at , 1 -- in
- (defun pipl?(pt pts eps / is at a)
- ;; by 狂刀
- ;; Edit by GSLS(SS) 2011.03.28
- (setq pt(trans pt 0 0)pts(mapcar(function(lambda(x)(trans x 0 0)))pts)Eps(abs Eps))
- (if(equalmember pt pts eps)0
- (progn(setq is(equal PI (abs(apply(function +)(mapcar(function(lambda (x y / a)
- (setq a (rem (- (angle pt x) (angle pt y)) PI))
- (if(equal (+(distance pt x)(distance pt y))(distance x y)Eps)(setq at T))a))
- (cons (last pts) pts) pts))) eps))(cond (at 0)(is 1)(T -1)))))
- (defun equalmember (e lst tor)
- (apply (function or)
- (mapcar (function (lambda (x) (equal x e tor))) lst)
- )
- )
|