(defun ufb00022 ( u_v ;並べ替える方向ベクトル u_p ;ベクトル方向へソートしたい点列座標 ; (1点目座標(X,Y) 2点目座標(X,Y) ...) u_eps ;許容誤差 u_epe ;許容誤差(規格化用) / pout ;ソート後の点列座標 ; (1点目座標(X,Y) 2点目座標(X,Y) ...) ; nil:判定できない ; ベクトルの長さが0 vx vy ll nn p1 ss xx yy px nc pp po lxp lxe nn1 nc2 nmi xmi nn2 lxpw mf mc elm ) ;点列を指定されたベクトル方向へ並べ替える (setq pout nil) (setq vx (car u_v)) (setq vy (cadr u_v)) (setq ll (sqrt (+ (* vx vx) (* vy vy)))) (if (> ll u_epe) (progn (setq nn (length u_p)) (if (< nn 2) (setq pout u_p) (progn (setq p1 (nth 0 u_p)) (setq ss (/ u_eps u_epe)) (setq xx (+ (car p1) (* ss vx))) (setq yy (+ (cadr p1) (* ss vy))) (setq px (list xx yy 0.0)) (setq nc 0) (repeat nn (setq pp (nth nc u_p)) (setq po (ufb00010 p1 px pp u_eps)) (setq xx (car po)) (if (= nc 0) (setq lxp (list (list xx pp))) (progn (setq lxe (list (list xx pp))) (setq lxp (append lxp lxe)) ) ) (setq nc (+ nc 1)) ) (setq nn1 (- nn 1)) (setq nc2 0) (repeat nn1 (setq lxe (nth nc2 lxp)) (setq xx (car lxe)) (setq nmi nc2) (setq xmi xx) (setq nn2 (- nn1 nc2)) (setq nc (+ nc2 1)) (repeat nn2 (setq lxe (nth nc lxp)) (setq xx (car lxe)) (if (< xx xmi) (progn (setq nmi nc) (setq xmi xx) ) ) (setq nc (+ nc 1)) ) (setq lxpw lxp) (setq mf 0) (setq mc 0) (repeat nn (setq elm (nth mc lxpw)) (if (= mc nc2) (setq elm (nth nmi lxpw)) ) (if (= mc nmi) (setq elm (nth nc2 lxpw)) ) (setq mc (+ mc 1)) (if (= mf 0) (progn (setq mf 1) (setq lxp (list elm)) ) (progn (setq lxp (append lxp (list elm))) ) ) ) (setq nc2 (+ nc2 1)) ) (setq nc 0) (repeat nn (setq lxe (nth nc lxp)) (if (= nc 0) (progn (setq pout (list (cadr lxe))) ) (progn (setq pp (list (cadr lxe))) (setq pout (append pout pp)) ) ) (setq nc (+ nc 1)) ) ) ) ) ) pout )