/** * Rescales Point2 so that length 1-2 is sum of covalent radii. if covalent radii cannot be found, * use bond length of 1.0 * * @param atom1 stationary atom * @param atom2 moveable atom * @param point2 coordinates for atom 2 * @return new coords for atom 2 */ public static Point3d rescaleBondLength(IAtom atom1, IAtom atom2, Point3d point2) { Point3d point1 = atom1.getPoint3d(); double d1 = atom1.getCovalentRadius(); double d2 = atom2.getCovalentRadius(); // in case we have no covalent radii, set to 1.0 double distance = (d1 < 0.1 || d2 < 0.1) ? 1.0 : atom1.getCovalentRadius() + atom2.getCovalentRadius(); Vector3d vect = new Vector3d(point2); vect.sub(point1); vect.normalize(); vect.scale(distance); Point3d newPoint = new Point3d(point1); newPoint.add(vect); return newPoint; }