Polygons with Double Coordinates

前端 未结 1 1031
别那么骄傲
别那么骄傲 2021-02-05 04:47

I have some questions about Polygons with points of Double type... What I have to do, is given points, create the polygon, and then, test if 1 concrete point is inside the poly

1条回答
  •  盖世英雄少女心
    2021-02-05 05:22

    You can do this with Path2D.Double:

    Path2D path = new Path2D.Double();
    
    path.moveTo(valoresX[0], valoresY[0]);
    for(int i = 1; i < valoresX.length; ++i) {
       path.lineTo(valoresX[i], valoresY[i]);
    }
    path.closePath();
    

    See also this question:

    Implementing Polygon2D in Java 2D

    0 讨论(0)
提交回复
热议问题