Simplified the function which calculates the barycentric coordinates.