Buy Magic Mushrooms
Magic Mushroom Gummies Best Amanita Muscaria Gummies
Apr 112010
 

Zach needed a parabola in QCAD, so I whipped up a quick script to generate DXF parabolas.  Source inside.

You’ll need the SDXF dxf generator library.  You can get it here. Just dump it in the same directory as this script, and you’re good to go.  Twiddle the parameters, run the script, and you’ve got your parabola.

import sdxf

# Set your parabola's parameters here
focus=1.5
range=(-10.0,10.0)
delta=0.2
centerRadius = 0.5  # radius of circle marking focus

d=sdxf.Drawing()

d.layers.append(sdxf.Layer(name="PARABOLA"))

def parabolaPoint(x,focus):
    return (x,(x**2)/(4*focus))

def addParabola(drawing,focus=1,range=(-5.0,5.0),delta=0.1):
    middle = sum(range)/2.0
    if (middle - range[0] < delta):
        p1 = parabolaPoint(range[0],focus)
        p2 = parabolaPoint(range[1],focus)
        drawing.append(sdxf.Line(points=[p1,p2],layer="PARABOLA"))
    else:
        addParabola(drawing,focus,(range[0],middle),delta)
        addParabola(drawing,focus,(middle,range[1]),delta)

d.append(sdxf.Circle(center=(0,focus),radius=centerRadius,layer="PARABOLA"))
addParabola(d,focus,range,delta)

d.saveas("parabola.dxf")
 Posted by at 4:19 pm

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)