|BaryCentric Coordinates is a way of representing a set of
weighted values for each point. The concept is used in numerous tests
not just our triangle/point demo.
P = uA + vB + wC
P is our point, A,B,C our triangle and of course u,v,w are our
The point is inside the triangle only if 0<= u,v,w <= 1, or
alternatively, if and only if 0<=v<=1.0f and 0<=w<=1 and v+w<=1
Not that I say v+w<=1, as u=1-w-v
Which leads us to rearranging for what u is, and gives us:
P = A + v(B-A) + w(C-A) = (1-v-w)A + vB + wC
And we can solve for v and w.
(Source + Executable)