Exemplo n.º 1
0
def thermal_pad(pad, size, paste_fraction, max_paste_size):
    paste_x = size[0] * dmath.sqrt(paste_fraction)
    paste_y = size[1] * dmath.sqrt(paste_fraction)
    n_x = dmath.ceil(paste_x / max_paste_size)
    n_y = dmath.ceil(paste_y / max_paste_size)

    paste_pad = pscad.rounded_square([paste_y / n_y, paste_x / n_x], D("0.05"), center=True)
    return pscad.union() + (
        pscad.row(pscad.rotate(90) + pscad.row(paste_pad, size[1] / n_y, n_y, center=True),
            size[0] / n_x, n_x, center=True),
        pscad.nopaste() + pad
    )
Exemplo n.º 2
0
def indent_pad(size, indent):
    return pscad.union() + (
        pscad.translate([-size[0] / 2, -size[1] / 2]) + (
            pscad.square([size[0], size[1] - indent]),

            pscad.right(indent) +
            pscad.square([size[0] - indent, size[1]]),

            pscad.down(size[1] - indent) +
            pscad.rotate(45) + pscad.square(indent * dmath.sqrt(D(2)))
        )
    )
Exemplo n.º 3
0
def paste_fraction(pad, fraction):
    try:
        fraction = dmath.sqrt(fraction)
    except:
        try:
            fraction = (fraction[0],fraction[1])
        except:
            fraction = (fraction[0],1)
    return union() + (
        scale(fraction) + pad,
        nopaste() + pad
    ),
Exemplo n.º 4
0
def test_sqrt():

    for x in range(0, 10):
        assert dmath.sqrt(x) == math.sqrt(x)
        assert grad(dmath.sqrt)(x) == approx(1 / (2 * math.sqrt(x)))
Exemplo n.º 5
0
Arquivo: pscad.py Projeto: bert/pscad
def paste_fraction(pad, fraction):
    return union() + (
        scale(dmath.sqrt(fraction)) + pad,
        nopaste() + pad
    ),