示例#1
0
def _triangle_area_centroid_normal(nodes): 
    """
    Returns area,centroid,unitNormal
    
    @param nodes:
      list of three triangle vertices
      
    @code
    n = Normal = a x b
    Area   = 1/2 * |a x b|
    V = <v1,v2,v3>
    |V| = sqrt(v1^0.5+v2^0.5+v3^0.5) = norm(V)

    Area = 0.5 * |n|
    unitNormal = n/|n|
    @endcode
    """
    (n0, n1, n2) = nodes
    vector = cross(n0 - n1, n0 - n2)
    length = norm(vector)
    normal = vector / length
    if allclose(norm(normal), 1.) == False:
        raise RuntimeError('function _triangle_area_centroid_normal, check...'
                    '\na = {0}\nb = {1}\nnormal = {2}\nlength = {3}\n'.format(
                    n0 - n1, n0 - n2, normal, length))

    return (0.5 * length, (n0 + n1 + n2) /3, normal)
示例#2
0
def _triangle_area_centroid_normal(nodes):
    """
    Returns area,centroid,unitNormal
    
    @param nodes:
      list of three triangle vertices
      
    @code
    n = Normal = a x b
    Area   = 1/2 * |a x b|
    V = <v1,v2,v3>
    |V| = sqrt(v1^0.5+v2^0.5+v3^0.5) = norm(V)

    Area = 0.5 * |n|
    unitNormal = n/|n|
    @endcode
    """
    (n0, n1, n2) = nodes
    vector = cross(n0 - n1, n0 - n2)
    length = norm(vector)
    normal = vector / length
    if allclose(norm(normal), 1.) == False:
        raise RuntimeError(
            'function _triangle_area_centroid_normal, check...'
            '\na = {0}\nb = {1}\nnormal = {2}\nlength = {3}\n'.format(
                n0 - n1, n0 - n2, normal, length))

    return (0.5 * length, (n0 + n1 + n2) / 3, normal)
示例#3
0
def _normal(a, b):
    """Finds the unit normal vector of 2 vectors"""
    vector = cross(a, b)
    normal = vector / norm(vector)
    assert allclose(norm(normal), 1.)
    return normal
示例#4
0
def _normal(a, b):
    """Finds the unit normal vector of 2 vectors"""
    vector = cross(a, b)
    normal = vector / norm(vector)
    assert allclose(norm(normal), 1.)
    return normal