Fixed cartesian_to_barycentric, seems to work now.