kornicameister
4/19/2013 - 12:37 AM

movePoint

movePoint

private void movePoint(final Point toBeMoved) {
        Point nearestPoint = Solution.getNearest(this.points, toBeMoved);
        switch (this.mode) {
            case ORDINARY:
                Solution.moveToPoint(nearestPoint, toBeMoved);
                break;
            case ORDINARY_RECT_NEIGH_0_15: {
                Solution.moveToPoint(nearestPoint, toBeMoved);
                final ValueDistance distance = new ValueDistance(0.15);
                List<Point> inAreaPoints = Solution.getMultiNearest(this.points, toBeMoved, distance);
                for (Point point : inAreaPoints) {
                    Solution.moveToPoint(point, toBeMoved, 1.0 / 6.0);
                }
            }
            break;
            case ORDINARY_RECT_NEIGHT_16: {
                Solution.moveToPoint(nearestPoint, toBeMoved);
                final ValueDistance distance = new ValueDistance(16.0);
                List<Point> inAreaPoints = Solution.getMultiNearest(this.points, toBeMoved, distance);
                for (Point point : inAreaPoints) {
                    Solution.moveToPoint(point, toBeMoved, 1.0 / 6.0);
                }
            }
            break;
            case ORDINARY_GAUSS: {
                Solution.moveToPoint(nearestPoint, toBeMoved);
                final ValueDistance distance = new GaussDistance(-1.0);
                List<Point> inAreaPoints = Solution.getMultiNearest(this.points, toBeMoved);
                for (Point point : inAreaPoints) {
                    Solution.moveToPoint(point, toBeMoved, distance);
                }
            }
        }
    }
    
    /***************************************************************************/
    public class GaussDistance extends ValueDistance {
    final Double alpha = 0.5;
    final Double gamma = 0.8;

    public GaussDistance(final Double distance) {
        super(distance);
    }

    @Override
    public Double distance() {
        return this.alpha * Math.exp(this.distance / this.gamma);
    }
}
/**************************************************************************/
 public static void moveToPoint(Point move, Point moveTo, Distances distance) {
        distance.setInitDistance(Solution.distance(move, moveTo));
        Double alpha = distance.distance();
        move.appendX(alpha * (moveTo.getX() - move.getX()));
        move.appendY(alpha * (moveTo.getY() - move.getY()));
    }