Exemplo n.º 1
0
def normalVertex2D(vprev, v, vnext):
    vec1 = vec.subtract(v, vprev)
    vec1 = vec.unitize(vec1)
    vec2 = vec.subtract(vnext, v)
    vec2 = vec.unitize(vec1)
    n = vec.add(vec1, vec2)
    n = vec.scale(n, 0.5)
    t = n.x
    n.x = -n.y
    n.y = t
    return n
Exemplo n.º 2
0
def shapeProfile(mesh):
    zFunction = SinusFunction(zFreq, zAmp, zPhase, zOffset)
    for v in mesh.vertices:
        pos_z = (v.z/300.0)*2*math.pi
        val_z = zFunction.getValue(pos_z)
        normal = vec.subtract(v, Vertex(0, 0, v.z))
        normal = vec.unitize(normal)
        nvec = vec.scale(normal, val_z)
        v.add(nvec)
    return mesh
Exemplo n.º 3
0
def normalFromTriangle(v1,v2,v3):
    """
    Returns the normal of a triangle defined by 3 vertices.
    The normal is a vector of length 1 perpendicular to the plane of the triangle.

    Arguments:
    ----------
    v1, v2, v3 : mola.core.Vertex
        the vertices get the normal from
    """
    v = vec.subtract(v2, v1)
    u = vec.subtract(v3, v1)
    crossProduct=vec.cross(v, u)
    return vec.unitize(crossProduct)
Exemplo n.º 4
0
def normalEdge2D(vprev, v):
    vec1 = vec.subtract(v, vprev)
    vec1 = vec.unitize(vec1)
    return vec.rot2D90(vec1)
Exemplo n.º 5
0
def normalFromTriangle(v1, v2, v3):
    v = _vec.subtract(v2, v1)
    u = _vec.subtract(v3, v1)
    crossProduct = _vec.cross(v, u)
    return _vec.unitize(crossProduct)