| 1672 | } |
| 1673 | |
| 1674 | ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) |
| 1675 | { |
| 1676 | ImVec2 ap = p - a; |
| 1677 | ImVec2 ab_dir = b - a; |
| 1678 | float dot = ap.x * ab_dir.x + ap.y * ab_dir.y; |
| 1679 | if (dot < 0.0f) |
| 1680 | return a; |
| 1681 | float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y; |
| 1682 | if (dot > ab_len_sqr) |
| 1683 | return b; |
| 1684 | return a + ab_dir * dot / ab_len_sqr; |
| 1685 | } |
| 1686 | |
| 1687 | bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) |
| 1688 | { |
no outgoing calls
no test coverage detected