;Fluch des Pharao
;Dies war die erste Aufgabe zum 8.Bundeswettbewerb Informatik 1989/90

(graphic)(clear)
(fill 3 0 0)
;neupos berechnet Streckenmitte
(defun neupos (xeck yeck)
              (setq x (+ x(/(- xeck x)2.0)))(setq y(+ y(/(- yeck y)2.0))))

;zeichnen ist die Hauptfunktion
(defun zeichnen (x1 y1 x2 y2 x3 y3 x y) ;x,y bezeichnen Startpunkt
 (setq D  (-(*(- x2 x1)(- y3 y1))(*(- x3 x1)(- y2 y1))))
 (setq Dr (-(*(- x  x1)(- y3 y1))(*(- x3 x1)(- y  y1))))
 (setq Ds (-(*(- x2 x1)(- y  y1))(*(- x  x1)(- y2 y1))))
 (cond ((eql D 0)(princ "Kein Dreieck eingegeben !")(terpri))
       (t (setq r (/ Dr D))(setq s (/ Ds D))
          (cond ((or (>(+ r s)1.0) (< r 0.0) (< s 0.0))
                 ;Startpunkt außerhalb des Dreiecks
                 (setq x x1)(setq y y1)) ;geh zur Ecke...
                (t (princ "Startpunkt ist im Dreieck !")(terpri)))
          (setq i 2000) ;Iterationszahl definieren
          (count i (setq z (random 3))
                   (cond ((< z 1.0)(neupos x1 y1)) ;Eckpunkt zufällig
                         ((< z 2.0)(neupos x2 y2)) ;wählen
                         (t        (neupos x3 y3)))
                   (draw t t -1 x y)(draw nil t 1 0 0)) ;Punkt zeichnen
          )))
(terpri)
(princ "Fluch des Pharao")(terpri)(princ "(c) 1989")(terpri)
(princ "Steffen Goebbels")(terpri)
(zeichnen -200.0 -190.0 -200.0 190.0 200.0 190.0 200.0 -190.0)
