Reputation: 9265
Given a Bounds
structure like this:
struct Bounds {
public double xMin;
public double xMax;
public double yMin;
public double yMax;
}
I'm trying to find out how two Bounds
A and B intersect. Possible results are:
My first and naive attempt at it, is to test how many points of A are in B and how many points of B are in A, but I need this test to be as fast as possible and there is probably a better way to do it.
Thanks a lot !
Upvotes: 1
Views: 1158
Reputation: 99124
Try it in 2D 1D first. It should be clear how to test two [xmin, xmax] objects for those five possible results. Then do the same for [ymin, ymax]. Then combine the two results:
(I think that covers it.)
Upvotes: 3