#include<stdio.h>#include<stdlib.h>structpt{floatx,y;};structquat{ptpoints[4];};floatcrossmulti2d(floatx1,floaty1,floatx2,floaty2){returnx1*y2-x2*y1;}boolinquat(quat_q,pt_pt){ptvec1,vec2;vec1.x=_q.points[1].x-_q.points[0].x;vec1.y=_q.points[1].y-_q.points[0].y;vec2.x=_pt.x-_q.points[0].x;vec2.y=_pt.y-_q.points[0].y;if(crossmulti2d(vec2.x,vec2.y,vec1.x,vec1.y)<0){returnfalse;}vec1.x=_q.points[2].x-_q.points[1].x;vec1.y=_q.points[2].y-_q.points[1].y;vec2.x=_pt.x-_q.points[1].x;vec2.y=_pt.y-_q.points[1].y;if(crossmulti2d(vec2.x,vec2.y,vec1.x,vec1.y)<0){returnfalse;}vec1.x=_q.points[3].x-_q.points[2].x;vec1.y=_q.points[3].y-_q.points[2].y;vec2.x=_pt.x-_q.points[2].x;vec2.y=_pt.y-_q.points[2].y;if(crossmulti2d(vec2.x,vec2.y,vec1.x,vec1.y)<0){returnfalse;}vec1.x=_q.points[0].x-_q.points[3].x;vec1.y=_q.points[0].y-_q.points[3].y;vec2.x=_pt.x-_q.points[3].x;vec2.y=_pt.y-_q.points[3].y;if(crossmulti2d(vec2.x,vec2.y,vec1.x,vec1.y)<0){returnfalse;}returntrue;}intmain(){quatshape={{{1,1},{2,1},{1,0},{0,0}}};pttests[]={{0.0,1.0},{1.0,0.5},{1.5,0},{1.5,0.5},{1.5,0.52},{1.5,0.49}};for(inti=0;i<sizeof(tests)/sizeof(pt);++i){if(inquat(shape,tests[i])==true){printf("pass\n");}else{printf("failed\n");}}return0;}