#include #include struct point { double x, y; }; struct line { point p1,p2; }; point tr[20][3]; point intersection[100]; int intno; int comb[20]; int max; double area; int n; inline void swap(point p[], int i,int j) { point temp; temp=p[i]; p[i]=p[j]; p[j]=temp; } // Tells if 3rd point if clockwise to the line(-1), // or anti-clockwise(+1), or if coincides(0). int ccw(point p0, point p1, point p2) { if(p0.x==p1.x && p0.y==p1.y) return 0; int dx1, dx2, dy1, dy2; dx1=p1.x - p0.x; dy1=p1.y - p0.y; dx2=p2.x - p0.x; dy2=p2.y - p0.y; if(dx1*dy2 > dy1*dx2) return +1; if(dx1*dy2 < dy1*dx2) return -1; if((dx1*dx2 < 0) || (dy1*dy2 < 0)) return -1; if((dx1*dx1+dy1*dy1) < (dx2*dx2+dy2+dy2)) return +1; return 0; } // Line Segment Intersection // returns 1 if an intersection, 0 if not inline int intersect(line l1, line l2) { return ((ccw(l1.p1, l1.p2, l2.p1) * ccw(l1.p1, l1.p2, l2.p2)) <=0) && ((ccw(l2.p1, l2.p2, l1.p1) * ccw(l2.p1, l2.p2, l1.p2)) <=0); } // returns the (approximate) angle made by the horizontal // and the line made by the 2 points. double theta(point p1, point p2) { int dx, dy, ax, ay; double t; dx = p2.x - p1.x; ax = abs(dx); dy = p2.y - p1.y; ay = abs(dy); t = (ax+ay == 0) ? 0 : (double) dy/(ax+ay); if(dx < 0) t = 2-t; else if (dy < 0) t = 4+t; return t*90.0; } // Given N points, it orders them so that they form a polygon void simplepolygon(point p[], int N) { int i,j; point temp; for(i=1;itheta(p[0],p[j])) swap(p,i,j); } // tells if 3 points are collinear or not inline int collinear(point p1, point p2, point p3) { if((p1.x==p2.x && p1.y==p2.y) || (p1.x==p3.x && p1.y==p3.y) || (p2.x==p3.x && p2.y==p3.y)) return 1; if((p2.y-p1.y)*(p3.x-p2.x)==(p3.y-p2.y)*(p2.x-p1.x)) return 1; return 0; } // Line Intersection // returns 0 if parallel, -1 if line segments form the same line // returns +1 if a proper intersection, puts intersection point in x,y int linesect(line l1, line l2, double& x, double& y) { if(collinear(l1.p1,l1.p2,l2.p1) && collinear(l1.p1,l1.p2,l2.p2) && collinear(l2.p1,l2.p2,l1.p1) && collinear(l2.p1,l2.p2,l1.p2)) return -1; int a1,b1,c1,a2,b2,c2,d; a1 = l1.p1.y - l1.p2.y; b1 = -1 * (l1.p1.x - l1.p2.x); c1 = (a1 * l1.p1.x) + (b1 * l1.p1.y); a2 = l2.p1.y - l2.p2.y; b2 = -1 * (l2.p1.x - l2.p2.x); c2 = (a2 * l2.p1.x) + (b2 * l2.p1.y); d = (b1 * a2) - (a1 * b2); if(d==0) return 0; x=((b1 * c2) - (b2 * c1))/double(d); y=((a2 * c1) - (a1 * c2))/double(d); return 1; } // takes a polygon of N points, and test point // and returns whether it is inside or not int inside(struct point t, struct point p[], int N) { int i,j,min=0,count=0; point temp1,temp2; for(i=1;imax) { // have got a combination now in comb //cout << "\ngot a combo..." << flush; for(i=1;i<=max;i++) { //cout << comb[i] << " " ; } //cout << endl; cout << flush; //compute their area int polyno=0; point poly[100]; point result[100]; int intno; // initial values for(i=0;i<3;i++) result[i]=tr[comb[1]-1][i]; intno=3; // get the intersection area for(i=1;i> n; for(i=0;i> tr[i][0].x >> tr[i][0].y; cin >> tr[i][1].x >> tr[i][1].y; cin >> tr[i][2].x >> tr[i][2].y; } //cout << "\nhere" << flush; // got the triangles int mult=1; double totalarea=0; for(i=0;i