class Solution public bool checkOverlapint radius int xCenter int yCenter int x1 int y1 int x2 int y2 ifx1-xCenterradius xCenter-x2radius y1-yCenterradius yCenter-y2radius
这个程序没有明确考虑圆心在矩形内部的情况,需要加上这个判断条件:
if (xCenter >= x1 && xCenter <= x2 && yCenter >= y1 && yCenter <= y2) {
return true;
}
原文地址: https://www.cveoy.top/t/topic/hrTw 著作权归作者所有。请勿转载和采集!