Welcome
Hello there ! Welcome to Interaction Cloud, a place to interact, share and enrich your knowledge on interesting topics in Design Patterns, User Interface Design, Gaming, etc. . I'm a graduate student at North Carolina State university pursuing my Master's degree in computer science. As a student I'm always interested in discovering and sharing information with everyone and hence I started this blog. I am front end designer by passion and a technology enthusiast. With this blog I plan to provide exposure to technologies, user interface design standards and much more. Hope you folks find it resourceful and useful.
Don't forget to visit my site for more information -
InteractionBeats
if (((x3 >= x1 && x3 <= x2 ||
ReplyDeletex3 <= x1 && x3 >= x2) &&
(y3 >= y1 && y3 <= y2) ||
y3 <= y1 && y3 >= y2)) ||
((x4 >= x1 && x4 <= x2 ||
x4 <= x1 && x4 >= x2) &&
(y4 >= y1 && y4 <= y2) ||
y4 <= y1 && y4 >= y2))) {
result = 0;
} else {
result = 1;
}
Hope this covers all corner cases too
ReplyDelete#include
typedef struct rect{
float x1;
float y1;
float x2;
float y2;
}rect;
int overlap(rect rect1,rect rect2){
if(rect1.x2-rect1.x1<rect2.x1-rect1.x1){
return 0;
}
if(rect2.x2-rect2.x1<rect1.x1-rect2.x1){
return 0;
}
if(rect1.y2-rect1.y1<rect2.y1-rect1.y1){
return 0;
}
if(rect1.y2-rect1.y1<rect2.y1-rect1.y1){
return 0;
}
return 1;
}
int main(){
rect rect1;
rect rect2;
rect1.x1=3;
rect1.y1=3;
rect1.x2=6;
rect1.y2=6;
rect2.x1=4;
rect2.y1=4;
rect2.x2=8;
rect2.y2=8;
printf("%d",overlap(rect1,rect2));
}