def sdf_to_contact()

in contactopt/diffcontact.py [0:0]


def sdf_to_contact(sdf, dot_normal, method=0):
    """
    Transform normalized SDF into some contact value
    :param sdf: NORMALIZED SDF, 1 is surface of object
    :param method: select method
    :return: contact (batch, S, 1)
    """
    if method == 0:
        c = 1 / (sdf + 0.0001)   # Exponential dropoff
    elif method == 1:
        c = -sdf + 2    # Linear dropoff
    elif method == 2:
        c = 1 / (sdf + 0.0001)   # Exponential dropoff
        c = torch.pow(c, 2)
    elif method == 3:
        c = torch.sigmoid(-sdf + 2.5)
    elif method == 4:
        c = (-dot_normal/2+0.5) / (sdf + 0.0001)   # Exponential dropoff with sharp normal
    elif method == 5:
        c = 1 / (sdf + 0.0001)   # Proxy for other stuff

    return torch.clamp(c, 0.0, 1.0)