0
\$\begingroup\$

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?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Why do you want to find specifically points with u+v+w = 1, when you are interested in the distance/influence? Why not just compute/compare distances to said 3 points? \$\endgroup\$
    – wondra
    Nov 2 '16 at 17:03
  • 1
    \$\begingroup\$ This is just chaining together two common operations: 1) find the closest point to p3 on the plane containing p0p1p2 (hint: find the normal n to that plane, then your in-plane point q = p3 - n * dot(n, p3 - p0)) 2) find the Barycentric coordinates of q within the triangle p0p1p2 \$\endgroup\$
    – DMGregory
    Nov 2 '16 at 17:16

You must log in to answer this question.

Browse other questions tagged .