(prompt "\nAngle Trisection by AutoCAD - MACLAURIN.LSP") (prompt "\nCommands: TEST MACLAURIN") (prompt "\nFunctions: (LOCATE) (PL_DISPLAY) (MACL_SETUP)") (prompt "\n ") ;---------------------------------------------------------- ;;;Tri_section by Colin Maclaurin---Trisectrix ;;; ;;;1/20/00 added geometric construction macl ;;; ;;;TEST (defun c:test() (setup_sysvar) (macl_setup) (command "_osnap" "nearest") (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (locate pnt_temp) ;compute all points (pl_display) ;display the polyline ) (reset_sysvar) );MACL ;;; ;;;LOCATE ;;; (defun locate (pnt_temp / ) (setq two_theta (angle pnt_origin pnt_temp) x_0 (cos two_theta) y_0 (sin two_theta) pnt_temp (list x_0 y_0) x_mid (* 0.5 x_0) y_mid (* 0.5 y_0) pnt_mid (list x_mid y_mid) pnt_perp (polar pnt_mid (+ half_pi two_theta) 0.5) pnt_x (inters pnt_ref pnt_temp pnt_mid pnt_perp nil) ) );LOCATE ;;; ;;;PL_DISPLAY ;;; (defun pl_display() (if (/= last_pline nil) (entdel last_pline)) (make_pt "0" 4 pnt_x) (command "_.pline" pnt_ref pnt_temp pnt_origin pnt_x pnt_mid "") (setq last_pline (entlast)) ) ;;; ;;;MACLAURIN (defun c:maclaurin( ) (setup_sysvar) (macl_setup) (while (<= (setq theta_new (+ theta_old del_theta)) theta_end) (setq rad_1 (* 2.0 (cos theta_new)) rad_2 (/ 1.0 rad_1) radius (- rad_1 rad_2) pnt_new (polar pnt_ref theta_new radius) ) (command "_.line" pnt_start pnt_new "") (setq pnt_start pnt_new theta_old theta_new ) );while loop ;;; (setq pick_line (entlast)) (command "_pedit" pick_line "Y" "_Join" "all" "" "_X") ;(command "_.point" pnt_origin) ;(command "_.point" pnt_ref) ;(command "_.line" x_left x_right "") ;(command "_.line" y_down y_up "") (command "_.zoom" "e") (command "_.line" pnt_ref pnt_new "") (reset_sysvar) ) ;;; ;;; ;;;DRAW_MACLAURIN (defun c:draw_maclaurin( ) (setup_sysvar) (macl_setup2) (while (<= (setq theta_new (+ theta_old del_theta)) theta_end) (setq pnt_p (list (cos theta_new) (sin theta_new)) rad_1 (distance pnt_c pnt_p) pnt_q (inters pnt_c pnt_p pnt_e pnt_f nil) rad_2 (distance pnt_c pnt_q) radius (- rad_1 rad_2) pnt_new (pld pnt_c pnt_p radius) ) (setq dist (distance pnt_start pnt_new)) (command "_.line" pnt_start pnt_new "") (setq pnt_start pnt_new theta_old theta_new ) );while loop ;;; (setq pick_line (entlast)) (command "_.pedit" pick_line "Y" "_Join" "all" "" "_X") ;(command "_.point" pnt_origin) ;(command "_.point" pnt_ref) ;(command "_.line" x_left x_right "") ;(command "_.line" y_down y_up "") (command "_.zoom" "e") ;(command "_.line" pnt_ref pnt_new "") (reset_sysvar) ) ;;; ;;; ;;;DRAW_MACLAURIN_ONLY (defun c:draw_maclaurin_only( ) (setup_sysvar) (macl_setup2) (alert "\nStart drawing curve.") (setq step 0) (while (<= (setq theta_new (+ theta_old del_theta)) theta_end) (setq pnt_p (list (cos theta_new) (sin theta_new)) rad_1 (distance pnt_c pnt_p) pnt_q (inters pnt_c pnt_p pnt_e pnt_f nil) rad_2 (distance pnt_c pnt_q) radius (- rad_1 rad_2) pnt_new (pld pnt_c pnt_p radius) ) (make_line_1 "layer2" 2 pnt_start pnt_new ) (setq pnt_start pnt_new theta_old theta_new ) (if (and (= jpg_yes 1) (= (rem step 20) 0)) (make_jpg)) ;;jpgout for animation (command "_.delay" 50) (setq step (1+ step)) );while loop ;;; (setq pick_line (entlast)) (command "_.pedit" pick_line "Y" "_Join" "all" "" "") (setq half_curve (entlast)) (make_jpg) ;;jpgout command (alert "\nMake a mirror image") (command "_.mirror" half_curve "" pnt_c pnt_b "") ;(command "_.point" pnt_origin) ;(command "_.point" pnt_ref) ;(command "_.line" x_left x_right "") ;(command "_.line" y_down y_up "") ;(command "_.zoom" "e") ;(command "_.line" pnt_ref pnt_new "") ;(reset_sysvar) ) ;;; ;;;MACL_SETUP (defun macl_setup() (setq x_left '(-1.25 0) x_right '(1.25 0) y_up '(0 1.25) y_down '(0 -0.25) half_pi (* 0.5 pi) pnt_origin '(0 0) pnt_org '(0 0) pnt_ref '(-1 0) pnt_c '(-1 0) pnt_b '(1 0) ;theta_end (/ pi 3.0) theta_end (* 0.4 pi) ;; del_theta (/ theta_end 1000) ;0.001 theta_old 0.0 radius 1.0 pnt_start '(0.5 0) ) (setvar "PDMODE" 32) (setvar "PDSIZE" -2) (make_line_1 "0" 8 y_up y_down) (make_line_1 "0" 8 x_left x_right) (make_pt "0" 0 pnt_org) (make_pt "0" 0 pnt_b) (make_pt "0" 0 pnt_c) (command "_.arc" "_C" pnt_origin '(1 0) pnt_ref) (command "_.zoom" "e") (command "_.regen") );MACL_SETUP ;;; ;;;MACL_SETUP2 (defun macl_setup2() (setq x_left '(-1.5 0) x_right '(1. 0) y_up '(0 1.25) y_down '(0 -0.25) half_pi (* 0.5 pi) pnt_origin '(0 0) pnt_org '(0 0) pnt_ref '(-1 0) pnt_c '(-1 0) pnt_b '(1 0) ;theta_end (/ pi 3.0) theta_end (* 0.90 pi) ;; del_theta (/ pi 180.) ;every one degree theta_old 0.0 radius 1.0 pnt_start '(0.5 0) pnt_e '(-0.5 0) pnt_f '(-0.5 1.5) yl_up '(-1.5 1.25) yl_down '(-1.5 -2.85) chr_size 0.1 txt_angle 0. ) (setvar "PDMODE" 32) (setvar "PDSIZE" -2) (make_line_1 "0" 8 y_up y_down) (make_line_1 "0" 8 x_left x_right) (make_line_1 "0" 8 yl_down yl_up) (textdisplay "C" pnt_c chr_size txt_angle) (textdisplay "O" pnt_org chr_size txt_angle) (textdisplay "B" pnt_b chr_size txt_angle) (make_pt "0" 0 pnt_org) (make_pt "0" 0 pnt_b) (make_pt "0" 0 pnt_c) (command "_.arc" "_C" pnt_origin '(1 0) pnt_ref) (command "_.zoom" "e") (command "_.regen") );MACL_SETUP ;;-------------------------------------------------------------------------- (princ)