Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool checkRectangle(int i,bool square)
- {
- int counter,length,width,diagonal;
- for(int j = 1; j < 4 ; j++)
- {
- int x1 = p[subsets[i][0]].first;
- int y1 = p[subsets[i][0]].second;
- int x2 = p[subsets[i][j]].first;
- int y2 = p[subsets[i][j]].second;
- if(j == 1)
- length = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
- if(j == 2)
- diagonal = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
- if(j == 3)
- width = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
- }
- for(int j = 0 ; j < 4 ; j++)
- {
- int x1 = p[subsets[i][j]].first;
- int y1 = p[subsets[i][j]].second;
- counter = 0;
- for(int k = 0 ; k < 4 ; k++)
- {
- if(j == k)continue;
- int x2 = p[subsets[i][k]].first;
- int y2 = p[subsets[i][k]].second;
- int temp = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
- if(temp == width)
- counter++;
- if(temp == length)
- counter++;
- if(temp == diagonal)
- counter++;
- }
- if(square)
- {
- if(counter != 5)
- return false;
- }
- else if(counter != 3)return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement