Rectangle.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:RobotIGS 作者:
/**
 * Create a rectangle based on a set of points
 *
 * @param points Set of points (at least 4) defining the rectangle
 */
public Rectangle(Point[] points) {
    //Find top-left and bottom-right
    Point min = new Point(Double.MAX_VALUE, Double.MAX_VALUE);
    Point max = new Point(Double.MIN_VALUE, Double.MIN_VALUE);
    for (Point p : points) {
        if (p.x < min.x) {
            min.x = p.x;
        }
        if (p.y < min.y) {
            min.y = p.y;
        }
        if (p.x > max.x) {
            max.x = p.x;
        }
        if (p.y > max.y) {
            max.y = p.y;
        }
    }
    setRect(new Rect(min, max));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号