You can make a Polygon out of your Triangle and use the contains method.:
1 2 3 4 5 6
| public boolean isInsideTriangle(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4) { Polygon p=new Polygon(new int[]{x1,x2,x3},new int[]{y1,y2,y3},3); if(p.contains(x4,y4)) return true; return false; } |
Or you can check check if the area of ABM+ACM+BCM=ABC(M is the point you check).If the point is inside the triangle they will be equal else they won't.The area of a triangle is (Heron's Formula) sqrt(p*(p-a)*(p-b)*(p-c)) where a,b,c are the lengths of BC,AC,AB and p is the semiperimeter((a+b+c)/2).
But I doubt the second method will run too fast. I don't know how fast the first one runs...
Hope this helps.
