;Cycloid First cut 2-7-98 ;;cycloid1.lsp (defun C:cycloid() ;Main routine (setup_cycloid) ;set up (setq counter 0) ;(alert "\nTo start, hit reutrn key and move cursor horizontally.") (while (setq pnt_tmp (cadr (grread T)) ) ;continuous mouse tracking (get_value) (if (>= counter 1) (clear_lines)) (command "_.insert" "cycle" pnt_center 1.0 1.0 angle_tmp) (command "explode" (entlast)) (setq counter (1+ counter)) ) (setvar "blipmode" sblip) (setvar "cmdecho" scmde) ) ;;; ;;; Cycloid_curve ;;; (defun c:cycloid_curve() (setup_cycloid_curve) ;set up (make_jpg) (make_jpg) (make_jpg) (setq theta_0 0 theta_end (* 2 pi) ndiv 150 del_theta (/ (- theta_end theta_0) ndiv) pnt_old '(0 0) count 0 ) (repeat (1+ ndiv) (entdel old_circle) (setq theta (+ theta_0 (* count del_theta)) x (- theta (sin theta)) y (- 1 (cos theta)) pnt_new (list x y) pnt_center (list theta 1) pnt_across (plt pnt_new pnt_center 2.0) ) (make_circle_1 "0" 8 pnt_center radius) (setq old_circle (entlast)) (make_pt "layer1" 1 pnt_new) (make_line_1 "layer2" 2 pnt_old pnt_new) (make_line_1 "layer3" 3 pnt_center pnt_new) ;(make_line_1 "layer3" 3 pnt_new pnt_across) (setq count (1+ count) pnt_old pnt_new ) (make_jpg) (command "_.delay" 150) ) (make_pt "0" 0 pnt_center) (make_jpg) (make_jpg) (make_jpg) (make_jpg) (reset_sysvar) ) ;;; ;;; (defun c:cycloid_area() (setup_cycloid_curve) ;set up (make_jpg) (make_jpg) (make_jpg) (setq theta_0 0 theta_end (* 2 pi) ndiv 150 del_theta (/ (- theta_end theta_0) ndiv) pnt_old '(0 0) pnt_base_old '(0 0) area_sum 0 count 0 ) (repeat (1+ ndiv) (entdel old_circle) (setq theta (+ theta_0 (* count del_theta)) x (- theta (sin theta)) y (- 1 (cos theta)) pnt_new (list x y) pnt_center (list theta 1) pnt_across (plt pnt_new pnt_center 2.0) pnt_base_new (list x 0) del_h (distance pnt_base_new pnt_base_old) area_sum (+ area_sum (* del_h y)) ) (make_circle_1 "0" 8 pnt_center radius) (setq old_circle (entlast)) (make_pt "layer1" 1 pnt_new) ;(make_line_1 "layer2" 2 pnt_old pnt_new) (make_line_1 "layer3" 3 pnt_base_new pnt_new) ;(make_line_1 "layer3" 3 pnt_new pnt_across) (setq count (1+ count) pnt_old pnt_new pnt_base_old pnt_base_new ) (make_jpg) (command "_.delay" 150) ) (make_pt "0" 0 pnt_center) (make_jpg) (make_jpg) (make_jpg) (make_jpg) (reset_sysvar) (setq result (/ area_sum 3.)) ) ;;; ;compute translation & angle values from pnt_tmp (defun get_value() (setq x_tmp (car pnt_tmp)) (setq angle_tmp (- (rtd x_tmp))) (setq pnt_center (list x_tmp 0)) ) ;clear construction lines (defun clear_lines( ) (setq block_set (ssget "X" (list (cons -4 "")) )) (setq n (sslength block_set)) (setq nminus (- n 3)) ;repeat for all circle & line elements (setq index 0) (repeat nminus (entdel (ssname block_set index)) (setq index (1+ index)) ) ) ; ;setup_cycloid (defun setup_cycloid() (setq sblip (getvar "blipmode")) (setq scmde (getvar "cmdecho")) (setvar "blipmode" 0) (setvar "cmdecho" 0) ;(set_layer) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.15) (setq pnt_init '(0 0) radius 1 ) (command "_.line" '(-10 -1) '(10 -1) "" ) ;layer 8 (make_circle_1 "layer8" 8 pnt_init radius) (make_pt "layer8" 8 pnt_init) ;layer 5 (make_pt "layer5" 5 '(0 1)) (make_pt "layer3" 3 '(0 0.5)) (make_pt "layer2" 2 '(0 1.45)) ;layer 1 (make_line_1 "layer1" 1 pnt_init '(0 1)) (command "_.layer" "_set" "0" "") (command "_.zoom" "_EXTENT") (command "_.regen") (setq pnt_uprr '( 1.5 1.5) pnt_lowl '(-1.5 -0.5)) (setq set_1 (ssget "C" pnt_uprr pnt_lowl )) ;select entity set for block (alert "\nHit return ley to start. Move mouse slowly along X-axis") (command "_.block" "cycle" pnt_init set_1 pause) ;block definition ) ;;; ;setup_cycloid_curve (defun setup_cycloid_curve() (setup_sysvar) (setvar "PDMODE" 32) (setvar "PDSIZE" 0.05) (setq pnt_init '(0 1) pnt_org '(0 0) pnt_x '(7.2 0) pnt_y '(0 2.25) pnt_left '(-1.1 0) chr_size 0.2 radius 1 lower_left '(-1.3 -0.4) upper_right '(7.5 2.75) ) (make_line_1 "0" 8 pnt_org pnt_y) (make_line_1 "0" 8 pnt_left pnt_x) (mark_id pnt_x "X" 1 chr_size) (mark_id pnt_y "Y" 1 chr_size) (mark_id pnt_org "O" 4 chr_size) ;layer 8 (make_circle_1 "layer8" 8 pnt_init radius) (make_circle_1 "layer8" 8 pnt_init radius) (setq old_circle (entlast)) (make_pt "0" 0 pnt_init) ; (command "_.zoom" "_W" lower_left upper_right) (command "_.zoom" "_E") (command "_.regen") )