/** * Returns the Vector that needs to be applied to shift a set of atoms to * the Centroid. * * @param atomSet * array of Atoms * @return the vector needed to shift the set of atoms to its geometric * center */ public static final Atom getCenterVector(Atom[] atomSet){ Atom centroid = getCentroid(atomSet); return getCenterVector(atomSet,centroid); }
/** * Center the atoms at the Centroid, if the centroid is already know. * * @param atomSet * a set of Atoms * @return an Atom representing the Centroid of the set of atoms * @throws StructureException * */ public static final Atom[] centerAtoms(Atom[] atomSet, Atom centroid) throws StructureException { Atom shiftVector = getCenterVector(atomSet, centroid); Atom[] newAtoms = new AtomImpl[atomSet.length]; for (int i =0 ; i < atomSet.length; i++){ Atom a = atomSet[i]; Atom n = add(a,shiftVector); newAtoms[i] = n ; } return newAtoms; }