here: http://content.gpwik...le#Other_Method
a:=-(R[1]*Q[2]-P[1]*Q[2]-R[1]*P[2]+P[2]*Q[1]+R[2]*P[1]-Q[1]*R[2]);
b:= (P[1]*R[0]+Q[1]*P[0]+R[1]*Q[0]-Q[1]*R[0]-P[1]*Q[0]-R[1]*P[0]);
c:= (Q[2]*R[0]+P[2]*Q[0]+R[2]*P[0]-P[2]*R[0]-Q[2]*P[0]-Q[0]*R[2]);
d:=-a*P[0]-b*P[2]-c*P[1];
result:= -(a*X+c*Y+d)/b; //z of point
I call this method 4 times to find the colour of a point inside a triangle. Once for red, green, blue and alpha.
I know this method works perfectly on right angled triangles, but I am using scalene triangles.
This should still work on any triangle right?
Most of the time this works, but sometimes the colour that is returned is way off, for example if
the three points of the triangle are close shades of brown(or even the same), the returned point is blue.
What happens when the point I am trying to find is outside the triangle? I am 99% sure that I am always
using a point inside the triangle. If it was slightly outside, would this make the problem I am having? or
could it be something else?
Thanks,
r_bewick