[英]Difference between intersection algorithm and Rectangle.intersects(Rectangle r)
Someone on a forum I go to said I shouldn't use Rectangle.intersects
for my collision detection, and I should use this algorithm instead: 我去的论坛上有人说我不应该将
Rectangle.intersects
用于碰撞检测,而应该使用以下算法:
boolean rectangleIntersects(float rect1x, float rect1y, float rect1w,
float rect1h, float rect2x, float rect2y,
float rect2w, float rect2h)
{
return (rect1x + rect1w >= rect2x &&
rect1y + rect1h >= rect2y &&
rect1x <= rect2x + rect2w &&
rect1y <= rect2y + rect2h);
}
But isn't the Rectangle.intersects
algorithm different, and better than this? 但是
Rectangle.intersects
算法是否有所不同,并且比这个更好?
Rectangle.intersects
基本相同,除了您的算法使用float
而不是double
并包括边界的相等条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.