Determine whether two rectangles intersect

From , 3 Years ago, written in Java, viewed 249 times.
URL https://pastebin.vip/view/50c3d761
  1. import java.util.Arrays;
  2.  
  3. public class test {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. float[] x1 = { 2, 5 };
  8. float[] y1 = { 1, 3 };
  9. float[] x2 = { 5, 7 };
  10. float[] y2 = { 1, 3 };
  11. if (judge(x1, y1, x2, y2)) {
  12. System.out.println(“两矩形相交”);
  13. } else System.out.println(“两矩形不相交”);
  14.  
  15. }
  16.  
  17. public static boolean judge(float[] x1, float[] y1, float[] x2, float[] y2) {
  18.  
  19. if (x1[0] > x2[0]) {
  20. float[] temp = {0, 0};
  21. for (int i = 0; i x2[0] && ((y1[0] >= y2[0] && y1[0] = y2[0] && y1[1] <= y2[1]))) {
  22. return true;
  23. }
  24.  
  25. return false;
  26. }
  27. }

Reply to "Determine whether two rectangles intersect"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website