code: public static Point3d get3DCentreOfMass(IAtomContainer ac) {
          double xsum = 0.0;
          double ysum = 0.0;
          double zsum = 0.0;
  
          double totalmass = 0.0;
          Isotopes isotopes;
          try {
              isotopes = Isotopes.getInstance();
          } catch (IOException e) {
              throw new RuntimeException("Could not initialize Isotopes");
          }
  
          for (IAtom a : ac.atoms()) {
              Double mass = a.getExactMass();
              // some sanity checking
              if (a.getPoint3d() == null) return null;
              if (mass == null)
                  mass = isotopes.getNaturalMass(a);
  
              totalmass += mass;
              xsum += mass * a.getPoint3d().x;
              ysum += mass * a.getPoint3d().y;
              zsum += mass * a.getPoint3d().z;
          }
  
          return new Point3d(xsum / totalmass, ysum / totalmass, zsum / totalmass);
      }
docs: Calculates the center of mass for the <code>Atom</code>s in the AtomContainer.
  
  @param ac AtomContainer for which the center of mass is calculated
  @return The center of mass of the molecule, or <code>NULL</code> if the molecule
  does not have 3D coordinates or if any of the atoms do not have a valid atomic mass
  @cdk.keyword center of mass
  @cdk.dictref blue-obelisk:calculate3DCenterOfMass