niyaznigmatullin

Untitled

Jan 3rd, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.         Collections.sort(onCircle, new Comparator<Point2DDouble>() {
  2.  
  3.             int get(Point2DDouble e) {
  4.                 int x = comp.compare(e.x, 0);
  5.                 int y = comp.compare(e.y, 0);
  6.                 if (x > 0) {
  7.                     return y > 0 ? 2 : y < 0 ? 8 : 1;
  8.                 } else if (x < 0) {
  9.                     return y > 0 ? 4 : y < 0 ? 6 : 5;
  10.                 } else {
  11.                     return y > 0 ? 3 : y < 0 ? 7 : 0;
  12.                 }
  13.             }
  14.  
  15.             @Override
  16.             public int compare(Point2DDouble o1, Point2DDouble o2) {
  17.                 o1 = o1.subtract(circleCenter);
  18.                 o2 = o2.subtract(circleCenter);
  19.                 int c = get(o1) - get(o2);
  20.                 if (c != 0) return c;
  21.                 return comp.compare(o2.vmul(o1), 0);
  22.             }
  23.         });
Advertisement
Add Comment
Please, Sign In to add comment