home *** CD-ROM | disk | FTP | other *** search
- ;
- ; Refinement of a random polygon by iterative replacement of
- ; its vertices by the midpoints of its edges. This miraculously
- ; transforms most random polygons into an ellipse-shaped convex
- ; polygon.
- ;
- ; Written by Kelvin R. Throop in October 1985
- ;
- ; Based on the technique described in Philip J. Davis,
- ; "Circulant Matrices", Wiley 1979.
- ;
-
- (defun drawpoly (p)
- (setq dp p)
- (setq dl (length p))
- (command "pline")
- (repeat dl
- (command (car dp))
- (setq dp (cdr dp))
- )
- (command "c")
- )
-
- (defun C:RPOLY ()
- (setvar "cmdecho" 0)
- (setq cycno 0)
- (setq pl nil)
- (while (setq p (getpoint "Next point: "))
- (setq pl (cons p pl))
- )
- (setvar "blipmode" 0)
- (setq pvert (length pl))
-
- (drawpoly pl)
-
- (while (setq cyc (getint "Cycle count: "))
- (repeat cyc
- (setq plast (nth (1- pvert) pl))
- (setq pn nil)
- (setq pe pl)
- (repeat pvert
- (setq pc (car pe))
- (setq pe (cdr pe))
- (setq pn (cons (list (/ (+ (car pc) (car plast)) 2)
- (/ (+ (cadr pc) (cadr plast)) 2))
- pn)
- )
- (setq plast pc)
- )
- (setq pl pn)
- (setq cycno (1+ cycno))
- (princ "Cycle ")
- (princ cycno)
- (terpri)
- )
- (command "erase" "l" "")
- (drawpoly pn)
- (command "zoom" "e")
- )
- (setvar "cmdecho" 1)
- (setvar "blipmode" 1)
- )
-