/** * 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; }
/** * Projects a given point onto the axis of rotation * @param point * @return An atom which lies on the axis, or null if the RotationAxis is purely translational */ public Atom getProjectedPoint(Atom point) { if(rotationPos == null) { // translation only return null; } Atom localPoint = Calc.subtract(point, rotationPos); double dot = Calc.scalarProduct(localPoint, rotationAxis); Atom localProjected = Calc.scale(rotationAxis, dot); Atom projected = Calc.add(localProjected, rotationPos); return projected; }
/** * Use unit vectors NC and NCalpha Add them. Calc unit vector and * substract it from N. * C coordinates are from amino acid i-1 * N, CA atoms from amino acid i * * @link http://openbioinformatics.blogspot.com/ * 2009/08/how-to-calculate-h-atoms-for-nitrogens.html */ @SuppressWarnings("unused") private static Atom calc_H(Atom C, Atom N, Atom CA) throws StructureException { Atom nc = Calc.subtract(N,C); Atom nca = Calc.subtract(N,CA); Atom u_nc = Calc.unitVector(nc) ; Atom u_nca = Calc.unitVector(nca); Atom added = Calc.add(u_nc,u_nca); Atom U = Calc.unitVector(added); // according to Creighton distance N-H is 1.03 +/- 0.02A Atom H = Calc.add(N,U); H.setName("H"); // this atom does not have a pdbserial number ... return H; }
/** * Shift a vector. * * @param a * vector a * @param b * vector b */ public static final void shift(Atom a, Atom b){ Atom natom = add(a,b); double x = natom.getX(); double y = natom.getY() ; double z = natom.getZ(); a.setX(x); a.setY(y); a.setZ(z); }
/** * shift a structure with a vector. * * @param structure * a Structure object * @param a * an Atom object representing a shift vector */ public static final void shift(Structure structure, Atom a ){ AtomIterator iter = new AtomIterator(structure) ; while (iter.hasNext() ) { Atom atom = null ; atom = iter.next() ; Atom natom = add(atom,a); double x = natom.getX(); double y = natom.getY() ; double z = natom.getZ(); atom.setX(x); atom.setY(y); atom.setZ(z); } }
/** * Shift a Group with a vector. * * @param group * a group object * @param a * an Atom object representing a shift vector */ public static final void shift(Group group , Atom a ){ AtomIterator iter = new AtomIterator(group) ; while (iter.hasNext() ) { Atom atom = null ; atom = iter.next() ; Atom natom = add(atom,a); double x = natom.getX(); double y = natom.getY() ; double z = natom.getZ(); atom.setX(x); atom.setY(y); atom.setZ(z); } }
Atom virtualCB = Calc.add(aCB,tranMatrix); virtualCB.setName("CB");