旋轉卡殼卡卡

關於旋轉卡殼的比較詳細的介紹,這裏有兩篇文章(支持原創,拒絕轉載)

http://blog.sina.com.cn/s/blog_4afd4f7c010004y4.html

http://www.cppblog.com/staryjy/archive/2010/09/25/101412.html
這兩篇適合於不知道旋轉卡殼爲何物時入門用。

 

另外,這裏有關於旋轉卡殼詳盡的解釋與應用說明(包括點集的直徑,凸多邊形的寬,兩凸包的最遠距離,兩凸包的最近距離等)http://cgm.cs.mcgill.ca/~orm/rotcal.html
不要因爲都是英文而不想看,而去看中文版的,大牛的博客都是寫給他們自娛自樂然後讓一幫小弟膜拜的,仔細看一下原版會有很大幫助。中文版的只在於理解,而不能深刻理解。

然後就是我的旋轉卡殼了,poj2187這個題可以直接水過,不用旋轉卡殼就可以,toj2847就必須要用卡殼了

 

 

以上就是求點集直徑(最遠點對)的應用,而下面我們就解決旋轉卡殼求兩個凸包的最近距離的問題。
1.  Compute the vertex with minimum y coordinate for P (call it yminP) and the vertex with maximum y coordinate for Q (call it ymaxQ).
2. Construct two lines of support LP and LQ for the polygons at yminP and ymaxQ such that the polygons lie to the right of their respective lines of support. Then LP and LQ have opposite direction, and yminP and ymaxQ form an anti-podal pair between the polygons.
3. Compute dist(yminP,ymaxQ) and keep it as the minimum.
4. Rotate the lines clockwise until one of them coincides with an edge of its polygon.
5. If only one line coincides with an edge, then the vertex-edge anti-podal pair distance should be computed along with the new vertex-vertex anti-podal pairA distance. Both distances are compared the current minimum, which is updated if necessary. If both lines of support coincide with edges, then the situation is somewhat more complex. If the edges "overlap", that is if one can construct a line perpendicular to both edges and intersecting both edges (but not at vertices), then the edge-edge distance should be computed. Otherwise the three new vertex-vertex anti-podal pair distances are computed. All distances are compared to the current minimum which is updated if necessary.
6. Repeat steps 4 and 5, until the lines reach (yminP, ymaxQ) again.
7. Output the minimum distance.

這是英文版的最近點對的算法,簡單翻譯一下:
1、兩個凸多邊形,記爲P和Q,計算出P中y座標最小的點(記爲yminP) ,還有Q中y座標最大的點(記爲ymaxQ);
2、分別過yminP和yminQ做直線,並且使兩條直線平行(旋轉卡殼的過程中始終保持平行),記爲LP和LQ,此時凸多邊形分別位於LP和LQ的右邊。LP和LQ具有相反的方向,yminP和ymaxQ就構成了一對對踵點(對踵點的概念google一下)
3、計算yminP和ymaxQ的距離,存入最小距離(記爲minimum);
4、順時針旋轉直線(兩條直線都旋轉),直到其中一條直線與多邊形的某條邊重合。
5、如果此時只有一條直線與多邊形的一條邊重合,假如說LP和P的某一條邊(記爲e)重合,那麼可能的最近的點就是當前LQ與Q相交的那個頂點到e的最短距離(點到線段的最短距離);如果LP和LQ都與多邊形的某條邊重合,那麼如果有一條直線可以同時相交於這兩個邊並且垂直於這兩條邊,那麼LP和LQ之間的距離即爲可能的最近距離,否則就計算點到線段的距離(這一步可以簡化爲:兩條邊分別爲p1p2,q1q2,就計算p1到q1q2的最短距離,p2到q1q2的最短距離,q1到p1p2的最短距離,q2到p1p2的最短距離,然後取四個值的最小值),得到最小值以後,更新minimum
6、重複4和5,直到回到初始狀態
7、輸出最小距離
算法結束;

下面是應用實例:

 

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