;;TRAJECTORY.LSP ;;test program for seeing the trajectory of a ball ;; Oct 14,2007 by Takaya Iwamoto ;; (defun c:test() (setup_trajectory) ;(setq theta (getreal "\nTrajectrory angle (in degrees) def = 30.")) ;(if (= theta nil) (setq theta 30.)) (setq del_theta 2.5 out_counter 0 ) (repeat 36 (setq theta (* out_counter del_theta)) (setq cosine (cos (dtr theta)) sine (sin (dtr theta)) half_g (* 0.5 grav) old_pos pnt_org time_zero 0. counter 1 ) ;;compute trajectory and display (repeat 600 (setq time (* counter del_time) x_pos (* init_vel cosine time) y_pos (- (* init_vel sine time) (* half_g (* time time))) new_pos (list x_pos y_pos) ) (make_line_1 "0" 8 old_pos new_pos) (setq old_pos new_pos counter (1+ counter) ) );;;inside repeat loop (setq out_counter (1+ out_counter)) (command "_.delay" 750) );;;outside repeat loop ;;**************************************************** ;;draw envelope parabola (alert "\nDraw envelope parabola") (setq cosine 1. sine 0. half_g (* 0.5 grav) old_pos pnt_org time_zero 0. counter 1 ) (command "_.draworder" line_ox "" "_F") ;;compute trajectory and display (repeat 600 (setq time (* counter del_time) x_pos (* init_vel cosine time) y_pos (- (* init_vel sine time) (* half_g (* time time))) new_pos (list x_pos y_pos) ) (make_line_1 "layer7" 2 old_pos new_pos) (setq old_pos new_pos counter (1+ counter) ) );;;inside repeat loop ;;**************************************************** (command "_.delay" 1000) ;;make a selection set of layer7 (setq set_parabola (ssget "X" (list (cons 8 "layer7") ) )) (command "_.delay" 1500) (command "_.copy" set_parabola "" pnt_org pnt_top) (reset_sysvar) );;TEST---main ;;; ;;; ;;;SETUP_TRAJECTORY ;;; (defun setup_trajectory() (setup_sysvar) (setq grav 9.83 del_time 0.01 pnt_org '(0 0) init_vel 20. max_x 100. max_y 100. max_height '( 0 50.) y_axis (list 0 (- max_y)) x_axis (list max_x 0.) chr_size 8. top (/ (* init_vel init_vel) (* 2 grav)) pnt_top (list 0 top) ) (make_line_1 "0" 0 pnt_org x_axis) (setq line_ox (entlast)) (make_line_1 "0" 0 max_height y_axis) (mark_id pnt_org "O" 3 chr_size) (mark_id x_axis "X" 1 chr_size) (mark_id y_axis "Y" 1 chr_size) (command "_.zoom" "_E") (command "_.regen") );;SETUP_TRAJECTORY ;;; ;; (defun c:test_run() (setup_trajectory) (setq theta (getreal "\nTrajectrory angle (in degrees) def = 50.")) (if (= theta nil) (setq theta 50.)) (command "_.line" pnt_org "@50<50." "") (setq cosine (cos (dtr theta)) sine (sin (dtr theta)) half_g (* 0.5 grav) old_pos pnt_org time_zero 0. counter 1 del_time 0.05 ) ;;compute trajectory and display (repeat 100 (setq time (* counter del_time) x_pos (* init_vel cosine time) y_pos (- (* init_vel sine time) (* half_g (* time time))) new_pos (list x_pos y_pos) ) (make_line_1 "0" 2 old_pos new_pos) (setq old_pos new_pos counter (1+ counter) ) );;;inside repeat loop (reset_sysvar) );;TEST_run---main ;;;