(prompt "\nAngle Trisection by AutoCAD - KEMPE_6_RODS.LSP") (prompt "\nCommands: 6_rods ANIMATION_6_RODS") (prompt "\nFunctions: (LOCATE) (LOCATE_ADD) (SETUP) ") (prompt "\n (DOUBLE_LINK) (DISPLAY_NODES) (SHOW_RESULT)") (prompt "\n ") ;---------------------------------------------------------- ;link test #7 6/29/99 Takaya Iwamoto ;renamed link_7.lsp to Kempe_6_rods.lsp 4/29/2006 ;;; ;this is the same as link_6 except that point "B" "C" values ;is obtained by the generic function called double_link() ;test the generic function called double_link() ;; ;;; ;;;6_rods ;;;add one more link ;;; (defun C:6_rods() ;Main routine (setup) ;set up (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 pnt_d_t) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_tmp (cadr key)) (entdel last_pline) (locate pnt_tmp) (setq last_pline (entlast)) ) (show_result) ;(make_point "0" 0 pnt_e "E" 1 0.5) ;(make_point "0" 0 pnt_f "F" 3 0.5) (mark_angle pnt_b pnt_a pnt_f 1 "f" 0.3 2) (reset_sysvar) );6_rods main routine ;;; ;;;LOCATE ;; ;locate the point to satisfy the condition ;;; ;;; ;;;LOCATE ;; ;locate the point to satisfy the condition (defun LOCATE(pnt_tmp) ;;;1-st link (setq list_1 (double_link 4.0 8.0 pnt_a pnt_tmp)) (setq pnt_d pnt_tmp pnt_b (car list_1) pnt_c (cadr list_1) ) ;;;2-nd link (setq pnt_e (point_along_line pnt_b pnt_tmp (/ 2.0 8.0)) list_2 (double_link 2.0 4.0 pnt_a pnt_e) pnt_f (car list_2) ) (command "_.pline" pnt_a pnt_f pnt_e pnt_b pnt_a pnt_c pnt_d pnt_e "") );LOCATE ;;; ;;;DOUBLE_LINK ;;; ;;; el_1 length of shorter link ;;; el_2 length of longer link ;;; pnt_zero coordinate of the point at origin ;;; pnt_move coordinate of the point moved by mouse ;;; output_list coordinates of the two apex points ;;; (list pnt_1 pnt_2) ;;; (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) pnt_a '(0 0) pnt_b '(0.475728 3.97161) pnt_c '(6.95847 3.94711) pnt_d '(7.40417 0.0) pnt_e '(2.20784 2.97171) pnt_f '(-1.45735 1.36972) ) (regapp "my_point") (make_point "0" 0 pnt_d "D" 1 0.5) (setq pnt_d_t (entlast)) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" -2) (command "_.point" pnt_a) (command "_.pline" pnt_a pnt_f pnt_e pnt_b pnt_a pnt_c pnt_d pnt_e "") (setq last_pline (entlast)) (command "_.zoom" "_EXTENT") (command "_.zoom" "_S" "1.0") ) ;; (defun show_result() (c:display_nodes) (mark_angle pnt_b pnt_a pnt_c 1 "f" 0.3 2) (mark_angle pnt_b pnt_d pnt_c 1 "f" 0.3 3) (mark_angle pnt_b pnt_a pnt_f 1 "f" 0.3 2) ) ;; ;; (defun c:display_nodes() (set_txstyle "arial") (regapp "my_point") (make_point "0" 0 pnt_a "A" 4 0.5) (make_point "0" 0 pnt_b "B" 1 0.5) (make_point "0" 0 pnt_c "C" 1 0.5) (make_point "0" 0 pnt_d "D" 1 0.5) (make_point "0" 0 pnt_e "E" 2 0.5) (make_point "0" 0 pnt_f "F" 2 0.5) );; ;;; ;;;ANIMATION_6_rods ;;;call jpg_setup(output_filename) before running this executable. ;;;Do not forget to set jpg_yes on (=1) ;;; (defun C:animation_6_rods() ;Main routine (setup) ;set up ;(init_display) (setq init_pos pnt_d) ;(command "_.zoom" "_E") ;(command "_.regen") (setq end_pos '(9.06252268 2.77739649) 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) (command "_.zoom" "_Extent") ;(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) (command "_.zoom" "_Extent") (make_jpg) (show_result) (make_jpg) (make_jpg) (reset_sysvar) );;;ANIMATION_6_rods ;;; ;;-------------------------------------------------------------------------- (princ)