def stretch_metric(t3d, t2d, return_A2d=False, flippedCheck=None, normalize=False):
     
    q1 = t3d[:,0]
    q2 = t3d[:,1]
    q3 = t3d[:,2]
    s1 = t2d[:,0,0]
    s2 = t2d[:,1,0]
    s3 = t2d[:,2,0]
    t1 = t2d[:,0,1]
    t2 = t2d[:,1,1]
    t3 = t2d[:,2,1]
    A2d = ((s2-s1)*(t3-t1) - (s3-s1)*(t2-t1)) / 2.0
    A2d[A2d == 0] = numpy.inf
    assert(not(numpy.any(A2d==0) and return_A2d))
    
    S_s = (q1*(t2-t3)[:,None] + q2*(t3-t1)[:,None] + q3*(t1-t2)[:,None]) / (2.0 * A2d)[:,None]
    S_t = (q1*(s3-s2)[:,None] + q2*(s1-s3)[:,None] + q3*(s2-s1)[:,None]) / (2.0 * A2d)[:,None]
    
    L2 = numpy.sqrt((array_mult(S_s,S_s) + array_mult(S_t,S_t)) / 2.0)
    if flippedCheck is not None:
        L2[numpy.logical_xor(A2d < 0, flippedCheck < 0)] = numpy.inf
        L2[A2d == 0] = numpy.inf
    if normalize:
        A3d = tri_areas_3d(t3d)
        A2d[A2d == numpy.inf] = 0
        sumA3d = numpy.sum(A3d)
        if flippedCheck is None and sumA3d == 0:
            L2 = 0
        else:
            A3d[L2 == numpy.inf] = numpy.inf
            L2 = numpy.sqrt(numpy.sum(L2*L2*A3d) / sumA3d) * numpy.sqrt(numpy.sum(numpy.abs(A2d)) / sumA3d)
        
    if return_A2d:
        return L2, A2d
    
    return L2
Computes the texture stretch metric from
dataset/ETHPy150Open pycollada/meshtool/meshtool/filters/simplify_filters/sander_simplify.py/stretch_metric