# 在给定方向上包裹等距点集

``````lat_x <- c(21.00749, 21.02675, 21.00396, 21.04602, 21.02317,
21.06524, 21.00008, 21.04247, 21.08454, 21.0192)
``````

``````lon_y <- c(88.21993, 88.25369, 88.31292, 88.28740, 88.34669,
88.32118, 88.40608, 88.38045, 88.35494, 88.43984)
``````

1. 可能是一些2D阵列点分组以匹配网格

可以加快以下所有操作的速度。

2. 计算平均网格大小（左起为img1）

作为两个向量

3. 创建蓝点（img2）

作为： `gray_point (+/-) 0.5*blue_vector`

4. 创建红点（img3）

作为： `blue_point (+/-) 0.5*red_vector`

5. 创建灰线列表（img4）

取所有距离都接近平均网格距离的所有2个原始（灰色）点，并为其添加线

6. 创建红线列表（img4）

取所有距离接近平均网格距离的所有2个原始（灰色）点，如果它们不与灰线中的任何一条线相交，则为其添加线

7. 重新排列线点以匹配多边形绕组...

8. 角度

[edit1]对评论的回应

find few points that are closest to each other so pick any point and find all closest points to it. The possible distances should be near:

``````sqrt(1.0)*d,sqrt(1+1)*d,sqrt(1+2)*d,sqrt(2+2)*d,...
``````

where `d` is the grid size so compute `d` for few picked points. Remember the first smallest `d` found and throw away all that are not similar to smallest one. Make average of them and let call it `d`

grid vectors

Take any point `A` and find closest point `B` to it with distance near `d`. For example `+/-10%` comparison: `|(|A-B|-d)|<=0.1*d` Now the grid vector is `(B-A)`. Find few of them (picking different `A,B`) and group them by sign of `x,y` coordinates into 4 groups.

``````A.x+=0.5*red_vector.x;
A.y+=0.5*red_vector.y;
``````

`for`每2个点组合产生2个嵌套s `A,B`（原始表示灰线，移动红色表示红色轮廓线），并为距离添加条件

``````|(|A-B|-d)|<=0.1*d
``````

``````    int i,j,N=?;       // N is number of input points in pnt[]
double x,y,d=?,dd=d*d,de=0.1*d; // d is the avg grid size
double pnt[N][2]=?;    // your 2D points
for (i=0;i<N;i++)      // i - all points
for (j=i+1;j<N;j++)   // j - just the rest no need to test already tested combinations
{
x=pnt[i][0]-pnt[j][0];
y=pnt[i][1]-pnt[j][1];
if (fabs((x*x)+(y*y)-dd)<=de) ... // add line pnt[i],pnt[j] to the list...
}
``````

0 条评论