Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 KB | None | 0 0
  1.         static void GetQuarterArea(int x1, int y1, int x2, int y2,out int quarter,out int quarter2,out int sq1, out int sq2, out int sq3, out int sq4){
  2.             sq1 = 0;
  3.             sq2 = 0;
  4.             sq3 = 0;
  5.             sq4 = 0;
  6.                 quarter = 0;
  7.                 quarter2 = 0;
  8.             if (x1 > 0 & y1 > 0) quarter = 1;
  9.             if (x1 > 0 & y1 < 0) quarter = 4;
  10.             if (x1 < 0 & y1 > 0) quarter = 2;
  11.             if (x1 < 0 & y1 < 0) quarter = 3;
  12.             if (x2 > 0 & y2 > 0) quarter2 = 1;
  13.             if (x2 > 0 & y2 < 0) quarter2 = 4;
  14.             if (x2 < 0 & y2 > 0) quarter2 = 2;
  15.             if (x2 < 0 & y2 < 0) quarter2 = 3;
  16.             if (quarter == quarter2) sq1 = (x1 - x2) * (y1 - y2);
  17.             else {
  18.                 if (quarter == 2 & quarter2 == 4)
  19.                 {
  20.                     sq1 = (x2 * y1);
  21.                     sq2 = (x1 * y1);
  22.                     sq3 = (x1 * y2);
  23.                     sq4 = (x2 * y2);
  24.                 }
  25.                 if (quarter == 4 & quarter2 == 2)
  26.                 {
  27.                     sq1 = (x1 * y2);
  28.                     sq2 = (x1 * y1);
  29.                     sq3 = (x1 * y2);
  30.                     sq4 = (x2 * y2);
  31.            
  32.                 }
  33.                 if (quarter == 1 & quarter2 == 3)
  34.                 {
  35.                     sq1 = (x1 * y1);
  36.                     sq2 = (x2 * y1);
  37.                     sq3 = (x2 * y2);
  38.                     sq4 = (x1 * y2);
  39.  
  40.                 }
  41.                 if (quarter == 3 & quarter2 == 1)
  42.                 {
  43.                     sq1 = (x2 * y2);
  44.                     sq2 = (x1 * y2);
  45.                     sq3 = (x1 * y1);
  46.                     sq4 = (x2 * y1);
  47.  
  48.                 }
  49.                 if (quarter == 1 & quarter2 == 2){
  50.                     sq1 = (x1 * y1);
  51.                     sq2 = (x2 * y2);
  52.                    
  53.                 }
  54.                 if (quarter == 2 & quarter2 == 1)
  55.                 {
  56.                     sq2 = (x1 * y1);
  57.                     sq1 = (x2 * y2);
  58.  
  59.                 }
  60.                 if (quarter == 2 & quarter2 == 3)
  61.                 {
  62.                     sq2 = (x1 * y1);
  63.                     sq3 = (x2 * y2);
  64.  
  65.                 }
  66.                 if (quarter == 3 & quarter2 == 2)
  67.                 {
  68.                     sq3 = (x1 * y1);
  69.                     sq2 = (x2 * y2);
  70.  
  71.                 }
  72.                 if (quarter == 3 & quarter2 == 4)
  73.                 {
  74.                     sq3 = (x1 * y1);
  75.                     sq4 = (x2 * y2);
  76.  
  77.                 }
  78.                 if (quarter == 4 & quarter2 == 3)
  79.                 {
  80.                     sq4 = (x1 * y1);
  81.                     sq3 = (x2 * y2);
  82.  
  83.                 }
  84.                 if (quarter == 4 & quarter2 == 1)
  85.                 {
  86.                     sq4 = (x1 * y1);
  87.                     sq1 = (x2 * y2);
  88.  
  89.                 }
  90.                 if (quarter == 1 & quarter2 == 4)
  91.                 {
  92.                     sq1 = (x1 * y1);
  93.                     sq4 = (x2 * y2);
  94.  
  95.                 }
  96.             }
  97.             if (sq1 < 0) sq1 = sq1 * (-1);
  98.             if (sq2 < 0) sq2 = sq2 * (-1);
  99.             if (sq3 < 0) sq3 = sq3 * (-1);
  100.             if (sq4 < 0) sq4 = sq4 * (-1);
  101.  
  102.         }
  103.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement