2015-08-30 112 views
0

我遇到了麻煩,找到一種方法來計算任意多邊形內的「交叉場」。 由一張紙定義的交叉字段是與域邊界相切的最平滑的字段(在這種情況下是多邊形)我在四重拓撲論文中發現了很多,但令人驚訝的是甚至在維基百科中我都找不到交叉字段的定義。 我有圖像,但由於我是新來的,系統說我需要至少10個聲望點才能上傳圖像。如何計算任意多邊形內的幾何交叉場?

任何想法? 我認爲這可能是沿插值線的東西?給定一個內點確定到每個邊的距離,並將每條邊的切線和垂直矢量積分或加權, (或者其他任何因素) 但是其他更簡單的方法可能存在? 在此先感謝!

回答

0
//I've come up with something like this (for the 3D case), very raw, educational purposes 
float ditance2segment(Vector3D p, Vector3D p0, Vector3D p1){ 
    Vector3D v = p1 - p0; 
    Vector3D w = p - p0; 
    float c1 = v.Dot(w); 
    if (c1 <= 0) 
     return (p - p1).Length(); 
    float c2 = v.Dot(v); 
    if (c2 <= c1) 
     return (p - p1).Length(); 

    float b = c1/c2; 
    Vector3D pb = p0 + b*v; 
    return (p - pb).Length(); 

} 
void CrossFieldInterpolation(List<Vector3D>& Contour, List<Vector3D>& ContourN, Vector3D p, Vector3D& crossU, Vector3D& crossV){ 
    int N = Contour.Amount(); 
    for (int i=0; i < N; i++){ 
     Vector3D u = Contour[(i + 1) % N] - Contour[i];  
     Vector3D n = 0.5*(ContourN[(i + 1) % N] + ContourN[i]); 
     Vector3D v = -Vector3D::Cross(u,n); //perpendicular vector 
     u = Vector3D::Normalize(u); 
     n = Vector3D::Normalize(n); 
     v = Vector3D::Normalize(v); 

     float dist = ditance2segment(p, Contour[i], Contour[(i+1)%N]); 

     crossU += u/(1+dist); //to avoid infinity at points over the segment 
     crossV += v/(1+dist); 
    } 
    crossU = Vector3D::Normalize(crossU); 
    crossV = Vector3D::Normalize(crossV); 
    } 
+0

不,這是錯誤的...請有人可以幫忙嗎? –

0

您可以查看我正在開發的OpenSource Graphite軟件,它實現了我的研究小組開發的「週期性全局參數化」算法[1]。您可能也有我們開發最近[2],[3]

石墨網站算法喜歡下面的研究文章: http://alice.loria.fr/software/graphite

如何使用定期的全球參數: http://alice.loria.fr/WIKI/index.php/Graphite/PGP

[1] http://alice.loria.fr/index.php/publications.html?Paper=TOG_pgp%402006

[2] http://alice.loria.fr/index.php/[email protected]

[3] http://alice.loria.fr/index.php/publications.html?redirect=0&[email protected]&Author=vallet

+0

非常感謝!真的很棒的工作:) –