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

Function ImTriangleClosestPoint

tutorials/common/imgui/imgui.cpp:1601–1615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1599}
1600
1601ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
1602{
1603 ImVec2 proj_ab = ImLineClosestPoint(a, b, p);
1604 ImVec2 proj_bc = ImLineClosestPoint(b, c, p);
1605 ImVec2 proj_ca = ImLineClosestPoint(c, a, p);
1606 float dist2_ab = ImLengthSqr(p - proj_ab);
1607 float dist2_bc = ImLengthSqr(p - proj_bc);
1608 float dist2_ca = ImLengthSqr(p - proj_ca);
1609 float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca));
1610 if (m == dist2_ab)
1611 return proj_ab;
1612 if (m == dist2_bc)
1613 return proj_bc;
1614 return proj_ca;
1615}
1616
1617//-----------------------------------------------------------------------------
1618// [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