Given AutoCAD LISP Routine to generate a parabolic curve thru 3 points in the x-y plane with n segments of equal values of x dimensions along x axis → Create a Grasshopper component to accept given x-y plane, 3 points, and n number of segment of equal x values …generate a parabolic curve y=ax2+bx+c with the given number of segments n.

The AutoCAD LISP routine is written below. Please help me out here … Thank You,

pedro

```
(defun C:par( / pt1 pt2 pt3 pt_a pt_b dx x y x_start x_end num_pts a b c
ret_list ocmd oblip sset ent1)
(setq ocmd (getvar "cmdecho") oblip (getvar "blipmode"))
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(initget 7)
(setq pt1 (getpoint "\nSelect first point on parabola:"))
(setq pt2 (getpoint "\nSelect second point on parabola:"))
(setq pt3 (getpoint "\nSelect third point on parabola:"))
(setq num_pts (getint "\nNumber of points to use:"))
(setq ret_list (get_coeff pt1 pt2 pt3))
(setq a (nth 0 ret_list)
b (nth 1 ret_list)
c (nth 2 ret_list)
x_start (nth 3 ret_list)
x_end (nth 4 ret_list)
)
(setq dx (/ (- x_end x_start) (float num_pts) ))
(setq x x_start)
(setq y (fpoly a b c x))
(setq pt_a (list x y 0.0))
(setq x (+ x_start dx))
(setq sset(ssadd))
(repeat num_pts
(setq y (fpoly a b c x))
(setq pt_b (list x y 0.0))
(command "_.pline" pt_a pt_b "")
(command "_.point" pt_a pt_b "")
(setq sset (ssadd (entlast) sset))
(setq pt_a pt_b x (+ x dx) )
)
(command "_.point" pt_a pt_b "")
(command "_.pedit" "L" "J" sset "" "")
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblip)
)
(defun get_coeff(pt1 pt2 pt3 / x1 x2 y1 y2 x3 y3 x1sq x2sq x3sq
a b c ret_list)
(setq x1 (car pt1) y1 (cadr pt1) x1sq (* x1 x1) )
(setq x2 (car pt2) y2 (cadr pt2) x2sq (* x2 x2) )
(setq x3 (car pt3) y3 (cadr pt3) x3sq (* x3 x3) )
(setq x_start (min x1 x2 x3) x_end (max x1 x2 x3))
(setq det1 (det x1sq x2sq x3sq x1 x2 x3 1.0 1.0 1.0))
(setq a(/ (det y1 y2 y3 x1 x2 x3 1.0 1.0 1.0) det1))
(setq b(/ (det x1sq x2sq x3sq y1 y2 y3 1.0 1.0 1.0) det1))
(setq c(/ (det x1sq x2sq x3sq x1 x2 x3 y1 y2 y3 ) det1))
(setq ret_list (list a b c x_start x_end))
)
(defun fpoly(a b c x / y)
(setq y (+ (* a x x) (* b x) c) )
)
(defun det(a1 a2 a3 b1 b2 b3 c1 c2 c3 / ret_val)
(setq ret_val (+
(* a1 (- (* b2 c3) (* b3 c2) ))
(* b1 (- (* c2 a3) (* c3 a2) ))
(* c1 (- (* a2 b3) (* a3 b2) ))
)
)
)
```