3D JPS

0.引言

記錄一下,不然久了可能就看不懂了。

1.圖解Neighbor Pruning & Forced Neighbors

Alt
case3中,方向爲正方體對角線。

Alt

	// 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?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章