I'm running A* Path finding over a 3D grid of data. Available movements are the 26 surrounding nodes (i.e. you can move diagonally) I've been using euclidean distance as the heuristic and this works well but I'd also like to try 'diagonal distance' to see how that works (and if there are any speed gains)
I've found some logic online to do this in 2 dimensions...
function heuristic(node) =
dx = abs(node.x - goal.x)
dy = abs(node.y - goal.y)
return D * (dx + dy) + (D2 - 2 * D) * min(dx, dy)
..,where D is the north/east/south/west distance (for example 1m) and D2 is the diagonal distance (for example sqrt(2))
I'm not exactly sure how to convert this to 3 dimensions - so any help would be greatly appreciated
As an extra question (as this is how much grid is in reality...) suppose nodes on the x and y axis are 5m apart, but 2m apart on the z axis...how would the formula work then?
Thanks for any help!