日期:2014-05-20 浏览次数:20728 次
public static void main(String[] args) {
System.out.println(isRectangle(1, 1, 23, -18, 13, 6, 11, -23));
}
public static boolean isRectangle(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
return (isRightangle(x1, y1, x2, y2, x4, y4) && x1 + x3 == x2 + x4 && y1 + y3 == y2 + y4)
------解决方案--------------------
(isRightangle(x1, y1, x2, y2, x3, y3) && x1 + x4 == x2 + x3 && y1 + y4 == y2 + y3)
------解决方案--------------------
(isRightangle(x1, y1, x3, y3, x4, y4) && x1 + x2 == x3 + x4 && y1 + y2 == y3 + y4);
}
public static boolean isRightangle(double x1, double y1, double x2, double y2, double x3, double y3) {
return !(((x1 == x2) && (y1 == y2))
------解决方案--------------------
((x1 == x3) && (y1 == y3)))
&& (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1) == 0.0;
}