def make_rotating_slits(length, width, N, radius, layers, angleRef=False):
    cell = Cell('RotatingSlits')
    if not (type(layers) == list): layers = [layers]
    allslits = Cell('All Slits')
    angles = np.linspace(0, 360, N)
    #        radius = length*12.
    translation = (radius, 0)
    pt1 = np.array((-length / 2., -width / 2.)) + translation
    pt2 = np.array((length / 2., width / 2.)) + translation
    slit = Cell("Slit")
    for l in layers:
        rect = Rectangle(pt1, pt2, layer=l)
        slit.add(rect)
        for angle in angles:
            allslits.add(slit.copy(), rotation=angle)
        cell.add(allslits)

        if angleRef:
            labelCell = Cell('AngleLabels')
            lineCell = Cell('Line')
            pt1 = (-radius * 0.9, 0)
            pt2 = (radius * 0.9, 0)
            line = Path([pt1, pt2], width=width, layer=l)
            dLine = dashed_line(pt1, pt2, 2, width, l)
            lineCell.add(line)
            labelCell.add(lineCell, rotation=0)
            labelCell.add(lineCell, rotation=60)
            labelCell.add(lineCell, rotation=-60)
            labelCell.add(dLine, rotation=30)
            labelCell.add(dLine, rotation=90)
            labelCell.add(dLine, rotation=-30)
            cell.add(labelCell)
        return cell
示例#2
0
def make_rotating_branches(length,
                           width,
                           N,
                           radius,
                           layers,
                           angle_sweep=360,
                           angle_ref=False,
                           angle_offset=0):
    cell = Cell('RotatingBranches')
    if not (type(layers) == list):
        layers = [layers]
    allslits = Cell('All Slits')
    angles = np.linspace(0, angle_sweep, N)
    translation = (radius, 0)
    pt1 = np.array((-length / 2., -width / 2.)) + translation
    pt2 = np.array((length / 2., width / 2.)) + translation

    branch = make_branch(length, width, layers)
    for element in branch.elements:
        element.origin = [radius, 0]
    for angle in angles:
        allslits.add(branch.copy(), rotation=angle_offset + angle)
    cell.add(allslits)

    for l in layers:
        if angle_ref:
            labelCell = Cell('AngleLabels')
            lineCell = Cell('Line')
            pt1 = (0, 0)
            pt2 = (radius * 0.9, 0)
            line = Path([pt1, pt2], width=width, layer=l)
            dLine = dashed_line(pt1, pt2, 2, width, l)
            lineCell.add(line)

            rot_angle = 0
            while True:
                if abs(rot_angle) > abs(angle_sweep):
                    break
                if abs(rot_angle) % 60 == 0:
                    labelCell.add(lineCell, rotation=rot_angle)
                if (abs(rot_angle) - 30) % 60 == 0:
                    labelCell.add(dLine, rotation=rot_angle)
                rot_angle += np.sign(angle_sweep) * 15
            cell.add(labelCell)
    return cell
示例#3
0
def make_rotating_slits(length,
                        width,
                        N,
                        radius,
                        layers,
                        angle_sweep=360,
                        angle_ref=False):
    cell = Cell('RotatingSlits')
    if not (type(layers) == list): layers = [layers]
    allslits = Cell('All Slits')
    angles = np.linspace(0, angle_sweep, N)
    #        radius = length*12.
    translation = (radius, 0)
    pt1 = np.array((-length / 2., -width / 2.)) + translation
    pt2 = np.array((length / 2., width / 2.)) + translation
    slit = Cell("Slit")
    for l in layers:
        rect = Rectangle(pt1, pt2, layer=l)
        slit.add(rect)
        for angle in angles:
            allslits.add(slit.copy(), rotation=angle)
        cell.add(allslits)

    for l in layers:
        if angle_ref:
            label_cell = Cell('AngleLabels')
            line_cell = Cell('Line')
            pt1 = (0, 0)
            pt2 = (radius * 0.9, 0)
            line = Path([pt1, pt2], width=width, layer=l)
            d_line = dashed_line(pt1, pt2, 2, width, l)
            line_cell.add(line)

            rot_angle = 0
            while True:
                if abs(rot_angle) > abs(angle_sweep):
                    break
                if abs(rot_angle) % 60 == 0:
                    label_cell.add(line_cell, rotation=rot_angle)
                if (abs(rot_angle) - 30) % 60 == 0:
                    label_cell.add(d_line, rotation=rot_angle)
                rot_angle += np.sign(angle_sweep) * 15
            cell.add(label_cell)
    return cell