日期:2014-05-20 浏览次数:20846 次
x={10,20,30...} y={20,40,60...} Polygon p = new Polygon(x, y, x.length); //创建多边形 if (p.contains(new Point(mouse.x, mouse.y))) { //判断多边形是否包含某个点 System.out.println("contains"); }
------解决方案--------------------
int[] x = new int[] { 10, 10, 30, 40 }; int[] y = new int[] { 10, 30, 60, 10 }; Polygon polygon = new Polygon(x, y, x.length); Point p = new Point(20, 25); System.out.println(polygon.contains(p)); Point q = new Point(100, 100); System.out.println(polygon.contains(q));