我有一個形狀,它看起來像這樣:
好的,根據polyfill algorithm來填補我需要通過掃描線的區域的顏色。
我提供了6條掃描線。如何在Polyfill算法中處理Horizantal?
掃描1:從y=-1
開始像這樣:
你知道,如果以前的頂點/點和一個頂點/點都在同一側,也不會考慮爲交集。
#list of lines that each line contain [(startpoint, endpoint)]
listLines = [[(4,-1),(4,-2)]]
掃描2:從y=-2
開始像這樣:在這裏
同樣的事情發生,因爲Point13和Point15都在同一側Point14沒有考慮作爲交集,以及作爲點9(原因點10和點8在同一側)。
#list of lines that each line contain [(startpoint, endpoint)]
listLines = [[(1.7,-2),(6.5,-2)]]
掃描3:從y=-3
開始像這樣:
但這裏是混亂的部分,現在我不明白的水平線。
#list of lines that each line contain [(startpoint, endpoint)]
listLines = [[(2.4,-3),(7,-3)],[(9,-3),(10.5,-3)]]
#list of lines that each line contain [(startpoint, endpoint)]
listLines = [[(2,-4),(3,-4)],[(5,-4),(8,-4)]]
一切工作完全。
#list of lines that each line contain [(startpoint, endpoint)]
listLines = [[(3.5,-5),(5,-5)],[(6,-5),(9.5,-5)]]
掃描6:從y=-6
開始像這樣:
在這裏也完全工作,我沒有得到任何交集。
#list of lines that each line contain [(startpoint, endpoint)]
listLines = []
當我在看polyfill算法教程/文章或示例時,沒有提及如何處理水平線。任何人有任何想法應該如何處理水平線?
注:所以從我的理解:
如果下一個和上線在同一側,別指望像這樣任何交集:
但如果下一個和上線在對面狀所以:
我必須看看我收集到的頂點總數。
1-如果偶,我必須添加第一個交點。
2-如果奇數,我必須添加最後一個交點。
所以爲了解決這個問題,我拿出我需要運行的優化和重建形狀,只需通過查找每一個直線方程,併爲那些有解決方案相同的方程,刪除共享頂點,這將使形狀簡單,所以不會是任何線上的任何額外的頂點。
這只是奇怪,他們到目前爲止關於掃描線算法,但沒有提及任何有關重疊線方程。不是嗎?
看到我爲了什麼在掃描線3和4 – Shreesh