(defun ufb00021 ( u_p ;構成点の座標 ; (始点座標(X,Y) 2点目座標(X,Y) ...) u_pc ;内外判定をしたい点の座標 u_eps ;許容誤差 u_epa ;許容誤差(度) / flgo ; 0:外側 ; 1:内側 ; nil:判定できない ; 構成点が3点未満 aee nn nc pp xx yy len aa nc2 p1 p2 le1 le2 lew an aw1 aw2 ) ;内外判定をする(計算はZ=0の2次元で行う) (setq flgo nil) (setq aee 360.0) (setq nn (length u_p)) (if (>= nn 3) (progn (setq nc 0) (repeat nn (setq pp (nth nc u_p)) (setq nc (+ nc 1)) (setq xx (- (car pp) (car u_pc))) (setq yy (- (cadr pp) (cadr u_pc))) (setq len (sqrt (+ (* xx xx) (* yy yy)))) (if (<= len u_eps) ;構成点の近傍の場合は内側とする (setq flgo 1) ) ) (setq nc 0) (repeat nn (setq nc2 (+ nc 1)) (if (>= nc2 nn) (setq nc2 0) ) (setq p1 (nth nc u_p)) (setq p2 (nth nc2 u_p)) (setq nc (+ nc 1)) (setq xx (- (car p2) (car p1))) (setq yy (- (cadr p2) (cadr p1))) (setq len (sqrt (+ (* xx xx) (* yy yy)))) (setq xx (- (car p1) (car u_pc))) (setq yy (- (cadr p1) (cadr u_pc))) (setq le1 (sqrt (+ (* xx xx) (* yy yy)))) (setq xx (- (car p2) (car u_pc))) (setq yy (- (cadr p2) (cadr u_pc))) (setq le2 (sqrt (+ (* xx xx) (* yy yy)))) (setq lew (- (+ le1 le2) len)) (if (<= (abs lew) u_eps) ;構成点の線上の場合は内側とする (setq flgo 1) ) ) (if (/= flgo 1) (progn (setq aa 0.0) (setq nc 0) (repeat nn (setq nc2 (+ nc 1)) (if (>= nc2 nn) (setq nc2 0) ) (setq an (ufb00014 u_pc (nth nc u_p) u_pc (nth nc2 u_p) u_eps)) (if (/= an nil) (setq aa (+ aa an)) ) (setq nc (+ nc 1)) ) (setq flgo 0) (setq aa (abs aa)) (setq aw1 (- aee u_epa)) (setq aw2 (+ aee u_epa)) (if (and (>= aa aw1) (<= aa aw2)) (setq flgo 1) ) ) ) ) ) flgo )