/** * Translates an atom object, given a Vector3d (i.e. the vecmath library * double-precision 3-d vector) * * @param atom * @param v */ public static final void translate (Atom atom, Vector3d v) { atom.setX(atom.getX()+v.x); atom.setY(atom.getY()+v.y); atom.setZ(atom.getZ()+v.z); }
double y = Double.parseDouble(getAttribute(eqr, "y")); double z = Double.parseDouble(getAttribute(eqr, "z")); shift.setX(x); shift.setY(y); shift.setZ(z);
double y = Double.parseDouble (atom.getCartn_y()); double z = Double.parseDouble (atom.getCartn_z()); a.setX(x); a.setY(y); a.setZ(z);
/** * Multiply elements of a by s (in place) * * @param a * @param s * @return the modified a */ public static Atom scaleEquals(Atom a, double s) { double x = a.getX(); double y = a.getY(); double z = a.getZ(); x *= s; y *= s; z *= s; //Atom b = new AtomImpl(); a.setX(x); a.setY(y); a.setZ(z); return a; }
/** * 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); }
/** * Rotate a single Atom aroud a rotation matrix. The rotation Matrix must be * a pre-multiplication 3x3 Matrix. * * If the matrix is indexed m[row][col], then the matrix will be * pre-multiplied (y=atom*M) * * @param atom * atom to be rotated * @param m * a rotation matrix represented as a double[3][3] array */ public static final void rotate(Atom atom, double[][] m){ double x = atom.getX(); double y = atom.getY() ; double z = atom.getZ(); double nx = m[0][0] * x + m[0][1] * y + m[0][2] * z ; double ny = m[1][0] * x + m[1][1] * y + m[1][2] * z ; double nz = m[2][0] * x + m[2][1] * y + m[2][2] * z ; atom.setX(nx); atom.setY(ny); atom.setZ(nz); }
/** * Multiply elements of a by s * * @param a * @param s * @return A new Atom with s*a */ public static Atom scale(Atom a, double s) { double x = a.getX(); double y = a.getY(); double z = a.getZ(); Atom b = new AtomImpl(); b.setX(x*s); b.setY(y*s); b.setZ(z*s); return b; }
public FragmentPair(int length, int p1, int p2) { super(); this.length = length ; pos1 = p1; pos2 = p2; contacts = 0; cluster = 0; rms = 0.0; used = 0; covered = 0; unitv = new AtomImpl(); unitv.setX(0); unitv.setY(0); unitv.setZ(1); rot = null; trans = new AtomImpl(); center1 = new AtomImpl(); center2 = new AtomImpl(); } @Override
/** * Transforms an atom object, given a Matrix4d (i.e. the vecmath library * double-precision 4x4 rotation+translation matrix). The transformation * Matrix must be a post-multiplication Matrix. * * @param atom * @param m */ public static final void transform (Atom atom, Matrix4d m) { Point3d p = new Point3d(atom.getX(),atom.getY(),atom.getZ()); m.transform(p); atom.setX(p.x); atom.setY(p.y); atom.setZ(p.z); }
/** * add two atoms ( a + b). * * @param a * an Atom object * @param b * an Atom object * @return an Atom object */ public static final Atom add(Atom a, Atom b){ Atom c = new AtomImpl(); c.setX( a.getX() + b.getX() ); c.setY( a.getY() + b.getY() ); c.setZ( a.getZ() + b.getZ() ); return c ; }
/** * Perform linear transformation s*X+B, and store the result in b * * @param s * Amount to scale x * @param x * Input coordinate * @param b * Vector to translate (will be modified) * @return b, after modification */ public static Atom scaleAdd(double s, Atom x, Atom b){ double xc = s*x.getX() + b.getX(); double yc = s*x.getY() + b.getY(); double zc = s*x.getZ() + b.getZ(); //Atom a = new AtomImpl(); b.setX(xc); b.setY(yc); b.setZ(zc); return b; }
/** * subtract two atoms ( a - b). * * @param a * an Atom object * @param b * an Atom object * @return n new Atom object representing the difference */ public static final Atom subtract(Atom a, Atom b) { Atom c = new AtomImpl(); c.setX( a.getX() - b.getX() ); c.setY( a.getY() - b.getY() ); c.setZ( a.getZ() - b.getZ() ); return c ; }
/** * 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); } }
private static Atom calcSimple_H(Atom c, Atom o, Atom n) { Atom h = Calc.subtract(c,o); double dist = Calc.getDistance(o,c); //System.out.println(dist); double x = n.getX() + h.getX() / dist; double y = n.getY() + h.getY() / dist; double z = n.getZ() + h.getZ() / dist; h.setX(x); h.setY(y); h.setZ(z); h.setName("H"); return h; }
/** * 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); } }
/** * Rotate an Atom around a Matrix object. The rotation Matrix must be a * pre-multiplication Matrix. * * @param atom * atom to be rotated * @param m * rotation matrix to be applied to the atom */ public static final void rotate(Atom atom, Matrix m){ 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.times(m); atom.setX(na.get(0,0)); atom.setY(na.get(0,1)); atom.setZ(na.get(0,2)); }
atom.setAltLoc(Character.valueOf(' ')); atom.setX(x); atom.setY(y); atom.setZ(z);
/** * Vector product (cross product). * * @param a * an Atom object * @param b * an Atom object * @return an Atom object */ public static final Atom vectorProduct(Atom a , Atom b){ Atom c = new AtomImpl(); c.setX( a.getY() * b.getZ() - a.getZ() * b.getY() ) ; c.setY( a.getZ() * b.getX() - a.getX() * b.getZ() ) ; c.setZ( a.getX() * b.getY() - a.getY() * b.getX() ) ; return c ; }