Jump to content

How to draw this parabola?


Recommended Posts

Posted (edited)

I need to draw a parabola based on this equation.

 

y = x^2/(4*f)

f = 9.846171

range of x -20.6816 to +20.66816

 

Now upon researching i came across a lisp routine for a parabola which is below. I'm not familiar with what this lisp is telling me. So my question is how do i go about pluging my equation in to the lisp routine to get the right parabola drawen? I'm assuming the 3rd line into the lisp routine where it give's the equation f=w^2/16/h, i would modify to say f=w^2/4*h, is this right? I would appreciate any help

 

; draws parabola
; to draw parabola with given width (w) and height (h)
; calculate focus-vertex distance (f): f=w^2/16/h,
; draw parabola, trim the height, verify dimensions

(defun c:pbl (/ f mxx x ip y cp1 cp2 p1 p2 e1 e2 osn)    
 (setq osn (getvar "OSMODE"))
 (setvar "cmdecho" 0)
 (if (= ff nil)
   (setq ff 1.0)
 )
 (princ "\n Focus to center point of parabola <distance> < ")
 (princ ff)
 (princ " > ??: ")
 (initget 2)
 (setq f (getdist))
 (if (= f nil)
   (setq f ff)
 )
 (setq ff f)

 (if (= mxxx nil)
   (setq mxxx 2.0)
 )
 (princ "\n Height < ")
 (princ mxxx)
 (princ " > ?? : ")
 (setq mxx (getdist))
 (if (= mxx nil)
   (setq mxx mxxx)
 )
 (setq mxxx mxx)
 (setq mx (+ mxx f))

 (if (= x1 nil)
   (setq x1 0.1)
 )
 (princ "\n Precision < x distance > < ")
 (princ x1)
 (princ " > ?? : ")
 (setq x (getdist))
 (if (= x nil)
   (setq x x1)
 )
 (setq x1 x)
 (if (> x 1)
   (setq x 1)
 )
; -- FIRST SEGMENT ---
 (setq ip (getpoint "\n Insert by focus: "))    ; ip = focus point
 (setq y (+ f (/ (expt x 2) (* 4 f))))    ; y = distance of point from base line
 (setq cp1 (polar ip (* pi 1.5) (* f 2)))
 (setq p1 (polar cp1 (* pi 0.5) f))
 (setq cp2 (polar cp1 0 x))
 (setq p2 (polar cp2 (* pi 0.5) y))
 (setvar "osmode" 0)
 (command "pline" p1 "w" 0 0 p2 "")
 (setq e1 (entlast))
 (setq xx x)

 (while (> mx y)
   (setq xx (+ xx x))
   (setq y (+ f (/ (expt xx 2) (* 4 f))))
   (setq cp2 (polar cp1 0 xx))
   (setq p2 (polar cp2 (* pi 0.5) y))
   (command "line" "" p2 "")
   (setq e2 (entlast))
   (command "pedit" e1 "j" e2 "" "")
 )
 (command "mirror" e1 "" ip cp1 "")
 (command "circle" ip x)
 (setvar "osmode" osn)
 (princ)
)
(prompt "\n type  pbl  for parabola")

Edited by SLW210
Code Tags!!
Posted

This doesn't use the lisp, but here's a way...

Open the attached excel file (rename it to Parabola.xls) and highlight column D

Hit Ctrl+C (to copy to clipboard)

In your dwg start the Pline command

At the Specify start point: prompt hit Ctrl+V (to paste the data from the clipboard)

Parabola.xls.txt

Posted

pretty easy as above has shown

given F=9.846171 (setq 4f (* f 4.0))

y = x^2/(4*f)

this is (setq y (/ (*x x ) 4f))

x= -20.6816

(setq inc (say 0.002))

(setq nums (fix (/ (* 206816 2.0) inc))))

 

(repeat nums

(setq y (/ (*x x ) 4f))

(setq xy (list x y))

(command "point" xy)

(setq x (+ x inc))

) ; end repeat

Posted

Cadman, here (attached) is another one so you can do what you want. This one has 3 options for entering parameters. WH (width and height of parabola), FH (focus distance and height) and FW ( focus distance and width). Load the routine type > pbl Parabola-W+F.lsp

Posted
Cadman, here (attached) is another one so you can do what you want. This one has 3 options for entering parameters. WH (width and height of parabola), FH (focus distance and height) and FW ( focus distance and width). Load the routine type > pbl

 

 

 

How accurate is this? Does it still use the equation y = x^2/(4*f)

Posted

Autocad uses double precision or at least single precision so should be accurate unless you work for NASA.

 

The only thing to be carefull of is in lisp if you do x/4 this is not the same as x/4.0 the extra .0 implies to make it a real not an integer answer can make the difference sometimes.

 

if worried about precison then rewrite in VBA etc and set all variables to double precison.

Posted

I wrote the original lisp and then someone requested the width, so I wrote this one. Just delete the "original" lisp and use the one I posted here.

 

How accurate? At the third prompt, you can set the accuracy by varying "x" stepping (precision ..). Smaller the number finer the parabola.

 

Yes, it does use the " y = x^2/(4*f) " formula.You can find it in each "while" loop in the code.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...