【发布时间】:2020-03-20 03:16:56
【问题描述】:
我正在绘制四个多边形。我需要确定其他多边形内的点的坐标。我已经在谷歌搜索但没有得到正确的代码。请在此处提出一种方法或使用我的一组坐标发布一些代码。
// Draw and fill polygons
import java.awt.Graphics;
public class Polygon2 extends java.applet.Applet
{
int xCoords[] = { 10,90,200,270,200,90};
int yCoords[] = { 50,20,20,50,130,130};
//int xFillCoords[] = { 450, 600, 700, 550, 450, 450 };
int x2Coords[] = { 120,230,200,150,100};
int y2Coords[] = { 10,10,60,80,70};
public void paint(Graphics g)
{
g.drawPolygon(xCoords, yCoords, 6);
g.drawPolygon(x2Coords, y2Coords, 5);
g.drawRect(60, 60, 30, 30);
g.drawRect(100, 150, 150, 100);
//g.fillPolygon(xFillCoords, yCoords, 5);
}
}
四个多边形
【问题讨论】:
-
This 可能会帮助您确定一个点是否在一个 poligon 内。
标签: java