Esempio n. 1
0
def splitRelMultiple(face, direction, splits):
    sA = []
    sA.append(face.vertices[direction])
    lA = face.vertices[direction + 1]
    sB = []
    sB.append(face.vertices[direction + 3])
    lB = face.vertices[(direction + 2) % len(face.vertices)]

    for i in range(len(splits)):
        sA.append(vec.betweenRel(sA[0], lA,splits[i]))
        sB.append(vec.betweenRel(sB[0], lB,splits[i]))
    sA.append(lA)
    sB.append(lB)

    result = []
    for i in range(len(splits) + 1):
        if(dir == 1):
            f = Face([sB[i], sA[i], sA[i+1], sB[i+1]])
            faceUtils.copyProperties(face, f)
            result.append(f)
        else:
            f = Face([sB[i], sB[i+1], sA[i+1], sA[i]])
            faceUtils.copyProperties(face, f)
            result.append(f)
    return result
Esempio n. 2
0
def splitRelFreeQuad(face, indexEdge,  split1,  split2):
    """
    Splits a quad in two new quads through the points specified
    by relative position along the edge.

    Arguments:
    ----------
    face : mola.core.Face
        The face to be extruded
    indexEdge : int
        direction of split, 0: 0->2, 1: 1->3
    split1, split2 : float
        relative position of split on each edge (0..1)
    """
    # only works with quads, therefore return original face if triangular
    if len(face.vertices) != 4:
        return face

    # constrain indexEdge to be either 0 or 1
    indexEdge = indexEdge%2

    indexEdge1 = (indexEdge + 1) % len(face.vertices)
    indexEdge2 = (indexEdge + 2) % len(face.vertices)
    indexEdge3 = (indexEdge + 3) % len(face.vertices)
    p1 = vec.betweenRel(face.vertices[indexEdge], face.vertices[indexEdge1], split1)
    p2 = vec.betweenRel(face.vertices[indexEdge2 ], face.vertices[indexEdge3], split2)
    faces = []
    if indexEdge == 0:
        f1 = Face([face.vertices[0], p1, p2, face.vertices[3]])
        f2 = Face([p1, face.vertices[1], face.vertices[2], p2])
        faceUtils.copyProperties(face, f1)
        faceUtils.copyProperties(face, f2)
        faces.extend([f1, f2])
    elif indexEdge == 1:
        f1 = Face([face.vertices[0], face.vertices[1], p1, p2])
        f2 = Face([p2, p1, face.vertices[2], face.vertices[3]])
        faceUtils.copyProperties(face,f1)
        faceUtils.copyProperties(face,f2)
        faces.extend([f1, f2])
    return faces
Esempio n. 3
0
def createProfileSubdivision(z):
    global freq_Z
    vertices = polyUtils.constructCircle(15, 8, z)
    for i in range(3):
        newVertices = []
        v0 = vertices[-1]
        for i, v1 in enumerate(vertices):
            newVertices.append(v0)
            n = polyUtils.normalEdge2DNonUnified(v0, v1)

            n = vec.scale(n, math.sin(freq_Z * z / 300))
            center = vec.betweenRel(v0, v1, 0.5)
            newVertices.append(vec.add(center, n))
            v0 = v1
        vertices = newVertices
    #vertices=polyUtils.subdivideCatmull2D(vertices)
    return vertices