/** * Rotate a group object. * * @param group a group to be rotated * @param m a Matrix object representing the translation matrix */ public static final void rotate(Group group, Matrix m) { AtomIterator iter = new AtomIterator(group); while (iter.hasNext()) { Atom atom = (Atom) iter.next(); rotate(atom, m); } }
/** * Rotate a structure object. * * @param structure the structure to be rotated * @param m rotation matrix to be applied */ public static final void rotate(Structure structure, Matrix m) { AtomIterator iter = new AtomIterator(structure); while (iter.hasNext()) { Atom atom = (Atom) iter.next(); rotate(atom, m); } }
/** * Rotate a structure. * * @param structure a Structure object * @param rotationmatrix an array (3x3) of double representing the rotation matrix. * @throws StructureException ... */ public static final void rotate(Structure structure, double[][] rotationmatrix) throws StructureException { double[][] m = rotationmatrix; if (m.length != 3) { throw new StructureException("matrix does not have size 3x3 !"); } AtomIterator iter = new AtomIterator(structure); while (iter.hasNext()) { Atom atom = (Atom) iter.next(); Calc.rotate(atom, rotationmatrix); } }
/** * 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 = (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); } }
/** * calculate structure + Matrix coodinates ... * * @param s the structure to operate on * @param matrix a Matrix object */ public static final void plus(Structure s, Matrix matrix) { AtomIterator iter = new AtomIterator(s); Atom oldAtom = null; Atom rotOldAtom = null; while (iter.hasNext()) { Atom atom = null; atom = (Atom) iter.next(); try { if (oldAtom != null) { // System.out.println("before " +getDistance(oldAtom,atom)); } } catch (Exception e) { e.printStackTrace(); } oldAtom = (Atom) atom.clone(); double x = atom.getX(); double y = atom.getY(); double z = atom.getZ(); double[][] ad = new double[][] {{x, y, z}}; Matrix am = new Matrix(ad); Matrix na = am.plus(matrix); double[] coords = new double[3]; coords[0] = na.get(0, 0); coords[1] = na.get(0, 1); coords[2] = na.get(0, 2); atom.setCoords(coords); try { if (rotOldAtom != null) { // System.out.println("after " + getDistance(rotOldAtom,atom)); } } catch (Exception e) { e.printStackTrace(); } rotOldAtom = (Atom) atom.clone(); } }