;;;series summation ;;; GSS_2.LSP modified GSS_1.LSP ;;; Sept 24, 2003 Takaya Iwamoto ;;; geometric series r = 4/1 ;;; (defun c:gss_2 () (setup_gss2) (while (= (Yes_or_No "Go to next step ?") "_Y") (qtr_quad pnt_a pnt_b pnt_c pnt_d) (IF (= JPG_YES 1) (make_jpg) ) ) ;;;end of while loop (alert "\n****End****\nInfinite sum of geometirc series (1/4) \nis equal to 1/3" ) (textdisplay "Sum of all yellow" '(1.2 1.5) 0.12 0.) (textdisplay "squares is 1/3 ." '(1.2 1.3) 0.12 0.) (IF (= JPG_YES 1) (make_jpg) ) (reset_sysvar) ) ;;;C:gss_1 ;;; ;;; (defun setup_gss2 () (setup_sysvar) (setq pnt_a '(-1 0) pnt_b '(1 0) pnt_c '(1 2) pnt_d '(-1 2) lower_left '(-1.25 -0.25) upper_right '(2.5 2.25) nstep 1 ) (make_line_1 "0" 8 pnt_a pnt_b) (make_line_1 "0" 8 pnt_b pnt_c) (make_line_1 "0" 8 pnt_c pnt_d) (make_line_1 "0" 8 pnt_d pnt_a) (command "_.zoom" "W" lower_left upper_right) (IF (= JPG_YES 1) (make_jpg) ) (qtr_quad pnt_a pnt_b pnt_c pnt_d) (IF (= JPG_YES 1) (make_jpg) ) ) ;;;SETUP_GSS2 ;;; ;;; ;;;qtr_quad shade a quarter of a square defined by 3 corner points ;;; (defun qtr_quad (pnt_1 pnt_2 pnt_3 pnt_4 / pnt_4 pnt_5 pnt_6) (setq pnt_5 (mid_point pnt_1 pnt_2) pnt_6 (mid_point pnt_2 pnt_3) pnt_7 (mid_point pnt_3 pnt_4) pnt_8 (mid_point pnt_4 pnt_1) pnt_9 (mid_point pnt_6 pnt_8) ref_len (distance pnt_1 pnt_5) text_size1 (* 0.25 ref_len) pnt_text1 (shift_pnt (plt pnt_1 pnt_9 0.1) (list 0 text_size1)) text_size2 (* 0.6 text_size1) pnt_text2 (shift_pnt pnt_text1 (list (* 2.75 text_size1) text_size1) ) ) (shaded_quad "layer40" pnt_1 pnt_5 pnt_9 pnt_8) (shaded_quad "layer110" pnt_5 pnt_2 pnt_6 pnt_9) (shaded_quad "layer180" pnt_8 pnt_9 pnt_7 pnt_4) ;;;write text 1/4, 1/16, 1/64, etc in the yellow squares ;;;then increment nstep by 1 (setvar "Cecolor" "1") (if (= nstep 1) (textdisplay " 1/4 " pnt_text1 text_size1 0.) (progn (textdisplay "(1/4)" pnt_text1 text_size1 0.) (textdisplay (itoa nstep) pnt_text2 text_size2 0.) ) ) ;;;end of if loop (setvar "Cecolor" "BYLAYER") (setq nstep (1+ nstep)) ;;;redefine a new triangle (setq pnt_a pnt_9 pnt_b pnt_6 pnt_d pnt_7 ) (make_line_1 "0" 1 pnt_4 pnt_1) (make_line_1 "0" 1 pnt_1 pnt_2) ) ;;;QTR_TRIG ;;; ;;;GET_CURTEXT ;;; (defun get_curtext1 (num) (cond ((= num 1) "1/4") ((= num 2) "1/16") ((= num 3) "1/64") ((= num 4) "1/256") ((= num 5) "1/1024") ((= num 6) "1/4096") (t "") ) ) ;;;GET_CURTEXT1 ;;; (defun get_curtext (num) (setq temp1 "1/" temp2 (itoa (expt 4 num)) temp (strcat temp1 temp2) ) ) ;;;GET_CURTEXT