Given three points \$p_1,p_2,p_3\$, how would one approximate the best positive weights \$(u, v, w)\$ such that \$u+v+w = 1\$ and that the distance between the new \$up_0 + vp_1 + wp_2\$ from \$p_3\$ is minimal?
Basically, the enemy's unit is positioned between several "bases" on a 2d plainand it's easy to tell which is closest or even find the "weights" between two bases \$(t, 1-t)\$ to compute the relative fractions (eg. 0.3, 0.7). How does one find the optimal weights for three surrounding points?
u+v+w = 1
, when you are interested in the distance/influence? Why not just compute/compare distances to said 3 points? \$\endgroup\$p3
on the plane containingp0p1p2
(hint: find the normaln
to that plane, then your in-plane pointq = p3 - n * dot(n, p3 - p0)
) 2) find the Barycentric coordinates ofq
within the trianglep0p1p2
\$\endgroup\$