;;; Hüllpolygon ;;; Grobentwurf 7.11.2015 ;;; Autor jupa ;;; Starten mit "hp" (defun c:hp (/ Punkte P-Start P-lfd P-last W-Liste Erg-Liste W-last) ;;; Punktliste erzeugen; an konkrete Aufgabe anpassen (defun P_Liste (/ p_in Punktliste) (while (setq p_in (getpoint "\nPunkt eingeben: ")) (setq Punktliste (cons p_in Punktliste)) ) ) ;;; Startpunkt (kleinster y-Wert) ermitteln (defun Startpunkt (P-Liste /) (car (vl-sort P-Liste (function (lambda (x1 x2) (< (cadr x1) (cadr x2)) ) ) ) ) ) ;;; erzeuge Winkelliste (defun W_Liste (P1 PL W-temp / temp1 temp2) ; P1 = aktueller Punkt, PL = Punktliste, W-temp = W_last (setq temp1 (mapcar '(Lambda (x / w1) (if (and (/= P1 x) (/= P-last x)) (progn (setq w1 (- (angle P1 x) W-temp)) (if (< w1 0)(setq w1 (+ w1 pi pi))) (cons x w1) ) ) ) PL ) ) (setq temp2 (vl-sort temp1 (function (lambda (x1 x2) (< (cdr x1) (cdr x2)) ) ) ) ) (while (= (car temp2) nil) (setq temp2 (cdr temp2))) temp2 ) ;;; Hauptprogramm (setq Punkte (P_Liste)) (setq P-Start (Startpunkt Punkte)) (setq P-lfd P-Start) (setq P-last P-Start) (setq W-last 0.0) (setq W-Liste (W_Liste P-lfd Punkte W-last)) (setq Erg-Liste (cons P-Start Erg-Liste)) (setq P-lfd (caar W-Liste)) (setq W-last (angle P-last P-lfd)) (while (/= P-lfd P-Start) (setq Erg-Liste (cons P-lfd Erg-Liste)) (setq W-Liste (W_Liste P-lfd Punkte W-last)) (setq P-last P-lfd) (setq P-lfd (caar W-Liste)) (setq W-last (angle P-last P-lfd)) ) Erg-Liste ;;; (command "_line") ;;; (mapcar 'command Erg-Liste) ;;; (command "s") )