(prompt "\nAngle Trisection by AutoCAD - PASCAL.LSP") (prompt "\nCommands: PASCAL_1 PASCAL_11 PASCAL_12 PASCAL_2 PASCAL_3") (prompt "\nCommands: CARDIOID_1 PASCAL_4 PASCAL_5 ENV_PASCAL") (prompt "\nFunctions: (SETUP) (DEF_ANGLE) ") (prompt "\n ") ;---------------------------------------------------------- ;Tri_section by Pascal ;;; pascal_1 (defun c:pascal_1() (setup_sysvar) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq const_a (/ 2.0 pi ) x_left '(-2 0) x_right '(2.5 0) y_up '(0 2.5) y_down '(0 -2.5) pnt_origin '(0 0) pnt_ref '(-1 0) b_value 0.0 radius 1.0 ) (command "_.point" pnt_origin) (command "_.line" x_left x_right "") (command "_.line" y_down y_up "") (make_circle_1 "0" 0 pnt_origin 1.0) (command "_.zoom" "_EXTENT" ) (setq last_line nil) (setq b_value (getreal "\nAssign a value to length b <1.0>: ")) (if (= b_value nil) (setq b_value 1.0)) (setq answer (getpoint "\nPress left mouse to start and move the mouse counterclock-wise.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq theta (angle pnt_ref pnt_temp) two_theta (* 2.0 theta) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new (polar pnt_int theta b_value) ) (if (/= last_line nil) (entdel last_line)) (make_pt "layer1" 1 pnt_int) (make_pt "layer5" 5 pnt_new) (make_line_1 "0" 0 pnt_ref pnt_new ) (setq last_line (entlast)) ) (reset_sysvar) );PASCAL_1 ;;; ;;; (defun c:pascal_11() (setup_sysvar) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq const_a (/ 2.0 pi ) x_left '(-2 0) x_right '(2.5 0) y_up '(0 2.5) y_down '(0 -2.5) pnt_origin '(0 0) pnt_ref '(-1 0) b_value 0.0 radius 1.0 ) (command "_.point" pnt_origin) (command "_.line" x_left x_right "") (command "_.line" y_down y_up "") (command "_.zoom" "_EXTENT" ) (setq last_line nil) (setq b_value (getreal "\nAssign a value to length b <1.0>: ")) (if (= b_value nil) (setq b_value 1.0)) (setq answer (getpoint "\nPress left mouse to start and move the mouse counterclock-wise.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq theta (angle pnt_ref pnt_temp) two_theta (* 2.0 theta) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new1 (polar pnt_int theta b_value) pnt_new2 (polar pnt_int (+ pi theta) b_value) ) (if (/= last_line nil) (entdel last_line)) (make_pt "layer1" 1 pnt_int) (make_pt "layer5" 5 pnt_new1) (make_pt "layer2" 2 pnt_new2) (make_line_1 "0" 0 pnt_ref pnt_new1 ) (setq last_line (entlast)) ) (reset_sysvar) );PASCAL_11 ;;; (defun c:pascal_12() (setup_sysvar) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq const_a (/ 2.0 pi ) x_left '(-2 0) x_right '(2.5 0) y_up '(0 2.5) y_down '(0 -2.5) pnt_origin '(0 0) pnt_ref '(-1 0) b_value 0.0 radius 1.0 ) (command "_.point" pnt_origin) (command "_.line" x_left x_right "") (command "_.line" y_down y_up "") (make_circle_1 "0" 0 pnt_origin 1.0) (command "_.zoom" "_EXTENT" ) (setq last_line nil) (setq b_value (getreal "\nAssign a value to length b <1.0>: ")) (if (= b_value nil) (setq b_value 1.0)) (setq answer (getpoint "\nPress left mouse to start and move the mouse counterclock-wise.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq theta (angle pnt_ref pnt_temp) two_theta (* 2.0 theta) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new1 (polar pnt_int theta b_value) pnt_new2 (polar pnt_int (+ pi theta) b_value) ) (if (/= last_line nil) (entdel last_line)) (make_pt "layer1" 1 pnt_int) (make_pt "layer5" 5 pnt_new1) (make_pt "layer2" 2 pnt_new2) (make_line_1 "layer3" 3 pnt_new2 pnt_new1) (make_line_1 "0" 0 pnt_ref pnt_new1 ) (setq last_line (entlast)) ) (reset_sysvar) ); ;;; ;;; PASCAL_2 line segments (defun c:pascal_2() (setup_sysvar) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq const_a (/ 2.0 pi ) x_left '(-2 0) x_right '(2.5 0) y_up '(0 2.5) y_down '(0 -2.5) pnt_origin '(0 0) pnt_ref '(-1 0) b_value 0.0 radius 1.0 ) (make_pt "0" 0 pnt_origin) (make_pt "0" 0 pnt_ref) (make_line_1 "0" 0 x_left x_right) (make_line_1 "0" 0 y_down y_up) (command "_.zoom" "_EXTENT" ) (setq last_line nil) (setq b_value (getreal "\nAssign a value to length b <1.0>: ")) (if (= b_value nil) (setq b_value 1.0)) (setq pnt_s (list (+ 1.0 b_value) 0)) (setq answer (getpoint "\nPress left mouse to start and move the mouse counterclock-wise.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq theta (angle pnt_ref pnt_temp) two_theta (* 2.0 theta) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new (polar pnt_int theta b_value) ) (if (/= last_line nil) (entdel last_line)) (make_pt "layer1" 1 pnt_int) (make_line_1 "layer2" 2 pnt_s pnt_new ) (setq pnt_s pnt_new) (make_line_1 "layer5" 5 pnt_ref pnt_new ) (setq last_line (entlast)) ) (reset_sysvar) );;; ;;; ;;; PASCAL_3 polylines & grdraw (defun c:pascal_3() (setup_sysvar) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq const_a (/ 2.0 pi ) x_left '(-1.5 0) x_right '(2.5 0) y_up '(0 2.5) y_down '(0 -2.5) pnt_origin '(0 0) pnt_ref '(-1 0) b_value 0.0 radius 1.0 ) (command "_.point" pnt_origin) (command "_.point" pnt_ref) (command "_.line" x_left x_right "") (command "_.line" y_down y_up "") (command "_.zoom" "_EXTENT" ) ;(setq pnt_s '(2 0)) ;(setq last_line nil) (setq b_value (getreal "\nAssign a value to length b <1.0>: ")) (if (= b_value nil) (setq b_value 1.0)) (setq pnt_s (list (+ 1.0 b_value) 0)) (setq answer (getpoint "\nPress left mouse to start and move the mouse counterclock-wise.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq theta (angle pnt_ref pnt_temp) two_theta (* 2.0 theta) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new (polar pnt_int theta b_value) ) ;(if (/= last_line nil) (entdel last_line)) (command "_.point" pnt_int) ;(command "_.point" pnt_new) ;(command "_.line" pnt_s pnt_new "") ;(setq pnt_s pnt_new) (make_line_1 "layer1" 1 pnt_ref pnt_int) (make_line_1 "layer2" 2 pnt_int pnt_new) (command "_.line" pnt_s pnt_new "") (setq pnt_s pnt_new) ) (reset_sysvar) );;; ;;;; ;Cardioid--parametric formulation (defun c:cardioid_1() (setvar "PDMODE" 32) (setq const_a (/ 2.0 pi ) x_left '(-1 0) x_right '(1 0) y_up '(0 1) y_down '(0 -1) pnt_origin '(0 0) const_1 0.25 const_2 0.25 ) (setq theta_end (* 2.0 pi) del_theta 0.001 theta_old 0.0 ) (setq pnt_old pnt_origin) (while ( <= (setq theta_new (+ theta_old del_theta)) theta_end) (setq theta_2 (* 2.0 theta_new) sine_th (* 2. (sin theta_new)) cos_th (* 2. (cos theta_new)) sine_2th (sin theta_2) cos_2th (cos theta_2) x_value (* const_1 (- cos_th cos_2th)) y_value (* const_2 (- sine_th sine_2th)) pnt_new (list x_value y_value) ) (command "_.line" pnt_old pnt_new "") (setq pnt_old pnt_new theta_old theta_new ) ) ;;;; (setq pick_line (entlast)) (command "_pedit" pick_line "Y" "_Join" "all" "" "_X") (command "_.point" pnt_origin) (command "_.line" x_left x_right "") (command "_.line" y_down y_up "") (command "_.zoom" "_EXTENT" ) );; ;;; ;;; trial 4 polylines & grdraw (defun c:pascal_4() (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq const_a (/ 2.0 pi) x_left '(-1.5 0) x_right '(2.5 0) y_up '(0 2.5) y_down '(0 -2.5) pnt_origin '(0 0) pnt_ref '(-1 0) b_value 0.0 radius 1.0 ) (command "_.point" pnt_origin) (command "_.point" pnt_ref) (command "_.line" x_left x_right "" ) (command "_.line" y_down y_up "") (command "_circle" pnt_origin radius) (command "_.zoom" "_EXTENT") ;(setq pnt_s '(2 0)) ;(setq last line nil) (setq b_value (getreal "\nAssign a value to length b <1.0>: ")) (if (= b_value nil) (setq b_value 1.0)) (setq pnt_s (list (+ 1.0 b_value) 0)) (setq answer (getpoint "\nPress left mouse to start and move the mouse counterclock-wise.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq theta (angle pnt_ref pnt_temp) two_theta (* 2.0 theta) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new (polar pnt_int theta b_value) ) ;(if (/= last_line nil) (entclel last - line)) (command "_.line" pnt_s pnt_new "") (setq pnt_s pnt_new) (grdraw pnt_ref pnt_int 1) (grdraw pnt_int pnt_new 2) ) ) ;;; ;;trial 5--Pascal , (defun c:pascal_5() (setup) (make_jpg) (setq theta_end (/ pi 2.0) del_theta (/ theta_end 1000) theta_old 0.0 radius 1.0 theta_end (* 2. pi) ) (setq pnt_start '(2 0) ) (while ( <= (setq theta_new (+ theta_old del_theta)) theta_end) (setq two_theta (* 2.0 theta_new) x_temp (* radius (cos two_theta)) y_temp (* radius (sin two_theta)) pnt_int (list x_temp y_temp) pnt_new (polar pnt_int theta_new radius) ) (make_line_1 "layer2" 2 pnt_start pnt_new ) (setq pnt_start pnt_new theta_old theta_new ) ) (setq pick_line (entlast)) (command "_pedit" pick_line "Y" "_Join" "all" "" "_X") (make_line_1 "0" 8 pnt_ref pnt_new ) ;;;last point (make_point "0" 0 pnt_new "E" 3 0.10) (make_jpg) ;; define angle (def_angle) (make_jpg) (reset_sysvar) ) ;;; ;;;SETUP ;;; setup (defun SETUP() (setup_sysvar) (set_txstyle "arial") (setvar "PDMODE" 34) (setvar "PDSIZE" -3) (make_line_1 "layer8" 8 (setq x_left '(-1.25 0)) (setq x_right '(2.25 0)) ) (make_line_1 "layer8" 8 (setq y_down '(0 -0.25)) (setq y_up '(0 2 )) ) (setq pnt_origin '(0 0) pnt_ref '(-1 0) ) (make_arc_cbe "layer1" 1 pnt_origin '(1 0) pnt_ref) (regapp "my_point") (make_point "0" 0 pnt_origin "O" 3 0.10) (make_point "0" 0 x_right "B" 1 0.10) (make_point "0" 0 pnt_ref "C" 1 0.10) ;(if (= jpg_yes 1) (jpg_setup "Pascal_Trisection")) (make_jpg) );SETUP ;;; ;;;DEF_ANGLE ;;; ;specify the angle to be tri_sected (defun DEF_ANGLE() (make_arc_cbe "layer5" 5 pnt_origin '(2.1 0) '(-2.1 0)) (setq temp_arc (entlast)) (command "_osnap" "_nearest") (command "_.zoom" "_EXTENT") (alert "Select a point on the yellow arc to define an angle") (make_line_1 "0" 3 '(0 0) (setq pnt_a (getpoint '(0 0) "\nDefine a point \"A\":")) ) (entdel temp_arc) (make_point "0" 0 pnt_a "A" 2 0.10) (make_line_1 "0" 4 pnt_ref pnt_a) (command "_.regen") );DEF_ANGLE ;envelop of circles on a circle with a selected ref_point (defun c:env_pascal() (setup_sysvar) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" -2) (setq ref_radius 1.0 pnt_center '(0 0) y_up '(0 3) y_down '(0 -3) x_left '(-4 0) x_right '(4 0) ) (make_circle_1 "0" 2 '(0 0) ref_radius) (make_line_1 "0" 8 y_down y_up) (make_line_1 "0" 8 x_left x_right) (make_pt "0" 0 '(-3 0)) (make_pt "0" 0 '(-2 0)) (make_pt "0" 0 '(-1.5 0)) (make_pt "0" 0 '(-1 0)) (make_pt "0" 0 '(-0.75 0)) (make_pt "0" 0 '(-0.50 0)) (command "_.zoom" "_EXTENT" ) (setvar "OSMODE" 552) ;;; node, near, intersection (setq line_color 0) (setq line_color (getint "\nSelect color code:")) (if (= line_color 0) (setq line_color 8)) (make_pt "0" 5 (setq pnt_s (getpoint "\nSelect a reference point along the X-axis"))) (setvar "OSMODE" 0) (setq answer (getpoint "\nPress left mouse to start and follow the circle.\nPress left mouse to stop")) (while (and (setq key (grread T)) (= (car key) 5) ) (setq pnt_temp (cadr key)) (setq temp_angle (angle pnt_center pnt_temp) temp_x (* (cos temp_angle) ref_radius) temp_y (* (sin temp_angle) ref_radius) cir_loc (list temp_x temp_y) temp_rad (distance cir_loc pnt_s) ) (make_circle_1 "0" line_color cir_loc temp_rad) ) (make_pt "0" 5 pnt_s) (make_circle_1 "0" 2 '(0 0) ref_radius) (command "_.line" '(0 -6) '(0 6) "") (command "_.line" '(-6 0) '(6 0) "") (reset_sysvar) );;;ENV_PASCAL ;;-------------------------------------------------------------------------- (princ)