Projecting a set of 2d real numbers to constrained grid

32 Views Asked by At

I have a set of 2D coordinates, ((x1, y1), (x2, y2), ..., (xn, yn)) I want to transform them into a grid encoding their relative positions in a way that minimizes the information lost, e.g. :

[[(x4, y4), (x2, y2)]

 [(x3, y3), (x1, y1), (x5, y5)]]

With the constraint that there can only be up to five items on each "line" of the grid

Would encode the relationship:

(x4, y4) is to the left of (x2, y2): x4 < x2

(x4, y4) is above ((x3, y3), (x1, y1), (x5, y5)): y4 > y3, y4 > y1, y4 > y5

Any ideas? Or is this not a well-framed problem.