XMin = X[0]; XMax = X[0]
the same for Y
for i = 1..N-1
Check distance from X[i] to XMax and XMin
Get largest of them D
If D is larger than W/2, shift X[i] by W
//example1: W=100, Xmin = 70, XMax = 90, X[i]=10 => X[i]=20+100 = 120
//example2: W=100, Xmin = 5, XMax = 12, X[i]=98 => X[i]=98-100 = -2
the same for Y
update Min/Max
Calc (W + Average(X[i])) %% W //modulo operation
我以前为拉马钱德兰的阴谋做过。我会检查,但我似乎记得我使用的算法是:
所以,假设你的点在X轴上被分割,你会发现点集的最小X坐标大于区域的中点轴。然后找到距离Y轴边缘的距离。然后将整个簇移动d。你知道吗
如果群集大小相对较小(小于网格的一半),可以使用简单的方法:
假设曲面的宽度和高度是W和H。假设曲面的尺寸是三倍的,所以有-W..2*W和-H..2*H轴范围。展开包装的值。你知道吗
相关问题 更多 >
编程相关推荐