public static boolean collideRectCircle(double rectWidth, double rectHeight, double rectRotation, double rectCenterX, double rectCenterY, double circleCenterX, double circleCenterY, double circleRadius) {
double tx, ty, cx, cy;
if (rectRotation == 0) {
tx = circleCenterX;
ty = circleCenterY;
cx = rectCenterX;
cy = rectCenterY;
} else {
tx = Math.cos(rectRotation) * circleCenterX - Math.sin(rectRotation) * circleCenterY;
ty = Math.cos(rectRotation) * circleCenterY + Math.sin(rectRotation) * circleCenterX;
cx = Math.cos(rectRotation) * rectCenterX - Math.sin(rectRotation) * rectCenterY;
cy = Math.cos(rectRotation) * rectCenterY + Math.sin(rectRotation) * rectCenterX;
}
return collideRectPoint(rectWidth, rectHeight, rectRotation, rectCenterX, rectCenterY, circleCenterX, circleCenterY) ||
collideCircleLine(tx, ty, circleRadius, cx - rectWidth / 2, cy + rectHeight / 2, cx + rectWidth / 2, cy + rectHeight / 2) ||
collideCircleLine(tx, ty, circleRadius, cx + rectWidth / 2, cy + rectHeight / 2, cx + rectWidth / 2, cy - rectHeight / 2) ||
collideCircleLine(tx, ty, circleRadius, cx + rectWidth / 2, cy - rectHeight / 2, cx - rectWidth / 2, cy - rectHeight / 2) ||
collideCircleLine(tx, ty, circleRadius, cx - rectWidth / 2, cy - rectHeight / 2, cx - rectWidth / 2, cy + rectHeight / 2);
}