MCPcopy Create free account
hub / github.com/RenderKit/embree / ImLineClosestPoint

Function ImLineClosestPoint

tutorials/common/imgui/imgui.cpp:1569–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1567}
1568
1569ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p)
1570{
1571 ImVec2 ap = p - a;
1572 ImVec2 ab_dir = b - a;
1573 float dot = ap.x * ab_dir.x + ap.y * ab_dir.y;
1574 if (dot < 0.0f)
1575 return a;
1576 float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y;
1577 if (dot > ab_len_sqr)
1578 return b;
1579 return a + ab_dir * dot / ab_len_sqr;
1580}
1581
1582bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
1583{

Callers 3

ImTriangleClosestPointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected