Java 如何使用一组点创建边界框?

Java 如何使用一组点创建边界框?,java,Java,我有一个2D点的ArrayList。如何使用java使用这些点创建矩形 点的ArrayList为: [277.0, 275.0, 269.0, 271.0, 260.0, 268.0, 184.0, 277.0, 160.0, 288.0, 137.0, 303.0, 115.0, 319.0, 97.0, 337.0, 80.0, 357.0, 67.0, 375.0, 59.0, 394.0, 55.0, 413.0, 53.0, 433.0, 55.0, 456.0, 59.0, 482.

我有一个2D点的
ArrayList
。如何使用java使用这些点创建矩形

点的
ArrayList
为:

[277.0, 275.0, 269.0, 271.0, 260.0, 268.0, 184.0, 277.0, 160.0, 288.0, 137.0, 303.0, 115.0, 319.0, 97.0, 337.0, 80.0, 357.0, 67.0, 375.0, 59.0, 394.0, 55.0, 413.0, 53.0, 433.0, 55.0, 456.0, 59.0, 482.0, 66.0, 507.0, 77.0, 534.0, 90.0, 558.0, 103.0, 578.0, 117.0, 594.0, 131.0, 607.0, 147.0, 616.0, 163.0, 622.0, 179.0, 624.0, 198.0, 623.0, 221.0, 618.0, 244.0, 608.0, 266.0, 595.0, 284.0, 581.0, 300.0, 565.0, 316.0, 548.0, 329.0, 530.0, 339.0, 511.0, 348.0, 493.0, 355.0, 473.0, 361.0, 454.0, 364.0, 436.0, 367.0, 420.0, 368.0, 403.0, 367.0, 388.0, 366.0, 371.0, 360.0, 338.0, 356.0, 323.0, 349.0, 309.0, 343.0, 298.0, 337.0, 289.0, 329.0, 283.0, 320.0, 280.0, 309.0, 281.0, 299.0, 282.0, 299.0, 282.0277.0275.0]


在列表中查找最小和最大x和y坐标。边界框将具有以下角:

(xmin,ymin),(xmin,ymax),(xmax,ymax),(xmax,ymin)

在列表中找到最小和最大的x和y坐标。您的边界框将有以下角:

(xmin,ymin),(xmin,ymax),(xmax,ymax),(xmax,ymin)

您用一种错误的方式解释了您的问题。我必须猜测您的观点是哪种类型的。不过,您可以使用Java Api中的
矩形2D
类。有关更多信息,请单击

某些点的边界框的一般概念是:

计算每个标注的所有点的最大值和最小值并保存它们。边界框由具有这些坐标值的点组成。对于二维情况,这将是以下四个点:

(xmin,ymin),(xmin,ymax),(xmax,ymax),(xmax,ymin)

对于代码片段:

        // Constructs a new Rectangle whose upper-left corner is 
        // specified by the Point argument, and whose width and 
        // height are specified by the Dimension argument.
        Rectangle2D rect = new Rectangle(new Point(3, 4), new Dimension(200, 200));

        // For a Rectangle with double Coordinates
        Rectangle2D floatRect = new Rectangle2D.Double(3.0, 4.0, width, height);

您对问题的解释很糟糕。我必须猜测您的观点属于哪种类型。不过,您可以使用Java Api中的
Rectangle2D
类。有关详细信息,请单击

某些点的边界框的一般概念是:

计算每个标注的所有点的最大值和最小值并保存它们。边界框由具有这些坐标值的点组成。对于二维情况,这将是以下四个点:

(xmin,ymin),(xmin,ymax),(xmax,ymax),(xmax,ymin)

对于代码片段:

        // Constructs a new Rectangle whose upper-left corner is 
        // specified by the Point argument, and whose width and 
        // height are specified by the Dimension argument.
        Rectangle2D rect = new Rectangle(new Point(3, 4), new Dimension(200, 200));

        // For a Rectangle with double Coordinates
        Rectangle2D floatRect = new Rectangle2D.Double(3.0, 4.0, width, height);

我不知道如何创建。我不知道如何创建。如果矩形旋转,这将不起作用。因此,如果它沿X和Y方向笔直,您将得到正确的结果,但如果旋转矩形,您将得到矩形以外的值。如果矩形旋转,这将不起作用。因此,如果它沿X和Y方向笔直,您将得到正确的结果结果正确,但如果旋转矩形,则会得到矩形之外的值