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

Function ImTriangleClosestPoint

KBotExt/imgui/imgui.cpp:1706–1720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1704}
1705
1706ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
1707{
1708 ImVec2 proj_ab = ImLineClosestPoint(a, b, p);
1709 ImVec2 proj_bc = ImLineClosestPoint(b, c, p);
1710 ImVec2 proj_ca = ImLineClosestPoint(c, a, p);
1711 float dist2_ab = ImLengthSqr(p - proj_ab);
1712 float dist2_bc = ImLengthSqr(p - proj_bc);
1713 float dist2_ca = ImLengthSqr(p - proj_ca);
1714 float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca));
1715 if (m == dist2_ab)
1716 return proj_ab;
1717 if (m == dist2_bc)
1718 return proj_bc;
1719 return proj_ca;
1720}
1721
1722//-----------------------------------------------------------------------------
1723// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)

Callers 1

ColorPicker4Method · 0.85

Calls 3

ImLineClosestPointFunction · 0.85
ImLengthSqrFunction · 0.85
ImMinFunction · 0.85

Tested by

no test coverage detected