/** * Extract the translational vector as an Atom of a transformation matrix. * * @param transform * Matrix4d * @return Atom shift vector */ public static Atom getTranslationVector(Matrix4d transform){ Atom transl = new AtomImpl(); double[] coords = {transform.m03, transform.m13, transform.m23}; transl.setCoords(coords); return transl; }
public static final Atom invert(Atom a) { double[] coords = new double[]{0.0,0.0,0.0} ; Atom zero = new AtomImpl(); zero.setCoords(coords); return subtract(zero, a); }
/** * Handle cases with small angles of rotation * @param rotation * @param translation */ private void calculateTranslationalAxis(Matrix rotation, Atom translation) { // set axis parallel to translation rotationAxis = Calc.scale(translation, 1./Calc.amount(translation)); // position is undefined rotationPos = null; screwTranslation = translation; otherTranslation = new AtomImpl(); otherTranslation.setCoords(new double[] {0,0,0}); }
/** * Returns the centroid of the set of atoms. * * @param atomSet * a set of Atoms * @return an Atom representing the Centroid of the set of atoms */ public static final Atom getCentroid(Atom[] atomSet){ // if we don't catch this case, the centroid returned is (NaN,NaN,NaN), which can cause lots of problems down the line if (atomSet.length==0) throw new IllegalArgumentException("Atom array has length 0, can't calculate centroid!"); double[] coords = new double[3]; coords[0] = 0; coords[1] = 0; coords[2] = 0 ; for (Atom a : atomSet) { coords[0] += a.getX(); coords[1] += a.getY(); coords[2] += a.getZ(); } int n = atomSet.length; coords[0] = coords[0] / n; coords[1] = coords[1] / n; coords[2] = coords[2] / n; Atom vec = new AtomImpl(); vec.setCoords(coords); return vec; }
/** * Returns the unit vector of vector a . * * @param a * an Atom object * @return an Atom object */ public static final Atom unitVector(Atom a) { double amount = amount(a) ; double[] coords = new double[3]; coords[0] = a.getX() / amount ; coords[1] = a.getY() / amount ; coords[2] = a.getZ() / amount ; a.setCoords(coords); return a; }
/** * Returns the Vector that needs to be applied to shift a set of atoms to * the Centroid, if the centroid is already known * * @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){ double[] coords = new double[3]; coords[0] = 0 - centroid.getX(); coords[1] = 0 - centroid.getY(); coords[2] = 0 - centroid.getZ(); Atom shiftVec = new AtomImpl(); shiftVec.setCoords(coords); return shiftVec; }
rotationAxis.setCoords(rotAx);
coords[1] = na.get(0,1); coords[2] = na.get(0,2); atom.setCoords(coords); try { if ( rotOldAtom != null){
shift1.setCoords(new double[]{0,0,1}); Atom shift2 = alig.getShift();
unitvector.setCoords(utmp[0]);