示例#1
0
  /**
   * calculate distance between two atoms.
   *
   * @param a an Atom object
   * @param b an Atom object
   * @return a double
   * @throws StructureException ...
   */
  public static BigDecimal getPreciseDistance(Atom a, Atom b) throws StructureException {
    double x = a.getX() - b.getX();
    double y = a.getY() - b.getY();
    double z = a.getZ() - b.getZ();

    double s = x * x + y * y + z * z;
    BigSqrt sqrt = new BigSqrt();
    BigDecimal d = new BigDecimal(s);
    BigDecimal dist = sqrt.sqrt(d);

    return dist;
  }
示例#2
0
  private static Atom calcSimple_H(Atom c, Atom o, Atom n) throws StructureException {

    Atom h = Calc.substract(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");
    h.setFullName(" H  ");
    return h;
  }