navmesh 生成網格信息 三角化切分多邊形中檢測有效分割的算法

Detecting Valid Partitions

Two algorithms are used to determine whether a group of three vertices can form a valid internal triangle. The first algorithm is fast and can quickly cull partitions that lie entirely outside of the polygon. If the partition is inside the polygon a more expensive algorithm is used to make sure it doesn't intersect any existing polygon edges.

兩個算法用來實現這一點:

第一個算法簡單,並且可以很快地排除掉完全在多邊形外邊的分割。

第二個算法是用來確保在多邊形內部的分割不會與其它已經存在的多邊形的邊相交。

 

The Internal Angle Algorithm

 

如圖:AB是要檢測的潛在分割

Cast two rays out along the edges connected to vertex A. The interior angle is the angle in the direction of the polygon. If the partition endpoint (vertex B) is within the interior angle, then it is a potential valid partition.

找到點A所連接的兩個邊,如果分割的另一邊B是在內角範圍內,則說明是潛在有效的分割。(otential valid partition)

This second example is the same scenario with different vertices. Since the partition endpoint (vertex B) is outside the interior angle, it can't be a valid partition.

下圖展現不同的頂點的情況,以B爲結束點的分割,就在內角以外,不能被看成是有效分割。

The Edge Intersection Algorithm

This algorithm is much easier to understand. It simply loops through all edges in the polygon and checks to see if the potential partition intersects with any of them. If it does, it isn't a valid partition.

邊相交算法就是遍歷所有多邊形的邊以檢查是否有潛在的分割線段與這些邊相交,如果有,那麼就不是一個有效分割。

Only if both algorithms pass is the partition considered valid.

兩個算法都通過了 那就是有效分割拉。

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