Esempio n. 1
0
def spherical_segment(l, le, w, we, **faceparamdict):
    """
    lxw mm edge tabbed rectangle, with score for tab folds
    :parameter l: edge length - untabbed
    :parameter le: length of end tab
    :parameter w: side length - sloped tabbed side for spherical triangle_pair
    :parameter we: length of end tab
    :parameter faceparamdict: see calling routines
    :return list of lists [[sublists for sequence of points to be cut],[sublists for sequence of points to be scored]]
    """

    # angles from Coxeter for spherical kaleidoscope
    # 2,3,3  54deg44min x2, 70deg32min
    # 2,3,4  35deg16min, 45deg, 54deg44min
    # 2,3,5  20deg54min, 31deg43min, 37deg23min
    theta = (35 + 16 / 60) / 2
    sint = math.sin(math.radians(theta))
    cost = math.cos(math.radians(theta))

    # comment out one or other of these lines if ends are to be tabbed or not TODO need to lengthen second straight edge
    # _edge_dwgl = edgetab_dwg(l, le, **faceparamdict)      # normal edge
    _edge_dwgl = {
        'cut': [[(0, 0), (2 * l * sint, 0)]]
    }  # override to give flat edge rather than tab

    _edge_dwgw = edgetab_dwg(w, we, **faceparamdict)

    # rect 4 side alternate transform
    trl = [(180, 2 * l * sint, 0),
           (270 - theta, 2 * l * sint + w * sint, w * cost), (0, 0, w * cost),
           (90 + theta, 0, 0)]

    _dwg = {}
    for k in _edge_dwgl:
        _layer = []
        for i in range(4):
            angle, x, y = trl[i]
            if i % 2 == 0:
                _layer.extend(
                    translate_layer(rotate_layer(_edge_dwgl[k], angle),
                                    (x, y)))
            else:
                _layer.extend(
                    translate_layer(rotate_layer(_edge_dwgw[k], angle),
                                    (x, y)))
        _dwg[k] = _layer

    return _dwg
Esempio n. 2
0
def nsided_polygon(edge_dwg, l, n):
    """
    repeat edge drawing to form a regular n sided polygon drawing
    :param edge_dwg: edge drawing
    :param l: edge length
    :param n: number of edges
    :return: polygonised drawing
    """

    #half internal angle of polygon for translation
    theta_radians = (math.pi - (2 * math.pi / n)) / 2
    v = (-l / 2, (l / 2) * math.tan(theta_radians))

    # Translate - assumes edge starts at origin, so first translate to correct radial position
    _edge_dwg = translate_drawing(edge_dwg, v)

    # Rotations - create polygon from n rotations of edge
    _dwg = {}
    for k, layer in _edge_dwg.items():
        _layer = []
        for i in range(n):
            _layer.extend(
                rotate_layer(layer,
                             math.degrees(2 * math.pi / n) * i))
        _dwg[k] = _layer

    return _dwg
Esempio n. 3
0
def transformlist_polygon(edge_dwg, trl):
    """
    repeat edge drawing to form a polygon with equal edges from transform list
    :param edge_dwg: edge drawing
    :param trl: transform list = list of tuples (angle, x, y) for sequence of translate(rotate(pl, angle), (x,y) operations
    :return: polygonised drawing
    """
    _dwg = {}
    for k, layer in edge_dwg.items():
        _layer = []
        for (angle, x, y) in trl:
            _layer.extend(translate_layer(rotate_layer(layer, angle), (x, y)))
        _dwg[k] = _layer

    return _dwg
