barycentricWeights method

void barycentricWeights(
  1. double x,
  2. double y,
  3. double ax,
  4. double ay,
  5. double bx,
  6. double by,
  7. double cx,
  8. double cy,
  9. Vec3 result,
)

Implementation

void barycentricWeights(
  double x,
  double y,
  double ax,
  double ay,
  double bx,
  double by,
  double cx,
  double cy,
  Vec3 result
) {
  result.x = ((by - cy) * (x - cx) + (cx - bx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy));
  result.y = ((cy - ay) * (x - cx) + (ax - cx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy));
  result.z = 1 - result.x - result.y;
}