コード例 #1
0
ファイル: Molecule.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Adds a Science_Chemistry_Atom object to the list of atoms in the molecule
  * 
  * @param   object  Science_Chemistry_Atom   $atom
  * @return  boolean
  * @access  public
  * @see     initMolecule()
  */
 function addAtom($atom)
 {
     if (Science_Chemistry_Atom::isAtom($atom)) {
         $this->atoms[] = $atom;
         $this->num_atoms++;
         // unset the distance matrix and
         // connection table if they are not empty
         // so next time either one is requested
         // it gets calculated anew
         if (!empty($this->dist_matrix)) {
             $this->dist_matrix = array();
         }
         if (!empty($this->conn_table)) {
             $this->conn_table = array();
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
 /**
  * Calculates the cartesian distance from this atom
  * instance to another
  *
  * @param   object  Science_Chemistry_Atom $atom2
  * @return  float   distance
  * @access  public
  */
 function distance($atom2)
 {
     if (!empty($this->xyz) && Science_Chemistry_Coordinates::areCoordinates($this->xyz) && Science_Chemistry_Atom::isAtom($atom2)) {
         return $this->xyz->distance($atom2->xyz);
     } else {
         return -1.0;
     }
 }