def barycentricCoordinatesOf(P, A, B, C, areaFunc):
    """
    Computes the barycentric coordinates of the point P in the triangle ABC. 
    
    WARNING: Only correct if P is on the triangle ABC.

    Parameters:
        P: T - The point at which to compute the barycentric coordinates. 
        A: T - Corner of the triangle. 
        B: T - Corner of the triangle. 
        C: T - Corner of the triangle. 
        areaFunc: (T, T, T) -> U - The area function for the generic point type T. 

    Returns: 
        The barycentric coordinates of u, v, w of P where uA + vB + wC = P.  
    """
    invABC = 1.0 / areaFunc(A, B, C)
    CAP = areaFunc(C, A, P)
    ABP = areaFunc(A, B, P)
    BCP = areaFunc(B, C, P)
    return CAP * invABC, ABP * invABC, BCP * invABC