I'm trying to figure out a way to transform a $2$d point $(x, y)$ into a single value that retains a certain 'order' based on specific rules. I will try to explain as best as I can:
Any coordinate in the "FRONT" area should return a value that's smaller than any coordinate in the "BACK" area. What I am trying to achieve, is to be able to order multiple points like these, while retaining the "FONT" / "BACK" rule but reduced to a single "order" number:
In this case, the order would be f(a) < f(b) < f(c).
In case of two areas overlap, the formula should be able to prioritize one axis (in my case, I will always prioritize the $x$ axis). What I mean is, if two points are both "behind" each other, the point with a smaller $x$ value will be ordered first:
In the example above, "B" and "C" are both behind each other - but since b.x < c.x, "B" will come first: f(a) < f(b) < f(c).
Lastly, if all the above works and there is a way to do it, can the formula be extended to include a different angle than a right angle, for the "FRONT" area? Example:
Just to clarify: I'm not sure if this approach is the best approach to begin with. I'm trying to find a solution for this for a program I'm writing, where only one order number is available to sort these points.
The pseudo code for the rules mentioned above would look something like this:
if( p1.x < p2.x && p1.y < p2.y ) {
// p1 is in front of p2
} else if( p1.x < p2.x && p1.y > p2.y ) { // the previously mentioned overlap
// p1 is in front of p2
} else {
// p1 is behind p2
}
But my issue is, I have to be able to create a result without comparing two points to each other (since the points are moving and it would be a mess to order them each frame). I'm looking for a method to generate this order without comparing two coordinates.
Is that possible?



