All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xguzm.pathfinding.grid.heuristics.ChebyshevDistance Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package org.xguzm.pathfinding.grid.heuristics;

import org.xguzm.pathfinding.Heuristic;
import org.xguzm.pathfinding.NavigationNode;
import org.xguzm.pathfinding.grid.GridCell;

public class ChebyshevDistance implements Heuristic{

	@Override
	public float calculate(NavigationNode from, NavigationNode to) {
		GridCell c1 = (GridCell)from, c2 = (GridCell) to;
		
		return calculate(Math.abs(c2.x - c1.x), Math.abs(c2.y - c1.y));
	}
	
	public float calculate(int dx, int dy) {
		return Math.max(dx, dy);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy