(prompt "\nAngle Trisection by AutoCAD - KEMPE_8_RODS.LSP") (prompt "\nCommands: 8_RODS ANIMATION_8_RODS") (prompt "\nFunctions: (LOCATE) (SETUP) (INIT_DISPLAY)") (prompt "\n (DOUBLE_LINK) (DISPLAY_NODES) (SHOW_RESULT)") ;---------------------------------------------------------- ;link test #8 6/30/99 Takaya Iwamoto ;test the generic function called double_link() ;; added two more double link ;;renamed link_8.lsp-->Kempe_8_rods.lsp 4/29/2006 ;; ;; (defun C:8_rods() ;Main routine (setup) ;set up (init_display) (setvar "PDSIZE" 0.025) (alert "Place the cursor near the point \"D\", then click left mouse to start.") (setq answer (getpoint "\nPress left mouse to start.Click mouse to stop."))(terpri) (entdel new_pnt_ent) (entdel new_txt_ent) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_tmp (cadr key)) (entdel last_pline) (locate pnt_tmp) (pl_display) (setq last_pline (entlast)) );;;while loop (show_result) (reset_sysvar) );8_RODS ;;; ; (defun init_display() ;(setq init_pos '(8.36295 0.772121 0)) (setq init_pos pnt_d) (locate init_pos) ;(pl_display) (command "_.pline" pnt_g pnt_2a pnt_a pnt_3a pnt_g pnt_e pnt_1a pnt_a pnt_1b pnt_d pnt_e "") (setq last_pline (entlast)) (regapp "my_point") (make_point "0" 0 pnt_d "D" 1 pnt_size) (c:z_e) ) ;locate the point to satisfy the condition (defun locate(pnt_tmp) (setq pnt_d pnt_tmp) ;;first link (setq list_1 (double_link 4.0 8.0 pnt_a pnt_tmp)) (setq pnt_1a (car list_1) pnt_1b (cadr list_1) ) ;;2-nd link (setq pnt_e (point_along_line pnt_1a pnt_tmp (/ 2.0 8.0)) list_2 (double_link 2.0 4.0 pnt_a pnt_e) pnt_2a (car list_2) ) ;;3-rd link (setq pnt_g (point_along_line pnt_2a pnt_e (/ 1.0 4.0)) list_3 (double_link 1.0 2.0 pnt_a pnt_g) pnt_3a (car list_3) ) ;(command "_.pline" pnt_g pnt_2a pnt_a pnt_3a pnt_g pnt_e ; pnt_1a pnt_a pnt_1b pnt_tmp pnt_e "") ) (defun pl_display() (command "_.pline" pnt_g pnt_2a pnt_a pnt_3a pnt_g pnt_e pnt_1a pnt_a pnt_1b pnt_tmp pnt_e "") ) ;;double_link ;; (defun double_link(el_1 el_2 pnt_zero pnt_move / output_list) (setq el (distance pnt_zero pnt_move) el_sqr (* el el) el_1_sqr (* el_1 el_1) el_2_sqr (* el_2 el_2) two_el (* 2.0 el) two_el_sqr (* 2.0 el_sqr) del_el (- el_2_sqr el_1_sqr) l_a (/ (- el_sqr del_el) two_el) l_b (/ (+ el_sqr del_el) two_el) ratio_a (/ l_a el) ratio_b (/ l_b el) val_1 (- el_1 l_a) val_2 (+ el_1 l_a) c_sqr (* val_1 val_2) ) (if (>= c_sqr 0.0) (setq el_c (sqrt c_sqr)) (setq el_c 0.0)) ;; compute the location of the kink points (setq pnt_1 (point_off_line pnt_zero pnt_move ratio_a half_pi el_c) pnt_2 (point_off_line pnt_zero pnt_move ratio_b half_pi el_c) ) (setq output_list (list pnt_1 pnt_2)) ) ;setup (defun setup() (setup_sysvar) (setq half_pi (* 0.5 pi) quart_pi (* 0.25 pi) sqrt_5 (sqrt 5.0) a (/ 4.0 sqrt_5) c (/ 8.0 sqrt_5) b (* 4.0 sqrt_5) pnt_a '(0 0) pnt_b (list a c) pnt_c (list (- b a) c ) pnt_d (list b 0.0) pnt_size 0.35 mark_size 0.25 ) (setvar "PDMODE" 32) (setvar "PDSIZE" -3) (command "_.point" pnt_a) (make_pt "0" 8 '(-2.5 -2.0)) (make_pt "0" 8 '(10 7)) ) ;; (defun show_result() (c:display_nodes) (mark_angle pnt_1a pnt_a pnt_1b 0.75 "f" mark_size 2) (mark_angle pnt_2a pnt_a pnt_1a 0.75 "f" mark_size 2) (mark_angle pnt_3a pnt_a pnt_2a 0.75 "f" mark_size 2) ) ;; ;; (defun c:display_nodes() (set_txstyle "arial") (regapp "my_point") (make_point "0" 0 pnt_a "A" 4 pnt_size) (make_point "0" 0 pnt_1b "B" 1 pnt_size) (make_point "0" 0 pnt_1a "C" 1 pnt_size) (make_point "0" 0 pnt_2a "F" 2 pnt_size) (make_point "0" 0 pnt_3a "H" 3 pnt_size) (make_point "0" 0 pnt_e "E" 2 pnt_size) (make_point "0" 0 pnt_g "G" 2 pnt_size) (make_point "0" 0 pnt_d "D" 1 pnt_size) );;; ;;; ;;;ANIMATION_8_rods ;;;call jpg_setup(output_filename) before running this executable. ;;;Do not forget to set jpg_yes on (=1) ;;; (defun C:animation_8_rods() ;Main routine (setup) ;set up (init_display) ;(command "_.zoom" "_E") ;(command "_.regen") (setq end_pos '(9.08169559 -2.57373799) dist (distance init_pos end_pos) nstep 5 del_step (/ 1. (float nstep)) ;;5 steps animation n_cur 1 ) (make_jpg) (alert "\nNext step?") (entdel new_pnt_ent) (entdel new_txt_ent) (repeat nstep (setq pnt_tmp (plt init_pos end_pos (* n_cur del_step))) (entdel last_pline) (locate pnt_tmp) (pl_display) (setq last_pline (entlast)) ;(show_status) (make_jpg) ;;make jpg file (alert "\nNext step?") (command "_.delay" 500) (setq n_cur (1+ n_cur)) );;;repeat loop (c:display_nodes) (make_jpg) (show_result) (make_jpg) (make_jpg) (reset_sysvar) );;;ANIMATION_8_rods ;;; ;;-------------------------------------------------------------------------- (princ)