Closed kun1224 closed 4 months ago
- Dijkstra和Astar
/** * 计算栅格索引 * @param node * @return */ double Astar::calIndex(Astar::Node *node) { // cout<<node->x<<","<<node->y<<endl; return (node->y - min_y) * x_width + (node->x - min_x); }
是不是应该修改成
return node->y * x_width + node->x;
maybe it's not necessry? I think the code is ok.. By the way, we just want to transfer node to index, actually we can use any way to make it as long as it works, not just a only way.
yeah, I konw this fuction just calculate index as the key of open and closed map . but this way can easily let learner konw its meaning. For example, I try to understand why node->y can minus min_y
yeah, I konw this fuction just calculate index as the key of open and closed map . but this way can easily let learner konw its meaning. For example, I try to understand why node->y can minus min_y
emm, maybe it's not complicated, why here minus min_y is because we always based on the minimum position to define.
是不是应该修改成
return node->y * x_width + node->x;