I need a function that returns an array of points, it has to maximize the number of points in a rectangle. The function has to favour 100mm spacing (in any direction) but it can deviate by x (integer) to create points that would almost fit. We also want to minimize deviation.
There are shapes in the given area that points cannot fall within. I have a working function boolean isCollide(Point point).
The is actually a CAD problem, and the logic will be applied to Catia v5. I am hoping for sudo code. The rectangle size is constant and is dimensioned with PLATEXMAX and PLATEYMAX.
My solution has to be exhaustive, all my attempts have only given heuristic solutions. Algorithm efficiency is not an issue. Anyone faced a similar issue, or have any suggestions?
I have created an illustration to show a visual representation of my problem. http://tinypic.com/r/vebtj5/8
EDIT:
Point[] tempArray = new Point[]
for i=0 to PLATEXMX{
for j=0 to PLATEYMAX{
Point test = new Point(i,j)
Boolean found = false
foreach tpoint in tempArray{
if !found{
for n=0 to deviation{
if tpoint.distanceTo(test) < (100 + n){
if !(isCollide(test){
tempArray.add(test)
break
} else{
//check points offset from this point
//check every offset point 360deg around test
//increase checking radius to max deviation
}
}
}
}