Discussion:
How to draw parabola in Acad
(too old to reply)
jochen
2004-02-23 15:37:33 UTC
Permalink
Perhaps by cutting a cone...
Regards
Jochen
www.black-cad.de
Hi, Does anyone know how to draw a parabolic curve in Acad 2000i. Not a
spline or fit curve or elipse, but a real parabola.
Thanks,
Phil
Tracy W. Lincoln
2004-02-23 16:46:18 UTC
Permalink
Found on the Internet via a Google search... hope it helps:

Here is one way to draw a parabola using a AutoLISP routine.

The routine prompts you three points the parabola is
to pass through, and the number of lines to draw (for controlling
the resolution) computes the coefficients of the parabola,
and draws polylines from the left most point to the right most
point, and joins the polylines.

You can modify this routine to suit your needs.

For example you might want to specify the start & end values for x.


To load the routine : (load "par")
To run the routine : par

------------------------------------------------------------------------

(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 "")
(setq sset (ssadd (entlast) sset))
(setq pt_a pt_b x (+ x dx) )
)

(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) ))
)
)
)

----------------------------------------------------------------------

Ravi Banthia
//Autodesk Product Support on the Internet//

--
**************************************************************
Please, DO NOT send technical requests to me via private e-mail
**************************************************************

Tracy W. Lincoln
Assistant Moderator - Autodesk Discussion Forum
http://www.autodesk.com/discussion-announcements
Hi, Does anyone know how to draw a parabolic curve in Acad 2000i. Not a
spline or fit curve or elipse, but a real parabola.
Thanks,
Phil
Loading...