public static Point[] generateSpline(final Point[] controls) {
	    final double degree = controls.length - 1;
	    final java.util.Vector<Point> spline = new java.util.Vector<Point>();
	    boolean lastFlag = false;
	    for (double theta = 0; theta <= 1; theta += 0.01) {
	      double x = 0;
	      double y = 0;
	      for (double index = 0; index <= degree; index++) {
	        final double probPoly = nCk((int) degree, (int) index) * Math.pow(theta, index) * Math.pow(1D - theta, degree - index);
	        x += probPoly * controls[(int) index].x;
	        y += probPoly * controls[(int) index].y;
	      }
	      final Point temp = new Point((int) x, (int) y);
	      try {
	        if (!temp.equals(spline.lastElement())) {
	          spline.add(temp);
	        }
	      } catch (final Exception e) {
	        spline.add(temp);
	      }
	      lastFlag = theta != 1.0;
	    }
	    if (lastFlag) {
	      spline.add(new Point(controls[(int) degree].x, controls[(int) degree].y));
	    }
	    adaptiveMidpoints(spline);
	    return spline.toArray(new Point[spline.size()]);
	  }