我试图分别从 ArrayList 的点将所有 x 和 y 坐标相加。
public static ArrayList knots = new ArrayList<Point>();
public Point centroid() {
Point center = new Point();
for(int i=0; i<knots.size(); i++) {
????????????????????
return center;
}
如何找到质心??
public Point centroid() {
double centroidX = 0, centroidY = 0;
for(Point knot : knots) {
centroidX += knot.getX();
centroidY += knot.getY();
}
return new Point(centroidX / knots.size(), centroidY / knots.size());
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)