bool point2Dtriangle(double e,double f, double a,double b,double c, double g,double h,double i, double v, double w){
/* inputs: e=point.x, f=point.y
a=triangle.Ax, b=triangle.Bx, c=triangle.Cx
g=triangle.Ay, h=triangle.By, i=triangle.Cy */
v = 1 - (f * (b - c) + h * (c - e) + i * (e - b)) / (g * (b - c) + h * (c - a) + i * (a - b));
w = (f * (a - b) + g * (b - e) + h * (e - a)) / (g * (b - c) + h * (c - a) + i * (a - b));
if (*v > -0.0 && *v < 1.0000001 && *w > -0.0 && *w < *v) return true;//is inside
else return false;//is outside
return 0;
}
almost perfect Cartesian coordinates converted from barycentric
are exported within *v (x) and *w (y) doubles.
Both export doubles should have a * char before in every case, likely: *v and *w
Code can be used for the other triangle of a quadrangle too.
Hereby signed wrote only triangle abc from the clockwise abcd quad.
A---B
|..\\.o|
|....\\.|
D---C
the o point is inside ABC triangle
for testing with with second triangle call this function CDA direction, and results should be correct after *v=1-*v;
and *w=1-*w;
for the quadrangle