(prompt "\nDoubling the Cube by AutoCAD - Menaechmus_Delian.LSP") (prompt "\nCommands: TEST MENAECHMUS_Delian ") (prompt "\n ") ;---------------------------------------------------------- ;; Draw parabolas & rectangular hyperbola used for Delian Problems ;; Menaechmus has invented conics and used conics to solve Delian Problem ;; ;;;;; ;; 8/25/00 updated Nov,2003 ;;; 12/15/06 copied Menaechmus.lsp ;;;TEST (defun C:test() (princ "need test routine") ) ;;;Menaechmus (defun c:menaechmus() (setup_menaechmus) ;Delian solution by Conics ;;draw x2 = ay curve (setq pnt_start (list x_start (f_x2_ay a_value x_start))) (setq step 0 pnt_old pnt_start) (while (< (setq x_t (+ x_start (* step x_inc))) x_end) (setq x_t (+ x_start (* step x_inc)) y_t (f_x2_ay a_value x_t) pnt_new (list x_t y_t)) ;;;; draw a line segment--later merged into one polyline (make_line_1 "layer2" 2 pnt_old pnt_new ) (setq pnt_old pnt_new step (+ 1 step)) ) ;;draw y2 = bx curve (setq pnt_start (list (f_y2_bx b_value y_start) y_start)) (setq step 0 pnt_old pnt_start) (while (< (setq y_t (+ y_start (* step y_inc))) y_end) (setq y_t (+ y_start (* step y_inc)) x_t (f_y2_bx b_value y_t) pnt_new (list x_t y_t)) ;;;; draw a line segment--later merged into one polyline (make_line_1 "layer3" 3 pnt_old pnt_new ) (setq pnt_old pnt_new step (+ 1 step)) ) (command "_.zoom" "_Extent") ;;draw x*y = a*b rectangular hyperbola (setq x_start 0.5) ;;;limit range for rectangular hyperbola (setq pnt_start (list x_start (f_xy_ab a_value b_value x_start))) (setq step 0 pnt_old pnt_start) (while (< (setq x_t (+ x_start (* step x_inc))) x_end) (setq x_t (+ x_start (* step x_inc)) y_t (f_xy_ab a_value b_value x_t) pnt_new (list x_t y_t)) ;;;; draw a line segment--later merged into one polyline (make_line_1 "layer4"4 pnt_old pnt_new ) (setq pnt_old pnt_new step (+ 1 step)) ) ) ;; (prompt "\nsetup_menaechmus") ;; ;;SETUP_Menaechmus (defun setup_menaechmus() (setup_sysvar) (set_txstyle "arial") (setvar "PDMODE" 34) (setvar "PDSIZE" -2) (make_line_1 "0" 8 '(-3 0) '(3 0)) (make_line_1 "0" 8 '(0 -2) '(0 4)) (setq chr_size 0.25) (textdisplay "x" '(3 0) chr_size 0.) (textdisplay "y" '(0 4) chr_size 0.) (command "_.zoom" "_Extent") (command "_.regen") (setq a_value (getreal "\nA value:(def = 1.0)")) (if (= a_value nil) (setq a_value 1.)) (setq b_value (getreal "\nB value:(def = 2.0)")) (if (= b_value nil) (setq b_value 2.)) (setq x_start (getreal "\nStart value for X: (def = -2)")) (if (= x_start nil) (setq x_start -2)) (setq x_end (getreal "\nEnd value for X: (def = 2)")) (if (= x_end nil) (setq x_end 2)) (setq x_inc (getreal "\nIncrement for X: (def = 0.01)")) (if (= x_inc nil) (setq x_inc 0.01)) (setq y_start (getreal "\nStart value for Y: (def = -3)")) (if (= y_start nil) (setq y_start -3)) (setq y_end (getreal "\nEnd value for Y: (def = 3)")) (if (= y_end nil) (setq y_end 3)) (setq y_inc (getreal "\nIncrement for Y: (def = 0.01)")) (if (= y_inc nil) (setq y_inc 0.01)) );;;setup_menaechmus ;;; ;;; (prompt "\nDRAW_X2_AY") ;;;DRAW_X2_AY ;;;draw x^2 = a*y parabola (defun c:test_draw_x2_ay( ) (setup_x2_ay) (disp_x2_ay 0.2) ;;initial display (while (setq pnt_temp (getpoint "\nPick a point on the Y-axis. Hit return key to quit")) (setq dist_y (cadr pnt_temp)) ;(entdel line_ent) (disp_x2_ay dist_y) ) (reset_sysvar) );C:TEST_DRAW_X2_AY ;;; ;;;draw x^2 = a*y parabola automatically (defun c:auto_draw_x2_ay( ) (setup_x2_ay) ;;;------------------------------------------------------------------ (setq n_repeat 50 y_step 0.02 y_start 0.0 step 1 pnt_old '(0 0) ) (disp_x2_ay y_step) ;;dummy line (make_jpg) (command "_.delay" 500) (repeat n_repeat (entdel line_ent) (setq dist_y (+ y_start (* y_step step))) (disp_x2_ay dist_y) (setq step (1+ step) pnt_old pnt_p ) (make_jpg) (command "_.delay" 150) ) (reset_sysvar) );C:auto_DRAW_X2_AY ;;; ;;; (defun disp_x2_ay(y_val ) (setq pnt_y (list 0 y_val) x_val (sqrt (* a_val y_val)) pnt_xbase (list x_val 0) new_pos (list x_val y_val) rad_arc (* 0.5 y_val a_val) ctr_arc (list 0. (* 0.5 (- y_val a_val))) pnt_p new_pos ) (command "_.pline" pnt_a "A" "CE" ctr_arc pnt_y "L" new_pos pnt_xbase "") (setq line_ent (entlast)) ;(make_pt "0" 2 new_pos) (make_line_1 "0" 2 pnt_old pnt_p) ) ;;; (prompt "\nDRAW_XY_AB") ;;;DRAW_XY_AB ;;;draw x*y = a*b rectangular hyperbola (defun c:test_draw_xy_ab( ) (setup_xy_ab) (disp_xy_ab 0.75) ;;initial display (while (setq pnt_temp (getpoint "\nPick a point on the X-axis. Hit return key to quit")) (setq dist_x (car pnt_temp)) ;(entdel line_ent) (disp_xy_ab dist_x) ) (reset_sysvar) );C:test_DRAW_XY_AB ;;; ;;;draw x*y = a*b rectangular hyperbola (defun c:auto_draw_xy_ab( ) (setup_xy_ab) (setq n_repeat 40 x_step 0.05 x_start 0.7 step 1 pnt_old (list x_start (/ (* a_val b_val) x_start) ) ) (disp_xy_ab x_start) ;;dummy line (make_jpg) (command "_.delay" 500) (repeat n_repeat (entdel line_ent) (setq dist_x (+ x_start (* x_step step))) (disp_xy_ab dist_x) (setq step (1+ step) pnt_old pnt_p ) (make_jpg) (command "_.delay" 150) ) (reset_sysvar) );C:test_DRAW_XY_AB ;;; ;;; (defun disp_xy_ab(x_val ) (setq pnt_f (list x_val 0) pnt_g (list x_val (- a_val)) pnt_h (inters pnt_g pnt_org pnt_b pnt_D nil) y_val (cadr pnt_h) pnt_p (list x_val y_val) ) (command "_.pline" pnt_f pnt_g pnt_org pnt_h pnt_p "cl") (setq line_ent (entlast)) (make_line_1 "0" 4 pnt_old pnt_p) ;(make_pt "0" 2 pnt_p) ) ;;; (prompt "\nDRAW_Y2_BX") ;;;DRAW_Y2_BX ;;;draw y^2 = b*x parabola (defun c:draw_y2_bx( ) (setup_y2_bx) (setq step 0 pnt_old pnt_start) (while (< (setq y_t (+ y_start (* step y_inc))) y_end) (setq y_t (+ y_start (* step y_inc)) x_t (f_y2_bx b_value y_t) pnt_new (list x_t y_t)) ;;;; draw a line segment--later merged into one polyline (make_line_1 "layer3" 3 pnt_old pnt_new ) (setq pnt_old pnt_new step (+ 1 step)) ) (reset_sysvar) );C:DRAW_Y2_BX ;;; ;;; (prompt "\nSETUP_X2_AY") ;;; ;;SETUP_X2_AY ;; setup system variables for x^2 = a*y parabola ;; (defun setup_x2_ay() (setup_sysvar) (set_txstyle "arial") (setvar "PDMODE" 32) (setvar "PDSIZE" -3) (setq a_val (getreal "\nA value:")) (if (= a_val nil) (setq a_val 1.0)) (setq pnt_a (list 0 (- a_val)) pnt_org '(0 0) x_left '(-0.20 0) x_right '(1.20 0) y_down '(0 -1.1) y_up '(0 1.20) chr_size 0.1 ) (make_line_1 "0" 8 x_left x_right) (make_line_1 "0" 8 y_down y_up) (textdisplay "x" x_right chr_size 0.) (textdisplay "y" y_up chr_size 0.) (make_pt "0" 0 pnt_a) (make_pt "0" 0 pnt_org) (textdisplay "A" (shift_pnt pnt_a '(-0.12 0)) chr_size 0.) (textdisplay "O" (shift_pnt pnt_org '(-0.12 0)) chr_size 0.) (command "_.zoom" "_E") (command "_.regen") );;SETUP_X2_AY (prompt "\nSETUP_Y2_BX") ;;; ;;SETUP_Y2_BX ;; setup system variables for y^2 = b*x parabola ;; (defun setup_y2_bx() (setup_sysvar) ;(set_layer) (set_txstyle "arial") (setvar "PDMODE" 34) (setvar "PDSIZE" -2) (setq b_value (getreal "\nB value:") y_start (getreal "\nStart value for Y:") y_end (getreal "\nEnd value for Y:") y_inc (getreal "\nStep value for Y:") ) (setq pnt_start (list (f_y2_bx b_value y_start) y_start)) (command "_.zoom" "_EXTENT") );;SETUP_Y2_BX (prompt "\nSETUP_XY_AB") ;;; ;;SETUP_XY_AB ;; setup system variables for x*y = a*b rectangular hyperbola ;; (defun setup_xy_ab( ) (setup_sysvar) (set_txstyle "arial") (setvar "PDMODE" 32) (setvar "PDSIZE" -3) (setq a_value (getreal "\nA value:") b_value (getreal "\nB value:") ) (if (= a_val nil) (setq a_val 1.0)) (if (= b_val nil) (setq b_val 2.0)) (setq pnt_a (list 0 (- a_val)) pnt_b (list (- b_val) 0) pnt_org '(0 0) x_right '(3.0 0) y_up '(0 3.0) chr_size 0.1 pnt_e (list 3.0 (- a_val)) pnt_d (list (- b_val) 3.0) pnt_c (list (- b_val) (- a_val)) ) (make_line_1 "0" 8 pnt_b x_right) (make_line_1 "0" 8 pnt_a y_up) (make_line_1 "0" 8 pnt_ab pnt_ax) (make_line_1 "0" 8 pnt_ab pnt_by) (make_line_1 "0" 1 pnt_b pnt_org) (make_line_1 "0" 3 pnt_a pnt_org) (textdisplay "X" (shift_pnt x_right '(-0.12 0)) chr_size 0.) (textdisplay "Y" (shift_pnt y_up '(0.05 -0.10)) chr_size 0.) (make_pt "0" 0 pnt_a) (make_pt "0" 0 pnt_org) (make_pt "0" 0 pnt_b) (textdisplay "A" (shift_pnt pnt_a '(-0.12 0)) chr_size 0.) (textdisplay "O" (shift_pnt pnt_org '(-0.12 0)) chr_size 0.) (textdisplay "B" (shift_pnt pnt_b '(-0.12 0)) chr_size 0.) (textdisplay "C" (shift_pnt pnt_c '(-0.12 0)) chr_size 0.) (textdisplay "D" (shift_pnt pnt_d '(0.05 -0.10)) chr_size 0.) (textdisplay "E" (shift_pnt pnt_e '(-0.12 0)) chr_size 0.) (command "_.zoom" "_E") (command "_.regen") );;SETUP_XY_AB ;;; ;;-------------------------------------------------------------------------- (princ)