(defun c:z ()
(setvar "cmdecho" 0)
(setvar "cecolor" "1")
(setq p1 (list 54.124 120.414))
(setq p2 (list 55.124 140.011))
(setq p30 (list 129.87 87.994))
(setq lst (list p1 p2 p30))
(defun high (A B C / S AREA H x y z)
(setq x (distance A B))
(setq y (distance B C))
(setq z (distance A C))
(setq S (/ (+ x y z) 2))
(setq AREA (sqrt (* S (- S x) (- S y) (- S z))))
(/ (* AREA 2) x)
);_计算点到直线的距离
(setq num 3)
(setq limit 1)
(defun Douglas (i j)
(setq lst1 (nth i lst) lst2 (nth j lst))
(setq k (+ 1 i) max 0)
(while (< k j)
(setq lst3 (nth k lst))
(setq dist (high lst1 lst2 lst3))
(if (> dist max)
(progn
(setq n k)
(setq max dist)
);_progn
);_if
(setq k (+ k 1))
);_while
(if (> max limit)
(progn
(command "pline" lst1 lst3 lst2 "")
(prin1 max)
);_progn
(progn
(command "pline" lst1 lst2 "")
);_progn
);_if
);_defun
(Douglas (0 (- num 1)))
(prin1))