struct point {
float x;
float y;
};
//求取三角形面积,1/2*AB*AC
float Area(const point p1,point p2,point p3) {
point AB, BC;
AB.x = p1.x - p2.x;
BC.x = p3.x - p2.x;
AB.y = p1.y - p2.y;
BC.y = p3.y - p2.y;
return fabs((AB.x * BC.y - BC.x - BC.y)) / 2.0f;
}
bool InArea(const point A, const point B, const point C,const point D) {
float SABC, SABP, SACP, SBCP;
SABC = Area(A,B,C);
SABP = Area(A, B, D);
SACP = Area(A, C, D);
SBCP = Area(B, C, D);
float sum = SABP + SACP + SBCP;
if ((SABC - sum < 0.001) && (sum - SABC) < 0.001) return true;
else return false;
}