;;This program demonstrates the use of AutoCAD commands,;; car cdr append cons foreach mapcar apply;;;;It provides a function to draw a parabolic arch, which is ;;given by a simple formula,;;;; Y = - a XX + h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Another way of doing the same thing as 'pline_from_points_1.; This time, I will use WHILE and a diminishing point list.(defun pline_from_points_2 (point_list) (command "pline") ; starts pline command (while point_list (command (car point_list)) ; always extract the first point (setq point_list (cdr point_list)) ; get rid of the first point from the list ) (command "") )

; (pline_from_points_2 pl) ; use this for test

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Yet another way of doing the same thing as 'pline_from_points_1.; It demonstrates the use of AutoLISP functions, 'apply and 'append. (defun pline_from_points_3 (point_list / arg_list) ; arg_list is a list looking like ("pline" '(x1 y1) '(x2 y2) ..... "") ; this is the arguments required for "command" command next. (setq arg_list (append (list "pline") point_list (list ""))) ; this does the same thing as (command pline" '(x1 y1) '(x2 y2) ..... "") (apply 'command arg_list))

; (pline_from_points_3 pl) ; use this for test

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;This computes the parabola's coefficient values from the given;wide and high of the parabola; formula is Y = - a XX + h; when X=0, Y = high; when X=w/2, Y = 0

;1] get the coefficient values for the equation (setq coef (get_coefficient wide high)) ; this returns a list of a and h's values (setq a (nth 0 coef)) ; takes out the first value for a (setq h (nth 1 coef)) ; takes out the second value for h

;3] repeat to create a series of points on the parabola ; points are stored in 'upper_points ; First, computes the increment for x (setq wide (* wide 1.0)) ; make sure this is a real number and ; not an integer before division below (setq x_inc (/ wide (* num_div)))

;4] make the points on the lower side of the arch by ; scaling the y-coordinates of the upper points by 0.85 (setq lower_points (mapcar '(lambda (pt) ; this keeps x and scales the y of a point (list (nth 0 pt) (* 0.85 (nth 1 pt)))) upper_points) )