| 1588 | } |
| 1589 | |
| 1590 | void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w) |
| 1591 | { |
| 1592 | ImVec2 v0 = b - a; |
| 1593 | ImVec2 v1 = c - a; |
| 1594 | ImVec2 v2 = p - a; |
| 1595 | const float denom = v0.x * v1.y - v1.x * v0.y; |
| 1596 | out_v = (v2.x * v1.y - v1.x * v2.y) / denom; |
| 1597 | out_w = (v0.x * v2.y - v2.x * v0.y) / denom; |
| 1598 | out_u = 1.0f - out_v - out_w; |
| 1599 | } |
| 1600 | |
| 1601 | ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) |
| 1602 | { |