问题描述
我的code打印套(X,Y)坐标的二维空间,在区间[0,1]。
My code prints a sets of (X,Y) coordinates in 2D space in the range [0,1].
void Rect_Print() {
cout << "In counter-clockwise fashion" << endl;
cout << "#Rectangle ( x0, y0) ( x1, y1) " << endl;
for (int b=0; b<Rect_Count; b++) {
double Area = (Rect[b].x0 - Rect[b].x1) * (Rect[b].y0 - Rect[b].y1);
cout << fixed << setprecision(4) << (b+1) <<
" (" << Rect[b].x0 << "," << Rect[b].y0 <<
") (" << Rect[b].x1 << "," << Rect[b].y1 << ")" << endl;
}
cout << "Number of divisions (N = 3j-2) = " << Rect_Count << endl;
}
这些点划分的(3J-2)子矩形(不统一),一个单位正方形。对于每一个特定的矩形,我想相邻矩形的总数算吧。
These points divide a unit square in a (3j-2) sub-rectangles (not uniform). For each of the specific rectangle, I would like to count the total number of rectangle adjacent to it.
示例的
-
假设第一个坐标划分单元正方形分成四个矩形这样的:
Suppose the first coordinate divide the unit square into four rectangles like:
在此图片可以看到,还有的三个矩形的与相邻矩形3。
In this picture you can see, there are three rectangles adjacent with rectangle-3.
如果我继续这样,以后我第六步单位正方形分为19矩形。因此,它是这样的:
If I proceed that way, after my sixth step the unit square divide into 19 rectangles. So it's look like:
现在还有的五类矩形的邻近矩形3。 六类矩形的相邻矩形-11。
Now there are five rectangles adjacent to rectangle-3. six rectangles adjacent to rectangle-11.
假设我有一台的 10000 的协调和它们的子划分成方形小分的矩形。我想用C ++来算相邻他们的矩形数。我该怎么办呢?
Suppose I have a sets of ten thousand coordinate and they sub-divide the square into small sub-rectangles. I would like to use c++ to count the number of rectangles adjacent to each of them. How can I do it?
搜索互联网后,它似乎弗莱恩可以帮我做的伎俩。我读用户手册,但不明白我怎么能做到这一点。
After searching on Internet it seems the Flann may help me to do the trick. I read the user manual but could not understand how can I do that.
谁能帮助我?
推荐答案
您可以找一个R树或kd树。树形图算法的工作原理类似。良好的开端是在箱子上进行排序,并把它们在树通过递归的2轴分割它,并期待在那里下一个框配合。
You can look for a r-tree or kd-tree. The treemap algorithm works similar. A good start is to sort the boxes and put them in the tree by recursively split it at the 2 axis and look where the next box fits.
这篇关于算相邻矩形的数目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!