Esempio n. 4
0
def transformlist_polygon_indexedges(edge_dwg_list, trli):
    """
    repeat edge drawing from list of edges to form a polygon with unequal edges from indexed transform list
    :param edge_dwg_list: list of edge drawings, index position indicated in trli
    :param trli: transform list = list of tuples (angle, x, y, i) for sequence of translate(rotate(pl, angle), (x,y) operations
        with index i used to select edge from list of edges
    :return: polygonised cut and score line point lists
    """
    _dwg = {}
    for k in edge_dwg_list[0]:
        _layer = []
        for (angle, x, y, i) in trli:
            _layer.extend(
                translate_layer(rotate_layer(edge_dwg_list[i][k], angle),
                                (x, y)))
        _dwg[k] = _layer

    return _dwg
Esempio n. 5
0
def triangle_custom_pair(l, le, **faceparamdict):
    """
    l mm edge0 triangle_pair, edge1, edge2 in ratio set below
    :parameter l: edge length
    :parameter le: length of end tab
    :parameter faceparamdict: see calling routines
    :return [cutlpl, scorelpl] for polyhedron triangle_pair tabbed face
    """

    # 90, 45, 45 triangle_pair
    # ratio0l for scaling from l, ratio of edge1 and edge2 to edge0
    ratio_0l, ratio_10, ratio_20 = 1, 1, math.sqrt(2)
    # triangle_pair, 3 side transform list
    l0, le0 = ratio_0l * l, ratio_0l * le
    trl = [(180, l0, 0), (90, 0, 0), (-45, 0, l0)]

    # # lengths 1, sqrt2, sqrt3 triangle_pair
    # # ratio0l for scaling from l, ratio of edge1 and edge2 to edge0
    # ratio_0l, ratio_10, ratio_20 = 1, math.sqrt(2), math.sqrt(3)
    # # triangle_pair, 3 side transform list
    # # trl = [(180, l, 0), (90, 0, 0), (-54.74, 0, l * ratio_10)]
    # # mirror
    # trl = [(0, 0, 0), (90, 0, -l * ratio_10), (-(180 - 54.74), l, 0)]

    _edge_dwgl = []
    _edge_dwgl.append(edgetab_dwg(l0, le0, **faceparamdict))
    _edge_dwgl.append(
        edgetab_dwg(l0 * ratio_10, le0 * ratio_10, **faceparamdict))
    _edge_dwgl.append(
        edgetab_dwg(l0 * ratio_20, le0 * ratio_20, **faceparamdict))

    _dwg = {}
    for k in _edge_dwgl[0]:
        _layer = []
        for i in range(3):
            angle, x, y = trl[i]
            _layer.extend(
                translate_layer(rotate_layer(_edge_dwgl[i][k], angle), (x, y)))
        _dwg[k] = _layer

    # pair for easier array tiling
    _dwg = pair_drawing(_dwg, (180, 1.1 * l0, 1.1 * l0))

    return _dwg
Esempio n. 6
0
def triangle_nscored_pair(l, le, nscored, **faceparamdict):
    """
    l mm edge equilateral triangle_pair, with nscored edges scored
    testing use of unscored edges for non-convex joins
    :parameter l: eq tri edge length
    :parameter le: length of end tab
    :parameter faceparamdict: see calling routines
    :parameter nscored: the number of scored edges - must be 0, 1 or 2 (3 gives same result as triangle_pair)
    :return dwg
    """
    _edge_dwg = edgetab_dwg(l, le, **faceparamdict)
    # half internal angle of polygon for translation
    n = 3
    theta_radians = (math.pi - (2 * math.pi / n)) / 2
    v = (-l / 2, (l / 2) * math.tan(theta_radians))

    # translate to correct radial position
    _edge_dwg = translate_drawing(_edge_dwg, v)

    # Rotations - create polygon from n rotations of edge
    _dwg = {}
    for k, layer in _edge_dwg.items():
        _layer = []
        for i in range(n):
            if k == 'score':
                if i < nscored:
                    continue
            _layer.extend(
                rotate_layer(layer,
                             math.degrees(2 * math.pi / n) * i))
        _dwg[k] = _layer

    # add another for easier array tiling
    _dwg = pair_drawing(_dwg, (180, 0.63 * l, -0.25 * l))

    return _dwg