public static Point[] generateControls(final int sx, final int sy, final int ex, final int ey, int ctrlSpacing, int ctrlVariance) {
	    final double dist = Math.sqrt((sx - ex) * (sx - ex) + (sy - ey) * (sy - ey));
	    final double angle = Math.atan2(ey - sy, ex - sx);
	    int ctrlPoints = (int) Math.floor(dist / ctrlSpacing);
	    ctrlPoints = ctrlPoints * ctrlSpacing == dist ? ctrlPoints - 1 : ctrlPoints;
	    if (ctrlPoints <= 1) {
	      ctrlPoints = 2;
	      ctrlSpacing = (int) dist / 3;
	      ctrlVariance = (int) dist / 2;
	    }
	    final Point[] result = new Point[ctrlPoints + 2];
	    result[0] = new Point(sx, sy);
	    for (int i = 1; i < ctrlPoints + 1; i++) {
	      final double radius = ctrlSpacing * i;
	      final Point cur = new Point((int) (sx + radius * Math.cos(angle)), (int) (sy + radius * Math.sin(angle)));
	      double percent = 1D - (double) (i - 1) / (double) ctrlPoints;
	      percent = percent > 0.5 ? percent - 0.5 : percent;
	      percent += 0.25;
	      final int curVariance = (int) (ctrlVariance * percent);
	      /**
	       * Hopefully {@link java.util.Random} is thread safe. (it is in Sun
	       * JVM 1.5+)
	       */
	      cur.x = (int) (cur.x + curVariance * 2 * staticRandom.nextDouble() - curVariance);
	      cur.y = (int) (cur.y + curVariance * 2 * staticRandom.nextDouble() - curVariance);
	      result[i] = cur;
	    }
	    result[ctrlPoints + 1] = new Point(ex, ey);
	    return result;
	  }