Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Collections.sort(onCircle, new Comparator<Point2DDouble>() {
- int get(Point2DDouble e) {
- int x = comp.compare(e.x, 0);
- int y = comp.compare(e.y, 0);
- if (x > 0) {
- return y > 0 ? 2 : y < 0 ? 8 : 1;
- } else if (x < 0) {
- return y > 0 ? 4 : y < 0 ? 6 : 5;
- } else {
- return y > 0 ? 3 : y < 0 ? 7 : 0;
- }
- }
- @Override
- public int compare(Point2DDouble o1, Point2DDouble o2) {
- o1 = o1.subtract(circleCenter);
- o2 = o2.subtract(circleCenter);
- int c = get(o1) - get(o2);
- if (c != 0) return c;
- return comp.compare(o2.vmul(o1), 0);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment