MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / ImLineClosestPoint

Function ImLineClosestPoint

Dependencies/ImGui/src/imgui.cpp:1973–1984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1971}
1972
1973ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p)
1974{
1975 ImVec2 ap = p - a;
1976 ImVec2 ab_dir = b - a;
1977 float dot = ap.x * ab_dir.x + ap.y * ab_dir.y;
1978 if (dot < 0.0f)
1979 return a;
1980 float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y;
1981 if (dot > ab_len_sqr)
1982 return b;
1983 return a + ab_dir * dot / ab_len_sqr;
1984}
1985
1986bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
1987{

Callers 3

ImTriangleClosestPointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected