; The Codewriting Workbook ; Creating Computational Architecture in AutoLISP ; by Robert J. Krawczyk ; Princeton Architectural Press, 2008 ; -------------------------------------------------------------------------- ; CH06D.LSP ; -------------------------------------------------------------------------- ; Disclaimer: The information contained in this file is distributed on an ; "as is" basis, without warranty. Although every precaution has been taken ; in the preparation of this work, the author and publisher shall not have ; any liability to any person or entity with respect to any loss or damage ; caused or alleged to be caused directly or indirectly by the information ; contained in this work. ; -------------------------------------------------------------------------- (defun dtr (a) (* pi (/ a 180.0))) (defun rtd (a) (/ (* a 180.0) pi)) ; -------------------------------------------------------------------------- (defun sign (a) (if (< a 0.0) (- 0 1.0) (+ 0 1.0))) ; -------------------------------------------------------------------------- (defun rn (/ modulus multiplier increment random) (if (not rnseed) (setq rnseed (getvar "DATE"))) (setq modulus 65536 multiplier 25173 increment 13849 rnseed (rem (+ (* multiplier rnseed) increment) modulus) random (/ rnseed modulus) ) ) ;--------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun rotate2d ( pt ptc ang / pt1 pt2 ) ; rotate pt ang degrees (setq pt1 (list (+ (nth 0 pt) (- 0 (nth 0 ptc))) (+ (nth 1 pt) (- 0 (nth 1 ptc))) (nth 2 pt))) (setq pt2 (list (- (* (nth 0 pt1) (cos (dtr ang))) (* (nth 1 pt1) (sin (dtr ang)))) (+ (* (nth 0 pt1) (sin (dtr ang))) (* (nth 1 pt1) (cos (dtr ang)))) (nth 2 pt))) (list (+ (nth 0 pt2) (+ 0 (nth 0 ptc))) (+ (nth 1 pt2) (+ 0 (nth 1 ptc))) (nth 2 pt)) ) ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; ZW - zoom window (defun c:zw () (command "zoom" "w") ) ; ZP - zoom previous (defun c:zp () (command "zoom" "p") ) ; ZE - zoom extents (defun c:ze () (command "zoom" "e" "zoom" ".9x") ) ; ZX - zoom .9x (defun c:zx () (command "zoom" ".9x") ) ;--------------------------------------------------------------------------- ; VT - top view (defun c:vt () (command "vpoint" "r" 270 90) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VL - left view (defun c:vl () (command "vpoint" "r" 180 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VR - right view (defun c:vr () (command "vpoint" "r" 0 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VF - front view (defun c:vf () (command "vpoint" "r" 270 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VB - back view (defun c:vb () (command "vpoint" "r" 90 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VSW - SW view (defun c:vsw () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 225 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ; VSE - SE view (defun c:vse () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 315 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ; VNE - NE view (defun c:vne () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 45 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog01 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) ; start mesh (command ".3DMESH" ytimes xtimes) ; start y location (setq yloc (nth 1 pnt0)) (repeat ytimes ; start x location (setq xloc (nth 0 pnt0)) (repeat xtimes ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (setq zheight (* (rn) maxheight)) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; inc x location (setq xloc (+ xloc xside)) ) ; inc y location (setq yloc (+ yloc yside)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog02 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) ; start mesh (command ".3DMESH" ytimes xtimes) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat ytimes ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat xtimes ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum ytimes)) (= xnum 1)) (= xnum xtimes)) (setq zheight 0.0) (setq zheight (* (rn) maxheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; inc x location (setq xloc (+ xloc xside)) (setq xnum (+ xnum 1)) ) ; inc y location (setq yloc (+ yloc yside)) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog02a () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq maxoffset (getdist pnt0 "\nEnter maximum XY offset:")) ; start mesh (command ".3DMESH" ytimes xtimes) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat ytimes ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat xtimes ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum ytimes)) (= xnum 1)) (= xnum xtimes)) (progn (setq zheight 0.0) (setq xoff 0.0) (setq yoff 0.0) ) (progn (setq zheight (* (rn) maxheight)) (setq opnt (polar (list 0 0 0) (dtr (* (rn) 360.0)) (* (rn) maxoffset))) (setq xoff (nth 0 opnt)) (setq yoff (nth 1 opnt)) ) ) ; grid pt (setq pnt2 (list (+ (nth 0 pnt1) xoff) (+ (nth 1 pnt1) yoff) zheight)) ; add mesh pt (command pnt2) ; inc x location (setq xloc (+ xloc xside)) (setq xnum (+ xnum 1)) ) ; inc y location (setq yloc (+ yloc yside)) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog03 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) ; start mesh (command ".3DMESH" ytimes (+ xtimes 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat ytimes ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat xtimes ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum ytimes)) (= xnum 1)) (= xnum xtimes)) (setq zheight 0.0) (setq zheight (* (rn) maxheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (setq xloc (+ xloc xside)) (setq xnum (+ xnum 1)) ) ; repeat first point (command pnt3) ; inc y location (setq yloc (+ yloc yside)) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog04 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ xtimes 2)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (setq zheight 0.0) (setq zheight (+ (* (rn) (- maxheight minheight)) minheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog05 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (setq zheight 0.0) (setq zheight (+ (* (rn) (- maxheight minheight)) minheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog06 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (setq zheight 0.0) (setq zheight (+ (* (rn) (* (/ xloc (* xside xtimes)) (- maxheight minheight))) minheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog07 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; ang start and inc (setq ang 0.0) (setq anginc (/ 360.0 xtimes)) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (setq zheight 0.0) (setq zheight (+ (* (rn) (* (abs (sin (dtr ang))) m(- maxheight minheight))) minheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ; inc angle (setq ang (+ ang anginc)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog08 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) (setq xanginc (getint "\nEnter angle increment:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; ang start and inc (setq ang (* (fix (* (rn) 12.0)) xanginc)) (setq totalang (* (fix (* (rn) 24.0)) xanginc)) (setq anginc (/ totalang xtimes)) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (setq zheight 0.0) (setq zheight (+ (* (sin (dtr ang)) (- maxheight minheight)) minheight)) ) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ; inc angle (setq ang (+ ang anginc)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog09 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) (setq xanginc (getint "\nEnter angle increment:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; ang start and inc (setq ang (* (fix (* (rn) 12.0)) xanginc)) (setq totalang (* (fix (* (rn) 24.0)) xanginc)) (setq anginc (/ totalang xtimes)) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (setq zheight 0.0) (setq zheight (+ (* (sin (dtr ang)) (- maxheight minheight)) minheight)) ) ; near edge (if (and (= ynum 2) (> xnum 1) (< xnum (+ xtimes 2))) (setq zheight minheight)) ; far edge (if (and (= ynum (+ ytimes 1)) (> xnum 1) (< xnum (+ xtimes 2))) (setq zheight minheight)) ; left edge (if (and (= xnum 2) (> ynum 1) (< ynum (+ ytimes 2))) (setq zheight minheight)) ; right edge (if (and (= xnum (+ xtimes 1)) (> ynum 1) (< ynum (+ ytimes 2))) (setq zheight minheight)) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ; inc angle (setq ang (+ ang anginc)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog09a () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) (setq xanginc (getint "\nEnter angle increment:")) (setq maxyoff (getdist "\nEnter maximum Y offset:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; ang start and inc (setq ang (* (fix (* (rn) 12.0)) xanginc)) (setq totalang (* (fix (* (rn) 24.0)) xanginc)) (setq anginc (/ totalang xtimes)) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute Y offset (setq yoff (* (sin (dtr ang)) maxyoff)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (progn (setq zheight 0.0) (setq yoff 0.0) ) (setq zheight (+ (* (sin (dtr ang)) (- maxheight minheight)) minheight)) ) ; near edge (if (and (= ynum 2) (> xnum 1) (< xnum (+ xtimes 2))) (progn (setq zheight minheight) (setq yoff 0.0) )) ; far edge (if (and (= ynum (+ ytimes 1)) (> xnum 1) (< xnum (+ xtimes 2))) (progn (setq zheight minheight) (setq yoff 0.0) )) ; left edge (if (and (= xnum 2) (> ynum 1) (< ynum (+ ytimes 2))) (progn (setq zheight minheight) (setq yoff 0.0) )) ; right edge (if (and (= xnum (+ xtimes 1)) (> ynum 1) (< ynum (+ ytimes 2))) (progn (setq zheight minheight) (setq yoff 0.0) )) ; grid pt (setq pnt2 (list (nth 0 pnt1) (+ (nth 1 pnt1) yoff) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ; inc angle (setq ang (+ ang anginc)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog10 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq xtimes (getint "\nEnter number X repeats:")) (setq ytimes (getint "\nEnter number Y repeats:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq minheight (getdist pnt0 "\nEnter minimum height:")) (setq xanginc (getint "\nEnter angle increment:")) ; start mesh (command ".3DMESH" (+ ytimes 2) (+ (+ xtimes 2) 1)) ; start y location (setq yloc (nth 1 pnt0)) (setq ynum 1) (repeat (+ ytimes 2) ; ang start and inc (setq ang (* (fix (* (rn) 12.0)) xanginc)) (setq totalang (* (fix (* (rn) 24.0)) xanginc)) (setq anginc (/ totalang xtimes)) ; select function (setq nfunc (+ (fix (* (rn) 6.99)) 1)) ; start x location (setq xloc (nth 0 pnt0)) (setq xnum 1) (repeat (+ xtimes 2) ; grid pt (setq pnt1 (list xloc yloc 0)) ; compute height (if (or (or (or (= ynum 1) (= ynum (+ ytimes 2))) (= xnum 1)) (= xnum (+ xtimes 2))) (progn (setq zheight 0.0) ) (progn (setq zmaxoff (- maxheight minheight)) (if (= nfunc 1) (setq zoff (* zmaxoff 0.5))) (if (= nfunc 2) (setq zoff (* (sin (dtr ang)) zmaxoff))) (if (= nfunc 3) (setq zoff (* (abs (sin (dtr ang))) zmaxoff))) (if (= nfunc 4) (setq zoff (* (* (abs (sin (dtr ang))) zmaxoff) -1))) (if (= nfunc 5) (setq zoff (* (cos (dtr ang)) zmaxoff))) (if (= nfunc 6) (setq zoff (* (abs (cos (dtr ang))) zmaxoff))) (if (= nfunc 7) (setq zoff (* (* (abs (cos (dtr ang))) zmaxoff) -1))) (setq zheight (+ minheight zoff)) ) ) ; near edge (if (and (= ynum 2) (> xnum 1) (< xnum (+ xtimes 2))) (setq zheight minheight)) ; far edge (if (and (= ynum (+ ytimes 1)) (> xnum 1) (< xnum (+ xtimes 2))) (setq zheight minheight)) ; left edge (if (and (= xnum 2) (> ynum 1) (< ynum (+ ytimes 2))) (setq zheight minheight)) ; right edge (if (and (= xnum (+ xtimes 1)) (> ynum 1) (< ynum (+ ytimes 2))) (setq zheight minheight)) ; grid pt (setq pnt2 (list (nth 0 pnt1) (nth 1 pnt1) zheight)) ; add mesh pt (command pnt2) ; save first pt (if (= xnum 1) (setq pnt3 pnt2)) ; inc x location (if (and (> xnum 1) (< xnum (- (+ xtimes 2) 1))) (setq xloc (+ xloc xside)) ) (setq xnum (+ xnum 1)) ; inc angle (setq ang (+ ang anginc)) ) ; repeat first point (command pnt3) ; inc y location (if (and (> ynum 1) (< ynum (- (+ ytimes 2) 1))) (setq yloc (+ yloc yside)) ) (setq ynum (+ ynum 1)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog11 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq rtimes (getint "\nEnter number radial points:")) (setq ztimes (getint "\nEnter number Z points:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq crad (getdist pnt0 "\nEnter radius:")) ; Z inc (setq zinc (/ maxheight ztimes)) (command ".3DMESH" ztimes rtimes) ; start z location (setq zloc (nth 2 pnt0)) (repeat ztimes ; start radial location (setq rang 0.0) (setq ranginc (/ 360.0 rtimes)) (repeat rtimes ; radial distance (setq xoff (* crad (cos (dtr rang)))) (setq yoff (* crad (sin (dtr rang)))) ; grid pt (setq npnt (list (+ (nth 0 pnt0) xoff) (+ (nth 1 pnt0) yoff) zloc)) ; add mesh pt (command npnt) ; inc radial location (setq rang (+ rang ranginc)) ) ; inc z location (setq zloc (+ zloc zinc)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog11a () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq rtimes (getint "\nEnter number radial points:")) (setq ztimes (getint "\nEnter number Z points:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq crad (getdist pnt0 "\nEnter radius:")) ; Z inc (setq zinc (/ maxheight ztimes)) (command ".3DMESH" ztimes (+ rtimes 1)) ; start z location (setq zloc (nth 2 pnt0)) (repeat ztimes ; start radial location (setq rang 0.0) (setq ranginc (/ 360.0 rtimes)) (setq rnum 1) (repeat rtimes ; radial distance (setq xoff (* crad (cos (dtr rang)))) (setq yoff (* crad (sin (dtr rang)))) ; grid pt (setq npnt (list (+ (nth 0 pnt0) xoff) (+ (nth 1 pnt0) yoff) zloc)) ; add mesh pt (command npnt) ; save first pt (if (= rnum 1) (setq fpnt npnt)) ; inc radial location (setq rang (+ rang ranginc)) (setq rnum (+ rnum 1)) ) ; add first pt (command fpnt) ; inc z location (setq zloc (+ zloc zinc)) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog11b () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq rtimes (getint "\nEnter number radial points:")) (setq ztimes (getint "\nEnter number Z points:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq crad (getdist pnt0 "\nEnter radius:")) ; Z inc (setq zinc (/ maxheight ztimes)) (command ".3DMESH" (+ ztimes 2) (+ rtimes 1)) ; bottom pts (repeat (+ rtimes 1) (command pnt0) ) ; start z location (setq zloc (nth 2 pnt0)) (repeat ztimes ; start radial location (setq rang 0.0) (setq ranginc (/ 360.0 rtimes)) (setq rnum 1) (repeat rtimes ; radial distance (setq xoff (* crad (cos (dtr rang)))) (setq yoff (* crad (sin (dtr rang)))) ; grid pt (setq npnt (list (+ (nth 0 pnt0) xoff) (+ (nth 1 pnt0) yoff) zloc)) ; add mesh pt (command npnt) ; save first pt (if (= rnum 1) (setq fpnt npnt)) ; inc radial location (setq rang (+ rang ranginc)) (setq rnum (+ rnum 1)) ) ; add first pt (command fpnt) ; inc z location (setq zloc (+ zloc zinc)) ) ; bottom pts (repeat (+ rtimes 1) (command (list (nth 0 pnt0) (nth 1 pnt0) (- zloc zinc))) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog12 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq rtimes (getint "\nEnter number radial points:")) (setq ztimes (getint "\nEnter number Z points:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq cradoff (getdist pnt0 "\nEnter radius offset:")) (setq fanginc (getint "\Enter starting angle increment:")) (setq fcycles (getreal "\Enter total angle cycles:")) ; Z inc (setq zinc (/ maxheight ztimes)) (command ".3DMESH" (+ ztimes 2) (+ rtimes 1)) ; bottom pts (repeat (+ rtimes 1) (command pnt0) ) ; start z location (setq zloc (nth 2 pnt0)) (repeat ztimes ; offset ang (setq sang (* (fix (* (rn) 24)) fanginc)) (setq sanginc (/ (* 360.0 fcycles) rtimes)) ; start radial location (setq rang 0.0) (setq ranginc (/ 360.0 rtimes)) (setq rnum 1) (repeat rtimes ; radial distance (setq nrad (+ crad (* (sin (dtr sang)) cradoff))) (setq xoff (* nrad (cos (dtr rang)))) (setq yoff (* nrad (sin (dtr rang)))) ; grid pt (setq npnt (list (+ (nth 0 pnt0) xoff) (+ (nth 1 pnt0) yoff) zloc)) ; add mesh pt (command npnt) ; save first pt (if (= rnum 1) (setq fpnt npnt)) ; inc radial location (setq rang (+ rang ranginc)) (setq rnum (+ rnum 1)) (setq sang (+ sang sanginc)) ) ; add first pt (command fpnt) ; inc z location (setq zloc (+ zloc zinc)) ) ; bottom pts (repeat (+ rtimes 1) (command (list (nth 0 pnt0) (nth 1 pnt0) (- zloc zinc))) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog13 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq rtimes (getint "\nEnter number radial points:")) (setq ztimes (getint "\nEnter number Z points:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq cradoff (getdist pnt0 "\nEnter radius offset:")) (setq fanginc (getint "\Enter starting angle increment:")) (setq fcycles (getreal "\Enter total angle cycles:")) ; Z inc (setq zinc (/ maxheight ztimes)) (command ".3DMESH" (+ rtimes 1) (+ ztimes 2)) ; start radial location (setq rnum 1) (setq rang 0.0) (setq ranginc (/ 360.0 rtimes)) (repeat (+ rtimes 1) ; bottom pt (command pnt0) ; start z location (setq znum 1) (setq zloc (nth 2 pnt0)) (setq sang (* (fix (* (rn) 24)) fanginc)) (setq sanginc (/ (* 360.0 fcycles) ztimes)) ; save first angle (if (= rnum 1) (setq fsang sang)) ; check for last segment (if (= rnum (+ rtimes 1)) (progn (setq rang 0.0) (setq sang fsang) )) (repeat ztimes ; radial distance (setq nrad (+ crad (* (sin (dtr sang)) cradoff))) (setq xoff (* nrad (cos (dtr rang)))) (setq yoff (* nrad (sin (dtr rang)))) ; grid pt (setq npnt (list (+ (nth 0 pnt0) xoff) (+ (nth 1 pnt0) yoff) zloc)) ; Aadd mesh pt (command npnt) ; inc height location (setq znum (+ znum 1)) (setq zloc (+ zloc zinc)) (setq sang (+ sang sanginc)) ) ; inc radial location (setq rnum (+ rnum 1)) (setq rang (+ rang ranginc)) ; top pt (command (list (nth 0 pnt0) (nth 1 pnt0) (* zinc ztimes))) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- (defun prog14 () (graphscr) (command ".ERASE" "all" "") ; set start point (setq pnt0 (list 0 0 0)) (setq rtimes (getint "\nEnter number radial points:")) (setq ztimes (getint "\nEnter number Z points:")) (setq maxheight (getdist pnt0 "\nEnter maximum height:")) (setq cxrad (getdist pnt0 "\nEnter X radius:")) (setq cyrad (getdist pnt0 "\nEnter Y radius:")) (setq cradoff (getdist pnt0 "\nEnter radius offset:")) (setq fanginc (getint "\Enter starting angle increment:")) (setq fcycles (getreal "\Enter total angle cycles:")) ; Z inc (setq zinc (/ maxheight ztimes)) (command ".3DMESH" (+ rtimes 1) (+ ztimes 2)) ; start radial location (setq rnum 1) (setq rang 0.0) (setq ranginc (/ 360.0 rtimes)) (repeat (+ rtimes 1) ; bottom pt (command pnt0) ; start z location (setq znum 1) (setq zloc (nth 2 pnt0)) (setq sang (* (fix (* (rn) 24)) fanginc)) (setq sanginc (/ (* 360.0 fcycles) ztimes)) ; save first angle (if (= rnum 1) (setq fsang sang)) ; check for last segment (if (= rnum (+ rtimes 1)) (progn (setq rang 0.0) (setq sang fsang) )) (repeat ztimes ; radial distance (setq nxrad (+ cxrad (* (sin (dtr sang)) cradoff))) (setq nyrad (+ cyrad (* (sin (dtr sang)) cradoff))) (setq xoff (* nxrad (cos (dtr rang)))) (setq yoff (* nyrad (sin (dtr rang)))) ; grid pt (setq npnt (list (+ (nth 0 pnt0) xoff) (+ (nth 1 pnt0) yoff) zloc)) ; Aadd mesh pt (command npnt) ; inc height location (setq znum (+ znum 1)) (setq zloc (+ zloc zinc)) (setq sang (+ sang sanginc)) ) ; inc radial location (setq rnum (+ rnum 1)) (setq rang (+ rang ranginc)) ; top pt (command (list (nth 0 pnt0) (nth 1 pnt0) (* zinc ztimes))) ) (command ".ZOOM" "e") (princ) ) ;-------------------------------------------------------------------------- ;--------------------------------------------------------------------------