源代码
public bool JudgeRectangleIntersect(double RecAleftX, double RecAleftY, double RecArightX, double RecArightY, double RecBleftX, double RecBleftY, double RecBrightX, double RecBrightY) { bool isIntersect = false; try { double zx = getAbsluteValue(RecAleftX + RecArightX - RecBleftX - RecBrightX); double x = getAbsluteValue(RecAleftX - RecArightX) + getAbsluteValue(RecBleftX - RecBrightX); double zy = getAbsluteValue(RecAleftY + RecArightY - RecBleftY - RecBrightY); double y = getAbsluteValue(RecAleftY - RecArightY) + getAbsluteValue(RecBleftY - RecBrightY); if (zx <= x && zy <= y) //需要确认两矩形边线重合是否定义为相交 此处定义为相交。 { isIntersect = true; } } catch (Exception ex) { string str = ex.Message; } return isIntersect; } private double getAbsluteValue(double douValue) { if (douValue >= 0) { return douValue; } else { return douValue * -1; } }