大家好,又见面了,我是你们的朋友全栈君。
记录一下,不然久了可能就看不懂了。
case3中,方向为正方体对角线。
// nsz contains the number of neighbors for the four different types of moves:
// no move (norm 0): 26 neighbors always added
// 0 forced neighbors to check (never happens)
// 0 neighbors to add if forced (never happens)
// straight (norm 1): 1 neighbor always added
// 8 forced neighbors to check
// 8 neighbors to add if forced
// diagonal (norm sqrt(2)): 3 neighbors always added
// 8 forced neighbors to check
// 12 neighbors to add if forced
// diagonal (norm sqrt(3)): 7 neighbors always added
// 6 forced neighbors to check
// 12 neighbors to add if forced
static constexpr int nsz[4][2] = {
{
26, 0}, {
1, 8}, {
3, 12}, {
7, 12}};
straight (norm 1): 即是case1,对垂直与屏幕的平面,从当前节点检测周围8个点是不是障碍物,如果是,则下一平面的8个点即为forced neighbors,将8个均加入openset,疑问:为什么不是将下一平面的9个点均加入?哦:1 neighbor always added。
diagonal (norm sqrt(3)): 即是case3,从小正方体看,”7 neighbors always added”容易理解(7个natural neighbors),从底层图看,图中没画完全,再考虑障碍物对称情况,可能会有6个forced neighbors。“12 neighbors to add if forced”是最多12个neighbors加入openset,而不是13个。
diagonal (norm sqrt(2)): 即是case2,先看case3,再看case2其实更好理解,case2的顶层类似于case3的底层,于是有6个可能的forced neighbors,然后再看中间层的情况,同样是只画了一部分(画全了更不好理解了),对称性加上去就可以看出有2个可能的forced neighbors,故,case2一共有8个可能的forced neighbors。方向只在中间层,“3 neighbors always added”很好理解。疑问:为什么是“12 neighbors to add if forced”而不是11?
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/191360.html原文链接:https://javaforall.cn