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

Function ImTriangleClosestPoint

Dependencies/ImGui/src/imgui.cpp:2005–2019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2003}
2004
2005ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
2006{
2007 ImVec2 proj_ab = ImLineClosestPoint(a, b, p);
2008 ImVec2 proj_bc = ImLineClosestPoint(b, c, p);
2009 ImVec2 proj_ca = ImLineClosestPoint(c, a, p);
2010 float dist2_ab = ImLengthSqr(p - proj_ab);
2011 float dist2_bc = ImLengthSqr(p - proj_bc);
2012 float dist2_ca = ImLengthSqr(p - proj_ca);
2013 float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca));
2014 if (m == dist2_ab)
2015 return proj_ab;
2016 if (m == dist2_bc)
2017 return proj_bc;
2018 return proj_ca;
2019}
2020
2021//-----------------------------------------------------------------------------
2022// [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