边界交叉点
给定这样的 Bounds
结构:
struct Bounds {
public double xMin;
public double xMax;
public double yMin;
public double yMax;
}
我试图找出两个 Bounds
A 和 B 如何相交。可能的结果是:
- A 和 B 根本不相交
- A 和 B 相等
- A 完全包含 B
- B 完全包含 A
- A 和 B 彼此相交
我的第一个天真的尝试是测试 A 有多少点在 B 中B 有多少个点在 A 中,但我需要这个测试尽可能快,并且可能有更好的方法来做到这一点。
多谢 !
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:
- A and B do not intersect at all
- A and B are equal
- A fully contains B
- B fully contains A
- A and B intersect each other
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 !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先在
2D1D 中尝试。应该清楚如何测试两个 [xmin, xmax] 对象以获得这五个可能的结果。然后对 [ymin, ymax] 执行相同操作。然后合并两个结果:((我认为这涵盖了它。)
Try it in
2D1D 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.)