;;;series summation ;;; GSS_1.LSP ;;; Sept 24, 2003 Takaya Iwamoto ;;; geometric series r = 4/1 ;;; (defun c:gss_1 () (setup_gss1) (while (= (Yes_or_No "Go to next step ?") "_Y") (qtr_trig pnt_a pnt_b pnt_c) (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 green" '(0.43 1.5) 0.12 0.) (textdisplay "triangles is 1/3 ." '(0.43 1.3) 0.12 0.) (IF (= JPG_YES 1) (make_jpg) ) (reset_sysvar) ) ;;;C:gss_1 ;;; ;;; (defun setup_gss1 () (setup_sysvar) (setq pnt_a '(-1 0) pnt_b '(1 0) pnt_c (list 0 (sqrt 3.)) lower_left '(-1.5 -0.5) upper_right '(1.5 2) 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_a) (command "_.zoom" "W" lower_left upper_right) (IF (= JPG_YES 1) (make_jpg) ) (qtr_trig pnt_a pnt_b pnt_c) (IF (= JPG_YES 1) (make_jpg) ) ) ;;;SETUP_GSS1 ;;; ;;;qtr_trig shade a quarter of a triangle defined by 3 corner points ;;; (defun qtr_trig (pnt_1 pnt_2 pnt_3 / pnt_4 pnt_5 pnt_6) (setq pnt_4 (mid_point pnt_1 pnt_2) pnt_5 (mid_point pnt_2 pnt_3) pnt_6 (mid_point pnt_3 pnt_1) ref_len (distance pnt_1 pnt_4) text_size1 (* 0.25 ref_len) pnt_text1 (shift_pnt (plt pnt_4 pnt_6 0.5) (list 0 0)) text_size2 (* 0.6 text_size1) pnt_text2 (shift_pnt pnt_text1 (list (* 2.75 text_size1) text_size1) ) ) (shaded_triangle "layer40" pnt_1 pnt_4 pnt_6) (shaded_triangle "layer110" pnt_4 pnt_5 pnt_6) (shaded_triangle "layer180" pnt_4 pnt_2 pnt_5) (make_line_1 "0" 8 pnt_6 pnt_5) ;;;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_6 pnt_b pnt_5 ) ) ;;;QTR_TRIG