double fnc(double x, double y, double z) { return la0(x, y, z) * la1(x, y, z) * la2(x, y, z) * la3(x, y, z) * ph0 * ph0 * ph0; }
bool hitboxCollision(int a_x,int a_y,int a_width,int a_height,float a_angle, int b_x,int b_y,int b_width,int b_height,float b_angle) { Point pa1(a_x, a_y); Point pa2(a_x + cos (a_angle*PI/180) * a_width ,a_y - sin (a_angle*PI/180) * a_width); Point pa3(a_x + cos (a_angle*PI/180) * a_width + sin (a_angle*PI/180) * a_height, a_y - sin (a_angle*PI/180) * a_width + cos (a_angle*PI/180) * a_height); Point pa4(a_x + sin (a_angle*PI/180) * a_height, a_y + cos (a_angle*PI/180) * a_height); Point pb1(b_x, b_y); Point pb2(b_x + cos (b_angle*PI/180) * b_width ,b_y - sin (b_angle*PI/180) * b_width); Point pb3(b_x + cos (b_angle*PI/180) * b_width + sin (b_angle*PI/180) * b_height, b_y - sin (b_angle*PI/180) * b_width + cos (b_angle*PI/180) * b_height); Point pb4(b_x + sin (b_angle*PI/180) * b_height, b_y + cos (b_angle*PI/180) * b_height); Line la1(pa1,pa2); Line la2(pa2,pa3); Line la3(pa3,pa4); Line la4(pa4,pa1); Line lb1(pb1,pb2); Line lb2(pb2,pb3); Line lb3(pb3,pb4); Line lb4(pb4,pb1); if(segmentIntersection(la1,lb1)) return true; if(segmentIntersection(la1,lb2)) return true; if(segmentIntersection(la1,lb3)) return true; if(segmentIntersection(la1,lb4)) return true; if(segmentIntersection(la2,lb1)) return true; if(segmentIntersection(la2,lb2)) return true; if(segmentIntersection(la2,lb3)) return true; if(segmentIntersection(la2,lb4)) return true; if(segmentIntersection(la3,lb1)) return true; if(segmentIntersection(la3,lb2)) return true; if(segmentIntersection(la3,lb3)) return true; if(segmentIntersection(la3,lb4)) return true; if(segmentIntersection(la4,lb1)) return true; if(segmentIntersection(la4,lb2)) return true; if(segmentIntersection(la4,lb3)) return true; if(segmentIntersection(la4,lb4)) return true; return false; /* vector<Point*>intersections; intersections.push_back(lineIntersection(la1,lb1)); intersections.push_back(lineIntersection(la1,lb2)); intersections.push_back(lineIntersection(la1,lb3)); intersections.push_back(lineIntersection(la1,lb4)); intersections.push_back(lineIntersection(la2,lb1)); intersections.push_back(lineIntersection(la2,lb2)); intersections.push_back(lineIntersection(la2,lb3)); intersections.push_back(lineIntersection(la2,lb4)); intersections.push_back(lineIntersection(la3,lb1)); intersections.push_back(lineIntersection(la3,lb2)); intersections.push_back(lineIntersection(la3,lb3)); intersections.push_back(lineIntersection(la3,lb4)); intersections.push_back(lineIntersection(la4,lb1)); intersections.push_back(lineIntersection(la4,lb2)); intersections.push_back(lineIntersection(la4,lb3)); intersections.push_back(lineIntersection(la4,lb4)); int x_min=0;int x_max=0; int y_max=0;int y_min=0; if(a_width*a_height>b_width*b_height) { x_min = pa1.x; x_min=min(x_min,pa2.x); x_min=min(x_min,pa3.x); x_min=min(x_min,pa4.x); x_max = pa1.x; x_max=max(x_max,pa2.x); x_max=max(x_max,pa3.x); x_max=max(x_max,pa4.x); y_min = pa1.y; y_min=min(y_min,pa2.y); y_min=min(y_min,pa3.y); y_min=min(y_min,pa4.y); y_max = pa1.y; y_max=max(y_max,pa2.y); y_max=max(y_max,pa3.y); y_max=max(y_max,pa4.y); }else { x_min = pb1.x; x_min=min(x_min,pb2.x); x_min=min(x_min,pb3.x); x_min=min(x_min,pb4.x); x_max = pb1.x; x_max=max(x_max,pb2.x); x_max=max(x_max,pb3.x); x_max=max(x_max,pb4.x); y_min = pb1.y; y_min=min(y_min,pb2.y); y_min=min(y_min,pb3.y); y_min=min(y_min,pb4.y); y_max = pb1.y; y_max=max(y_max,pb2.y); y_max=max(y_max,pb3.y); y_max=max(y_max,pb4.y); } int cont=0; for(int i=0;i<(int)intersections.size();i++) { Point* point=intersections[i]; if(point!=NULL) { if(point->x > x_min && point->x < x_max && point->y > y_min && point->y < y_max) { cont++; } } } vector<Point*>::iterator i; for ( i = intersections.begin() ; i < intersections.end(); i++ ) { delete * i; } if(cont>=8) return true; */ return false; }