CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Posts
    4

    A* algorithm help

    I have a set of node - node with it's associated cost. This cost is represented as a distance in feet.
    I also have a coordinate for each node. Now in the A* algorithm I will need to add the cost from node to node + the heuristic cost to the destination. However, these two values needs to be on the same metric/unit. I can't have one in feet and the other one in coordinate.

    I know that in order to do this I first need to find a scaling factor, to scale the cost in distance from feet to coordinate distance. Right? All I can say is that all this cost is scalable. So this beta value will be the same for all pair of node-node.. Question is how do I find this value?

  2. #2
    Join Date
    Oct 2006
    Posts
    616

    Re: A* algorithm help

    To find the ratio between your "world" coordinate units to the cost/heuristic function units, just look at the distance cost between 2 adjacent points relative to the "coordinate" distance between those 2 points.

    To find the "coordinate" distance between two (x,y) coordinates, use this formula:
    Code:
    distance(x,y) = sqrt(x*x + y*y)
    Small remark: the reason that the distance cost function and the heuristic function should be of the same units is that the A* heuristic is consistent only if it upholds the Triangle Inequality for any 3 points in the set.

    Regards,
    Zachm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured