java中的非轴对齐方框的简单快速的碰撞算法 [英] Simple and fast collision algorithm in java for non-axis aligned boxes

查看:173
本文介绍了java中的非轴对齐方框的简单快速的碰撞算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个需要检测2个非轴对齐框之间的碰撞的程序。我的程序只需要指示2个非轴对齐框是否碰撞。我想要最简单和最有效的算法。

I'm making a program that needs to detect the collision between 2 non-axis aligned boxes. My program only needs an indication if 2 non-axis aligned boxes are colliding. I would like to have the most simple and efficient algorithm possible.

这里我可以看出问题。

Here I visualized the problem.

所以你可以看到1,2和3的方格将返回true,因为它们与绿色方块相撞。
4将返回false,因为它不会相互冲突。

So as you can see squares 1,2 and 3 would return true because they collided with the green squares. 4 would return false because it isn't colliding.

我将所有的两个颜色的框都放在单独的数组列表中。

I do have all the boxes of both colors in separate array lists.

有没有人知道这个问题的库或算法?谢谢提前。

Does anybody know a library or algorithm for this problem? Thanks in advance.

推荐答案

查看java.awt.geom包中的Area类。

Check out the Area class in the java.awt.geom package.

http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Area.html

这篇关于java中的非轴对齐方框的简单快速的碰撞算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