Advertisement
What_Ever

Untitled

Feb 3rd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. bool checkRectangle(int i,bool square)
  2. {
  3.     int counter,length,width,diagonal;
  4.     for(int j = 1; j < 4 ; j++)
  5.     {
  6.         int x1 = p[subsets[i][0]].first;
  7.         int y1 = p[subsets[i][0]].second;
  8.         int x2 = p[subsets[i][j]].first;
  9.         int y2 = p[subsets[i][j]].second;
  10.         if(j == 1)
  11.             length = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
  12.         if(j == 2)
  13.             diagonal = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
  14.         if(j == 3)
  15.             width = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
  16.     }
  17.     for(int j = 0 ; j < 4 ; j++)
  18.     {
  19.         int x1 = p[subsets[i][j]].first;
  20.         int y1 = p[subsets[i][j]].second;
  21.         counter = 0;
  22.         for(int k = 0 ; k < 4 ; k++)
  23.         {
  24.             if(j == k)continue;
  25.             int x2 = p[subsets[i][k]].first;
  26.             int y2 = p[subsets[i][k]].second;
  27.             int temp = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
  28.             if(temp == width)
  29.                 counter++;
  30.             if(temp == length)
  31.                 counter++;
  32.             if(temp == diagonal)
  33.                 counter++;
  34.         }
  35.         if(square)
  36.         {
  37.             if(counter != 5)
  38.                 return false;
  39.         }
  40.         else if(counter != 3)return false;
  41.     }
  42.     return true;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement