Пример #1
0
def smooth_plot(x, y, a, A, B):
    """
    Helper function for the notebook smoothing widget.
    """
    x = np.linspace(A[0], B[0], x.size)
    fig = pylab.figure()
    y_smooth = gaussian_filter1d(np.array(y), a, mode="nearest")
    y, y_smooth = fit_multiple([y, y_smooth], A, B, offset=False)

    pylab.plot(x, y, label="Drawn")
    pylab.plot(x, y_smooth, "k--", label="Smoothed")
    pylab.legend()
    mn = min([y.min(), y_smooth.min()])
    mx = max([y.max(), y_smooth.max()])
    pylab.text(A[0], A[1], "A", fontsize=20)
    pylab.text(B[0], B[1], "B", fontsize=20)
    #axes = pylab.gca()
    #axes.get_xaxis().set_visible(False)
    #axes.get_yaxis().set_visible(False)

    pylab.ylim(mn-15, mx+15)
    pylab.xlim(A[0]-15, B[0]+15)
    return y_smooth
Пример #2
0
def smooth_plot(x, y, a, A, B):
    """
    Helper function for the notebook smoothing widget.
    """
    x = np.linspace(A[0], B[0], x.size)
    fig = pylab.figure()
    y_smooth = gaussian_filter1d(np.array(y), a, mode="nearest")
    y, y_smooth = fit_multiple([y, y_smooth], A, B, offset=False)

    pylab.plot(x, y, label="Drawn")
    pylab.plot(x, y_smooth, "k--", label="Smoothed")
    pylab.legend()
    mn = min([y.min(), y_smooth.min()])
    mx = max([y.max(), y_smooth.max()])
    pylab.text(A[0], A[1], "A", fontsize=20)
    pylab.text(B[0], B[1], "B", fontsize=20)
    #axes = pylab.gca()
    #axes.get_xaxis().set_visible(False)
    #axes.get_yaxis().set_visible(False)

    pylab.ylim(mn - 15, mx + 15)
    pylab.xlim(A[0] - 15, B[0] + 15)
    return y_smooth
Пример #3
0
    d = rotate([90,0,0])(d)

    code1 = ("module %s_curve(wall_width) { " % name) + scad_render( d) + " }\n\n"
    code1 = code1.replace('"wall_width"', "wall_width")

    code2 = "module %s() {\n union() {\n"  % name
    code2 += "   translate([0, -%f, %f]) %s_curve(%f);\n" % (channel_width, channel_depth, name, wall_width)
    code2 += "   %s_curve(%f);\n" % (name, channel_width)
    code2 += "   translate([0, %f, %f]) %s_curve(%f);\n" % (wall_width, channel_depth, name, wall_width)
    code2 += "   translate([0, %f, 0]) cube([%f, %f, %f]);\n" % (-(channel_width + wall_width), stop, channel_width + 2*wall_width, channel_depth + 0.01)
    code2 += "   translate([%f, %f, 0]) cube([%f, %f, %f]);\n" % (stop, -(channel_width + wall_width), start_backdepth, channel_width + 2*wall_width, max(y) + start_backheight)
    code2 += "   translate([-%f, -%f, 0]) cube([%f, %f, %f]); }\n}\n\n" % (endstop_thickness, (channel_width + wall_width), endstop_thickness, channel_width + 2*wall_width, endstop_height)

    return code1 + code2

if __name__ == "__main__":
    from cycloid import cycloid
    A = [0, 95.0] # Start point
    B = [229, 1.0] # End point
    from fit import fit_multiple
    x,y = cycloid(A,B,100)
    y2 = np.linspace(A[0], B[0], 100)

    y,y2 = fit_multiple([y,y2], A, B)
    print ramp([y,y2], length = B[0] - A[0], thickness = 10, channel_depth=1.5, wall_width=2, channel_width=10, endstop_height=40)