public List<Triangle> triangulate(MonotonePolygon polygon) {
        final ArrayList<Point> points = new ArrayList<Point>(polygon.getPoints());
        Collections.sort(points);

        if (points.size() < 3) {
            throw new RuntimeException("strange polygon");
        }

        final List<Triangle> triangles = new ArrayList<Triangle>();
        final LinkedList<Point> temp = new LinkedList<Point>();
        temp.addLast(points.get(0));
        temp.addLast(points.get(1));
        for (int i = 2; i < points.size(); ++i) {
            final Point lastInStack = temp.getLast();
            final Point current = points.get(i);
            if (polygon.getPointType(lastInStack) != polygon.getPointType(current)) {
                // different chains
                while (temp.size() >= 2 && Util.isAngleGood(temp.get(0), temp.get(1), current, polygon)) {
                    triangles.add(new Triangle(temp.get(0), temp.get(1), current));
                    temp.pollFirst();
                }
                temp.addLast(current);
            } else {
                //same chains
                while (temp.size() >= 2 && Util.isAngleGood(temp.getLast(), Util.getlast2(temp), current, polygon)) {
                    triangles.add(new Triangle(temp.getLast(), Util.getlast2(temp), current));
                    temp.pollLast();
                }
                temp.addLast(current);
            }
        }
        return triangles;
    }