Hi people,
What's wrong with this lisp? I found it on-line and it doesn't
seem to work.
Vinny
;function to find the midpoint between two points
(defun mid (a b)
(list (/ (+ (car a)(car b)) 2)
(/ (+ (cadr a)(cadr b)) 2)
)
)
;function to generate random number
(defun rand (pt / rns rleng lastrn)
(setq rns (rtos (* (car pt)(cadr pt)(getvar "tdusrtimer"))))
(setq rnleng (strlen rns))
(setq lastrn (substr rns rnleng 1))
(setq rn (* 0.6 (atof lastrn)))
(fix rn)
)
;The Chaos game
(defun C:CHAOS (/ pta ptb ptc rn count lastpt randn key)
(setq pta '( 2.0000 1 )) ;define point a
(setq ptb '( 7.1962 10)) ;define point b
(setq ptc '(12.3923 1 )) ;define point c
(setq lastpt (getpoint "Pick a start point:")) ;pick a point to start
(while (/= key 3) ;while pick button not pushed
(setq randn (rand lastpt)) ;get random number
(cond ;find midpoint to a b or c
( (= randn 0)(setq lastpt (mid lastpt pta)) ) ;use corner a if 0
( (= randn 1)(setq lastpt (mid lastpt pta)) ) ;use corner a if 1
( (= randn 2)(setq lastpt (mid lastpt ptb)) ) ;use corner b if 2
( (= randn 3)(setq lastpt (mid lastpt ptb)) ) ;use corner b if 3
( (= randn 4)(setq lastpt (mid lastpt ptc)) ) ;use corner c if 4
( (= randn 5)(setq lastpt (mid lastpt ptc)) ) ;use corner c if 5
);end cond
(grdraw lastpt lastpt 5) ;draw midpoint
(setq key (car (grread T))) ;test for pick
);end while
);end Chaos