class GeometryTools {

    public static Point2d get2DCenter(Iterable<IAtom> atoms) {
        double xsum = 0;
        double ysum = 0;
        int length = 0;
        for (IAtom atom : atoms) {
            if (atom.getPoint2d() != null) {
                xsum += atom.getPoint2d().x;
                ysum += atom.getPoint2d().y;
                length++;
            }
        }
        return new Point2d(xsum / (double) length, ysum / (double) length);
    }

}