MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / ImLineClosestPoint

Function ImLineClosestPoint

KBotExt/imgui/imgui.cpp:1674–1685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1672}
1673
1674ImVec2 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
1687bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
1688{

Callers 3

ImTriangleClosestPointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected