2015-08-30 114 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

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