public static bool isLineIntersectRectangle(float linePointX1, float linePointY1, float linePointX2, float linePointY2, float rectangleLeftTopX, float rectangleLeftTopY, float rectangleRightBottomX, float rectangleRightBottomY) { float lineHeight = linePointY1 - linePointY2; float lineWidth = linePointX2 - linePointX1; // 计算叉乘 float c = linePointX1 * linePointY2 - linePointX2 * linePointY1; if ((lineHeight * rectangleLeftTopX + lineWidth * rectangleLeftTopY + c >= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleRightBottomY + c <=